Codechange: use std::string and concatenation when combining multiple formatted strings

This commit is contained in:
Rubidium
2023-06-04 19:28:18 +02:00
committed by rubidium42
parent 07add7a96e
commit 820fe8c621
3 changed files with 15 additions and 18 deletions

View File

@@ -875,9 +875,8 @@ struct DepotWindow : Window {
}
/* Build tooltipstring */
static char details[1024];
details[0] = '\0';
char *pos = details;
static std::string details;
details.clear();
for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
if (capacity[cargo_type] == 0) continue;
@@ -886,13 +885,13 @@ struct DepotWindow : Window {
SetDParam(1, loaded[cargo_type]); // {CARGO} #2
SetDParam(2, cargo_type); // {SHORTCARGO} #1
SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2
pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, lastof(details));
details += GetString(STR_DEPOT_VEHICLE_TOOLTIP_CARGO);
}
/* Show tooltip window */
uint64 args[2];
args[0] = (whole_chain ? num : v->engine_type);
args[1] = (uint64)(size_t)details;
args[1] = (uint64)(size_t)details.c_str();
GuiShowTooltips(this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
return true;