From ed1dfa39c257fb14b9094f971a82f84082b07e46 Mon Sep 17 00:00:00 2001 From: crorvig Date: Thu, 5 Sep 2019 23:21:50 -0400 Subject: [PATCH 1/4] Fix #9955 Allow resizing of map in pause mode Prevents infinite loop by forcing BuildInPauseMode on for the duration of the map_remove_out_of_range_elements() call. --- src/openrct2/world/Map.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index f4a30336d3..c49632847e 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1541,6 +1541,8 @@ void map_restore_provisional_elements() void map_remove_out_of_range_elements() { int32_t mapMaxXY = gMapSizeMaxXY; + //#9955 ensure that we can remove elements + bool buildState = gCheatsBuildInPauseMode; for (int32_t y = 0; y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); y += 32) { @@ -1559,6 +1561,8 @@ void map_remove_out_of_range_elements() } } } + //#9955 reset cheat state + CheatsSet(CheatType::BuildInPauseMode, buildState); } static void map_extend_boundary_surface_extend_tile(const SurfaceElement& sourceTile, SurfaceElement& destTile) From 7f54ba0be7dfc8553a17c9c105ca37686fe5f969 Mon Sep 17 00:00:00 2001 From: crorvig Date: Thu, 5 Sep 2019 23:25:29 -0400 Subject: [PATCH 2/4] Set BuildInPauseMode to true during map_remove_out_of_range_elements() Set BuildInPauseMode to true during map_remove_out_of_range_elements() --- src/openrct2/world/Map.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index c49632847e..5174b21991 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1543,6 +1543,7 @@ void map_remove_out_of_range_elements() int32_t mapMaxXY = gMapSizeMaxXY; //#9955 ensure that we can remove elements bool buildState = gCheatsBuildInPauseMode; + CheatsSet(CheatType::BuildInPauseMode, true); for (int32_t y = 0; y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); y += 32) { From db5c018e2245988994ea96d689e1a8f40ab75fd0 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 3 Oct 2019 22:22:24 +0200 Subject: [PATCH 3/4] Add requested check --- src/openrct2/world/Map.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 5174b21991..22af58af05 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1541,28 +1541,33 @@ void map_restore_provisional_elements() void map_remove_out_of_range_elements() { int32_t mapMaxXY = gMapSizeMaxXY; - //#9955 ensure that we can remove elements + // Ensure that we can remove elements bool buildState = gCheatsBuildInPauseMode; CheatsSet(CheatType::BuildInPauseMode, true); - for (int32_t y = 0; y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); y += 32) + // Since we might lack cheat permission, check if the cheat has really been turned on. + if (gCheatsBuildInPauseMode) { - for (int32_t x = 0; x < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); x += 32) + for (int32_t y = 0; y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); y += 32) { - if (x == 0 || y == 0 || x >= mapMaxXY || y >= mapMaxXY) + for (int32_t x = 0; x < (MAXIMUM_MAP_SIZE_TECHNICAL * 32); x += 32) { - // Note this purposely does not use LandSetRightsAction as X Y coordinates are outside of normal range. - auto surfaceElement = map_get_surface_element_at({ x, y }); - if (surfaceElement != nullptr) + if (x == 0 || y == 0 || x >= mapMaxXY || y >= mapMaxXY) { - surfaceElement->SetOwnership(OWNERSHIP_UNOWNED); - update_park_fences_around_tile({ x, y }); + // Note this purposely does not use LandSetRightsAction as X Y coordinates are outside of normal range. + auto surfaceElement = map_get_surface_element_at({ x, y }); + if (surfaceElement != nullptr) + { + surfaceElement->SetOwnership(OWNERSHIP_UNOWNED); + update_park_fences_around_tile({ x, y }); + } + clear_elements_at({ x, y }); } - clear_elements_at({ x, y }); } } } - //#9955 reset cheat state + + //#Reset cheat state CheatsSet(CheatType::BuildInPauseMode, buildState); } From d5866e1d14cf3470123b9b7ace4b88a6fc426727 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 3 Oct 2019 22:27:19 +0200 Subject: [PATCH 4/4] Update changelog [ci skip] --- distribution/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 09bccccac2..3140844ac6 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -21,6 +21,7 @@ - Fix: [#9729] Peeps do not take into account height difference when deciding to pathfind to a ride entrance (original bug). - Fix: [#9902] Doors/Portcullis do not check to make sure doors are open causing double opens. - Fix: [#9926] Africa - Oasis park has wrong peep spawn (original bug). +- Fix: [#9955] Resizing map in while pause mode does not work and may result in freezes. - Fix: [#9957] When using 'no money' cheat, guests complain of running out of cash. - Fix: [#9970] Wait for quarter load fails. - Fix: [#10017] Ghost elements influencing ride excitement.