diff options
author | frosch <frosch@openttd.org> | 2015-10-30 17:24:05 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2015-10-30 17:24:05 +0000 |
commit | 312809228d52009191e2000cc1a49272b48f9699 (patch) | |
tree | 73cb9b4dafeb07e368cfac307a7e1963f07b6bd2 | |
parent | 44d1fc42530a304e501e4f41ff0c26bf19971e6a (diff) | |
download | openttd-312809228d52009191e2000cc1a49272b48f9699.tar.xz |
(svn r27426) -Change: Round loading percentage in loading indicators and conditional orders towards 50%, so that 0% and 100% mean completely empty or full.
-rw-r--r-- | src/vehicle.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 46f98fe63..a482520f2 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1290,6 +1290,9 @@ void AgeVehicle(Vehicle *v) * @param front The front vehicle of the consist to check. * @param colour The string to show depending on if we are unloading or loading * @return A percentage of how full the Vehicle is. + * Percentages are rounded towards 50%, so that 0% and 100% are only returned + * if the vehicle is completely empty or full. + * This is useful for both display and conditional orders. */ uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour) { @@ -1337,7 +1340,13 @@ uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour) if (max == 0) return 100; /* Return the percentage */ - return (count * 100) / max; + if (count * 2 < max) { + /* Less than 50%; round up, so that 0% means really empty. */ + return CeilDiv(count * 100, max); + } else { + /* More than 50%; round down, so that 100% means really full. */ + return (count * 100) / max; + } } /** |