Mercurial > hg > openttd
changeset 4832:7616105a7370 draft
(svn r6756) - Fix: When resolving vehicle groups, only fall back to the default group if the group chosen is undefined, not if it returns a bad result. This fixes some issues with UKRS.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Thu, 12 Oct 2006 15:05:25 +0000 |
parents | 1965a9c3ce48 |
children | fef144289a3e |
files | newgrf_engine.c |
diffstat | 1 files changed, 11 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -862,14 +862,12 @@ { const SpriteGroup *group; ResolverObject object; - CargoID cargo = GC_PURCHASE; + CargoID cargo; NewVehicleResolver(&object, engine, v); - if (v != NULL) { - cargo = _global_cargo_id[_opt.landscape][v->cargo_type]; - assert(cargo != GC_INVALID); - } + cargo = (v == NULL) ? GC_PURCHASE : _global_cargo_id[_opt.landscape][v->cargo_type]; + assert(cargo != GC_INVALID); group = engine_custom_sprites[engine][cargo]; @@ -879,13 +877,8 @@ if (overset != NULL) group = overset; } + if (group == NULL) group = engine_custom_sprites[engine][GC_DEFAULT]; group = Resolve(group, &object); - - if ((group == NULL || group->type != SGT_RESULT) && cargo != GC_DEFAULT) { - // This group is empty but perhaps there'll be a default one. - group = Resolve(engine_custom_sprites[engine][GC_DEFAULT], &object); - } - if (group == NULL || group->type != SGT_RESULT) return 0; return group->g.result.sprite + (direction % group->g.result.num_sprites); @@ -951,6 +944,7 @@ object.callback_param2 = param2; cargo = (v == NULL) ? GC_PURCHASE : _global_cargo_id[_opt.landscape][v->cargo_type]; + assert(cargo != GC_INVALID); group = engine_custom_sprites[engine][cargo]; @@ -960,13 +954,8 @@ if (overset != NULL) group = overset; } + if (group == NULL) group = engine_custom_sprites[engine][GC_DEFAULT]; group = Resolve(group, &object); - - if ((group == NULL || group->type != SGT_CALLBACK) && cargo != GC_DEFAULT) { - // This group is empty but perhaps there'll be a default one. - group = Resolve(engine_custom_sprites[engine][GC_DEFAULT], &object); - } - if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; return group->g.callback.result; @@ -997,6 +986,7 @@ object.u.vehicle.parent = parent; cargo = (v == NULL) ? GC_PURCHASE : _global_cargo_id[_opt.landscape][v->cargo_type]; + assert(cargo != GC_INVALID); group = engine_custom_sprites[engine][cargo]; @@ -1006,13 +996,8 @@ if (overset != NULL) group = overset; } + if (group == NULL) group = engine_custom_sprites[engine][GC_DEFAULT]; group = Resolve(group, &object); - - if ((group == NULL || group->type != SGT_CALLBACK) && cargo != GC_DEFAULT) { - // This group is empty but perhaps there'll be a default one. - group = Resolve(engine_custom_sprites[engine][GC_DEFAULT], &object); - } - if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; return group->g.callback.result; @@ -1033,6 +1018,8 @@ object.trigger = trigger; cargo = _global_cargo_id[_opt.landscape][v->cargo_type]; + assert(cargo != GC_INVALID); + group = engine_custom_sprites[v->engine_type][cargo]; if (v->type == VEH_Train) { @@ -1040,14 +1027,8 @@ if (overset != NULL) group = overset; } + if (group == NULL) group = engine_custom_sprites[v->engine_type][GC_DEFAULT]; group = Resolve(group, &object); - if (group == NULL && v->cargo_type != GC_DEFAULT) { - // This group is empty but perhaps there'll be a default one. - group = Resolve(engine_custom_sprites[v->engine_type][GC_DEFAULT], &object); - } - - /* Really return? */ - if (group == NULL) return; new_random_bits = Random(); v->random_bits &= ~object.reseed;