summaryrefslogtreecommitdiff
path: root/engine.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-11-15 20:52:11 +0000
committertron <tron@openttd.org>2004-11-15 20:52:11 +0000
commitb65bda506c8199ab2e5e83cb93626ade806a6e60 (patch)
tree8b3f2d93253ce49b0edbcf70e33d4c79e2729ac5 /engine.c
parent61103119fbf35f3d83ad42aa952dca9a858b358f (diff)
downloadopenttd-b65bda506c8199ab2e5e83cb93626ade806a6e60.tar.xz
(svn r635) Fix choosing a spritegroup from deterministic variational spritegroups if there is no structure to search (i.e. in purchase lists) (pasky)
Diffstat (limited to 'engine.c')
-rw-r--r--engine.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/engine.c b/engine.c
index 1a6d737ff..fdc9eda01 100644
--- a/engine.c
+++ b/engine.c
@@ -255,22 +255,36 @@ ResolveVehicleSpriteGroup(struct SpriteGroup *spritegroup, struct Vehicle *veh)
struct SpriteGroup *target;
int value = -1;
- //debug("[%p] Having fun resolving variable %x", dsg->variable);
+ //debug("[%p] Having fun resolving variable %x", veh, dsg->variable);
if ((dsg->variable >> 6) == 0) {
/* General property */
value = GetDeterministicSpriteValue(dsg->variable);
} else {
- /* Station-specific property. */
+ /* Vehicle-specific property. */
+
+ if (veh == NULL) {
+ /* We are in a purchase list of something,
+ * and we are checking for something undefined.
+ * That means we should get the first target
+ * (NOT the default one). */
+ if (dsg->num_ranges > 0) {
+ target = &dsg->ranges[0].group;
+ } else {
+ target = dsg->default_group;
+ }
+ return ResolveVehicleSpriteGroup(target, NULL);
+ }
+
if (dsg->var_scope == VSG_SCOPE_PARENT) {
/* First engine in the vehicle chain */
- if (veh != NULL && veh->type == VEH_Train)
+ if (veh->type == VEH_Train)
veh = GetFirstVehicleInChain(veh);
}
if (dsg->variable == 0x40) {
- if (veh && veh->type == VEH_Train) {
+ if (veh->type == VEH_Train) {
Vehicle *u = GetFirstVehicleInChain(veh);
byte chain_before = 0, chain_after = 0;
@@ -293,7 +307,7 @@ ResolveVehicleSpriteGroup(struct SpriteGroup *spritegroup, struct Vehicle *veh)
// TTDPatch runs on little-endian arch;
// Variable is 0x80 + offset in TTD's vehicle structure
switch (dsg->variable - 0x80) {
-#define veh_prop(id_, value_) case id_: if (veh != NULL) value = value_; break /* XXX factorise "if" */
+#define veh_prop(id_, value_) case id_: value = value_; break
veh_prop(0x00, veh->type);
veh_prop(0x01, veh->subtype);
veh_prop(0x04, veh->index);