summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-08 17:27:13 +0000
committerfrosch <frosch@openttd.org>2011-11-08 17:27:13 +0000
commit52774235eb6eb8affb7e68b94c490d3f09e7ae31 (patch)
treeaf07d5b6df28b5c9fdcef94e0f67ecec290e1764 /src/industry_cmd.cpp
parent30874b5e81af0fff2f42d34b9b105ee86666b8ac (diff)
downloadopenttd-52774235eb6eb8affb7e68b94c490d3f09e7ae31.tar.xz
(svn r23148) -Change: [NewGRF] Check the results of various callbacks for validness.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index aa6cce7b4..668749678 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1644,7 +1644,10 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
if (HasBit(indspec->callback_mask, CBM_IND_DECIDE_COLOUR)) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_DECIDE_COLOUR, 0, 0, i, type, INVALID_TILE);
- if (res != CALLBACK_FAILED) i->random_colour = GB(res, 0, 4);
+ if (res != CALLBACK_FAILED) {
+ if (GB(res, 4, 11) != 0) ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_DECIDE_COLOUR, res);
+ i->random_colour = GB(res, 0, 4);
+ }
}
if (HasBit(indspec->callback_mask, CBM_IND_INPUT_CARGO_TYPES)) {
@@ -1652,6 +1655,10 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
for (uint j = 0; j < lengthof(i->accepts_cargo); j++) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
+ if (indspec->grf_prop.grffile->grf_version >= 8 && res >= 0x100) {
+ ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_INPUT_CARGO_TYPES, res);
+ break;
+ }
i->accepts_cargo[j] = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
}
}
@@ -1661,6 +1668,10 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
for (uint j = 0; j < lengthof(i->produced_cargo); j++) {
uint16 res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE);
if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break;
+ if (indspec->grf_prop.grffile->grf_version >= 8 && res >= 0x100) {
+ ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, res);
+ break;
+ }
i->produced_cargo[j] = GetCargoTranslation(GB(res, 0, 8), indspec->grf_prop.grffile);
}
}