changeset 11059:b843df5d362a draft

(svn r15399) -Fix [FS#2617]: For articulated parts v->cargo_type == CT_INVALID is possible.
author frosch <frosch@openttd.org>
date Sat, 07 Feb 2009 16:17:03 +0000
parents f68131a5cf7e
children d85c5180effe
files src/newgrf_engine.cpp
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -845,6 +845,12 @@
 
 	const Engine *e = GetEngine(engine);
 
+	/* Engines are not available, when their cargo is not available.
+	 * But that does not apply to articulated parts. */
+	if (cargo == CT_INVALID) cargo = CT_DEFAULT;
+
+	assert(cargo < lengthof(e->group));
+
 	group = e->group[cargo];
 	if (group != NULL) return group;