summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-01-27 07:13:58 +0000
committerpeter1138 <peter1138@openttd.org>2006-01-27 07:13:58 +0000
commit571bbc06d78356db2652160eff4cd5c2f738e643 (patch)
treea3fa5e0789f4db675b5dd43f9c0d98bfa51fbad9
parenta6756ccf211954e03019c1f9feb684dff9ef3ee3 (diff)
downloadopenttd-571bbc06d78356db2652160eff4cd5c2f738e643.tar.xz
(svn r3449) - NewGRF Fix: When changing the sprite ID of a vehicle, if it is not FD (custom graphics), the value needs to changed from a 16bit array offset to an array index. (fixes tropicstw.grf)
-rw-r--r--newgrf.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/newgrf.c b/newgrf.c
index 695f6cb62..0adf1af72 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -272,6 +272,11 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
FOR_EACH_OBJECT {
uint8 spriteid = grf_load_byte(&buf);
+ /* TTD sprite IDs point to a location in a 16bit array, but we use it
+ * as an array index, so we need it to be half the original value. */
+ if (spriteid < 0xFD)
+ spriteid >>= 1;
+
rvi[i].image_index = spriteid;
}
} break;
@@ -481,6 +486,9 @@ static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
if (spriteid == 0xFF)
spriteid = 0xFD; // cars have different custom id in the GRF file
+ if (spriteid < 0xFD)
+ spriteid >>= 1;
+
rvi[i].image_index = spriteid;
}
} break;
@@ -582,6 +590,9 @@ static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
if (spriteid == 0xFF)
spriteid = 0xFD; // ships have different custom id in the GRF file
+ if (spriteid < 0xFD)
+ spriteid >>= 1;
+
svi[i].image_index = spriteid;
}
} break;
@@ -699,6 +710,9 @@ static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte *
if (spriteid == 0xFF)
spriteid = 0xFD; // ships have different custom id in the GRF file
+ if (spriteid < 0xFD)
+ spriteid >>= 1;
+
avi[i].image_index = spriteid;
}
} break;