Codechange: Preprocess text ref stack parameters. (#13642)
NewGRF text ref stack is now processed in advance, creating parameters as necessary, and then encoding this into an EncodedString.
This commit is contained in:
@@ -473,6 +473,13 @@ CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRF
|
||||
|
||||
if (cb_res < 0x400) {
|
||||
res = CommandCost(GetGRFStringID(grffile->grfid, GRFSTR_MISC_GRF_TEXT + cb_res));
|
||||
|
||||
/* If this error isn't for the local player then it won't be seen, so don't bother encoding anything. */
|
||||
if (!IsLocalCompany()) return res;
|
||||
|
||||
StringID stringid = GetGRFStringID(grffile->grfid, GRFSTR_MISC_GRF_TEXT + cb_res);
|
||||
auto params = GetGRFSringTextStackParameters(grffile, stringid, 4);
|
||||
res.SetEncodedMessage(GetEncodedStringWithArgs(stringid, params));
|
||||
} else {
|
||||
switch (cb_res) {
|
||||
case 0x400: return res; // No error.
|
||||
@@ -490,14 +497,6 @@ CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRF
|
||||
}
|
||||
}
|
||||
|
||||
/* If this error isn't for the local player then it won't be seen, so don't bother encoding anything. */
|
||||
if (!IsLocalCompany()) return res;
|
||||
|
||||
/* Copy some parameters from the registers to the error message text ref. stack */
|
||||
std::array<StringParameter, 20> params{};
|
||||
res.UseTextRefStack(grffile, 4);
|
||||
res.SetEncodedMessage(GetEncodedStringWithArgs(res.GetErrorMessage(), params));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user