(svn r27426) -Change: Round loading percentage in loading indicators and conditional orders towards 50%, so that 0% and 100% mean completely empty or full.

This commit is contained in:
frosch
2015-10-30 17:24:05 +00:00
parent c74ffeecd1
commit 0f8f738942

View File

@@ -1290,6 +1290,9 @@ void AgeVehicle(Vehicle *v)
* @param front The front vehicle of the consist to check. * @param front The front vehicle of the consist to check.
* @param colour The string to show depending on if we are unloading or loading * @param colour The string to show depending on if we are unloading or loading
* @return A percentage of how full the Vehicle is. * @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) uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour)
{ {
@@ -1337,8 +1340,14 @@ uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour)
if (max == 0) return 100; if (max == 0) return 100;
/* Return the percentage */ /* Return the percentage */
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; return (count * 100) / max;
} }
}
/** /**
* Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc. * Vehicle entirely entered the depot, update its status, orders, vehicle windows, service it, etc.