From 438b197b807e090a1a35ebace0b94e293e53bc37 Mon Sep 17 00:00:00 2001 From: Richard Fine Date: Tue, 3 Nov 2020 20:30:36 -0500 Subject: [PATCH] Debunch peeps (#12917) * Stop guests from being forced to the center line of a path over time Change the way we apply randomness to peep destinations when moving from one tile to the next, to allow peeps that are moving along a straight path to maintain their perpendicular offset relative to the path direction, instead of being (eventually) forced back to the center line. * Update test expectations The changes to guest movement mean that the number of steps taken for these expected paths are now slightly different to before. --- CMakeLists.txt | 4 ++-- distribution/changelog.txt | 1 + openrct2.proj | 4 ++-- src/openrct2/network/NetworkBase.cpp | 2 +- src/openrct2/peep/GuestPathfinding.cpp | 26 +++++++++++++++++++++++++- test/tests/Pathfinding.cpp | 10 +++++----- 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cee71e7a3..ff81ed4369 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,8 @@ set(TITLE_SEQUENCE_SHA1 "304d13a126c15bf2c86ff13b81a2f2cc1856ac8d") set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.18/objects.zip") set(OBJECTS_SHA1 "4a3c32a0251c3babe014844f2c683fc32138b3f2") -set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.19/replays.zip") -set(REPLAYS_SHA1 "8EAAE223FF9FE4D49949C9F343831977E6DB6CDE") +set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.20/replays.zip") +set(REPLAYS_SHA1 "65532bcb21c39236cfc1b7301d30297506383b65") option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(WITH_TESTS "Build tests") diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 98d81b1f75..de275a2a89 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -4,6 +4,7 @@ - Change: [#13346] Change FootpathScenery to FootpathAddition in all occurrences - Fix: [#13334] Uninitialised variables in CustomTabDesc - Fix: [#13342] Rename tabChange to onTabChange in WindowDesc interface +- Improved: [#12917] Changed peep movement so that they stay more spread out over the full width of single tile paths. 0.3.2 (2020-11-01) ------------------------------------------------------------------------ diff --git a/openrct2.proj b/openrct2.proj index fb0dbb0de8..bc535a7743 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -48,8 +48,8 @@ 304d13a126c15bf2c86ff13b81a2f2cc1856ac8d https://github.com/OpenRCT2/objects/releases/download/v1.0.18/objects.zip 4a3c32a0251c3babe014844f2c683fc32138b3f2 - https://github.com/OpenRCT2/replays/releases/download/v0.0.19/replays.zip - 8EAAE223FF9FE4D49949C9F343831977E6DB6CDE + https://github.com/OpenRCT2/replays/releases/download/v0.0.20/replays.zip + 65532bcb21c39236cfc1b7301d30297506383b65 diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 98ceb82277..9cf8fee65c 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -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 "0" +#define NETWORK_STREAM_VERSION "1" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 34342acb3e..2a55d8d9ac 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -137,7 +137,31 @@ static int32_t peep_move_one_tile(Direction direction, Peep* peep) peep->DestinationTolerance = 2; if (peep->State != PeepState::Queuing) { - peep->DestinationTolerance = (scenario_rand() & 7) + 2; + // When peeps are walking along a path, we would like them to be spread out across the width of the path, + // instead of all walking along the exact center line of the path. + // + // Setting a random DestinationTolerance does not work very well for this. It means that peeps will make + // their new pathfinding decision at a random time, and so will distribute a bit when they are turning + // corners (which is good); but, as they walk along a straight path, they will - eventually - have had a + // low tolerance value which forced them back to the center of the path, where they stay until they turn + // a corner. + // + // What we want instead is to apply that randomness in the direction they are walking ONLY, and keep their + // other coordinate constant. + + int8_t offset = (scenario_rand() & 7) - 3; + if (direction == 0 || direction == 2) + { + // Peep is moving along X, so apply the offset to the X position of the destination and keep their current Y + peep->DestinationX += offset; + peep->DestinationY = peep->y; + } + else + { + // Peep is moving along Y, so apply the offset to the Y position of the destination and keep their current X + peep->DestinationX = peep->x; + peep->DestinationY += offset; + } } return 0; } diff --git a/test/tests/Pathfinding.cpp b/test/tests/Pathfinding.cpp index 7dcdc9be71..9ee1d01483 100644 --- a/test/tests/Pathfinding.cpp +++ b/test/tests/Pathfinding.cpp @@ -215,13 +215,13 @@ TEST_P(SimplePathfindingTest, CanFindPathFromStartToGoal) INSTANTIATE_TEST_CASE_P( ForScenario, SimplePathfindingTest, ::testing::Values( - SimplePathfindingScenario("StraightFlat", { 19, 15, 14 }, 24), SimplePathfindingScenario("SBend", { 15, 12, 14 }, 88), - SimplePathfindingScenario("UBend", { 17, 9, 14 }, 86), SimplePathfindingScenario("CBend", { 14, 5, 14 }, 164), - SimplePathfindingScenario("TwoEqualRoutes", { 9, 13, 14 }, 87), - SimplePathfindingScenario("TwoUnequalRoutes", { 3, 13, 14 }, 87), + SimplePathfindingScenario("StraightFlat", { 19, 15, 14 }, 24), SimplePathfindingScenario("SBend", { 15, 12, 14 }, 87), + SimplePathfindingScenario("UBend", { 17, 9, 14 }, 87), SimplePathfindingScenario("CBend", { 14, 5, 14 }, 164), + SimplePathfindingScenario("TwoEqualRoutes", { 9, 13, 14 }, 89), + SimplePathfindingScenario("TwoUnequalRoutes", { 3, 13, 14 }, 89), SimplePathfindingScenario("StraightUpBridge", { 12, 15, 14 }, 24), SimplePathfindingScenario("StraightUpSlope", { 14, 15, 14 }, 24), - SimplePathfindingScenario("SelfCrossingPath", { 6, 5, 14 }, 213)), + SimplePathfindingScenario("SelfCrossingPath", { 6, 5, 14 }, 211)), SimplePathfindingScenario::ToName); class ImpossiblePathfindingTest : public PathfindingTestBase, public ::testing::WithParamInterface