361 } |
362 } |
362 } |
363 } |
363 } |
364 } |
364 } |
365 } |
365 |
366 |
|
367 static int MapOldSubType(const Vehicle *v) |
|
368 { |
|
369 if (v->type != VEH_Train) return v->subtype; |
|
370 if (IsTrainEngine(v)) return 0; |
|
371 if (IsFreeWagon(v)) return 4; |
|
372 return 2; |
|
373 } |
|
374 |
366 typedef SpriteGroup *(*resolve_callback)(const SpriteGroup *spritegroup, |
375 typedef SpriteGroup *(*resolve_callback)(const SpriteGroup *spritegroup, |
367 const Vehicle *veh, uint16 callback_info, void *resolve_func); /* XXX data pointer used as function pointer */ |
376 const Vehicle *veh, uint16 callback_info, void *resolve_func); /* XXX data pointer used as function pointer */ |
368 |
377 |
369 static const SpriteGroup* ResolveVehicleSpriteGroup(const SpriteGroup *spritegroup, |
378 static const SpriteGroup* ResolveVehicleSpriteGroup(const SpriteGroup *spritegroup, |
370 const Vehicle *veh, uint16 callback_info, resolve_callback resolve_func) |
379 const Vehicle *veh, uint16 callback_info, resolve_callback resolve_func) |
440 // TTDPatch runs on little-endian arch; |
449 // TTDPatch runs on little-endian arch; |
441 // Variable is 0x80 + offset in TTD's vehicle structure |
450 // Variable is 0x80 + offset in TTD's vehicle structure |
442 switch (dsg->variable - 0x80) { |
451 switch (dsg->variable - 0x80) { |
443 #define veh_prop(id_, value_) case (id_): value = (value_); break |
452 #define veh_prop(id_, value_) case (id_): value = (value_); break |
444 veh_prop(0x00, veh->type); |
453 veh_prop(0x00, veh->type); |
445 veh_prop(0x01, veh->subtype); |
454 veh_prop(0x01, MapOldSubType(veh)); |
446 veh_prop(0x04, veh->index); |
455 veh_prop(0x04, veh->index); |
447 veh_prop(0x05, veh->index & 0xFF); |
456 veh_prop(0x05, veh->index & 0xFF); |
448 /* XXX? Is THIS right? */ |
457 /* XXX? Is THIS right? */ |
449 veh_prop(0x0A, PackOrder(&veh->current_order)); |
458 veh_prop(0x0A, PackOrder(&veh->current_order)); |
450 veh_prop(0x0B, PackOrder(&veh->current_order) & 0xff); |
459 veh_prop(0x0B, PackOrder(&veh->current_order) & 0xff); |