diff --git a/src/base_media_base.h b/src/base_media_base.h index 93bdfabb42..ae678adb2e 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -130,11 +130,9 @@ struct BaseSet { */ std::string GetListLabel() const { - if (this->GetNumInvalid() == 0) return this->name; + if (this->GetNumInvalid() == 0) return GetString(STR_JUST_RAW_STRING, this->name); - SetDParamStr(0, this->name); - SetDParam(1, this->GetNumInvalid()); - return GetString(STR_BASESET_STATUS); + return GetString(STR_BASESET_STATUS, this->name, this->GetNumInvalid()); } /** diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index eda475e39f..25f0da948a 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -146,14 +146,12 @@ static bool EngineNameSorter(const GUIEngineListItem &a, const GUIEngineListItem if (a.engine_id != _last_engine[0]) { _last_engine[0] = a.engine_id; - SetDParam(0, PackEngineNameDParam(a.engine_id, EngineNameContext::PurchaseList)); - last_name[0] = GetString(STR_ENGINE_NAME); + last_name[0] = GetString(STR_ENGINE_NAME, PackEngineNameDParam(a.engine_id, EngineNameContext::PurchaseList)); } if (b.engine_id != _last_engine[1]) { _last_engine[1] = b.engine_id; - SetDParam(0, PackEngineNameDParam(b.engine_id, EngineNameContext::PurchaseList)); - last_name[1] = GetString(STR_ENGINE_NAME); + last_name[1] = GetString(STR_ENGINE_NAME, PackEngineNameDParam(b.engine_id, EngineNameContext::PurchaseList)); } int r = StrNaturalCompare(last_name[0], last_name[1]); // Sort by name (natural sorting). @@ -1369,8 +1367,7 @@ struct BuildVehicleWindow : Window { /* Filter engine name */ this->string_filter.ResetState(); - SetDParam(0, PackEngineNameDParam(e->index, EngineNameContext::PurchaseList)); - this->string_filter.AddLine(GetString(STR_ENGINE_NAME)); + this->string_filter.AddLine(GetString(STR_ENGINE_NAME, PackEngineNameDParam(e->index, EngineNameContext::PurchaseList))); /* Filter NewGRF extra text */ auto text = GetNewGRFAdditionalText(e->index); diff --git a/src/cargotype.cpp b/src/cargotype.cpp index c0def89dc4..72364e361b 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -284,9 +284,7 @@ std::optional BuildCargoAcceptanceString(const CargoArray &acceptan /* If the accepted value is less than 8, show it in 1/8:ths */ if (acceptance[cargo_type] < 8) { - SetDParam(0, acceptance[cargo_type]); - SetDParam(1, cs->name); - line << GetString(STR_LAND_AREA_INFORMATION_CARGO_EIGHTS); + line << GetString(STR_LAND_AREA_INFORMATION_CARGO_EIGHTS, acceptance[cargo_type], cs->name); } else { line << GetString(cs->name); } diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 239fba8014..9cfcacc93a 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -415,8 +415,7 @@ verify_name:; if (cc->name_1 == str && cc->name_2 == strp) goto bad_town_name; } - SetDParam(0, strp); - name = GetString(str); + name = GetString(str, strp); if (Utf8StringLength(name) >= MAX_LENGTH_COMPANY_NAME_CHARS) goto bad_town_name; set_name:; @@ -540,14 +539,12 @@ restart:; /* Reserve space for extra unicode character. We need to do this to be able * to detect too long president name. */ - SetDParam(0, c->index); - std::string name = GetString(STR_PRESIDENT_NAME); + std::string name = GetString(STR_PRESIDENT_NAME, c->index); if (Utf8StringLength(name) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) continue; for (const Company *cc : Company::Iterate()) { if (c != cc) { - SetDParam(0, cc->index); - std::string other_name = GetString(STR_PRESIDENT_NAME); + std::string other_name = GetString(STR_PRESIDENT_NAME, cc->index); if (name == other_name) goto restart; } } @@ -819,17 +816,14 @@ static IntervalTimer _economy_companies_yearly({TimerGameEcono */ CompanyNewsInformation::CompanyNewsInformation(const Company *c, const Company *other) { - SetDParam(0, c->index); - this->company_name = GetString(STR_COMPANY_NAME); + this->company_name = GetString(STR_COMPANY_NAME, c->index); if (other != nullptr) { - SetDParam(0, other->index); - this->other_company_name = GetString(STR_COMPANY_NAME); + this->other_company_name = GetString(STR_COMPANY_NAME, other->index); c = other; } - SetDParam(0, c->index); - this->president_name = GetString(STR_PRESIDENT_NAME_MANAGER); + this->president_name = GetString(STR_PRESIDENT_NAME_MANAGER, c->index); this->colour = c->colour; this->face = c->face; @@ -1187,8 +1181,7 @@ CommandCost CmdRenameCompany(DoCommandFlags flags, const std::string &text) MarkWholeScreenDirty(); CompanyAdminUpdate(c); - SetDParam(0, c->index); - std::string new_name = GetString(STR_COMPANY_NAME); + std::string new_name = GetString(STR_COMPANY_NAME, c->index); AI::BroadcastNewEvent(new ScriptEventCompanyRenamed(c->index, new_name)); Game::NewEvent(new ScriptEventCompanyRenamed(c->index, new_name)); } @@ -1242,8 +1235,7 @@ CommandCost CmdRenamePresident(DoCommandFlags flags, const std::string &text) MarkWholeScreenDirty(); CompanyAdminUpdate(c); - SetDParam(0, c->index); - std::string new_name = GetString(STR_PRESIDENT_NAME); + std::string new_name = GetString(STR_PRESIDENT_NAME, c->index); AI::BroadcastNewEvent(new ScriptEventPresidentRenamed(c->index, new_name)); Game::NewEvent(new ScriptEventPresidentRenamed(c->index, new_name)); } @@ -1323,11 +1315,8 @@ CommandCost CmdGiveMoney(DoCommandFlags flags, Money money, CompanyID dest_compa cur_company.Restore(); if (_networking) { - SetDParam(0, dest_company); - std::string dest_company_name = GetString(STR_COMPANY_NAME); - - SetDParam(0, _current_company); - std::string from_company_name = GetString(STR_COMPANY_NAME); + std::string dest_company_name = GetString(STR_COMPANY_NAME, dest_company); + std::string from_company_name = GetString(STR_COMPANY_NAME, _current_company); NetworkTextMessage(NETWORK_ACTION_GIVE_MONEY, GetDrawStringCompanyColour(_current_company), false, from_company_name, dest_company_name, amount.GetCost()); } diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 19449b17e1..97b7feabe8 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1870,8 +1870,7 @@ DEF_CONSOLE_CMD(ConCompanies) for (const Company *c : Company::Iterate()) { /* Grab the company name */ - SetDParam(0, c->index); - std::string company_name = GetString(STR_COMPANY_NAME); + std::string company_name = GetString(STR_COMPANY_NAME, c->index); std::string colour = GetString(STR_COLOUR_DARK_BLUE + _company_colours[c->index]); IConsolePrint(CC_INFO, "#:{}({}) Company Name: '{}' Year Founded: {} Money: {} Loan: {} Value: {} (T:{}, R:{}, P:{}, S:{}) {}", diff --git a/src/fios.cpp b/src/fios.cpp index cdb653a338..1729a58451 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -339,8 +339,7 @@ static void FiosGetFileList(SaveLoadOperation fop, bool show_dirs, FiosGetTypeAn fios.type = FIOS_TYPE_PARENT; fios.mtime = 0; fios.name = ".."; - SetDParamStr(0, ".."); - fios.title = GetString(STR_SAVELOAD_PARENT_DIRECTORY); + fios.title = GetString(STR_SAVELOAD_PARENT_DIRECTORY, ".."); sort_start = file_list.size(); } @@ -354,8 +353,7 @@ static void FiosGetFileList(SaveLoadOperation fop, bool show_dirs, FiosGetTypeAn fios.type = FIOS_TYPE_DIR; fios.mtime = 0; fios.name = FS2OTTD(dir_entry.path().filename()); - SetDParamStr(0, fios.name + PATHSEP); - fios.title = GetString(STR_SAVELOAD_DIRECTORY); + fios.title = GetString(STR_SAVELOAD_DIRECTORY, fios.name + PATHSEP); } /* Sort the subdirs always by name, ascending, remember user-sorting order */ diff --git a/src/group_gui.cpp b/src/group_gui.cpp index f504515d02..c040312c2e 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -170,13 +170,11 @@ void BuildGuiGroupList(GUIGroupList &dst, bool fold, Owner owner, VehicleType ve list.Sort([&last_group](const GUIGroupListItem &a, const GUIGroupListItem &b) -> bool { if (a.group != last_group[0].first) { - SetDParam(0, a.group->index); - last_group[0] = {a.group, GetString(STR_GROUP_NAME)}; + last_group[0] = {a.group, GetString(STR_GROUP_NAME, a.group->index)}; } if (b.group != last_group[1].first) { - SetDParam(0, b.group->index); - last_group[1] = {b.group, GetString(STR_GROUP_NAME)}; + last_group[1] = {b.group, GetString(STR_GROUP_NAME, b.group->index)}; } int r = StrNaturalCompare(last_group[0].second, last_group[1].second); // Sort by name (natural sorting). diff --git a/src/highscore.cpp b/src/highscore.cpp index 112b88d5a2..1520a1ac4d 100644 --- a/src/highscore.cpp +++ b/src/highscore.cpp @@ -68,9 +68,7 @@ int8_t SaveHighScoreValue(const Company *c) std::move_backward(it, highscores.end() - 1, highscores.end()); /* Fill the elements. */ - SetDParam(0, c->index); - SetDParam(1, c->index); - it->name = GetString(STR_HIGHSCORE_NAME); // get manager/company name string + it->name = GetString(STR_HIGHSCORE_NAME, c->index, c->index); // get manager/company name string it->score = score; it->title = EndGameGetPerformanceTitleFromValue(score); return std::distance(highscores.begin(), it); @@ -104,9 +102,7 @@ int8_t SaveHighScoreValueNetwork() for (size_t i = 0; i < count && i < highscores.size(); i++) { const Company *c = cl[i]; auto &highscore = highscores[i]; - SetDParam(0, c->index); - SetDParam(1, c->index); - highscore.name = GetString(STR_HIGHSCORE_NAME); // get manager/company name string + highscore.name = GetString(STR_HIGHSCORE_NAME, c->index, c->index); // get manager/company name string highscore.score = c->old_economy[0].performance_history; highscore.title = EndGameGetPerformanceTitleFromValue(highscore.score); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 6eccb0cc1a..4b7779fde0 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -391,13 +391,9 @@ class BuildIndustryWindow : public Window { } if (numcargo > 0) { - SetDParam(0, CargoSpec::Get(cargolist[firstcargo])->name); - SetDParamStr(1, cargo_suffix[firstcargo].text); - cargostring = GetString(prefixstr) + cargostring; + cargostring = GetString(prefixstr, CargoSpec::Get(cargolist[firstcargo])->name, cargo_suffix[firstcargo].text) + cargostring; } else { - SetDParam(0, STR_JUST_NOTHING); - SetDParamStr(1, ""); - cargostring = GetString(prefixstr); + cargostring = GetString(prefixstr, STR_JUST_NOTHING, ""); } return cargostring; diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 9e6e7393db..0855b25d36 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -313,13 +313,11 @@ struct SelectGameWindow : public Window { bool changed = false; if (NWidgetResizeBase *wid = this->GetWidget(WID_SGI_BASESET); wid != nullptr && wid->current_x > 0) { - SetDParam(0, _missing_extra_graphics); - changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_BASESET), 3); + changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_BASESET, _missing_extra_graphics), 3); } if (NWidgetResizeBase *wid = this->GetWidget(WID_SGI_TRANSLATION); wid != nullptr && wid->current_x > 0) { - SetDParam(0, _current_language->missing); - changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION), 3); + changed |= wid->UpdateMultilineWidgetSize(GetString(STR_INTRO_TRANSLATION, _current_language->missing), 3); } if (changed) this->ReInit(0, 0, this->flags.Test(WindowFlag::Centred)); diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index b2e6e86964..c40663bbb4 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -384,10 +384,8 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) const auto &back = k->second; back_time = back.time; if (back.Usage() > 0) { - SetDParam(0, back.cargo); - SetDParam(1, back.Usage()); - SetDParam(2, back.Usage() * 100 / (back.capacity + 1)); - tooltip_extension = GetString(STR_LINKGRAPH_STATS_TOOLTIP_RETURN_EXTENSION); + tooltip_extension = GetString(STR_LINKGRAPH_STATS_TOOLTIP_RETURN_EXTENSION, + back.cargo, back.Usage(), back.Usage() * 100 / (back.capacity + 1)); } } /* Add information about the travel time if known. */ diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index e971720de6..f494d11fa6 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -179,8 +179,7 @@ public: this->landinfo_data.clear(); /* Tiletype */ - SetDParam(0, td.dparam); - this->landinfo_data.push_back(GetString(td.str)); + this->landinfo_data.push_back(GetString(td.str, td.dparam)); /* Up to four owners */ for (uint i = 0; i < 4; i++) { @@ -211,94 +210,76 @@ public: this->landinfo_data.push_back(GetString(str)); /* Location */ - SetDParam(0, TileX(tile)); - SetDParam(1, TileY(tile)); - SetDParam(2, GetTileZ(tile)); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_COORDS)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_COORDS, TileX(tile), TileY(tile), GetTileZ(tile))); /* Tile index */ - SetDParam(0, tile); - SetDParam(1, tile); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_INDEX)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LANDINFO_INDEX, tile, tile)); /* Local authority */ - SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE); - if (t != nullptr) { - SetDParam(0, STR_TOWN_NAME); - SetDParam(1, t->index); + if (t == nullptr) { + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE, std::monostate{})); + } else { + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY, STR_TOWN_NAME, t->index)); } - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY)); /* Build date */ if (td.build_date != CalendarTime::INVALID_DATE) { - SetDParam(0, td.build_date); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_BUILD_DATE)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_BUILD_DATE, td.build_date)); } /* Station class */ if (td.station_class != STR_NULL) { - SetDParam(0, td.station_class); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_STATION_CLASS)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_STATION_CLASS, td.station_class)); } /* Station type name */ if (td.station_name != STR_NULL) { - SetDParam(0, td.station_name); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_STATION_TYPE)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_STATION_TYPE, td.station_name)); } /* Airport class */ if (td.airport_class != STR_NULL) { - SetDParam(0, td.airport_class); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_AIRPORT_CLASS)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_AIRPORT_CLASS, td.airport_class)); } /* Airport name */ if (td.airport_name != STR_NULL) { - SetDParam(0, td.airport_name); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_AIRPORT_NAME)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_AIRPORT_NAME, td.airport_name)); } /* Airport tile name */ if (td.airport_tile_name != STR_NULL) { - SetDParam(0, td.airport_tile_name); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_AIRPORTTILE_NAME)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_AIRPORTTILE_NAME, td.airport_tile_name)); } /* Rail type name */ if (td.railtype != STR_NULL) { - SetDParam(0, td.railtype); - this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_RAIL_TYPE)); + this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_RAIL_TYPE, td.railtype)); } /* Rail speed limit */ if (td.rail_speed != 0) { - SetDParam(0, PackVelocity(td.rail_speed, VEH_TRAIN)); - this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_RAIL_SPEED_LIMIT)); + this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_RAIL_SPEED_LIMIT, PackVelocity(td.rail_speed, VEH_TRAIN))); } /* Road type name */ if (td.roadtype != STR_NULL) { - SetDParam(0, td.roadtype); - this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_ROAD_TYPE)); + this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_ROAD_TYPE, td.roadtype)); } /* Road speed limit */ if (td.road_speed != 0) { - SetDParam(0, PackVelocity(td.road_speed, VEH_ROAD)); - this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_ROAD_SPEED_LIMIT)); + this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_ROAD_SPEED_LIMIT, PackVelocity(td.road_speed, VEH_ROAD))); } /* Tram type name */ if (td.tramtype != STR_NULL) { - SetDParam(0, td.tramtype); - this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_TRAM_TYPE)); + this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_TRAM_TYPE, td.tramtype)); } /* Tram speed limit */ if (td.tram_speed != 0) { - SetDParam(0, PackVelocity(td.tram_speed, VEH_ROAD)); - this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_TRAM_SPEED_LIMIT)); + this->landinfo_data.push_back(GetString(STR_LANG_AREA_INFORMATION_TRAM_SPEED_LIMIT, PackVelocity(td.tram_speed, VEH_ROAD))); } /* Tile protection status */ @@ -308,8 +289,7 @@ public: /* NewGRF name */ if (td.grf != nullptr) { - SetDParamStr(0, td.grf); - this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_NEWGRF_NAME)); + this->landinfo_data.push_back(GetString(STR_LAND_AREA_INFORMATION_NEWGRF_NAME, td.grf)); } /* Cargo acceptance is displayed in a extra multiline */ diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index 611a3980ad..e8f6b78a4a 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -321,10 +321,8 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company auto p = std::make_unique(this, ADMIN_PACKET_SERVER_COMPANY_INFO); p->Send_uint8 (c->index); - SetDParam(0, c->index); - p->Send_string(GetString(STR_COMPANY_NAME)); - SetDParam(0, c->index); - p->Send_string(GetString(STR_PRESIDENT_NAME)); + p->Send_string(GetString(STR_COMPANY_NAME, c->index)); + p->Send_string(GetString(STR_PRESIDENT_NAME, c->index)); p->Send_uint8 (c->colour); p->Send_bool (true); p->Send_uint32(c->inaugurated_year.base()); @@ -346,10 +344,8 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyUpdate(const Compa auto p = std::make_unique(this, ADMIN_PACKET_SERVER_COMPANY_UPDATE); p->Send_uint8 (c->index); - SetDParam(0, c->index); - p->Send_string(GetString(STR_COMPANY_NAME)); - SetDParam(0, c->index); - p->Send_string(GetString(STR_PRESIDENT_NAME)); + p->Send_string(GetString(STR_COMPANY_NAME, c->index)); + p->Send_string(GetString(STR_PRESIDENT_NAME, c->index)); p->Send_uint8 (c->colour); p->Send_bool (true); p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 5ed500e36f..e4890d5699 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -277,8 +277,7 @@ private: } for (const Town *t : Town::Iterate()) { /* Get the town-name via the string-system */ - SetDParam(0, t->index); - std::string town_name = GetString(STR_TOWN_NAME); + std::string town_name = GetString(STR_TOWN_NAME, t->index); if (town_name.starts_with(query)) { suggestions.push_back(std::move(town_name)); } diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 8536bf8631..34adfdb2d2 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -970,9 +970,8 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet &p) /* For speaking to company, we need the company-name */ case NETWORK_ACTION_CHAT_COMPANY: { StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS; - SetDParam(0, ci_to->client_playas); - name = GetString(str); + name = GetString(str, ci_to->client_playas); ci = NetworkClientInfo::GetByClientID(_network_own_client_id); break; } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 90b4c12da0..e5a58ff80f 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1327,8 +1327,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co if (ci != nullptr && show_local) { if (from_id == CLIENT_ID_SERVER) { StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS; - SetDParam(0, ci_to->client_playas); - std::string name = GetString(str); + std::string name = GetString(str, ci_to->client_playas); NetworkTextMessage(action, GetDrawStringCompanyColour(ci_own->client_playas), true, name, msg, data); } else { for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) { @@ -2003,8 +2002,7 @@ void NetworkServerDoMove(ClientID client_id, CompanyID company_id) NetworkServerSendChat(NETWORK_ACTION_COMPANY_SPECTATOR, DESTTYPE_BROADCAST, 0, "", client_id); } else { /* The client has joined another company. */ - SetDParam(0, company_id); - std::string company_name = GetString(STR_COMPANY_NAME); + std::string company_name = GetString(STR_COMPANY_NAME, company_id); NetworkServerSendChat(NETWORK_ACTION_COMPANY_JOIN, DESTTYPE_BROADCAST, 0, company_name, client_id); } diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 576efbf37a..23d6b803d0 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -515,12 +515,9 @@ void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res) } /* debug output */ - SetDParamStr(0, grfconfig->GetName()); - Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY))); + Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY, grfconfig->GetName()))); - SetDParam(1, cbid); - SetDParam(2, cb_res); - Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT))); + Debug(grf, 0, "{}", StrMakeValid(GetString(STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, cbid, cb_res))); } /** diff --git a/src/openttd.cpp b/src/openttd.cpp index a80d494e86..82943ac624 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -622,8 +622,7 @@ int openttd_main(std::span arguments) fmt::print(stderr, "Failed to open savegame\n"); if (_load_check_data.HasErrors()) { InitializeLanguagePacks(); // A language pack is needed for GetString() - SetDParamStr(0, _load_check_data.error_msg); - fmt::print(stderr, "{}\n", GetString(_load_check_data.error)); + fmt::print(stderr, "{}\n", GetString(_load_check_data.error, _load_check_data.error_msg)); } return ret; } diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 6592e5e830..e95542f65f 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -185,8 +185,7 @@ protected: /* Generate generic title if selected page have no custom title. */ StoryPage *page = this->GetSelPage(); if (page != nullptr && page->title.empty()) { - SetDParam(0, GetSelPageNum() + 1); - selected_generic_title = GetString(STR_STORY_BOOK_GENERIC_PAGE_ITEM); + selected_generic_title = GetString(STR_STORY_BOOK_GENERIC_PAGE_ITEM, GetSelPageNum() + 1); } this->story_page_elements.ForceRebuild(); diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 42340df37f..24078ed766 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -47,8 +47,7 @@ void Subsidy::AwardTo(CompanyID company) this->awarded = company; this->remaining = _settings_game.difficulty.subsidy_duration * CalendarTime::MONTHS_IN_YEAR; - SetDParam(0, company); - std::string company_name = GetString(STR_COMPANY_NAME); + std::string company_name = GetString(STR_COMPANY_NAME, company); /* Add a news item */ std::pair reftype = SetupSubsidyDecodeParam(this, SubsidyDecodeParamType::NewsAwarded, 1); diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 44cbe713bc..ca8cf0084b 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -100,9 +100,7 @@ class DropDownListCompanyItem : public DropDownIcon, true>>(SPR_COMPANY_ICON, COMPANY_SPRITE_COLOUR(company), NetworkCanJoinCompany(company) ? SPR_EMPTY : SPR_LOCK, PAL_NONE, STR_NULL, company, false, shaded) { - SetDParam(0, company); - SetDParam(1, company); - this->SetString(GetString(STR_COMPANY_NAME_COMPANY_NUM)); + this->SetString(GetString(STR_COMPANY_NAME_COMPANY_NUM, company, company)); } }; diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index caabb617f1..8c1d4c0327 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2233,8 +2233,7 @@ std::tuple CmdFoundTown(DoCommandFlags flags, TileIn SetDParam(0, t->index); AddTileNewsItem(STR_NEWS_NEW_TOWN_UNSPONSORED, NewsType::IndustryOpen, tile); } else { - SetDParam(0, _current_company); - std::string company_name = GetString(STR_COMPANY_NAME); + std::string company_name = GetString(STR_COMPANY_NAME, _current_company); SetDParamStr(0, company_name); SetDParam(1, t->index); @@ -3408,8 +3407,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlags flags) if (flags.Test(DoCommandFlag::Execute)) { t->road_build_months = 6; - SetDParam(0, _current_company); - std::string company_name = GetString(STR_COMPANY_NAME); + std::string company_name = GetString(STR_COMPANY_NAME, _current_company); SetDParam(0, t->index); SetDParamStr(1, company_name); diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 2516bdaf8e..a508e5d15e 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -1667,16 +1667,12 @@ struct BuildHouseWindow : public PickerWindow { if (max_year == CalendarTime::MAX_YEAR) { return GetString(STR_HOUSE_PICKER_YEARS_ANY); } - SetDParam(0, max_year); - return GetString(STR_HOUSE_PICKER_YEARS_UNTIL); + return GetString(STR_HOUSE_PICKER_YEARS_UNTIL, max_year); } if (max_year == CalendarTime::MAX_YEAR) { - SetDParam(0, min_year); - return GetString(STR_HOUSE_PICKER_YEARS_FROM); + return GetString(STR_HOUSE_PICKER_YEARS_FROM, min_year); } - SetDParam(0, min_year); - SetDParam(1, max_year); - return GetString(STR_HOUSE_PICKER_YEARS); + return GetString(STR_HOUSE_PICKER_YEARS, min_year, max_year); } /** @@ -1688,12 +1684,10 @@ struct BuildHouseWindow : public PickerWindow { { std::stringstream line; - SetDParam(0, GetHouseName(hs)); - line << GetString(STR_HOUSE_PICKER_NAME); + line << GetString(STR_HOUSE_PICKER_NAME, GetHouseName(hs)); line << "\n"; - SetDParam(0, hs->population); - line << GetString(STR_HOUSE_PICKER_POPULATION); + line << GetString(STR_HOUSE_PICKER_POPULATION, hs->population); line << "\n"; line << GetHouseYear(hs->min_year, hs->max_year); @@ -1704,9 +1698,7 @@ struct BuildHouseWindow : public PickerWindow { if (hs->building_flags.Test(BuildingFlag::Size2x1)) size = 0x21; if (hs->building_flags.Test(BuildingFlag::Size1x2)) size = 0x12; if (hs->building_flags.Test(BuildingFlag::Size2x2)) size = 0x22; - SetDParam(0, GB(size, 0, 4)); - SetDParam(1, GB(size, 4, 4)); - line << GetString(STR_HOUSE_PICKER_SIZE); + line << GetString(STR_HOUSE_PICKER_SIZE, GB(size, 0, 4), GB(size, 4, 4)); line << "\n"; auto cargo_string = BuildCargoAcceptanceString(GetAcceptedCargoOfHouse(hs), STR_HOUSE_PICKER_CARGO_ACCEPTED); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 02c23eda99..4a27f73fc2 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -331,11 +331,9 @@ void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRF } /* debug output */ - SetDParamStr(0, grfconfig->GetName()); - Debug(grf, 0, "{}", StrMakeValid(GetString(part1))); + Debug(grf, 0, "{}", StrMakeValid(GetString(part1, grfconfig->GetName()))); - SetDParam(1, engine); - Debug(grf, 0, "{}", StrMakeValid(GetString(part2))); + Debug(grf, 0, "{}", StrMakeValid(GetString(part2, std::monostate{}, engine))); } /** diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 5222b97f81..3b62bb6dd8 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1450,14 +1450,12 @@ static bool VehicleNameSorter(const Vehicle * const &a, const Vehicle * const &b if (a != _last_vehicle[0]) { _last_vehicle[0] = a; - SetDParam(0, a->index); - last_name[0] = GetString(STR_VEHICLE_NAME); + last_name[0] = GetString(STR_VEHICLE_NAME, a->index); } if (b != _last_vehicle[1]) { _last_vehicle[1] = b; - SetDParam(0, b->index); - last_name[1] = GetString(STR_VEHICLE_NAME); + last_name[1] = GetString(STR_VEHICLE_NAME, b->index); } int r = StrNaturalCompare(last_name[0], last_name[1]); // Sort by name (natural sorting). diff --git a/src/viewport.cpp b/src/viewport.cpp index 7d8f6b5536..bea1f333b5 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1369,9 +1369,7 @@ static void ViewportAddTownStrings(DrawPixelInfo *dpi, const std::vectorcache.sign, flags, INVALID_COLOUR); if (str == nullptr) continue; - SetDParam(0, t->index); - SetDParam(1, t->cache.population); - *str = GetString(stringid); + *str = GetString(stringid, t->index, t->cache.population); } } @@ -1395,8 +1393,7 @@ static void ViewportAddSignStrings(DrawPixelInfo *dpi, const std::vectorowner == OWNER_NONE) ? COLOUR_GREY : (si->owner == OWNER_DEITY ? INVALID_COLOUR : _company_colours[si->owner])); if (str == nullptr) continue; - SetDParam(0, si->index); - *str = GetString(STR_SIGN_NAME); + *str = GetString(STR_SIGN_NAME, si->index); } } @@ -1417,12 +1414,9 @@ static void ViewportAddStationStrings(DrawPixelInfo *dpi, const std::vectorindex); - SetDParam(1, st->facilities); - *str = GetString(small ? STR_STATION_NAME : STR_VIEWPORT_STATION); + *str = GetString(small ? STR_STATION_NAME : STR_VIEWPORT_STATION, st->index, st->facilities); } else { /* Waypoint */ - SetDParam(0, st->index); - *str = GetString(STR_WAYPOINT_NAME); + *str = GetString(STR_WAYPOINT_NAME, st->index); } } }