From 01c4c0adc576b7942db9b13137b26ecfac9e7909 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Mon, 21 Dec 2015 22:45:52 +0100 Subject: [PATCH 1/4] Allow setting ownership of map edges --- distribution/changelog.txt | 1 + src/localisation/string_ids.h | 3 +++ src/world/park.c | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 076e9aa443..206c4bdfa0 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -29,6 +29,7 @@ - Feature: Ability to automatically open shops after placing them. - Feature: Ability to change the default inspection interval for rides. - Feature: Ability to disable lightning effect during a thunderstorm. +- Feature: Ability to set ownership of map edges. - Feature: Display a chat hotkey when joining a server. - Change: Server IP addresses are no longer shown in the server list. - Change: Theme format changed from INI to JSON (INI format no longer supported). diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index c843a189cd..c3c149b3ad 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -686,6 +686,8 @@ enum { STR_CANT_OPEN_PARK = 1723, STR_CANT_CLOSE_PARK = 1724, + STR_LAND_NOT_FOR_SALE = 1726, + STR_CONSTRUCTION_RIGHTS_NOT_FOR_SALE = 1727, STR_LAND_NOT_OWNED_BY_PARK = 1729, @@ -1770,6 +1772,7 @@ enum { STR_CANT_DECREASE_MAP_SIZE_ANY_FURTHER = 3213, STR_CANT_INCREASE_MAP_SIZE_ANY_FURTHER = 3214, + STR_TOO_CLOSE_TO_EDGE_OF_MAP = 3215, STR_SELECT_PARK_OWNED_LAND_TIP = 3216, diff --git a/src/world/park.c b/src/world/park.c index 1ec9193511..db904f4500 100644 --- a/src/world/park.c +++ b/src/world/park.c @@ -721,6 +721,12 @@ void update_park_fences(int x, int y) if (y > 0x1FFF) return; + // When setting the ownership of map edges + if (x <= 0 || x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16)) + return; + if (y <= 0 || y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16)) + return; + rct_map_element* sufaceElement = map_get_surface_element_at(x / 32, y / 32); if (sufaceElement == NULL)return; @@ -932,7 +938,7 @@ money32 map_buy_land_rights_for_tile(int x, int y, int setting, int flags) { } if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) != 0 || (surfaceElement->properties.surface.ownership & OWNERSHIP_AVAILABLE) == 0) { - gGameCommandErrorText = 1726; // Land not for sale! + gGameCommandErrorText = STR_LAND_NOT_FOR_SALE; return MONEY32_UNDEFINED; } if (flags & GAME_COMMAND_FLAG_APPLY) { @@ -960,7 +966,7 @@ money32 map_buy_land_rights_for_tile(int x, int y, int setting, int flags) { } if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) != 0 || (surfaceElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) == 0) { - gGameCommandErrorText = 1727; // Construction rights not for sale! + gGameCommandErrorText = STR_CONSTRUCTION_RIGHTS_NOT_FOR_SALE; return MONEY32_UNDEFINED; } @@ -996,13 +1002,13 @@ money32 map_buy_land_rights_for_tile(int x, int y, int setting, int flags) { return MONEY32_UNDEFINED; } - if (x <= 32 || y <= 32) { - gGameCommandErrorText = 3215; + if (x <= 0 || y <= 0) { + gGameCommandErrorText = STR_TOO_CLOSE_TO_EDGE_OF_MAP; return MONEY32_UNDEFINED; } - if (x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) - 32 || y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) - 32) { - gGameCommandErrorText = 3215; + if (x >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) || y >= RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16)) { + gGameCommandErrorText = STR_TOO_CLOSE_TO_EDGE_OF_MAP; return MONEY32_UNDEFINED; } From ed9334f9448040b36f081a3ae493b28e589f0f49 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 17 Jan 2016 17:23:56 +0100 Subject: [PATCH 2/4] Rename sub_68AE2A to clear_elements_at --- src/world/map.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/world/map.c b/src/world/map.c index 011af5b756..8265541ae4 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -71,7 +71,7 @@ bool gClearFootpath; static void tiles_init(); static void map_update_grass_length(int x, int y, rct_map_element *mapElement); static void map_set_grass_length(int x, int y, rct_map_element *mapElement, int length); -static void sub_68AE2A(int x, int y); +static void clear_elements_at(int x, int y); static void translate_3d_to_2d(int rotation, int *x, int *y); static void map_obstruction_set_error_text(rct_map_element *mapElement); @@ -4384,7 +4384,7 @@ void map_remove_out_of_range_elements() for (int y = 0; y < (256 * 32); y += 32) { for (int x = 0; x < (256 * 32); x += 32) { if (x == 0 || y == 0 || x >= mapMaxXY || y >= mapMaxXY) { - sub_68AE2A(x, y); + clear_elements_at(x, y); } else if (x >= mapMaxXY - 32 || y >= mapMaxXY - 32) { RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) += 32; map_buy_land_rights(x, y, x, y, 6, GAME_COMMAND_FLAG_APPLY); @@ -4473,7 +4473,11 @@ void map_extend_boundary_surface() } -static void sub_68AE2A(int x, int y) +/** + * Clears all elements properly from a certain tile. + * rct2: 0x0068AE2A + */ +static void clear_elements_at(int x, int y) { for (;;) { rct2_peep_spawn *peepSpawns = RCT2_ADDRESS(RCT2_ADDRESS_PEEP_SPAWNS, rct2_peep_spawn); @@ -4894,7 +4898,7 @@ void map_clear_all_elements() { for (int y = 0; y < (256 * 32); y += 32) { for (int x = 0; x < (256 * 32); x += 32) { - sub_68AE2A(x, y); + clear_elements_at(x, y); } } } From 15727b68a9b9ff1a68e1f5ebc504e299c58e76b4 Mon Sep 17 00:00:00 2001 From: Hielke Morsink <123mannetje@gmail.com> Date: Mon, 4 Apr 2016 09:08:55 +0200 Subject: [PATCH 3/4] Recalculating the fences when resizing the map --- src/windows/map.c | 6 ++++++ src/world/map.c | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/windows/map.c b/src/windows/map.c index 2f81c74f05..e8fb28dc31 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -1349,6 +1349,12 @@ static void map_window_increase_map_size() map_extend_boundary_surface(); window_map_init_map(); window_map_center_on_view_point(); + // Recalculate fences + for (int y = 0; y < RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16); y += 32) { + for (int x = 0; x < RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16); x += 32) { + update_park_fences(x, y); + } + } gfx_invalidate_screen(); } diff --git a/src/world/map.c b/src/world/map.c index 8265541ae4..5013ee1f55 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -4384,11 +4384,8 @@ void map_remove_out_of_range_elements() for (int y = 0; y < (256 * 32); y += 32) { for (int x = 0; x < (256 * 32); x += 32) { if (x == 0 || y == 0 || x >= mapMaxXY || y >= mapMaxXY) { + map_buy_land_rights(x, y, x, y, 1, GAME_COMMAND_FLAG_APPLY); clear_elements_at(x, y); - } else if (x >= mapMaxXY - 32 || y >= mapMaxXY - 32) { - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) += 32; - map_buy_land_rights(x, y, x, y, 6, GAME_COMMAND_FLAG_APPLY); - RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE_UNITS, uint16) -= 32; } } } From 1dbd313fb4b1cee071613a8bf2c184b8b828397e Mon Sep 17 00:00:00 2001 From: Hielke Morsink <123mannetje@gmail.com> Date: Mon, 4 Apr 2016 12:54:02 +0200 Subject: [PATCH 4/4] Moved logic from window to map, inside loops that already existed. --- src/windows/map.c | 6 ------ src/world/map.c | 5 ++++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/windows/map.c b/src/windows/map.c index e8fb28dc31..2f81c74f05 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -1349,12 +1349,6 @@ static void map_window_increase_map_size() map_extend_boundary_surface(); window_map_init_map(); window_map_center_on_view_point(); - // Recalculate fences - for (int y = 0; y < RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16); y += 32) { - for (int x = 0; x < RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAX_XY, uint16); x += 32) { - update_park_fences(x, y); - } - } gfx_invalidate_screen(); } diff --git a/src/world/map.c b/src/world/map.c index 5013ee1f55..495a8ef87b 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -4432,6 +4432,8 @@ void map_extend_boundary_surface() newMapElement->properties.surface.slope |= slope; newMapElement->base_height = z; newMapElement->clearance_height = z; + + update_park_fences(x << 5, y << 5); } x = RCT2_GLOBAL(RCT2_ADDRESS_MAP_SIZE, uint16) - 2; @@ -4466,8 +4468,9 @@ void map_extend_boundary_surface() newMapElement->properties.surface.slope |= slope; newMapElement->base_height = z; newMapElement->clearance_height = z; - } + update_park_fences(x << 5, y << 5); + } } /**