Fix possible cause for desyncs on ride crashes (#10104)

`scenario_rand` was used twice between two sequence points. The order of evaluation is unspecified in C++, meaning that these calls could be done in both forward and reverse order. Storing them in variables guarantees their order, making this cross-platform.
This commit is contained in:
Hielke Morsink 2019-10-16 21:51:59 +02:00 committed by GitHub
parent acab73ae6a
commit 8c1ccfdaa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 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 "18"
#define NETWORK_STREAM_VERSION "19"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;

View File

@ -5371,9 +5371,9 @@ static void vehicle_update_crash(rct_vehicle* vehicle)
curVehicle->crash_z++;
if ((scenario_rand() & 0xFFFF) <= 0x1555)
{
sprite_misc_explosion_cloud_create(
curVehicle->x + ((scenario_rand() & 2) - 1), curVehicle->y + ((scenario_rand() & 2) - 1),
curVehicle->z);
auto xOffset = (scenario_rand() & 2) - 1;
auto yOffset = (scenario_rand() & 2) - 1;
sprite_misc_explosion_cloud_create(curVehicle->x + xOffset, curVehicle->y + yOffset, curVehicle->z);
}
}
if (curVehicle->var_C8 + 7281 > 0xFFFF)