summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-12 12:51:16 +0000
committerrubidium <rubidium@openttd.org>2008-04-12 12:51:16 +0000
commit8c89250f58116309341c04ff4fc5d31887e8b180 (patch)
tree09b1450efc8dde9130eaac53fb3c345d2f94a0c6 /src
parent8410bff0782280166d172a8cc9021dca83a4f6df (diff)
downloadopenttd-8c89250f58116309341c04ff4fc5d31887e8b180.tar.xz
(svn r12669) -Fix (r12667): crash when a vehicle has never been to a station and the load percentage conditional variable is evaluated.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 34d7803fe..b1cd16763 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2150,13 +2150,13 @@ uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color)
bool loading = false;
const Vehicle *u = v;
- const Station *st = GetStation(v->last_station_visited);
+ const Station *st = v->last_station_visited != INVALID_STATION ? GetStation(v->last_station_visited) : NULL;
/* Count up max and used */
for (; v != NULL; v = v->Next()) {
count += v->cargo.Count();
max += v->cargo_cap;
- if (v->cargo_cap != 0) {
+ if (v->cargo_cap != 0 && color != NULL) {
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++;