(svn r20199) -Fix [FS#3964]: NewGRFs that defined a vehicle without either loaded or loading groups could crash OpenTTD

This commit is contained in:
yexo 2010-07-21 11:29:59 +00:00
parent 3e44b5e2e3
commit 5ac645ac1f
1 changed files with 2 additions and 0 deletions

View File

@ -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);