From d0950af9dfcf177a9b615e17a12080e28ada80c7 Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 10 Sep 2016 12:28:01 +0100 Subject: [PATCH] Integrate gClearSceneryCost and gLandRightsCost --- src/windows/clear_scenery.c | 14 +++++++++----- src/windows/land_rights.c | 7 +++++-- src/windows/park.c | 8 ++++---- src/windows/top_toolbar.c | 15 ++++++++------- src/world/map.c | 1 + src/world/map.h | 1 + src/world/scenery.c | 2 ++ src/world/scenery.h | 2 ++ 8 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/windows/clear_scenery.c b/src/windows/clear_scenery.c index a657d1b1f0..96766aa6b2 100644 --- a/src/windows/clear_scenery.c +++ b/src/windows/clear_scenery.c @@ -15,13 +15,14 @@ #pragma endregion #include "../addresses.h" -#include "../world/map.h" #include "../input.h" #include "../localisation/localisation.h" #include "../sprites.h" +#include "../interface/themes.h" #include "../interface/widget.h" #include "../interface/window.h" -#include "../interface/themes.h" +#include "../world/map.h" +#include "../world/scenery.h" #define MINIMUM_TOOL_SIZE 1 #define MAXIMUM_TOOL_SIZE 64 @@ -111,7 +112,7 @@ void window_clear_scenery_open() window_init_scroll_widgets(window); window_push_others_below(window); - RCT2_GLOBAL(0x00F1AD62, uint32) = MONEY32_UNDEFINED; + gClearSceneryCost = MONEY32_UNDEFINED; gClearSmallScenery = true; gClearLargeScenery = false; @@ -245,8 +246,11 @@ static void window_clear_scenery_paint(rct_window *w, rct_drawpixelinfo *dpi) // Draw cost amount x = (window_clear_scenery_widgets[WIDX_PREVIEW].left + window_clear_scenery_widgets[WIDX_PREVIEW].right) / 2 + w->x; y = window_clear_scenery_widgets[WIDX_PREVIEW].bottom + w->y + 5 + 27; - if (RCT2_GLOBAL(0x00F1AD62, uint32) != MONEY32_UNDEFINED && RCT2_GLOBAL(0x00F1AD62, uint32) != 0) - gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, 0, RCT2_ADDRESS(0x00F1AD62, void)); + if (gClearSceneryCost != MONEY32_UNDEFINED && + gClearSceneryCost != 0 + ) { + gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, 0, &gClearSceneryCost); + } } /** diff --git a/src/windows/land_rights.c b/src/windows/land_rights.c index c13d77d051..e2d70465a0 100644 --- a/src/windows/land_rights.c +++ b/src/windows/land_rights.c @@ -228,8 +228,11 @@ static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi) // Draw cost amount x = (window_land_rights_widgets[WIDX_PREVIEW].left + window_land_rights_widgets[WIDX_PREVIEW].right) / 2 + w->x; y = window_land_rights_widgets[WIDX_PREVIEW].bottom + w->y + 32; - if (RCT2_GLOBAL(0x00F1AD62, uint32) != MONEY32_UNDEFINED && RCT2_GLOBAL(0x00F1AD62, uint32) != 0) - gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, 0, RCT2_ADDRESS(0x00F1AD62, void)); + if (gLandRightsCost != MONEY32_UNDEFINED && + gLandRightsCost != 0 + ) { + gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, 0, &gLandRightsCost); + } } static int window_land_rights_should_close() diff --git a/src/windows/park.c b/src/windows/park.c index fa37ceddf0..30b500d842 100644 --- a/src/windows/park.c +++ b/src/windows/park.c @@ -760,8 +760,8 @@ static void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y) screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); if (mapTile.x == (sint16)0x8000){ - if (RCT2_GLOBAL(0x00F1AD62, money32) != MONEY32_UNDEFINED){ - RCT2_GLOBAL(0x00F1AD62, money32) = MONEY32_UNDEFINED; + if (gLandRightsCost != MONEY32_UNDEFINED) { + gLandRightsCost = MONEY32_UNDEFINED; window_invalidate_by_class(WC_CLEAR_SCENERY); } return; @@ -818,7 +818,7 @@ static void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y) if (!state_changed) return; - RCT2_GLOBAL(0x00F1AD62, uint32) = game_do_command( + gLandRightsCost = game_do_command( gMapSelectPositionA.x, 0x4, gMapSelectPositionA.y, @@ -826,7 +826,7 @@ static void window_park_entrance_tool_update_land_rights(sint16 x, sint16 y) GAME_COMMAND_BUY_LAND_RIGHTS, gMapSelectPositionB.x, gMapSelectPositionB.y - ); + ); } /** diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 8c9882d01c..34f0610429 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -1660,8 +1660,8 @@ static void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){ screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); if (mapTile.x == (sint16)0x8000){ - if (RCT2_GLOBAL(0x00F1AD62, money32) != MONEY32_UNDEFINED){ - RCT2_GLOBAL(0x00F1AD62, money32) = MONEY32_UNDEFINED; + if (gClearSceneryCost != MONEY32_UNDEFINED) { + gClearSceneryCost = MONEY32_UNDEFINED; window_invalidate_by_class(WC_CLEAR_SCENERY); } return; @@ -1722,10 +1722,11 @@ static void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){ int ecx = gMapSelectPositionA.y; int edi = gMapSelectPositionB.x; int ebp = gMapSelectPositionB.y; - money32 cost = game_do_command(eax, 0, ecx, 0, GAME_COMMAND_CLEAR_SCENERY, edi, ebp); + int clear = (gClearSmallScenery << 0) | (gClearLargeScenery << 1) | (gClearFootpath << 2); + money32 cost = game_do_command(eax, 0, ecx, clear, GAME_COMMAND_CLEAR_SCENERY, edi, ebp); - if (RCT2_GLOBAL(0x00F1AD62, money32) != cost){ - RCT2_GLOBAL(0x00F1AD62, money32) = cost; + if (gClearSceneryCost != cost) { + gClearSceneryCost = cost; window_invalidate_by_class(WC_CLEAR_SCENERY); return; } @@ -1739,8 +1740,8 @@ static void top_toolbar_tool_update_land_paint(sint16 x, sint16 y){ screen_get_map_xy(x, y, &mapTile.x, &mapTile.y, NULL); if (mapTile.x == (sint16)0x8000){ - if (RCT2_GLOBAL(0x00F1AD62, money32) != MONEY32_UNDEFINED){ - RCT2_GLOBAL(0x00F1AD62, money32) = MONEY32_UNDEFINED; + if (gClearSceneryCost != MONEY32_UNDEFINED) { + gClearSceneryCost = MONEY32_UNDEFINED; window_invalidate_by_class(WC_CLEAR_SCENERY); } return; diff --git a/src/world/map.c b/src/world/map.c index ff4db1f5a3..3108cdb68b 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -114,6 +114,7 @@ uint8 gLandToolTerrainSurface; uint8 gLandToolTerrainEdge; money32 gWaterToolRaiseCost; money32 gWaterToolLowerCost; +money32 gLandRightsCost; rct_xyz16 gCommandPosition; diff --git a/src/world/map.h b/src/world/map.h index cc2c7cf99d..a7c2ae4702 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -373,6 +373,7 @@ extern uint8 gLandToolTerrainSurface; extern uint8 gLandToolTerrainEdge; extern money32 gWaterToolRaiseCost; extern money32 gWaterToolLowerCost; +extern money32 gLandRightsCost; extern rct_xyz16 gCommandPosition; diff --git a/src/world/scenery.c b/src/world/scenery.c index 648a7acc97..395c32bf3f 100644 --- a/src/world/scenery.c +++ b/src/world/scenery.c @@ -61,6 +61,8 @@ sint16 gSceneryCtrlPressZ; uint8 gSceneryGroundFlags; +money32 gClearSceneryCost; + // rct2: 0x009A3E74 const rct_xy8 ScenerySubTileOffsets[] = { { 7, 7 }, diff --git a/src/world/scenery.h b/src/world/scenery.h index 24eb0f4109..aa916da1c4 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -248,6 +248,8 @@ extern const rct_xy8 ScenerySubTileOffsets[]; extern sint16 window_scenery_tab_entries[20][SCENERY_ENTRIES_BY_TAB + 1]; +extern money32 gClearSceneryCost; + void init_scenery(); void scenery_update_tile(int x, int y); void scenery_update_age(int x, int y, rct_map_element *mapElement);