From b64cd74a0ce1ba55d02cc57d8a311a4d00ff48ea Mon Sep 17 00:00:00 2001 From: Tyler Trahan Date: Wed, 17 Apr 2024 14:42:49 -0400 Subject: [PATCH] Codefix: Don't mix signed and unsigned ints in unbunching calculations (#12514) --- src/vehicle.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 5db7dcbf9b..e06a21445c 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2510,7 +2510,7 @@ void Vehicle::LeaveUnbunchingDepot() SetWindowDirty(WC_VEHICLE_TIMETABLE, this->index); /* Find the average travel time of vehicles that we share orders with. */ - uint num_vehicles = 0; + int num_vehicles = 0; TimerGameTick::Ticks total_travel_time = 0; Vehicle *u = this->FirstShared(); @@ -2523,10 +2523,10 @@ void Vehicle::LeaveUnbunchingDepot() } /* Make sure we cannot divide by 0. */ - num_vehicles = std::max(num_vehicles, 1u); + num_vehicles = std::max(num_vehicles, 1); /* Calculate the separation by finding the average travel time, then calculating equal separation (minimum 1 tick) between vehicles. */ - TimerGameTick::Ticks separation = std::max((total_travel_time / num_vehicles / num_vehicles), 1u); + TimerGameTick::Ticks separation = std::max((total_travel_time / num_vehicles / num_vehicles), 1); TimerGameTick::TickCounter next_departure = TimerGameTick::counter + separation; /* Set the departure time of all vehicles that we share orders with. */