1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-26 07:59:09 +00:00

Codefix: potential underflow of station rating

This commit is contained in:
Rubidium
2025-03-14 23:43:09 +01:00
parent ac2087a3eb
commit f7fe55bcb1

View File

@@ -3926,7 +3926,7 @@ static void UpdateStationRating(Station *st)
int or_ = ge->rating; // old rating
/* only modify rating in steps of -2, -1, 0, 1 or 2 */
ge->rating = rating = or_ + Clamp(ClampTo<uint8_t>(rating) - or_, -2, 2);
ge->rating = rating = ClampTo<uint8_t>(or_ + Clamp(rating - or_, -2, 2));
/* if rating is <= 64 and more than 100 items waiting on average per destination,
* remove some random amount of goods from the station */