Changeset - r8897:b8b92d97ba94
[Not reviewed]
master
0 1 0
rubidium - 16 years ago 2008-04-12 09:59:58
rubidium@openttd.org
(svn r12664) -Codechange: do not force the 'color' pointer to be non-NULL when trying to get the load percentage.
1 file changed with 8 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -2146,14 +2146,12 @@ uint8 CalcPercentVehicleFilled(Vehicle *
 
	int count = 0;
 
	int max = 0;
 
	int cars = 0;
 
	int unloading = 0;
 
	bool loading = false;
 

	
 
	assert(color != NULL);
 

	
 
	const Vehicle *u = v;
 
	const Station *st = GetStation(v->last_station_visited);
 

	
 
	/* Count up max and used */
 
	for (; v != NULL; v = v->Next()) {
 
		count += v->cargo.Count();
 
@@ -2162,18 +2160,20 @@ uint8 CalcPercentVehicleFilled(Vehicle *
 
			unloading += HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) ? 1 : 0;
 
			loading |= !(u->current_order.GetUnloadType() & OUFB_UNLOAD) && st->goods[v->cargo_type].days_since_pickup != 255;
 
			cars++;
 
		}
 
	}
 

	
 
	if (unloading == 0 && loading) {
 
		*color = STR_PERCENT_UP;
 
	} else if (cars == unloading || !loading) {
 
		*color = STR_PERCENT_DOWN;
 
	} else {
 
		*color = STR_PERCENT_UP_DOWN;
 
	if (color != NULL) {
 
		if (unloading == 0 && loading) {
 
			*color = STR_PERCENT_UP;
 
		} else if (cars == unloading || !loading) {
 
			*color = STR_PERCENT_DOWN;
 
		} else {
 
			*color = STR_PERCENT_UP_DOWN;
 
		}
 
	}
 

	
 
	/* Train without capacity */
 
	if (max == 0) return 100;
 

	
 
	/* Return the percentage */
0 comments (0 inline, 0 general)