Codechange: Use EncodedString for error messages. (#13569)

This commit is contained in:
Peter Nelson
2025-02-16 10:04:32 +00:00
committed by GitHub
parent 43c7865ca2
commit 2d7d085e8e
55 changed files with 426 additions and 390 deletions

View File

@@ -16,6 +16,7 @@
#include "house.h"
#include "industrytype.h"
#include "newgrf_config.h"
#include "company_func.h"
#include "clear_map.h"
#include "station_map.h"
#include "tree_map.h"
@@ -489,8 +490,13 @@ 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;
}
@@ -508,10 +514,9 @@ void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res)
if (grfconfig->grf_bugs.Test(GRFBug::UnknownCbResult)) {
grfconfig->grf_bugs.Set(GRFBug::UnknownCbResult);
SetDParamStr(0, grfconfig->GetName());
SetDParam(1, cbid);
SetDParam(2, cb_res);
ShowErrorMessage(STR_NEWGRF_BUGGY, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, WL_CRITICAL);
ShowErrorMessage(GetEncodedString(STR_NEWGRF_BUGGY, grfconfig->GetName()),
GetEncodedString(STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, std::monostate{}, cbid, cb_res),
WL_CRITICAL);
}
/* debug output */