summaryrefslogtreecommitdiff
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
commit9b282b3e51864af68b752831f68d719e9926c206 (patch)
tree852231dcb9853107b3876ca33a89cbeb47f20133
parent44a774a2775bfdbf270eac3adcd778e1ae4cba93 (diff)
downloadopenttd-9b282b3e51864af68b752831f68d719e9926c206.tar.xz
(svn r14555) -Codechange: replace ttd_strlcat and ttd_strlcpy with strecat and strecpy where direct conversion is possible
-rw-r--r--src/console_cmds.cpp6
-rw-r--r--src/debug.cpp2
-rw-r--r--src/fileio.cpp2
-rw-r--r--src/fios.cpp14
-rw-r--r--src/gfx.cpp2
-rw-r--r--src/misc_gui.cpp10
-rw-r--r--src/music/extmidi.cpp2
-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
-rw-r--r--src/newgrf_config.cpp2
-rw-r--r--src/openttd.cpp24
-rw-r--r--src/os2.cpp2
-rw-r--r--src/screenshot.cpp2
-rw-r--r--src/settings_gui.cpp6
-rw-r--r--src/strgen/strgen.cpp10
-rw-r--r--src/strings.cpp2
-rw-r--r--src/unix.cpp2
-rw-r--r--src/win32.cpp6
23 files changed, 85 insertions, 85 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 0d1c8a84e..c216097cf 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -250,8 +250,8 @@ DEF_CONSOLE_CMD(ConLoad)
_switch_mode = SM_LOAD;
SetFiosType(item->type);
- ttd_strlcpy(_file_to_saveload.name, FiosBrowseTo(item), sizeof(_file_to_saveload.name));
- ttd_strlcpy(_file_to_saveload.title, item->title, sizeof(_file_to_saveload.title));
+ strecpy(_file_to_saveload.name, FiosBrowseTo(item), lastof(_file_to_saveload.name));
+ strecpy(_file_to_saveload.title, item->title, lastof(_file_to_saveload.title));
} break;
default: IConsolePrintF(CC_ERROR, "%s: Not a savegame.", file);
}
@@ -1230,7 +1230,7 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0';
- ttd_strlcpy(_network_company_info[_local_company].password, argv[0], sizeof(_network_company_info[_local_company].password));
+ strecpy(_network_company_info[_local_company].password, argv[0], lastof(_network_company_info[_local_company].password));
if (!_network_server) {
NetworkClientSetPassword();
diff --git a/src/debug.cpp b/src/debug.cpp
index 157d033ae..10c43cf9c 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -163,7 +163,7 @@ const char *GetDebugString()
for (i++; i != endof(debug_level); i++) {
snprintf(dbgval, sizeof(dbgval), ", %s=%d", i->name, *i->level);
- ttd_strlcat(dbgstr, dbgval, sizeof(dbgstr));
+ strecat(dbgstr, dbgval, lastof(dbgstr));
}
return dbgstr;
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 543b76729..a4ba69cc2 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -310,7 +310,7 @@ FILE *FioFOpenFileSp(const char *filename, const char *mode, Searchpath sp, Subd
char buf[MAX_PATH];
if (subdir == NO_DIRECTORY) {
- ttd_strlcpy(buf, filename, lengthof(buf));
+ strecpy(buf, filename, lastof(buf));
} else {
snprintf(buf, lengthof(buf), "%s%s%s", _searchpaths[sp], _subdirs[subdir], filename);
}
diff --git a/src/fios.cpp b/src/fios.cpp
index aa2ecf236..6827f37aa 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -216,14 +216,14 @@ static FiosItem *FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_
fios = _fios_items.Append();
fios->type = FIOS_TYPE_PARENT;
fios->mtime = 0;
- ttd_strlcpy(fios->name, "..", lengthof(fios->name));
- ttd_strlcpy(fios->title, ".. (Parent directory)", lengthof(fios->title));
+ strecpy(fios->name, "..", lastof(fios->name));
+ strecpy(fios->title, ".. (Parent directory)", lastof(fios->title));
}
/* Show subdirectories */
if (mode != SLD_NEW_GAME && (dir = ttd_opendir(_fios_path)) != NULL) {
while ((dirent = readdir(dir)) != NULL) {
- ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name));
+ strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
/* found file must be directory, but not '.' or '..' */
if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) &&
@@ -232,7 +232,7 @@ static FiosItem *FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_
fios = _fios_items.Append();
fios->type = FIOS_TYPE_DIR;
fios->mtime = 0;
- ttd_strlcpy(fios->name, d_name, lengthof(fios->name));
+ strecpy(fios->name, d_name, lastof(fios->name));
snprintf(fios->title, lengthof(fios->title), "%s" PATHSEP " (Directory)", d_name);
str_validate(fios->title);
}
@@ -257,7 +257,7 @@ static FiosItem *FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_
while ((dirent = readdir(dir)) != NULL) {
char fios_title[64];
char *t;
- ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name));
+ strecpy(d_name, FS2OTTD(dirent->d_name), lastof(d_name));
if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG) || FiosIsHiddenFile(dirent)) continue;
@@ -270,12 +270,12 @@ static FiosItem *FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_
fios = _fios_items.Append();
fios->mtime = sb.st_mtime;
fios->type = type;
- ttd_strlcpy(fios->name, d_name, lengthof(fios->name));
+ strecpy(fios->name, d_name, lastof(fios->name));
/* Some callbacks want to lookup the title of the file. Allow that.
* If we just copy the title from the filename, strip the extension */
t = (fios_title[0] == '\0') ? *t = '\0', d_name : fios_title;
- ttd_strlcpy(fios->title, t, lengthof(fios->title));
+ strecpy(fios->title, t, lastof(fios->title));
str_validate(fios->title);
}
}
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 75189ab6a..9b613ceef 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -986,7 +986,7 @@ skip_cont:;
int DoDrawStringTruncated(const char *str, int x, int y, uint16 color, uint maxw)
{
char buffer[DRAW_STRING_BUFFER];
- ttd_strlcpy(buffer, str, sizeof(buffer));
+ strecpy(buffer, str, lastof(buffer));
TruncateString(buffer, maxw);
return DoDrawString(buffer, x, y, color);
}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 144602913..57ead63b2 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1488,7 +1488,7 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
break;
default:
- ttd_strlcpy(o_dir.name, _personal_dir, lengthof(o_dir.name));
+ strecpy(o_dir.name, _personal_dir, lastof(o_dir.name));
}
this->vscroll.cap = 10;
@@ -1574,14 +1574,14 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
_switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_SCENARIO : SM_LOAD;
SetFiosType(file->type);
- ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
- ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
+ strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
+ strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
delete this;
} else if (_saveload_mode == SLD_LOAD_HEIGHTMAP) {
SetFiosType(file->type);
- ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
- ttd_strlcpy(_file_to_saveload.title, file->title, sizeof(_file_to_saveload.title));
+ strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
+ strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
delete this;
ShowHeightmapLoad();
diff --git a/src/music/extmidi.cpp b/src/music/extmidi.cpp
index a4c5bfb00..cba772506 100644
--- a/src/music/extmidi.cpp
+++ b/src/music/extmidi.cpp
@@ -34,7 +34,7 @@ void MusicDriver_ExtMidi::Stop()
void MusicDriver_ExtMidi::PlaySong(const char* filename)
{
- ttd_strlcpy(this->song, filename, lengthof(this->song));
+ strecpy(this->song, filename, lastof(this->song));
this->DoStop();
}
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;
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index d52ee828c..389aeb408 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -446,7 +446,7 @@ char *FindUnknownGRFName(uint32 grfid, uint8 *md5sum, bool create)
grf = CallocT<UnknownGRF>(1);
grf->grfid = grfid;
grf->next = unknown_grfs;
- ttd_strlcpy(grf->name, UNKNOWN_GRF_NAME_PLACEHOLDER, sizeof(grf->name));
+ strecpy(grf->name, UNKNOWN_GRF_NAME_PLACEHOLDER, lastof(grf->name));
memcpy(grf->md5sum, md5sum, sizeof(grf->md5sum));
unknown_grfs = grf;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 58d193b80..45ba09de9 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -424,11 +424,11 @@ int ttd_main(int argc, char *argv[])
while ((i = MyGetOpt(&mgo)) != -1) {
switch (i) {
- case 'I': ttd_strlcpy(graphics_set, mgo.opt, sizeof(graphics_set)); break;
- case 'm': ttd_strlcpy(musicdriver, mgo.opt, sizeof(musicdriver)); break;
- case 's': ttd_strlcpy(sounddriver, mgo.opt, sizeof(sounddriver)); break;
- case 'v': ttd_strlcpy(videodriver, mgo.opt, sizeof(videodriver)); break;
- case 'b': ttd_strlcpy(blitter, mgo.opt, sizeof(blitter)); break;
+ case 'I': strecpy(graphics_set, mgo.opt, lastof(graphics_set)); break;
+ case 'm': strecpy(musicdriver, mgo.opt, lastof(musicdriver)); break;
+ case 's': strecpy(sounddriver, mgo.opt, lastof(sounddriver)); break;
+ case 'v': strecpy(videodriver, mgo.opt, lastof(videodriver)); break;
+ case 'b': strecpy(blitter, mgo.opt, lastof(blitter)); break;
#if defined(ENABLE_NETWORK)
case 'D':
strcpy(musicdriver, "null");
@@ -467,7 +467,7 @@ int ttd_main(int argc, char *argv[])
case 'i': _use_palette = (mgo.opt == NULL || atoi(mgo.opt) == 0) ? PAL_DOS : PAL_WINDOWS; break;
case 'g':
if (mgo.opt != NULL) {
- ttd_strlcpy(_file_to_saveload.name, mgo.opt, sizeof(_file_to_saveload.name));
+ strecpy(_file_to_saveload.name, mgo.opt, lastof(_file_to_saveload.name));
_switch_mode = SM_LOAD;
_file_to_saveload.mode = SL_LOAD;
@@ -522,11 +522,11 @@ int ttd_main(int argc, char *argv[])
/* override config? */
- if (!StrEmpty(graphics_set)) ttd_strlcpy(_ini_graphics_set, graphics_set, sizeof(_ini_graphics_set));
- if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
- if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
- if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
- if (!StrEmpty(blitter)) ttd_strlcpy(_ini_blitter, blitter, sizeof(_ini_blitter));
+ if (!StrEmpty(graphics_set)) strecpy(_ini_graphics_set, graphics_set, lastof(_ini_graphics_set));
+ if (!StrEmpty(musicdriver)) strecpy(_ini_musicdriver, musicdriver, lastof(_ini_musicdriver));
+ if (!StrEmpty(sounddriver)) strecpy(_ini_sounddriver, sounddriver, lastof(_ini_sounddriver));
+ if (!StrEmpty(videodriver)) strecpy(_ini_videodriver, videodriver, lastof(_ini_videodriver));
+ if (!StrEmpty(blitter)) strecpy(_ini_blitter, blitter, lastof(_ini_blitter));
if (resolution.width != 0) { _cur_resolution = resolution; }
if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear;
if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed;
@@ -1109,7 +1109,7 @@ static void DoAutosave()
SetDParam(0, _local_company);
SetDParam(1, _date);
GetString(buf, STR_4004, lastof(buf));
- ttd_strlcat(buf, ".sav", lengthof(buf));
+ strecat(buf, ".sav", lastof(buf));
} else {
/* generate a savegame name and number according to _settings_client.gui.max_num_autosaves */
snprintf(buf, sizeof(buf), "autosave%d.sav", _autosave_ctr);
diff --git a/src/os2.cpp b/src/os2.cpp
index 704ffe4a7..8ace477eb 100644
--- a/src/os2.cpp
+++ b/src/os2.cpp
@@ -75,7 +75,7 @@ void FiosGetDrives()
#else
snprintf(fios->name, lengthof(fios->name), "%c:", disk);
#endif
- ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
+ strecpy(fios->title, fios->name, lastof(fios->title));
}
}
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index 49bc132b6..f667ecf2f 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -548,7 +548,7 @@ static char *MakeScreenshotName(const char *ext)
size_t len;
if (_game_mode == GM_EDITOR || _game_mode == GM_MENU || _local_company == COMPANY_SPECTATOR) {
- ttd_strlcpy(_screenshot_name, "screenshot", lengthof(_screenshot_name));
+ strecpy(_screenshot_name, "screenshot", lastof(_screenshot_name));
} else {
SetDParam(0, _local_company);
SetDParam(1, _date);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index cab23a1d5..09c92f9c3 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1190,15 +1190,15 @@ struct CustomCurrencyWindow : Window {
case CUSTCURR_SEPARATOR: /* Thousands seperator */
_custom_currency.separator = StrEmpty(str) ? ' ' : str[0];
- ttd_strlcpy(this->separator, str, lengthof(this->separator));
+ strecpy(this->separator, str, lastof(this->separator));
break;
case CUSTCURR_PREFIX:
- ttd_strlcpy(_custom_currency.prefix, str, lengthof(_custom_currency.prefix));
+ strecpy(_custom_currency.prefix, str, lastof(_custom_currency.prefix));
break;
case CUSTCURR_SUFFIX:
- ttd_strlcpy(_custom_currency.suffix, str, lengthof(_custom_currency.suffix));
+ strecpy(_custom_currency.suffix, str, lastof(_custom_currency.suffix));
break;
case CUSTCURR_TO_EURO: { /* Year to switch to euro */
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index ed630d67f..ccf4c1398 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -643,11 +643,11 @@ static void HandlePragma(char *str)
if (!memcmp(str, "id ", 3)) {
_next_string_id = strtoul(str + 3, NULL, 0);
} else if (!memcmp(str, "name ", 5)) {
- ttd_strlcpy(_lang_name, str + 5, sizeof(_lang_name));
+ strecpy(_lang_name, str + 5, lastof(_lang_name));
} else if (!memcmp(str, "ownname ", 8)) {
- ttd_strlcpy(_lang_ownname, str + 8, sizeof(_lang_ownname));
+ strecpy(_lang_ownname, str + 8, lastof(_lang_ownname));
} else if (!memcmp(str, "isocode ", 8)) {
- ttd_strlcpy(_lang_isocode, str + 8, sizeof(_lang_isocode));
+ strecpy(_lang_isocode, str + 8, lastof(_lang_isocode));
} else if (!memcmp(str, "plural ", 7)) {
_lang_pluralform = atoi(str + 7);
if (_lang_pluralform >= lengthof(_plural_form_counts))
@@ -668,7 +668,7 @@ static void HandlePragma(char *str)
if (s == NULL) break;
if (_numgenders >= MAX_NUM_GENDER) error("Too many genders, max %d", MAX_NUM_GENDER);
- ttd_strlcpy(_genders[_numgenders], s, sizeof(_genders[_numgenders]));
+ strecpy(_genders[_numgenders], s, lastof(_genders[_numgenders]));
_numgenders++;
}
} else if (!memcmp(str, "case ", 5)) {
@@ -679,7 +679,7 @@ static void HandlePragma(char *str)
if (s == NULL) break;
if (_numcases >= MAX_NUM_CASES) error("Too many cases, max %d", MAX_NUM_CASES);
- ttd_strlcpy(_cases[_numcases], s, sizeof(_cases[_numcases]));
+ strecpy(_cases[_numcases], s, lastof(_cases[_numcases]));
_numcases++;
}
} else {
diff --git a/src/strings.cpp b/src/strings.cpp
index da08581a0..010298062 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1271,7 +1271,7 @@ bool ReadLanguagePack(int lang_index)
_langpack_offs = langpack_offs;
const char *c_file = strrchr(_dynlang.ent[lang_index].file, PATHSEPCHAR) + 1;
- ttd_strlcpy(_dynlang.curr_file, c_file, lengthof(_dynlang.curr_file));
+ strecpy(_dynlang.curr_file, c_file, lastof(_dynlang.curr_file));
_dynlang.curr = lang_index;
_dynlang.text_dir = (TextDirection)lang_pack->text_dir;
diff --git a/src/unix.cpp b/src/unix.cpp
index 7fafd3d67..2e62b6399 100644
--- a/src/unix.cpp
+++ b/src/unix.cpp
@@ -154,7 +154,7 @@ static const char *convert_tofrom_fs(iconv_t convd, const char *name)
size_t outlen = sizeof(buf) - 1;
size_t inlen = strlen(name);
- ttd_strlcpy(outbuf, name, sizeof(buf));
+ strecpy(outbuf, name, lastof(buf));
iconv(convd, NULL, NULL, NULL, NULL);
if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) {
diff --git a/src/win32.cpp b/src/win32.cpp
index 24bb976b3..27be2d8a1 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -803,7 +803,7 @@ void FiosGetDrives()
fios->type = FIOS_TYPE_DRIVE;
fios->mtime = 0;
snprintf(fios->name, lengthof(fios->name), PATHSEP "");
- ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
+ strecpy(fios->title, fios->name, lastof(fios->title));
#else
TCHAR drives[256];
const TCHAR *s;
@@ -814,7 +814,7 @@ void FiosGetDrives()
fios->type = FIOS_TYPE_DRIVE;
fios->mtime = 0;
snprintf(fios->name, lengthof(fios->name), "%c:", s[0] & 0xFF);
- ttd_strlcpy(fios->title, fios->name, lengthof(fios->title));
+ strecpy(fios->title, fios->name, lastof(fios->title));
while (*s++ != '\0') { /* Nothing */ }
}
#endif
@@ -1127,7 +1127,7 @@ bool InsertTextBufferClipboard(Textbuf *tb)
cbuf = GetClipboardData(CF_TEXT);
ptr = (const char*)GlobalLock(cbuf);
- ttd_strlcpy(utf8_buf, FS2OTTD(ptr), lengthof(utf8_buf));
+ strecpy(utf8_buf, FS2OTTD(ptr), lastof(utf8_buf));
GlobalUnlock(cbuf);
CloseClipboard();