summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-07-21 11:29:59 +0000
committeryexo <yexo@openttd.org>2010-07-21 11:29:59 +0000
commit5ac645ac1f98dea19976a935465057a4337836b8 (patch)
tree0bfcd946ff3630545ad7a31c7d110ec63d95f9f1 /src
parent3e44b5e2e32d91f1f326efd67658c9d53122b795 (diff)
downloadopenttd-5ac645ac1f98dea19976a935465057a4337836b8.tar.xz
(svn r20199) -Fix [FS#3964]: NewGRFs that defined a vehicle without either loaded or loading groups could crash OpenTTD
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp2
1 files changed, 2 insertions, 0 deletions
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);