mirror of https://github.com/OpenRCT2/OpenRCT2.git
Cap var2CTotal so it does not overflow
This commit is contained in:
parent
b1ab5c96e5
commit
99a662fc5f
|
@ -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 "25"
|
||||
#define NETWORK_STREAM_VERSION "26"
|
||||
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -475,7 +475,14 @@ int cable_lift_update_track_motion(rct_vehicle *cableLift)
|
|||
rct_vehicle* vehicle = GET_VEHICLE(spriteId);
|
||||
vehicleCount++;
|
||||
frictionTotal += vehicle->friction;
|
||||
var2CTotal += vehicle->acceleration;
|
||||
// Prevent over/underflow in var2CTotal
|
||||
if ((INT32_MAX - abs(vehicle->acceleration)) < abs(var2CTotal) &&
|
||||
(var2CTotal < 0) == (vehicle->acceleration < 0))
|
||||
{
|
||||
var2CTotal = (var2CTotal < 0) ? INT32_MIN : INT32_MAX ;
|
||||
} else {
|
||||
var2CTotal += vehicle->acceleration;
|
||||
}
|
||||
spriteId = vehicle->next_vehicle_on_train;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue