diff --git a/distribution/changelog.txt b/distribution/changelog.txt index ead1212795..e38563aac7 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -33,6 +33,7 @@ - Fix: [#6196, #6223] Guest's energy underflows and never decreases. - Fix: [#6198] You cannot cancel RCT1 directory selection. - Fix: [#6202] Guests can break occupied benches (original bug). +- Fix: [#6261, #6344, #6520] Broken pathfinding after removing park entrances with the tile inspector - Fix: [#6271] Wrong booster speed tooltip text. - Fix: [#6308] Cannot create title sequence if title sequences folder does not exist. - Fix: [#6318] Cannot sack staff that have not been placed diff --git a/src/openrct2/game.c b/src/openrct2/game.c index 6dc5e7c810..9f50012b3e 100644 --- a/src/openrct2/game.c +++ b/src/openrct2/game.c @@ -1121,6 +1121,9 @@ void game_fix_save_vars() // Fix invalid vehicle sprite sizes, thus preventing visual corruption of sprites fix_invalid_vehicle_sprite_sizes(); + + // Fix gParkEntrance locations for which the map_element no longer exists + fix_park_entrance_locations(); } void handle_park_load_failure_with_title_opt(const ParkLoadResult * result, const utf8 * path, bool loadTitleFirst) diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index c8642d775b..20316df88d 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -683,4 +683,22 @@ extern "C" return; } while (!map_element_is_last_for_tile(mapElement++)); } + + void fix_park_entrance_locations(void) + { + // Fix gParkEntrance locations for which the map_element no longer exists + for (uint8 entranceNum = 0; entranceNum < MAX_PARK_ENTRANCES; ++entranceNum) + { + if (gParkEntrances[entranceNum].x == LOCATION_NULL) + continue; + + if (map_get_park_entrance_element_at( + gParkEntrances[entranceNum].x, + gParkEntrances[entranceNum].y, + gParkEntrances[entranceNum].z >> 3, false) == NULL) + { + gParkEntrances[entranceNum].x = LOCATION_NULL; + } + } + } } diff --git a/src/openrct2/world/entrance.h b/src/openrct2/world/entrance.h index cf686d4696..9ef19c103a 100644 --- a/src/openrct2/world/entrance.h +++ b/src/openrct2/world/entrance.h @@ -58,6 +58,8 @@ void reset_park_entrance(); void maze_entrance_hedge_replacement(sint32 x, sint32 y, rct_map_element *mapElement); void maze_entrance_hedge_removal(sint32 x, sint32 y, rct_map_element *mapElement); +void fix_park_entrance_locations(); + #ifdef __cplusplus } #endif