From c531898c3b7f794886b4099137dff08dff665c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Tue, 20 Sep 2016 22:22:55 +0200 Subject: [PATCH] Peeps no longer interact with provisional paths In most cases peeps treaded provisional paths like paths that were already built. Since provisional paths aren't synced in muliplayer mode this caused a lot of desync. --- src/game.c | 3 +++ src/world/footpath.c | 4 ++++ src/world/footpath.h | 2 ++ src/world/map.c | 22 ++++++++++++++++++++++ src/world/map.h | 2 ++ 5 files changed, 33 insertions(+) diff --git a/src/game.c b/src/game.c index 9ac5b51d3a..e70ae64c11 100644 --- a/src/game.c +++ b/src/game.c @@ -364,8 +364,11 @@ void game_logic_update() scenario_update(); climate_update(); map_update_tiles(); + // Temporarily remove provisional paths to prevent peep from interacting with them + map_remove_provisional_elements(); map_update_path_wide_flags(); peep_update_all(); + map_restore_provisional_elements(); vehicle_update_all(); sprite_misc_update_all(); ride_update_all(); diff --git a/src/world/footpath.c b/src/world/footpath.c index c60c1e4a50..54b19f0019 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -34,6 +34,8 @@ void sub_6A7642(int x, int y, rct_map_element *mapElement); uint8 gFootpathProvisionalFlags; rct_xyz16 gFootpathProvisionalPosition; +uint8 gFootpathProvisionalType; +uint8 gFootpathProvisionalSlope; uint8 gFootpathConstructionMode; uint16 gFootpathSelectedId; uint8 gFootpathSelectedType; @@ -614,9 +616,11 @@ money32 footpath_provisional_set(int type, int x, int y, int z, int slope) cost = footpath_place(type, x, y, z, slope, GAME_COMMAND_FLAG_GHOST | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_4 | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY); if (cost != MONEY32_UNDEFINED) { + gFootpathProvisionalType = type; gFootpathProvisionalPosition.x = x; gFootpathProvisionalPosition.y = y; gFootpathProvisionalPosition.z = z & 0xFF; + gFootpathProvisionalSlope = slope; gFootpathProvisionalFlags |= PROVISIONAL_PATH_FLAG_1; if (gFootpathGroundFlags & ELEMENT_IS_UNDERGROUND) { diff --git a/src/world/footpath.h b/src/world/footpath.h index 0ce54be54c..8dec3de84e 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -52,6 +52,8 @@ enum { extern uint8 gFootpathProvisionalFlags; extern rct_xyz16 gFootpathProvisionalPosition; +extern uint8 gFootpathProvisionalType; +extern uint8 gFootpathProvisionalSlope; extern uint8 gFootpathConstructionMode; extern uint16 gFootpathSelectedId; extern uint8 gFootpathSelectedType; diff --git a/src/world/map.c b/src/world/map.c index 2b77929541..5804c5e74f 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -4442,6 +4442,28 @@ static void map_set_grass_length(int x, int y, rct_map_element *mapElement, int map_invalidate_tile(x, y, z0, z1); } +void map_remove_provisional_elements() +{ + if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) + { + footpath_provisional_remove(); + gFootpathProvisionalFlags |= PROVISIONAL_PATH_FLAG_1; + } +} + +void map_restore_provisional_elements() +{ + if (gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) + { + gFootpathProvisionalFlags &= ~PROVISIONAL_PATH_FLAG_1; + footpath_provisional_set(gFootpathProvisionalType, + gFootpathProvisionalPosition.x, + gFootpathProvisionalPosition.y, + gFootpathProvisionalPosition.z, + gFootpathProvisionalSlope); + } +} + int map_element_get_banner_index(rct_map_element *mapElement) { rct_scenery_entry* sceneryEntry; diff --git a/src/world/map.h b/src/world/map.h index 83d559206d..2cbd6a544b 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -407,6 +407,8 @@ rct_map_element *map_get_small_scenery_element_at(int x, int y, int z, int type, int map_element_height(int x, int y); void sub_68B089(); int map_coord_is_connected(int x, int y, int z, uint8 faceDirection); +void map_remove_provisional_elements(); +void map_restore_provisional_elements(); void map_update_path_wide_flags(); bool map_is_location_valid(int x, int y); bool map_is_location_owned(int x, int y, int z);