summaryrefslogtreecommitdiff
path: root/newgrf.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-12-18 10:46:06 +0000
committerpeter1138 <peter1138@openttd.org>2006-12-18 10:46:06 +0000
commitbc77a4f2b8229f13557316122f4fd07d41c1f471 (patch)
treed0112ab3cc649e05c63c4ef8170ee40a5e356cb4 /newgrf.c
parentcd5deab983b93988538dccbcbf826bee4f822a38 (diff)
downloadopenttd-bc77a4f2b8229f13557316122f4fd07d41c1f471.tar.xz
(svn r7503) -Codechange: [NewGRF] Add bounds checking for spriteset cargo types. (NewCargo support will change this rule a bit...)
Diffstat (limited to 'newgrf.c')
-rw-r--r--newgrf.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/newgrf.c b/newgrf.c
index 7a294c655..440cfbf31 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -1843,6 +1843,11 @@ static void FeatureMapSpriteGroup(byte *buf, int len)
if (ctype == 0xFE) ctype = GC_DEFAULT_NA;
if (ctype == 0xFF) ctype = GC_PURCHASE;
+ if (ctype >= NUM_GLOBAL_CID) {
+ grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype);
+ continue;
+ }
+
statspec->spritegroup[ctype] = _cur_grffile->spritegroups[groupid];
}
}
@@ -1919,6 +1924,11 @@ static void FeatureMapSpriteGroup(byte *buf, int len)
if (ctype == GC_INVALID) ctype = GC_PURCHASE;
+ if (ctype >= NUM_GLOBAL_CID) {
+ grfmsg(GMS_WARN, "FeatureMapSpriteGroup: Cargo type %d out of range, skipping.", ctype);
+ continue;
+ }
+
if (wagover) {
SetWagonOverrideSprites(engine, ctype, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count);
} else {