From f7fe55bcb17bea92373244628bbdd1f8fffcb5d0 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Fri, 14 Mar 2025 23:43:09 +0100 Subject: [PATCH] Codefix: potential underflow of station rating --- src/station_cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index ee05cd39d9..25b006e558 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -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(rating) - or_, -2, 2); + ge->rating = rating = ClampTo(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 */