forked from mirror/OpenTTD
Codechange: Store grfid with entity grfprops.
This allows using the grfid without having to dereference the grffile pointer. Uses no extra storage as it fits within otherwise wasted padding space.
This commit is contained in:
@@ -104,12 +104,12 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
|
||||
if (GB(callback, 0, 8) == 0xFF) return;
|
||||
if (callback < 0x400) {
|
||||
StartTextRefStackUsage(indspec->grf_prop.grffile, 6);
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback));
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grfid, 0xD000 + callback));
|
||||
StopTextRefStackUsage();
|
||||
suffix.display = CSD_CARGO_AMOUNT_TEXT;
|
||||
return;
|
||||
}
|
||||
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_CARGO_SUFFIX, callback);
|
||||
ErrorUnknownCallbackResult(indspec->grf_prop.grfid, CBID_INDUSTRY_CARGO_SUFFIX, callback);
|
||||
return;
|
||||
|
||||
} else { // GRF version 8 or higher.
|
||||
@@ -120,19 +120,19 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind,
|
||||
}
|
||||
if (callback < 0x400) {
|
||||
StartTextRefStackUsage(indspec->grf_prop.grffile, 6);
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 + callback));
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grfid, 0xD000 + callback));
|
||||
StopTextRefStackUsage();
|
||||
suffix.display = CSD_CARGO_AMOUNT_TEXT;
|
||||
return;
|
||||
}
|
||||
if (callback >= 0x800 && callback < 0xC00) {
|
||||
StartTextRefStackUsage(indspec->grf_prop.grffile, 6);
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grffile->grfid, 0xD000 - 0x800 + callback));
|
||||
suffix.text = GetString(GetGRFStringID(indspec->grf_prop.grfid, 0xD000 - 0x800 + callback));
|
||||
StopTextRefStackUsage();
|
||||
suffix.display = CSD_CARGO_TEXT;
|
||||
return;
|
||||
}
|
||||
ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_CARGO_SUFFIX, callback);
|
||||
ErrorUnknownCallbackResult(indspec->grf_prop.grfid, CBID_INDUSTRY_CARGO_SUFFIX, callback);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ public:
|
||||
}
|
||||
d = maxdim(d, strdim);
|
||||
|
||||
if (indsp->grf_prop.grffile != nullptr) {
|
||||
if (indsp->grf_prop.HasGrfFile()) {
|
||||
/* Reserve a few extra lines for text from an industry NewGRF. */
|
||||
extra_lines_newgrf = 4;
|
||||
}
|
||||
@@ -588,9 +588,9 @@ public:
|
||||
uint16_t callback_res = GetIndustryCallback(CBID_INDUSTRY_FUND_MORE_TEXT, 0, 0, nullptr, this->selected_type, INVALID_TILE);
|
||||
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);
|
||||
ErrorUnknownCallbackResult(indsp->grf_prop.grfid, CBID_INDUSTRY_FUND_MORE_TEXT, callback_res);
|
||||
} else {
|
||||
StringID str = GetGRFStringID(indsp->grf_prop.grffile->grfid, 0xD000 + callback_res); // No. here's the new string
|
||||
StringID str = GetGRFStringID(indsp->grf_prop.grfid, 0xD000 + callback_res); // No. here's the new string
|
||||
if (str != STR_UNDEFINED) {
|
||||
StartTextRefStackUsage(indsp->grf_prop.grffile, 6);
|
||||
DrawStringMultiLine(ir, str, TC_YELLOW);
|
||||
@@ -981,9 +981,9 @@ public:
|
||||
uint16_t callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->location.tile);
|
||||
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);
|
||||
ErrorUnknownCallbackResult(ind->grf_prop.grfid, CBID_INDUSTRY_WINDOW_MORE_TEXT, callback_res);
|
||||
} else {
|
||||
StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res);
|
||||
StringID message = GetGRFStringID(ind->grf_prop.grfid, 0xD000 + callback_res);
|
||||
if (message != STR_NULL && message != STR_UNDEFINED) {
|
||||
ir.top += WidgetDimensions::scaled.vsep_wide;
|
||||
|
||||
|
Reference in New Issue
Block a user