From 8c109307cfc1c5acd1556e22ea2b1c39d72d3783 Mon Sep 17 00:00:00 2001 From: Florian Will Date: Sat, 27 Apr 2019 11:51:59 +0200 Subject: [PATCH] Fix #8507: Incorrect change in vehicle rolling direction In OpenRCT2, when vehicles roll backward on a long, flat track piece, they would eventually change their direction of movement and move forward instead, after their velocity reached -4095. The acceleration due to rolling resistance and drag changes to 0 at that point, which caused the "implicit boost" up to a velocity of ~+32k (close to 2km/h) to trigger. The behavior is different in vanilla RCT2, where vehicles just keep on very slowly rolling backwards. This commit disables the "implicit forward boost" for vehicles rolling backward to mimic vanilla RCT2 behavior. --- distribution/changelog.txt | 1 + src/openrct2/network/Network.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 15 ++++++--------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index fed59bb16f..1120140d56 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -21,6 +21,7 @@ - Fix: [#7700, #8079, #8969] Crash when unloading buggy custom rides. - Fix: [#7878] Scroll shortcut keys ignore SHIFT/CTRL/ALT modifiers. - Fix: [#8219] Faulty folder recreation in "save" folder. +- Fix: [#8507] Incorrect change in vehicle rolling direction. - Fix: [#8537] Imported RCT1 rides/shops are all numbered 1. - Fix: [#8649] Setting date does not work in multiplayer. - Fix: [#8873] Potential crash when placing footpaths. diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 6e890297ff..de7e56f261 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -31,7 +31,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 "21" +#define NETWORK_STREAM_VERSION "22" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 40665151c7..1c52163f3f 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -9766,17 +9766,14 @@ int32_t vehicle_update_track_motion(rct_vehicle* vehicle, int32_t* outStation) { vehicle_update_track_motion_powered_ride_acceleration(vehicle, vehicleEntry, totalMass, &acceleration); } - else + else if (acceleration <= 0 && acceleration >= -500) { - if (acceleration <= 0) + // Probably moving slowly on a flat track piece, low rolling resistance and drag. + + if (vehicle->velocity <= 0x8000 && vehicle->velocity >= 0) { - if (acceleration >= -500) - { - if (vehicle->velocity <= 0x8000) - { - acceleration += 400; - } - } + // Vehicle is creeping forwards very slowly (less than ~2km/h), boost speed a bit. + acceleration += 400; } }