From d6cd62e633f8ec7ef15fac4c2d5c1ae120b9ad03 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 20 Aug 2010 15:35:14 +0000 Subject: (svn r20581) -Codechange: simplify getting the station in CalcPercentVehicleFilled --- src/vehicle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c19d03abc..5384f2954 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1038,7 +1038,9 @@ uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour) bool loading = false; const Vehicle *u = v; - const Station *st = v->last_station_visited != INVALID_STATION ? Station::Get(v->last_station_visited) : NULL; + /* The station may be NULL when the (colour) string does not need to be set. */ + const Station *st = Station::GetIfValid(v->last_station_visited); + assert(colour == NULL || st != NULL); /* Count up max and used */ for (; v != NULL; v = v->Next()) { -- cgit v1.2.3-70-g09d2