mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Finish loading water JSON objects
This commit is contained in:
@@ -56,6 +56,7 @@ enum {
|
||||
G1_FLAG_BMP = (1 << 0), // Image data is encoded as raw pixels (no transparency)
|
||||
G1_FLAG_1 = (1 << 1),
|
||||
G1_FLAG_RLE_COMPRESSION = (1 << 2), // Image data is encoded using RCT2's form of run length encoding
|
||||
G1_FLAG_PALETTE = (1 << 3), // Image data is a sequence of palette entries R8G8B8
|
||||
G1_FLAG_HAS_ZOOM_SPRITE = (1 << 4), // Use a different sprite for higher zoom levels
|
||||
G1_FLAG_NO_ZOOM_DRAW = (1 << 5), // Does not get drawn at higher zoom levels (only zoom 0)
|
||||
};
|
||||
|
||||
@@ -863,20 +863,9 @@ rct_size16 FASTCALL gfx_get_sprite_size(uint32 image_id)
|
||||
|
||||
size_t g1_calculate_data_size(const rct_g1_element * g1)
|
||||
{
|
||||
if (g1->flags & G1_FLAG_RLE_COMPRESSION)
|
||||
if (g1->flags & G1_FLAG_PALETTE)
|
||||
{
|
||||
uint16 * offsets = (uint16 *)g1->offset;
|
||||
uint8 * ptr = g1->offset + offsets[g1->height - 1];
|
||||
bool endOfLine = false;
|
||||
do
|
||||
{
|
||||
uint8 chunk0 = *ptr++;
|
||||
ptr++; // offset
|
||||
uint8 chunkSize = chunk0 & 0x7F;
|
||||
ptr += chunkSize;
|
||||
endOfLine = (chunk0 & 0x80) != 0;
|
||||
} while (!endOfLine);
|
||||
return ptr - g1->offset;
|
||||
return g1->width * 3;
|
||||
}
|
||||
else if (g1->flags & G1_FLAG_RLE_COMPRESSION)
|
||||
{
|
||||
|
||||
@@ -212,6 +212,7 @@ namespace ObjectFactory
|
||||
if (s == "footpath_banner") return OBJECT_TYPE_BANNERS;
|
||||
if (s == "footpath_item") return OBJECT_TYPE_PATH_BITS;
|
||||
if (s == "park_entrance") return OBJECT_TYPE_PARK_ENTRANCE;
|
||||
if (s == "water") return OBJECT_TYPE_WATER;
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ void WaterObject::ReadJsonPalette(const json_t * jPalette)
|
||||
auto jColours = json_object_get(jPalette, "colours");
|
||||
auto numColours = json_array_size(jColours);
|
||||
|
||||
auto data = std::make_unique<uint8[]>(numColours);
|
||||
auto data = std::make_unique<uint8[]>(numColours * 3);
|
||||
size_t dataIndex = 0;
|
||||
|
||||
size_t index;
|
||||
@@ -110,16 +110,18 @@ void WaterObject::ReadJsonPalette(const json_t * jPalette)
|
||||
if (szColour != nullptr)
|
||||
{
|
||||
auto colour = ParseColour(szColour);
|
||||
data[dataIndex + 0] = colour;
|
||||
data[dataIndex + 0] = (colour >> 16) & 0xFF;
|
||||
data[dataIndex + 1] = (colour >> 8) & 0xFF;
|
||||
data[dataIndex + 2] = (colour >> 16) & 0xFF;
|
||||
data[dataIndex + 2] = colour & 0xFF;
|
||||
}
|
||||
dataIndex += 3;
|
||||
}
|
||||
|
||||
rct_g1_element g1 = { 0 };
|
||||
g1.offset = data.get();
|
||||
g1.width = (sint16)numColours;
|
||||
g1.x_offset = (sint16)paletteStartIndex;
|
||||
g1.flags = G1_FLAG_PALETTE;
|
||||
|
||||
auto &imageTable = GetImageTable();
|
||||
imageTable.AddImage(&g1);
|
||||
|
||||
Reference in New Issue
Block a user