From 6a9cddf2d81cfbe93dc23ff1fc428366f1c204c1 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Thu, 2 Feb 2017 18:13:51 +0000 Subject: [PATCH] Label water object offsets --- src/openrct2/game.c | 22 +++++++++++----------- src/openrct2/object/WaterObject.cpp | 10 +++++----- src/openrct2/scenario/scenario.c | 2 +- src/openrct2/world/water.h | 10 +++++++--- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/openrct2/game.c b/src/openrct2/game.c index 152be822cb..f8614a8592 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -199,24 +199,24 @@ void update_palette_effects() } // animate the water/lava/chain movement palette - sint32 q = 0; + uint32 shade = 0; if (gConfigGeneral.render_weather_gloom) { uint8 gloom = gClimateCurrentWeatherGloom; if (gloom != 0) { FILTER_PALETTE_ID weatherColour = ClimateWeatherGloomColours[gloom]; - q = 1; + shade = 1; if (weatherColour != PALETTE_DARKEN_1) { - q = 2; + shade = 2; } } } uint32 j = gPaletteEffectFrame; j = (((uint16)((~j / 2) * 128) * 15) >> 16); - sint32 p = SPR_GAME_PALETTE_WATER; + uint32 waterId = SPR_GAME_PALETTE_WATER; if ((intptr_t)water_type != -1) { - p = water_type->var_06; + waterId = water_type->palette_index_1; } - rct_g1_element g1_element = g1Elements[q + p]; + rct_g1_element g1_element = g1Elements[shade + waterId]; uint8* vs = &g1_element.offset[j * 3]; uint8* vd = &gGamePalette[230 * 4]; sint32 n = 5; @@ -231,11 +231,11 @@ void update_palette_effects() vd += 4; } - p = SPR_GAME_PALETTE_3; + waterId = SPR_GAME_PALETTE_3; if ((intptr_t)water_type != -1) { - p = water_type->var_0A; + waterId = water_type->palette_index_2; } - g1_element = g1Elements[q + p]; + g1_element = g1Elements[shade + waterId]; vs = &g1_element.offset[j * 3]; n = 5; for (sint32 i = 0; i < n; i++) { @@ -250,8 +250,8 @@ void update_palette_effects() } j = ((uint16)(gPaletteEffectFrame * -960) * 3) >> 16; - p = SPR_GAME_PALETTE_4; - g1_element = g1Elements[q + p]; + waterId = SPR_GAME_PALETTE_4; + g1_element = g1Elements[shade + waterId]; vs = &g1_element.offset[j * 3]; vd += 12; n = 3; diff --git a/src/openrct2/object/WaterObject.cpp b/src/openrct2/object/WaterObject.cpp index 17a2ff245c..11a29e01f5 100644 --- a/src/openrct2/object/WaterObject.cpp +++ b/src/openrct2/object/WaterObject.cpp @@ -25,9 +25,9 @@ extern "C" void WaterObject::ReadLegacy(IReadObjectContext * context, IStream * stream) { stream->Seek(6, STREAM_SEEK_CURRENT); - _legacyType.var_06 = stream->ReadValue(); - _legacyType.var_0A = stream->ReadValue(); - _legacyType.var_0E = stream->ReadValue(); + _legacyType.palette_index_1 = stream->ReadValue(); + _legacyType.palette_index_2 = stream->ReadValue(); + _legacyType.flags = stream->ReadValue(); GetStringTable()->Read(context, stream, OBJ_STRING_ID_NAME); GetImageTable()->Read(context, stream); @@ -38,8 +38,8 @@ void WaterObject::Load() GetStringTable()->Sort(); _legacyType.string_idx = language_allocate_object_string(GetName()); _legacyType.image_id = gfx_object_allocate_images(GetImageTable()->GetImages(), GetImageTable()->GetCount()); - _legacyType.var_06 = _legacyType.image_id + 1; - _legacyType.var_0A = _legacyType.image_id + 4; + _legacyType.palette_index_1 = _legacyType.image_id + 1; + _legacyType.palette_index_2 = _legacyType.image_id + 4; load_palette(); gfx_invalidate_screen(); diff --git a/src/openrct2/scenario/scenario.c b/src/openrct2/scenario/scenario.c index e350a07b59..f9bda09fa8 100644 --- a/src/openrct2/scenario/scenario.c +++ b/src/openrct2/scenario/scenario.c @@ -424,7 +424,7 @@ static void scenario_week_update() rct_water_type* water_type = (rct_water_type*)object_entry_groups[OBJECT_TYPE_WATER].chunks[0]; - if (month <= MONTH_APRIL && (intptr_t)water_type != -1 && water_type->var_0E & 1) { + if (month <= MONTH_APRIL && (intptr_t)water_type != -1 && water_type->flags & WATER_FLAGS_ALLOW_DUCKS) { // 100 attempts at finding some water to create a few ducks at for (sint32 i = 0; i < 100; i++) { if (scenario_create_ducks()) diff --git a/src/openrct2/world/water.h b/src/openrct2/world/water.h index b7ad3e497f..6d57ca4a83 100644 --- a/src/openrct2/world/water.h +++ b/src/openrct2/world/water.h @@ -19,13 +19,17 @@ #include "../common.h" +enum { + WATER_FLAGS_ALLOW_DUCKS = (1 << 0) +}; + #pragma pack(push, 1) typedef struct rct_water_type { rct_string_id string_idx; // 0x00 uint32 image_id; // 0x02 - uint32 var_06; - uint32 var_0A; - uint16 var_0E; + uint32 palette_index_1; + uint32 palette_index_2; + uint16 flags; } rct_water_type; assert_struct_size(rct_water_type, 16); #pragma pack(pop)