diff options
author | rubidium <rubidium@openttd.org> | 2008-11-03 23:42:07 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-11-03 23:42:07 +0000 |
commit | 39450b6e4efddcb98d5a76f84242792efdc2025d (patch) | |
tree | 7a9ba419726fbc25b22fc7e3dd393696a783e042 /src | |
parent | e1bf231727486f906aa28b361e2d7b87a6f475ad (diff) | |
download | openttd-39450b6e4efddcb98d5a76f84242792efdc2025d.tar.xz |
(svn r14563) -Fix [FS#2395]: in the case that an industry NewGRF, a shared TTDPatch and
OpenTTD feature with it's origin in TTDPatch to replace/add/change vehicles
(including e.g. maximum speed, graphics and introduction year), stations,
bridges, industries, town houses or any other graphics used by either
TTDPatch or OpenTTD, would tell that building an industry is okay, which
is queried using a so-called callback that allows the NewGRF author to
test all kinds of information about the neighbourhood where the industry
might get build, it would corrupt, i.e. overwrite with invalid data, the
structure that is used to build up an error message. This then might result
in trying to resolve an invalid StringID, an internal numeric representation
of all translateable strings, which would in it's turn trigger a safety
check that is added to ensure invalid StringIDs are never resolved.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_industries.cpp | 3 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 9e40f2f28..da74f58d3 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -523,7 +523,7 @@ bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspe /* Unlike the "normal" cases, not having a valid result means we allow * the building of the industry, as that's how it's done in TTDP. */ - if (group == NULL || group->type != SGT_CALLBACK) return true; + if (group == NULL || group->type != SGT_CALLBACK || group->g.callback.result == 0x400) return true; /* Copy some parameters from the registers to the error message text ref. stack */ SwitchToErrorRefStack(); @@ -531,7 +531,6 @@ bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspe SwitchToNormalRefStack(); switch (group->g.callback.result) { - case 0x400: return true; case 0x401: _error_message = STR_0239_SITE_UNSUITABLE; break; case 0x402: _error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST; break; case 0x403: _error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT; break; diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 50bdcba4b..bab9977f7 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -284,6 +284,7 @@ bool PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, if (its->grf_prop.grffile->grf_version < 7) { return callback_res != 0; } + if (callback_res == 0x400) return true; /* Copy some parameters from the registers to the error message text ref. stack */ SwitchToErrorRefStack(); @@ -291,7 +292,6 @@ bool PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, SwitchToNormalRefStack(); switch (callback_res) { - case 0x400: return true; case 0x401: _error_message = STR_0239_SITE_UNSUITABLE; return false; case 0x402: _error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST; return false; case 0x403: _error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT; return false; |