1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Finish loading water JSON objects

This commit is contained in:
Ted John
2017-12-14 17:35:34 +00:00
committed by Gymnasiast
parent 40f775c39a
commit 3ead0f4289
4 changed files with 9 additions and 16 deletions

View File

@@ -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);