(svn r4500) - NewGRF: When running a callback with no vehicle, use the purchase list 'cargo' type first, and then fallback to the default if needed.
authorpeter1138
Fri, 21 Apr 2006 17:02:51 +0000
changeset 3607 45157f043dec
parent 3606 743a2cd312a9
child 3608 3738520a9b86
(svn r4500) - NewGRF: When running a callback with no vehicle, use the purchase list 'cargo' type first, and then fallback to the default if needed.
newgrf_engine.c
--- a/newgrf_engine.c	Fri Apr 21 09:18:39 2006 +0000
+++ b/newgrf_engine.c	Fri Apr 21 17:02:51 2006 +0000
@@ -481,11 +481,10 @@
 uint16 GetVehicleCallback(byte callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
 {
 	const SpriteGroup *group;
-	CargoID cargo = GC_DEFAULT;
+	CargoID cargo;
 	uint16 callback_info = callback | (param1 << 8); // XXX Temporary conversion between new and old format.
 
-	if (v != NULL)
-		cargo = _global_cargo_id[_opt.landscape][v->cargo_type];
+	cargo = (v == NULL) ? GC_PURCHASE : _global_cargo_id[_opt.landscape][v->cargo_type];
 
 	group = engine_custom_sprites[engine][cargo];
 
@@ -497,7 +496,7 @@
 
 	group = ResolveVehicleSpriteGroup(group, v, callback_info, (resolve_callback) ResolveVehicleSpriteGroup);
 
-	if (group == NULL && cargo != GC_DEFAULT) {
+	if ((group == NULL || group->type != SGT_CALLBACK) && cargo != GC_DEFAULT) {
 		// This group is empty but perhaps there'll be a default one.
 		group = ResolveVehicleSpriteGroup(engine_custom_sprites[engine][GC_DEFAULT], v, callback_info,
 		                                (resolve_callback) ResolveVehicleSpriteGroup);