From ee7a2c47f46d08ff975df18b01b283a0e569e2a8 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 13 Jun 2015 18:58:58 +0100 Subject: [PATCH] refactor map size --- src/addresses.h | 3 ++- src/interface/viewport.c | 10 +++++----- src/rct1.c | 4 ++-- src/rct1.h | 4 ++-- src/ride/track.c | 6 +++--- src/scenario.h | 6 +++--- src/windows/top_toolbar.c | 7 +------ src/world/footpath.c | 6 +++--- src/world/map.c | 34 +++++++++++++++++----------------- 9 files changed, 38 insertions(+), 42 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 09b995ff4b..e74cede5f2 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -403,8 +403,9 @@ #define RCT2_ADDRESS_NEXT_RESEARCH_EXPECTED_MONTH 0x013580E8 #define RCT2_ADDRESS_MAP_SIZE_UNITS 0x01358830 -#define RCT2_ADDRESS_MAP_MAXIMUM_X_Y 0x01358832 +#define RCT2_ADDRESS_MAP_SIZE_MINUS_2 0x01358832 #define RCT2_ADDRESS_MAP_SIZE 0x01358834 +#define RCT2_ADDRESS_MAP_MAX_XY 0x01358836 #define RCT2_ADDRESS_PARK_SIZE 0x013580EA #define RCT2_TOTAL_RIDE_VALUE 0x013580EE diff --git a/src/interface/viewport.c b/src/interface/viewport.c index f3c462988a..eaa10bc927 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -260,7 +260,7 @@ void sub_689174(sint16* x, sint16* y, sint16 *z) // HACK: This is to prevent the x and y values being set to values outside // of the map. This can happen when the height is larger than the map size. - sint16 max = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16); + sint16 max = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, sint16); if (pos.x > max && pos.y > max) { int x_corr[] = { -1, 1, 1, -1 }; int y_corr[] = { -1, -1, 1, 1 }; @@ -483,12 +483,12 @@ void viewport_update_position(rct_window *window) } //Clamp to the map maximum value (scenario specific) - if (x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ - x = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16); + if (x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, sint16)){ + x = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, sint16); at_map_edge = 1; } - if (y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ - y = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16); + if (y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, sint16)){ + y = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, sint16); at_map_edge = 1; } diff --git a/src/rct1.c b/src/rct1.c index ef7d150391..794507fec8 100644 --- a/src/rct1.c +++ b/src/rct1.c @@ -478,9 +478,9 @@ static void sub_69F06A() if (!(RCT2_GLOBAL(0x013CE770, uint32) & (1 << 13))) { RCT2_GLOBAL(0x013CE770, uint32) |= (1 << 13); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) = 127 * 32; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, uint16) = 4350; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, uint16) = 4350; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) = 128; - RCT2_GLOBAL(0x01358836, uint16) = 4095; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16) = 4095; } if (!(RCT2_GLOBAL(0x013CE770, uint32) & (1 << 15))) { RCT2_GLOBAL(0x013CE770, uint32) |= (1 << 15); diff --git a/src/rct1.h b/src/rct1.h index abb0aa26e6..d17fbbb7d8 100644 --- a/src/rct1.h +++ b/src/rct1.h @@ -154,10 +154,10 @@ typedef struct { uint16 cheat_detection_sv6_sc4[4]; uint16 unk_199C84; uint16 unk_199C86; - uint16 map_size_unk_a; + uint16 map_size_units; uint16 map_size_unk_b; uint16 map_size; - uint16 map_size_unk_c; + uint16 map_size_max_xy; uint32 same_price_flags; uint16 unk_199C94; uint8 unk_199C96[3]; diff --git a/src/ride/track.c b/src/ride/track.c index bc686e0c2e..dc47d39580 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -686,7 +686,7 @@ int backup_map(){ uint8* backup_info = RCT2_GLOBAL(0xF440F5, uint8*); *(uint32*)backup_info = RCT2_GLOBAL(0x0140E9A4, uint32); *(uint16*)(backup_info + 4) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16); - *(uint16*)(backup_info + 6) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, uint16); + *(uint16*)(backup_info + 6) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, uint16); *(uint16*)(backup_info + 8) = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16); *(uint32*)(backup_info + 10) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32); return 1; @@ -703,7 +703,7 @@ void reload_map_backup(){ uint8* backup_info = RCT2_GLOBAL(0xF440F5, uint8*); RCT2_GLOBAL(0x0140E9A4, uint32) = *(uint32*)backup_info; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) = *(uint16*)(backup_info + 4); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, uint16) = *(uint16*)(backup_info + 6); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, uint16) = *(uint16*)(backup_info + 6); RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16) = *(uint16*)(backup_info + 8); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint32) = *(uint32*)(backup_info + 10); @@ -718,7 +718,7 @@ void blank_map(){ // These values were previously allocated in backup map but // it seems more fitting to place in this function RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) = 0x1FE0; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, uint16) = 0x20FE; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, uint16) = 0x20FE; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16) = 0x100; rct_map_element* map_element; diff --git a/src/scenario.h b/src/scenario.h index 5a1a8951cc..56771d16c1 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -249,10 +249,10 @@ typedef struct { money32 cash; uint8 pad_013587FC[50]; uint16 word_0135882E; - uint16 word_01358830; - uint16 word_01358832; + uint16 map_size_units; + uint16 map_size_minus_2; uint16 map_size; - uint16 word_01358836; + uint16 map_max_xy; uint32 word_01358838; uint16 suggested_max_guests; uint16 park_rating_warning_days; diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 2763552e3d..e3c7500546 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -544,7 +544,7 @@ static void window_top_toolbar_invalidate() window_top_toolbar_widgets[WIDX_RESEARCH].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_FASTFORWARD].type = WWT_TRNBTN; window_top_toolbar_widgets[WIDX_CHEATS].type = WWT_TRNBTN; - window_top_toolbar_widgets[WIDX_DEBUG].type = WWT_TRNBTN; + window_top_toolbar_widgets[WIDX_DEBUG].type = gConfigGeneral.debugging_tools ? WWT_TRNBTN : WWT_EMPTY; if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)) { window_top_toolbar_widgets[WIDX_PAUSE].type = WWT_EMPTY; @@ -555,7 +555,6 @@ static void window_top_toolbar_invalidate() window_top_toolbar_widgets[WIDX_FINANCES].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_RESEARCH].type = WWT_EMPTY; window_top_toolbar_widgets[WIDX_CHEATS].type = WWT_EMPTY; - window_top_toolbar_widgets[WIDX_DEBUG].type = WWT_EMPTY; if (g_editor_step != EDITOR_STEP_LANDSCAPE_EDITOR) { window_top_toolbar_widgets[WIDX_MAP].type = WWT_EMPTY; @@ -586,10 +585,6 @@ static void window_top_toolbar_invalidate() if (!gConfigInterface.toolbar_show_cheats) window_top_toolbar_widgets[WIDX_CHEATS].type = WWT_EMPTY; - - if (!gConfigGeneral.debugging_tools) - window_top_toolbar_widgets[WIDX_DEBUG].type = WWT_EMPTY; - } enabledWidgets = 0; diff --git a/src/world/footpath.c b/src/world/footpath.c index d9c475515e..7caa8dbadf 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -51,9 +51,9 @@ static void automatically_set_peep_spawn(int x, int y, int z) int direction = 0; if (x != 32) { direction++; - if (y != RCT2_GLOBAL(0x001358830, uint16) - 32) { + if (y != RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) - 32) { direction++; - if (x != RCT2_GLOBAL(0x001358830, uint16) - 32) { + if (x != RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) - 32) { direction++; if (y != 32) return; @@ -309,7 +309,7 @@ static money32 footpath_place_real(int type, int x, int y, int z, int slope, int RCT2_GLOBAL(0x00F3EFA4, uint8) = 0; RCT2_GLOBAL(0x00F3EF88, uint16) = path_bit_type; // di - if (x >= RCT2_GLOBAL(0x01358830, uint16) || y >= RCT2_GLOBAL(0x01358830, uint16)) { + if (x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) || y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16)) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_OFF_EDGE_OF_MAP; return MONEY32_UNDEFINED; } diff --git a/src/world/map.c b/src/world/map.c index 1a765ddf59..fc4988a85e 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -255,10 +255,10 @@ void map_init(int size) RCT2_GLOBAL(RCT2_ADDRESS_GRASS_SCENERY_TILEPOS, sint16) = 0; _sub_6A876D_save_x = 0; _sub_6A876D_save_y = 0; - RCT2_GLOBAL(0x01358830, sint16) = size * 32 - 32; - RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16) = size * 32 - 2; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, sint16) = size * 32 - 32; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_MINUS_2, sint16) = size * 32 - 2; RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, sint16) = size; - RCT2_GLOBAL(0x01358836, sint16) = size * 32 - 33; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, sint16) = size * 32 - 33; RCT2_GLOBAL(0x01359208, sint16) = 7; map_update_tile_pointers(); RCT2_CALLPROC_EBPSAFE(0x0068ADBC); @@ -1264,8 +1264,8 @@ money32 map_clear_scenery(int x0, int y0, int x1, int y1, int flags) x0 = max(x0, 32); y0 = max(y0, 32); - x1 = min(x1, RCT2_GLOBAL(0x01358836, uint16)); - y1 = min(y1, RCT2_GLOBAL(0x01358836, uint16)); + x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); + y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); totalCost = 0; for (y = y0; y <= y1; y += 32) { @@ -1303,8 +1303,8 @@ money32 map_change_surface_style(int x0, int y0, int x1, int y1, uint8 surfaceSt x0 = max(x0, 32); y0 = max(y0, 32); - x1 = min(x1, RCT2_GLOBAL(0x01358836, uint16)); - y1 = min(y1, RCT2_GLOBAL(0x01358836, uint16)); + x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); + y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); int xMid, yMid; @@ -1450,7 +1450,7 @@ static money32 sub_66397F(int flags, int x, int y, int height, int style, int se } } - if (x > RCT2_GLOBAL(0x01358836, uint16) || y > RCT2_GLOBAL(0x01358836, uint16)) { + if (x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16) || y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_OFF_EDGE_OF_MAP; return MONEY32_UNDEFINED; } @@ -1496,8 +1496,8 @@ money32 raise_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b ax = max(ax, 32); ay = max(ay, 32); - bx = min(bx, RCT2_GLOBAL(0x01358836, uint16)); - by = min(by, RCT2_GLOBAL(0x01358836, uint16)); + bx = min(bx, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); + by = min(by, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); // find lowest map element in selection for (int yi = ay; yi <= by; yi += 32) { @@ -1549,8 +1549,8 @@ money32 lower_land(int flags, int x, int y, int z, int ax, int ay, int bx, int b ax = max(ax, 32); ay = max(ay, 32); - bx = min(bx, RCT2_GLOBAL(0x01358836, uint16)); - by = min(by, RCT2_GLOBAL(0x01358836, uint16)); + bx = min(bx, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); + by = min(by, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); // find highest map element in selection for (int yi = ay; yi <= by; yi += 32) { @@ -1609,8 +1609,8 @@ money32 raise_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) x0 = max(x0, 32); y0 = max(y0, 32); - x1 = min(x1, RCT2_GLOBAL(0x01358836, uint16)); - y1 = min(y1, RCT2_GLOBAL(0x01358836, uint16)); + x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); + y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); for (int yi = y0; yi <= y1; yi += 32) { for (int xi = x0; xi <= x1; xi += 32) { @@ -1676,8 +1676,8 @@ money32 lower_water(sint16 x0, sint16 y0, sint16 x1, sint16 y1, uint8 flags) x0 = max(x0, 32); y0 = max(y0, 32); - x1 = min(x1, RCT2_GLOBAL(0x01358836, uint16)); - y1 = min(y1, RCT2_GLOBAL(0x01358836, uint16)); + x1 = min(x1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); + y1 = min(y1, RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16)); for (int yi = y0; yi <= y1; yi += 32){ for (int xi = x0; xi <= x1; xi += 32){ @@ -1966,7 +1966,7 @@ void game_command_place_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi RCT2_GLOBAL(0x009DEA60, uint16) += 16; if(RCT2_GLOBAL(RCT2_ADDRESS_GAME_PAUSED, uint8) == 0 || gConfigCheat.build_in_pause_mode){ if(sub_68B044()){ - if(RCT2_GLOBAL(0x009D8150, uint8) & 1 || (x <= RCT2_GLOBAL(0x01358836, uint16) && y <= RCT2_GLOBAL(0x01358836, uint16))){ + if(RCT2_GLOBAL(0x009D8150, uint8) & 1 || (x <= RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16) && y <= RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16))){ rct_scenery_entry* scenery_entry = (rct_scenery_entry*)object_entry_groups[OBJECT_TYPE_SMALL_SCENERY].chunks[scenery_type]; if((scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_FULL_TILE && scenery_entry->small_scenery.flags & (SMALL_SCENERY_FLAG9 | SMALL_SCENERY_FLAG24 | SMALL_SCENERY_FLAG25)) || scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG9){ quadrant = 0;