Codechange: Use GetString() with argument parameters in simple cases. (#13551)

Avoids using global string parameters.
This commit is contained in:
Peter Nelson
2025-02-14 00:10:56 +00:00
committed by GitHub
parent c3d5e6d2a0
commit 20e57a02a2
26 changed files with 79 additions and 170 deletions
+4 -8
View File
@@ -321,10 +321,8 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company
auto p = std::make_unique<Packet>(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<Packet>(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
+1 -2
View File
@@ -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));
}
+1 -2
View File
@@ -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;
}
+2 -4
View File
@@ -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);
}