summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-14 13:22:30 +0000
committertron <tron@openttd.org>2006-06-14 13:22:30 +0000
commit74d40ced0a0cc8df642e6f7f9b7cdacd74f209d8 (patch)
tree1725f09e313dda5b276731bb0a52dcb6f597e161
parent3d41cb23d415cb4f39f8e0e5214e01ed73f2b945 (diff)
downloadopenttd-74d40ced0a0cc8df642e6f7f9b7cdacd74f209d8.tar.xz
(svn r5265) Replace a dozen bogus uses of strncmp() by strcmp()
-rw-r--r--console_cmds.c7
-rw-r--r--network_server.c14
-rw-r--r--network_udp.c4
3 files changed, 12 insertions, 13 deletions
diff --git a/console_cmds.c b/console_cmds.c
index 0994f3258..aa7a7d553 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -1202,7 +1202,7 @@ DEF_CONSOLE_CMD(ConSayClient)
DEF_CONSOLE_HOOK(ConHookServerPW)
{
- if (strncmp(_network_server_password, "*", NETWORK_PASSWORD_LENGTH) == 0) {
+ if (strcmp(_network_server_password, "*") == 0) {
_network_server_password[0] = '\0';
_network_game_info.use_password = 0;
} else {
@@ -1215,7 +1215,7 @@ DEF_CONSOLE_HOOK(ConHookServerPW)
DEF_CONSOLE_HOOK(ConHookRconPW)
{
- if (strncmp(_network_rcon_password, "*", NETWORK_PASSWORD_LENGTH) == 0)
+ if (strcmp(_network_rcon_password, "*") == 0)
_network_rcon_password[0] = '\0';
ttd_strlcpy(_network_game_info.rcon_password, _network_rcon_password, sizeof(_network_game_info.rcon_password));
@@ -1239,8 +1239,7 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[])
if (argc != 1) return false;
- if (strncmp(argv[0], "*", sizeof(_network_player_info[_local_player].password)) == 0)
- argv[0][0] = '\0';
+ if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0';
ttd_strlcpy(_network_player_info[_local_player].password, argv[0], sizeof(_network_player_info[_local_player].password));
diff --git a/network_server.c b/network_server.c
index e89973f12..7fa6d027b 100644
--- a/network_server.c
+++ b/network_server.c
@@ -578,8 +578,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_JOIN)
#if defined(WITH_REV) || defined(WITH_REV_HACK)
// Check if the client has revision control enabled
- if (strncmp(NOREV_STRING, client_revision, sizeof(client_revision)) != 0) {
- if (strncmp(_network_game_info.server_revision, client_revision, sizeof(_network_game_info.server_revision) - 1) != 0) {
+ if (strcmp(NOREV_STRING, client_revision) != 0) {
+ if (strcmp(_network_game_info.server_revision, client_revision) != 0) {
// Different revisions!!
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_REVISION);
@@ -656,7 +656,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
if (cs->status == STATUS_INACTIVE && type == NETWORK_GAME_PASSWORD) {
// Check game-password
- if (strncmp(password, _network_game_info.server_password, sizeof(password)) != 0) {
+ if (strcmp(password, _network_game_info.server_password) != 0) {
// Password is invalid
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
return;
@@ -675,7 +675,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_PASSWORD)
} else if (cs->status == STATUS_INACTIVE && type == NETWORK_COMPANY_PASSWORD) {
ci = DEREF_CLIENT_INFO(cs);
- if (strncmp(password, _network_player_info[ci->client_playas - 1].password, sizeof(password)) != 0) {
+ if (strcmp(password, _network_player_info[ci->client_playas - 1].password) != 0) {
// Password is invalid
SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_WRONG_PASSWORD);
return;
@@ -1119,7 +1119,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_RCON)
NetworkRecv_string(cs, p, pass, sizeof(pass));
NetworkRecv_string(cs, p, command, sizeof(command));
- if (strncmp(pass, _network_game_info.rcon_password, sizeof(pass)) != 0) {
+ if (strcmp(pass, _network_game_info.rcon_password) != 0) {
DEBUG(net, 0)("[RCon] Wrong password from client-id %d", cs->index);
return;
}
@@ -1396,7 +1396,7 @@ bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
found_name = true;
FOR_ALL_CLIENTS(new_cs) {
ci = DEREF_CLIENT_INFO(new_cs);
- if (strncmp(ci->client_name, new_name, NETWORK_CLIENT_NAME_LENGTH) == 0) {
+ if (strcmp(ci->client_name, new_name) == 0) {
// Name already in use
found_name = false;
break;
@@ -1405,7 +1405,7 @@ bool NetworkFindName(char new_name[NETWORK_CLIENT_NAME_LENGTH])
// Check if it is the same as the server-name
ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
if (ci != NULL) {
- if (strncmp(ci->client_name, new_name, NETWORK_CLIENT_NAME_LENGTH) == 0) {
+ if (strcmp(ci->client_name, new_name) == 0) {
// Name already in use
found_name = false;
}
diff --git a/network_udp.c b/network_udp.c
index 5cfd6615b..7b1ca7205 100644
--- a/network_udp.c
+++ b/network_udp.c
@@ -142,8 +142,8 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_SERVER_RESPONSE)
/* Check if we are allowed on this server based on the revision-match */
item->info.compatible = (
- strncmp(item->info.server_revision, _openttd_revision, NETWORK_REVISION_LENGTH) == 0 ||
- strncmp(item->info.server_revision, NOREV_STRING, NETWORK_REVISION_LENGTH) == 0) ? true : false;
+ strcmp(item->info.server_revision, _openttd_revision) == 0 ||
+ strcmp(item->info.server_revision, NOREV_STRING) == 0) ? true : false;
break;
}