diff options
author | frosch <frosch@openttd.org> | 2011-11-08 17:24:43 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-11-08 17:24:43 +0000 |
commit | d8f8909f859eb900ceaf8897537b2f46d970b308 (patch) | |
tree | 6a7c1eec6508195356926d1859b78305f959aafb /src/industry_gui.cpp | |
parent | cd029465e1d6413453cb16224d5000fa9689fa79 (diff) | |
download | openttd-d8f8909f859eb900ceaf8897537b2f46d970b308.tar.xz |
(svn r23142) -Change: [NewGRF v8] Unify the return values of callbacks returning D0xx texts.
Diffstat (limited to 'src/industry_gui.cpp')
-rw-r--r-- | src/industry_gui.cpp | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index d991c5c70..1ea3967fd 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -73,7 +73,10 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind, suffix[0] = '\0'; if (HasBit(indspec->callback_mask, CBM_IND_CARGO_SUFFIX)) { uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast<Industry *>(ind), ind_type, (cst != CST_FUND) ? ind->location.tile : INVALID_TILE); - if (GB(callback, 0, 8) != 0xFF) { + if (callback == CALLBACK_FAILED || callback == 0x400) return; + if (callback > 0x400) { + ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_CARGO_SUFFIX, callback); + } else if (indspec->grf_prop.grffile->grf_version >= 8 || GB(callback, 0, 8) != 0xFF) { StartTextRefStackUsage(6); GetString(suffix, GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback), suffix_last); StopTextRefStackUsage(); @@ -455,12 +458,16 @@ public: str = STR_NULL; if (HasBit(indsp->callback_mask, CBM_IND_FUND_MORE_TEXT)) { uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_FUND_MORE_TEXT, 0, 0, NULL, this->selected_type, INVALID_TILE); - if (callback_res != CALLBACK_FAILED) { // Did it fail? - str = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res); // No. here's the new string - if (str != STR_UNDEFINED) { - StartTextRefStackUsage(6); - DrawStringMultiLine(left, right, y, bottom, str, TC_YELLOW); - StopTextRefStackUsage(); + if (callback_res != CALLBACK_FAILED && callback_res != 0x400) { + if (callback_res > 0x400) { + ErrorUnknownCallbackResult(indsp->grf_prop.grffile->grfid, CBID_INDUSTRY_FUND_MORE_TEXT, callback_res); + } else { + str = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res); // No. here's the new string + if (str != STR_UNDEFINED) { + StartTextRefStackUsage(6); + DrawStringMultiLine(left, right, y, bottom, str, TC_YELLOW); + StopTextRefStackUsage(); + } } } } @@ -783,17 +790,21 @@ public: /* Get the extra message for the GUI */ if (HasBit(ind->callback_mask, CBM_IND_WINDOW_MORE_TEXT)) { uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->location.tile); - if (callback_res != CALLBACK_FAILED) { - StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res); - if (message != STR_NULL && message != STR_UNDEFINED) { - y += WD_PAR_VSEP_WIDE; - - StartTextRefStackUsage(6); - /* Use all the available space left from where we stand up to the - * end of the window. We ALSO enlarge the window if needed, so we - * can 'go' wild with the bottom of the window. */ - y = DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, UINT16_MAX, message, TC_BLACK); - StopTextRefStackUsage(); + if (callback_res != CALLBACK_FAILED && callback_res != 0x400) { + if (callback_res > 0x400) { + ErrorUnknownCallbackResult(ind->grf_prop.grffile->grfid, CBID_INDUSTRY_WINDOW_MORE_TEXT, callback_res); + } else { + StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res); + if (message != STR_NULL && message != STR_UNDEFINED) { + y += WD_PAR_VSEP_WIDE; + + StartTextRefStackUsage(6); + /* Use all the available space left from where we stand up to the + * end of the window. We ALSO enlarge the window if needed, so we + * can 'go' wild with the bottom of the window. */ + y = DrawStringMultiLine(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, UINT16_MAX, message, TC_BLACK); + StopTextRefStackUsage(); + } } } } |