summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/company_cmd.cpp6
-rw-r--r--src/network/network.cpp4
-rw-r--r--src/network/network_admin.cpp36
-rw-r--r--src/network/network_server.cpp13
-rw-r--r--src/newgrf.cpp4
5 files changed, 18 insertions, 45 deletions
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 17923377a..85809544d 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -1220,13 +1220,11 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
cur_company.Restore();
if (_networking) {
- char dest_company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
SetDParam(0, dest_company);
- GetString(dest_company_name, STR_COMPANY_NAME, lastof(dest_company_name));
+ std::string dest_company_name = GetString(STR_COMPANY_NAME);
- char from_company_name[MAX_LENGTH_COMPANY_NAME_CHARS * MAX_CHAR_LENGTH];
SetDParam(0, _current_company);
- GetString(from_company_name, STR_COMPANY_NAME, lastof(from_company_name));
+ std::string from_company_name = GetString(STR_COMPANY_NAME);
NetworkTextMessage(NETWORK_ACTION_GIVE_MONEY, GetDrawStringCompanyColour(_current_company), false, from_company_name, dest_company_name, amount.GetCost());
}
diff --git a/src/network/network.cpp b/src/network/network.cpp
index abc8bdbc0..19957f700 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -367,9 +367,7 @@ void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode)
str = paused ? STR_NETWORK_SERVER_MESSAGE_GAME_PAUSED : STR_NETWORK_SERVER_MESSAGE_GAME_UNPAUSED;
}
- char buffer[DRAW_STRING_BUFFER];
- GetString(buffer, str, lastof(buffer));
- NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, "", buffer);
+ NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, "", GetString(str));
break;
}
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp
index dfe09344a..419de71d1 100644
--- a/src/network/network_admin.cpp
+++ b/src/network/network_admin.cpp
@@ -133,11 +133,9 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendError(NetworkErrorCode er
p->Send_uint8(error);
this->SendPacket(p);
- char str[100];
- StringID strid = GetNetworkErrorMsg(error);
- GetString(str, strid, lastof(str));
+ std::string error_message = GetString(GetNetworkErrorMsg(error));
- DEBUG(net, 1, "[admin] The admin '%s' (%s) made an error and has been disconnected: '%s'", this->admin_name, this->admin_version, str);
+ DEBUG(net, 1, "[admin] The admin '%s' (%s) made an error and has been disconnected: '%s'", this->admin_name, this->admin_version, error_message.c_str());
return this->CloseConnection(true);
}
@@ -316,20 +314,13 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyNew(CompanyID comp
*/
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company *c)
{
- char company_name[NETWORK_COMPANY_NAME_LENGTH];
- char manager_name[NETWORK_COMPANY_NAME_LENGTH];
-
- SetDParam(0, c->index);
- GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
-
- SetDParam(0, c->index);
- GetString(manager_name, STR_PRESIDENT_NAME, lastof(manager_name));
-
Packet *p = new Packet(ADMIN_PACKET_SERVER_COMPANY_INFO);
p->Send_uint8 (c->index);
- p->Send_string(company_name);
- p->Send_string(manager_name);
+ SetDParam(0, c->index);
+ p->Send_string(GetString(STR_COMPANY_NAME));
+ SetDParam(0, c->index);
+ p->Send_string(GetString(STR_PRESIDENT_NAME));
p->Send_uint8 (c->colour);
p->Send_bool (NetworkCompanyIsPassworded(c->index));
p->Send_uint32(c->inaugurated_year);
@@ -352,20 +343,13 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyInfo(const Company
*/
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyUpdate(const Company *c)
{
- char company_name[NETWORK_COMPANY_NAME_LENGTH];
- char manager_name[NETWORK_COMPANY_NAME_LENGTH];
-
- SetDParam(0, c->index);
- GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
-
- SetDParam(0, c->index);
- GetString(manager_name, STR_PRESIDENT_NAME, lastof(manager_name));
-
Packet *p = new Packet(ADMIN_PACKET_SERVER_COMPANY_UPDATE);
p->Send_uint8 (c->index);
- p->Send_string(company_name);
- p->Send_string(manager_name);
+ SetDParam(0, c->index);
+ p->Send_string(GetString(STR_COMPANY_NAME));
+ SetDParam(0, c->index);
+ p->Send_string(GetString(STR_PRESIDENT_NAME));
p->Send_uint8 (c->colour);
p->Send_bool (NetworkCompanyIsPassworded(c->index));
p->Send_uint8 (CeilDiv(c->months_of_bankruptcy, 3)); // send as quarters_of_bankruptcy
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 85015fce1..71173a8d5 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -432,7 +432,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyInfo()
*/
NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode error, const char *reason)
{
- char str[100];
Packet *p = new Packet(PACKET_SERVER_ERROR);
p->Send_uint8(error);
@@ -440,7 +439,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
this->SendPacket(p);
StringID strid = GetNetworkErrorMsg(error);
- GetString(str, strid, lastof(str));
/* Only send when the current client was in game */
if (this->status > STATUS_AUTHORIZED) {
@@ -448,7 +446,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
this->GetClientName(client_name, lastof(client_name));
- DEBUG(net, 1, "'%s' made an error and has been disconnected: %s", client_name, str);
+ DEBUG(net, 1, "'%s' made an error and has been disconnected: %s", client_name, GetString(strid).c_str());
if (error == NETWORK_ERROR_KICKED && reason != nullptr) {
NetworkTextMessage(NETWORK_ACTION_KICKED, CC_DEFAULT, false, client_name, reason, strid);
@@ -469,7 +467,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
NetworkAdminClientError(this->client_id, error);
} else {
- DEBUG(net, 1, "Client %d made an error and has been disconnected: %s", this->client_id, str);
+ DEBUG(net, 1, "Client %d made an error and has been disconnected: %s", this->client_id, GetString(strid).c_str());
}
/* The client made a mistake, so drop the connection now! */
@@ -1128,7 +1126,6 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
{
/* This packets means a client noticed an error and is reporting this
* to us. Display the error and report it to the other clients */
- char str[100];
char client_name[NETWORK_CLIENT_NAME_LENGTH];
NetworkErrorCode errorno = (NetworkErrorCode)p->Recv_uint8();
@@ -1140,9 +1137,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
this->GetClientName(client_name, lastof(client_name));
StringID strid = GetNetworkErrorMsg(errorno);
- GetString(str, strid, lastof(str));
- DEBUG(net, 1, "'%s' reported an error and is closing its connection: %s", client_name, str);
+ DEBUG(net, 1, "'%s' reported an error and is closing its connection: %s", client_name, GetString(strid).c_str());
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", strid);
@@ -1317,10 +1313,9 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
/* Display the message locally (so you know you have sent it) */
if (ci != nullptr && show_local) {
if (from_id == CLIENT_ID_SERVER) {
- char name[NETWORK_NAME_LENGTH];
StringID str = Company::IsValidID(ci_to->client_playas) ? STR_COMPANY_NAME : STR_NETWORK_SPECTATORS;
SetDParam(0, ci_to->client_playas);
- GetString(name, str, lastof(name));
+ std::string name = GetString(str);
NetworkTextMessage(action, GetDrawStringCompanyColour(ci_own->client_playas), true, name, msg, data);
} else {
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 5ddfcaddd..29125f158 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -7759,9 +7759,7 @@ static void TranslateGRFStrings(ByteReader *buf)
* and disable this file. */
GRFError *error = DisableGrf(STR_NEWGRF_ERROR_LOAD_AFTER);
- char tmp[256];
- GetString(tmp, STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE, lastof(tmp));
- error->data = tmp;
+ error->data = GetString(STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE);
return;
}