summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorskidd13 <skidd13@openttd.org>2008-11-02 11:20:15 +0000
committerskidd13 <skidd13@openttd.org>2008-11-02 11:20:15 +0000
commit706dd0f86c2453eadb44742ca62d6c5d690e9238 (patch)
tree852231dcb9853107b3876ca33a89cbeb47f20133 /src/network
parentc03e55b32a4b9bf64c516d38ce75ff5c8ab39748 (diff)
downloadopenttd-706dd0f86c2453eadb44742ca62d6c5d690e9238.tar.xz
(svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network.cpp16
-rw-r--r--src/network/network_chat_gui.cpp2
-rw-r--r--src/network/network_client.cpp10
-rw-r--r--src/network/network_data.cpp2
-rw-r--r--src/network/network_gui.cpp12
-rw-r--r--src/network/network_server.cpp20
-rw-r--r--src/network/network_udp.cpp14
7 files changed, 38 insertions, 38 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 6ee777648..05839042d 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -212,19 +212,19 @@ void CDECL NetworkTextMessage(NetworkAction action, ConsoleColour color, bool se
SetDParamStr(0, name);
SetDParamStr(1, buf);
GetString(temp, self_send ? STR_NETWORK_CHAT_TO_COMPANY : STR_NETWORK_CHAT_COMPANY, lastof(temp));
- ttd_strlcpy(message, temp, sizeof(message));
+ strecpy(message, temp, lastof(message));
break;
case NETWORK_ACTION_CHAT_CLIENT:
SetDParamStr(0, name);
SetDParamStr(1, buf);
GetString(temp, self_send ? STR_NETWORK_CHAT_TO_CLIENT : STR_NETWORK_CHAT_CLIENT, lastof(temp));
- ttd_strlcpy(message, temp, sizeof(message));
+ strecpy(message, temp, lastof(message));
break;
default:
SetDParamStr(0, name);
SetDParamStr(1, buf);
GetString(temp, STR_NETWORK_CHAT_ALL, lastof(temp));
- ttd_strlcpy(message, temp, sizeof(message));
+ strecpy(message, temp, lastof(message));
break;
}
@@ -734,9 +734,9 @@ void NetworkAddServer(const char *b)
char host[NETWORK_HOSTNAME_LENGTH];
uint16 rport;
- ttd_strlcpy(host, b, lengthof(host));
+ strecpy(host, b, lastof(host));
- ttd_strlcpy(_settings_client.network.connect_to_ip, b, lengthof(_settings_client.network.connect_to_ip));
+ strecpy(_settings_client.network.connect_to_ip, b, lastof(_settings_client.network.connect_to_ip));
rport = NETWORK_DEFAULT_PORT;
ParseConnectionString(&company, &port, host);
@@ -774,7 +774,7 @@ bool NetworkClientConnectGame(const char *host, uint16 port)
if (port == 0) return false;
- ttd_strlcpy(_settings_client.network.last_host, host, sizeof(_settings_client.network.last_host));
+ strecpy(_settings_client.network.last_host, host, lastof(_settings_client.network.last_host));
_settings_client.network.last_port = port;
NetworkDisconnect();
@@ -815,8 +815,8 @@ static void NetworkInitGameInfo()
ci->client_index = NETWORK_SERVER_INDEX;
ci->client_playas = _network_dedicated ? COMPANY_SPECTATOR : _local_company;
- ttd_strlcpy(ci->client_name, _settings_client.network.client_name, sizeof(ci->client_name));
- ttd_strlcpy(ci->unique_id, _settings_client.network.network_id, sizeof(ci->unique_id));
+ strecpy(ci->client_name, _settings_client.network.client_name, lastof(ci->client_name));
+ strecpy(ci->unique_id, _settings_client.network.network_id, lastof(ci->unique_id));
}
bool NetworkServerStart()
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index 22b2df5fe..c2ce73a84 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -97,7 +97,7 @@ void CDECL NetworkAddChatMessage(uint16 color, uint8 duration, const char *messa
for (bufp = buf; lines != 0; lines--) {
ChatMessage *cmsg = &_chatmsg_list[msg_count++];
- ttd_strlcpy(cmsg->message, bufp, sizeof(cmsg->message));
+ strecpy(cmsg->message, bufp, lastof(cmsg->message));
/* The default colour for a message is company colour. Replace this with
* white for any additional lines */
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 0947f37a5..c90ffcc73 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -84,10 +84,10 @@ void HashCurrentCompanyPassword()
if (StrEmpty(_network_company_info[_local_company].password)) return;
_password_game_seed = _settings_game.game_creation.generation_seed;
- ttd_strlcpy(_password_server_unique_id, _settings_client.network.network_id, sizeof(_password_server_unique_id));
+ strecpy(_password_server_unique_id, _settings_client.network.network_id, lastof(_password_server_unique_id));
const char *new_pw = GenerateCompanyPasswordHash(_network_company_info[_local_company].password);
- ttd_strlcpy(_network_company_info[_local_company].password, new_pw, sizeof(_network_company_info[_local_company].password));
+ strecpy(_network_company_info[_local_company].password, new_pw, lastof(_network_company_info[_local_company].password));
}
@@ -419,7 +419,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
}
ci->client_playas = playas;
- ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name));
+ strecpy(ci->client_name, name, lastof(ci->client_name));
InvalidateWindow(WC_CLIENT_LIST, 0);
@@ -432,7 +432,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
ci->client_index = index;
ci->client_playas = playas;
- ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name));
+ strecpy(ci->client_name, name, lastof(ci->client_name));
InvalidateWindow(WC_CLIENT_LIST, 0);
@@ -951,7 +951,7 @@ void NetworkUpdateClientName()
} else {
if (NetworkFindName(_settings_client.network.client_name)) {
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", _settings_client.network.client_name);
- ttd_strlcpy(ci->client_name, _settings_client.network.client_name, sizeof(ci->client_name));
+ strecpy(ci->client_name, _settings_client.network.client_name, lastof(ci->client_name));
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
}
}
diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp
index 767d66cdf..13511cc3b 100644
--- a/src/network/network_data.cpp
+++ b/src/network/network_data.cpp
@@ -53,7 +53,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
c.callback = 0; // _callback_table[0] == NULL
}
- ttd_strlcpy(c.text, (_cmd_text != NULL) ? _cmd_text : "", lengthof(c.text));
+ strecpy(c.text, (_cmd_text != NULL) ? _cmd_text : "", lastof(c.text));
if (_network_server) {
/* If we are the server, we queue the command in our 'special' queue.
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index cc23c6eeb..fefdde532 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -672,9 +672,9 @@ public:
/* The name is only allowed when it starts with a letter! */
if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
- ttd_strlcpy(_settings_client.network.client_name, this->edit_str_buf, lengthof(_settings_client.network.client_name));
+ strecpy(_settings_client.network.client_name, this->edit_str_buf, lastof(_settings_client.network.client_name));
} else {
- ttd_strlcpy(_settings_client.network.client_name, "Player", lengthof(_settings_client.network.client_name));
+ strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));
}
return state;
}
@@ -1003,8 +1003,8 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
if (name != NULL) {
SetFiosType(this->map->type);
_file_to_saveload.filetype = FT_SCENARIO;
- ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
- ttd_strlcpy(_file_to_saveload.title, this->map->title, sizeof(_file_to_saveload.title));
+ strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
+ strecpy(_file_to_saveload.title, this->map->title, lastof(_file_to_saveload.title));
delete this;
SwitchMode(SM_START_SCENARIO);
@@ -1049,7 +1049,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
if (this->field == NSSW_GAMENAME) {
if (this->HandleEditBoxKey(NSSW_GAMENAME, key, keycode, state) == HEBR_CONFIRM) return state;
- ttd_strlcpy(_settings_client.network.server_name, this->text.buf, sizeof(_settings_client.network.server_name));
+ strecpy(_settings_client.network.server_name, this->text.buf, lastof(_settings_client.network.server_name));
}
return state;
@@ -1060,7 +1060,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
if (str == NULL) return;
if (this->widget_id == NSSW_SETPWD) {
- ttd_strlcpy(_settings_client.network.server_password, str, lengthof(_settings_client.network.server_password));
+ strecpy(_settings_client.network.server_password, str, lastof(_settings_client.network.server_password));
} else {
int32 value = atoi(str);
this->InvalidateWidget(this->widget_id);
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 07171bbe2..14d241243 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -679,7 +679,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
}
// We need a valid name.. make it Player
- if (StrEmpty(name)) ttd_strlcpy(name, "Player", sizeof(name));
+ if (StrEmpty(name)) strecpy(name, "Player", lastof(name));
if (!NetworkFindName(name)) { // Change name if duplicate
// We could not create a name for this client
@@ -689,8 +689,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
ci = DEREF_CLIENT_INFO(cs);
- ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name));
- ttd_strlcpy(ci->unique_id, unique_id, sizeof(ci->unique_id));
+ strecpy(ci->client_name, name, lastof(ci->client_name));
+ strecpy(ci->unique_id, unique_id, lastof(ci->unique_id));
ci->client_playas = playas;
ci->client_lang = client_lang;
@@ -1194,7 +1194,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_PASSWORD)
ci = DEREF_CLIENT_INFO(cs);
if (IsValidCompanyID(ci->client_playas)) {
- ttd_strlcpy(_network_company_info[ci->client_playas].password, password, sizeof(_network_company_info[0].password));
+ strecpy(_network_company_info[ci->client_playas].password, password, lastof(_network_company_info[0].password));
}
}
@@ -1218,7 +1218,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_SET_NAME)
// Display change
if (NetworkFindName(client_name)) {
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, "%s", client_name);
- ttd_strlcpy(ci->client_name, client_name, sizeof(ci->client_name));
+ strecpy(ci->client_name, client_name, lastof(ci->client_name));
NetworkUpdateClientInfo(ci->client_index);
}
}
@@ -1313,11 +1313,11 @@ void NetworkPopulateCompanyInfo()
FOR_ALL_COMPANIES(c) {
// Clean the info but not the password
- ttd_strlcpy(password, _network_company_info[c->index].password, sizeof(password));
+ strecpy(password, _network_company_info[c->index].password, lastof(password));
months_empty = _network_company_info[c->index].months_empty;
memset(&_network_company_info[c->index], 0, sizeof(NetworkCompanyInfo));
_network_company_info[c->index].months_empty = months_empty;
- ttd_strlcpy(_network_company_info[c->index].password, password, sizeof(_network_company_info[c->index].password));
+ strecpy(_network_company_info[c->index].password, password, lastof(_network_company_info[c->index].password));
// Grap the company name
SetDParam(0, c->index);
@@ -1372,7 +1372,7 @@ void NetworkPopulateCompanyInfo()
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
// Register local company (if not dedicated)
if (ci != NULL && IsValidCompanyID(ci->client_playas))
- ttd_strlcpy(_network_company_info[ci->client_playas].clients, ci->client_name, sizeof(_network_company_info[0].clients));
+ strecpy(_network_company_info[ci->client_playas].clients, ci->client_name, lastof(_network_company_info[0].clients));
FOR_ALL_CLIENTS(cs) {
char client_name[NETWORK_CLIENT_NAME_LENGTH];
@@ -1382,10 +1382,10 @@ void NetworkPopulateCompanyInfo()
ci = DEREF_CLIENT_INFO(cs);
if (ci != NULL && IsValidCompanyID(ci->client_playas)) {
if (!StrEmpty(_network_company_info[ci->client_playas].clients)) {
- ttd_strlcat(_network_company_info[ci->client_playas].clients, ", ", lengthof(_network_company_info[0].clients));
+ strecat(_network_company_info[ci->client_playas].clients, ", ", lastof(_network_company_info[0].clients));
}
- ttd_strlcat(_network_company_info[ci->client_playas].clients, client_name, lengthof(_network_company_info[0].clients));
+ strecat(_network_company_info[ci->client_playas].clients, client_name, lastof(_network_company_info[0].clients));
}
}
}
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index 070f17e1a..210a117ad 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -94,9 +94,9 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_FIND_SERVER)
ngi.dedicated = _network_dedicated;
ngi.grfconfig = _grfconfig;
- ttd_strlcpy(ngi.map_name, _network_game_info.map_name, lengthof(ngi.map_name));
- ttd_strlcpy(ngi.server_name, _settings_client.network.server_name, lengthof(ngi.server_name));
- ttd_strlcpy(ngi.server_revision, _openttd_revision, lengthof(ngi.server_revision));
+ strecpy(ngi.map_name, _network_game_info.map_name, lastof(ngi.map_name));
+ strecpy(ngi.server_name, _settings_client.network.server_name, lastof(ngi.server_name));
+ strecpy(ngi.server_revision, _openttd_revision, lastof(ngi.server_revision));
Packet packet(PACKET_UDP_SERVER_RESPONSE);
this->Send_NetworkGameInfo(&packet, &ngi);
@@ -209,8 +209,8 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_GET_NEWGRFS)
char name[NETWORK_GRF_NAME_LENGTH];
/* The name could be an empty string, if so take the filename */
- ttd_strlcpy(name, (in_reply[i]->name != NULL && !StrEmpty(in_reply[i]->name)) ?
- in_reply[i]->name : in_reply[i]->filename, sizeof(name));
+ strecpy(name, (in_reply[i]->name != NULL && !StrEmpty(in_reply[i]->name)) ?
+ in_reply[i]->name : in_reply[i]->filename, lastof(name));
this->Send_GRFIdentifier(&packet, in_reply[i]);
packet.Send_string(name);
}
@@ -465,8 +465,8 @@ void NetworkUDPQueryServer(const char* host, unsigned short port, bool manually)
if (StrEmpty(item->info.server_name)) {
memset(&item->info, 0, sizeof(item->info));
- ttd_strlcpy(item->info.server_name, host, lengthof(item->info.server_name));
- ttd_strlcpy(item->info.hostname, host, lengthof(item->info.hostname));
+ strecpy(item->info.server_name, host, lastof(item->info.server_name));
+ strecpy(item->info.hostname, host, lastof(item->info.hostname));
item->online = false;
}
item->manually = manually;