summaryrefslogtreecommitdiff
path: root/newgrf.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-01-12 07:57:40 +0000
committerpeter1138 <peter1138@openttd.org>2006-01-12 07:57:40 +0000
commit2067b2e7b48fa1491cdf89206e496637822128e8 (patch)
tree555bf0b107d0be3c97df100f8ba4e1321534972a /newgrf.c
parentbe288e4d1b462d51c8de2375f908aa667abda58c (diff)
downloadopenttd-2067b2e7b48fa1491cdf89206e496637822128e8.tar.xz
(svn r3394) - NewGRF fix: ignore non-climate dependent cargo types. The spec is rather vague on this, but we don't support newcargos anyway.
Diffstat (limited to 'newgrf.c')
-rw-r--r--newgrf.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/newgrf.c b/newgrf.c
index 989677d22..5b5774656 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -308,7 +308,11 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
FOR_EACH_OBJECT {
uint8 ctype = grf_load_byte(&buf);
- rvi[i].cargo_type = ctype;
+ if (ctype < NUM_CARGO) {
+ rvi[i].cargo_type = ctype;
+ } else {
+ grfmsg(GMS_NOTICE, "RailVehicleChangeInfo: Invalid cargo type %d, ignoring.", ctype);
+ }
}
} break;
case 0x16: { /* Weight */
@@ -492,7 +496,11 @@ static bool RoadVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
FOR_EACH_OBJECT {
uint8 cargo = grf_load_byte(&buf);
- rvi[i].cargo_type = cargo;
+ if (cargo < NUM_CARGO) {
+ rvi[i].cargo_type = cargo;
+ } else {
+ grfmsg(GMS_NOTICE, "RoadVehicleChangeInfo: Invalid cargo type %d, ignoring.", cargo);
+ }
}
} break;
case 0x11: { /* Cost factor */
@@ -610,7 +618,11 @@ static bool ShipVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
// assume otherwise.
cargo = local_cargo_id_ctype[cargo];
#endif
- svi[i].cargo_type = cargo;
+ if (cargo < NUM_CARGO) {
+ svi[i].cargo_type = cargo;
+ } else {
+ grfmsg(GMS_NOTICE, "ShipVehicleChangeInfo: Invalid cargo type %d, ignoring.", cargo);
+ }
}
} break;
case 0x0D: { /* Cargo capacity */