1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Avoid booster speed overflows and undefined behaviour, fixes #5679

This commit is contained in:
Gymnasiast
2017-06-21 09:54:36 +02:00
parent 1f180c19b3
commit 16900dd618
2 changed files with 7 additions and 3 deletions

View File

@@ -8612,10 +8612,14 @@ bool ride_type_supports_boosters(uint8 rideType)
return false;
}
uint16 get_booster_speed(uint8 rideType, uint16 rawSpeed)
sint32 get_booster_speed(uint8 rideType, sint32 rawSpeed)
{
sint8 shiftFactor = RideProperties[rideType].booster_speed_factor;
if (shiftFactor > 0)
if (shiftFactor == 0)
{
return rawSpeed;
}
else if (shiftFactor > 0)
{
return (rawSpeed << shiftFactor);
}

View File

@@ -1194,6 +1194,6 @@ const char * ride_type_get_enum_name(sint32 rideType);
uint8 ride_entry_get_first_non_null_ride_type(rct_ride_entry * rideEntry);
bool ride_type_supports_boosters(uint8 rideType);
uint16 get_booster_speed(uint8 rideType, uint16 rawSpeed);
sint32 get_booster_speed(uint8 rideType, sint32 rawSpeed);
#endif