summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-15 17:31:18 +0000
committertruelight <truelight@openttd.org>2004-12-15 17:31:18 +0000
commita4a3d829be1591bc94829bcf247ce0a5bb11d562 (patch)
tree5cdef31a05240e77a8a2d91d48a17c5c6dbcf03c
parentb615e854e1e12c15630a292dd75456e18a03951d (diff)
downloadopenttd-a4a3d829be1591bc94829bcf247ce0a5bb11d562.tar.xz
(svn r1101) -Fix: [Console] Removed magic numbers
-rw-r--r--console_cmds.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 95651c4ba..3f5e892af 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -602,11 +602,11 @@ DEF_CONSOLE_CMD(ConSet) {
}
if (argc == 3) {
// Change server password
- if (strncmp(argv[2], "*", 20) == 0) {
+ if (strncmp(argv[2], "*", NETWORK_PASSWORD_LENGTH) == 0) {
_network_game_info.server_password[0] = '\0';
_network_game_info.use_password = 0;
} else {
- strncpy(_network_game_info.server_password, argv[2], 20);
+ strncpy(_network_game_info.server_password, argv[2], sizeof(_network_game_info.server_password));
_network_game_info.use_password = 1;
}
IConsolePrintF(_iconsole_color_warning, "Game-password changed to '%s'", _network_game_info.server_password);
@@ -628,10 +628,10 @@ DEF_CONSOLE_CMD(ConSet) {
return NULL;
}
if (argc == 3) {
- if (strncmp(argv[2], "*", 20) == 0) {
+ if (strncmp(argv[2], "*", NETWORK_PASSWORD_LENGTH) == 0) {
_network_player_info[_local_player].password[0] = '\0';
} else {
- strncpy(_network_player_info[_local_player].password, argv[2], 20);
+ strncpy(_network_player_info[_local_player].password, argv[2], sizeof(_network_player_info[_local_player].password));
}
if (!_network_server)
SEND_COMMAND(PACKET_CLIENT_SET_PASSWORD)(_network_player_info[_local_player].password);
@@ -660,12 +660,12 @@ DEF_CONSOLE_CMD(ConSet) {
else {
if (NetworkFindName(argv[2])) {
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, ci->client_name, argv[2]);
- ttd_strlcpy(ci->client_name, argv[2], 40);
+ ttd_strlcpy(ci->client_name, argv[2], sizeof(ci->client_name));
NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
}
}
/* Also keep track of the new name on the client itself */
- ttd_strlcpy(_network_player_name, argv[2], 40);
+ ttd_strlcpy(_network_player_name, argv[2], sizeof(_network_player_name));
} else {
IConsolePrint(_iconsole_color_default, "With 'set name' you can change your network-player name.");
IConsolePrint(_iconsole_color_warning, "Usage: set name \"<name>\".");
@@ -680,9 +680,9 @@ DEF_CONSOLE_CMD(ConSet) {
return NULL;
}
if (argc == 3) {
- strncpy(_network_server_name, argv[2], 40);
+ strncpy(_network_server_name, argv[2], sizeof(_network_server_name));
IConsolePrintF(_iconsole_color_warning, "Server-name changed to '%s'", _network_server_name);
- ttd_strlcpy(_network_game_info.server_name, _network_server_name, 40);
+ ttd_strlcpy(_network_game_info.server_name, _network_server_name, sizeof(_network_game_info.server_name));
} else {
IConsolePrintF(_iconsole_color_default, "Current server-name is '%s'", _network_server_name);
IConsolePrint(_iconsole_color_warning, "Usage: set server_name \"<GameName>\".");