Codechange: do not keep local variable for temporary string parameters

This commit is contained in:
Rubidium
2023-06-27 17:24:43 +02:00
committed by rubidium42
parent e04d43f396
commit af9b9327af
5 changed files with 8 additions and 18 deletions

View File

@@ -77,9 +77,8 @@ static void ShowNewGRFInfo(const GRFConfig *c, const Rect &r, bool show_params)
for (uint i = 0; i < c->error->param_value.size(); i++) {
SetDParam(3 + i, c->error->param_value[i]);
}
std::string message = GetString(c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING);
SetDParamStr(0, message);
SetDParamStr(0, GetString(c->error->message != STR_NULL ? c->error->message : STR_JUST_RAW_STRING));
tr.top = DrawStringMultiLine(tr, c->error->severity);
}
@@ -90,8 +89,7 @@ static void ShowNewGRFInfo(const GRFConfig *c, const Rect &r, bool show_params)
}
/* Prepare and draw GRF ID */
std::string tmp = fmt::format("{:08X}", BSWAP32(c->ident.grfid));
SetDParamStr(0, tmp);
SetDParamStr(0, fmt::format("{:08X}", BSWAP32(c->ident.grfid)));
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_GRF_ID);
if ((_settings_client.gui.newgrf_developer_tools || _settings_client.gui.newgrf_show_old_versions) && c->version != 0) {
@@ -104,17 +102,14 @@ static void ShowNewGRFInfo(const GRFConfig *c, const Rect &r, bool show_params)
}
/* Prepare and draw MD5 sum */
tmp = FormatArrayAsHex(c->ident.md5sum);
SetDParamStr(0, tmp);
SetDParamStr(0, FormatArrayAsHex(c->ident.md5sum));
tr.top = DrawStringMultiLine(tr, STR_NEWGRF_SETTINGS_MD5SUM);
/* Show GRF parameter list */
if (show_params) {
std::string params;
if (c->num_params > 0) {
params = GRFBuildParamList(c);
SetDParam(0, STR_JUST_RAW_STRING);
SetDParamStr(1, params);
SetDParamStr(1, GRFBuildParamList(c));
} else {
SetDParam(0, STR_NEWGRF_SETTINGS_PARAMETER_NONE);
}