From 5ac645ac1f98dea19976a935465057a4337836b8 Mon Sep 17 00:00:00 2001 From: yexo Date: Wed, 21 Jul 2010 11:29:59 +0000 Subject: (svn r20199) -Fix [FS#3964]: NewGRFs that defined a vehicle without either loaded or loading groups could crash OpenTTD --- src/newgrf_engine.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 2caf89de1..cd48b48da 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -841,6 +841,8 @@ static const SpriteGroup *VehicleResolveReal(const ResolverObject *object, const uint totalsets = in_motion ? group->num_loaded : group->num_loading; + if (totalsets == 0) return NULL; + uint set = (v->cargo.Count() * totalsets) / max((uint16)1, v->cargo_cap); set = min(set, totalsets - 1); -- cgit v1.2.3-70-g09d2