1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 16:54:52 +01:00

Fix #7341: Staff may auto-spawn on guests walking outside of paths

Staff placement code has been modified to only count guests who are on path tiles.
If all guests in the park are off paths, then the park entrance is used as a fallback.
This commit is contained in:
William Fu
2018-05-15 06:19:07 -04:00
committed by Aaron van Geffen
parent 59e682a835
commit aece198560
3 changed files with 20 additions and 9 deletions

View File

@@ -34,7 +34,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "10"
#define NETWORK_STREAM_VERSION "11"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static rct_peep* _pickup_peep = nullptr;

View File

@@ -89,16 +89,22 @@ static inline void staff_autoposition_new_staff_member(rct_peep * newPeep)
newPeep->state = PEEP_STATE_FALLING;
sint16 x, y, z;
uint32 count = 0;
uint16 sprite_index;
rct_peep * guest = nullptr;
sint16 x, y, z;
uint32 count = 0;
uint16 sprite_index;
rct_peep * guest = nullptr;
rct_tile_element * guest_tile = nullptr;
// Count number of walking guests
FOR_ALL_GUESTS(sprite_index, guest)
{
if (guest->state == PEEP_STATE_WALKING)
++count;
{
// Check the walking guest's tile. Only count them if they're on a path tile.
guest_tile = map_get_path_element_at(guest->next_x / 32, guest->next_y / 32, guest->next_z);
if (guest_tile != nullptr)
++count;
}
}
if (count > 0)
@@ -109,9 +115,13 @@ static inline void staff_autoposition_new_staff_member(rct_peep * newPeep)
{
if (guest->state == PEEP_STATE_WALKING)
{
if (rand == 0)
break;
--rand;
guest_tile = map_get_path_element_at(guest->next_x / 32, guest->next_y / 32, guest->next_z);
if (guest_tile != nullptr)
{
if (rand == 0)
break;
--rand;
}
}
}