(svn r12180) -Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite.
authorpeter1138
Mon, 18 Feb 2008 19:20:37 +0000
changeset 9095 b5b66a0bbd2c
parent 9094 58d1cddf1af6
child 9096 6dedf7e114d0
(svn r12180) -Fix: Test purchase list loading/loaded sprites instead of unconditionally returning a possibly non-existant sprite.
src/newgrf_engine.cpp
--- a/src/newgrf_engine.cpp	Mon Feb 18 18:35:36 2008 +0000
+++ b/src/newgrf_engine.cpp	Mon Feb 18 19:20:37 2008 +0000
@@ -765,7 +765,11 @@
 	uint totalsets;
 	uint set;
 
-	if (v == NULL) return group->g.real.loading[0];
+	if (v == NULL) {
+		if (group->g.real.num_loading > 0) return group->g.real.loading[0];
+		if (group->g.real.num_loaded  > 0) return group->g.real.loaded[0];
+		return NULL;
+	}
 
 	bool in_motion = v->First()->current_order.type != OT_LOADING;