1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 12:33:17 +01:00

Clamp values in vehicle.c to prevent signed overflow

This commit is contained in:
Michał Janiszewski
2017-02-19 22:48:27 +01:00
committed by GitHub
parent f73aebe51d
commit 0f40930ec9
2 changed files with 3 additions and 3 deletions

View File

@@ -55,7 +55,7 @@ extern "C" {
// This define 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 "4"
#define NETWORK_STREAM_VERSION "5"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
#ifdef __cplusplus

View File

@@ -1251,7 +1251,7 @@ static void vehicle_update_measurements(rct_vehicle *vehicle)
sint32 distance = abs(((vehicle->velocity + vehicle->acceleration) >> 10) * 42);
if (vehicle->var_CE == 0){
ride->length[test_segment] += distance;
ride->length[test_segment] = add_clamp_sint32(ride->length[test_segment], distance);
}
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_G_FORCES)){
@@ -1538,7 +1538,7 @@ static void vehicle_update_measurements(rct_vehicle *vehicle)
sint32 distance = ((vehicle->velocity + vehicle->acceleration) >> 10) * 42;
if (distance < 0)return;
ride->sheltered_length += distance;
ride->sheltered_length = add_clamp_sint32(ride->sheltered_length, distance);
}
static uint16 sub_6D7AC0(sint32 currentSoundId, sint32 currentVolume, sint32 targetSoundId, sint32 targetVolume)