summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-01-13 15:00:16 +0000
committertron <tron@openttd.org>2007-01-13 15:00:16 +0000
commitabb644771af78103d1e8b8f5582e8a56c9dcfbfe (patch)
tree9bb1adc7db26f0d3e419320319b33f692cbcb593 /src/network
parentfc78ef95e16e890c917da7a52f7ab1d8f5773a05 (diff)
downloadopenttd-abb644771af78103d1e8b8f5582e8a56c9dcfbfe.tar.xz
(svn r8097) Replace strlen() {==,!=,>} 0 by the more concise {,!}StrEmpty(). Additionally the test takes O(1) instead of O(n) now
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_server.cpp3
-rw-r--r--src/network/network_udp.cpp6
2 files changed, 5 insertions, 4 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 59696c940..202220f34 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1291,8 +1291,9 @@ void NetworkPopulateCompanyInfo(void)
ci = DEREF_CLIENT_INFO(cs);
if (ci != NULL && IsValidPlayer(ci->client_playas)) {
- if (strlen(_network_player_info[ci->client_playas].players) != 0)
+ if (!StrEmpty(_network_player_info[ci->client_playas].players)) {
ttd_strlcat(_network_player_info[ci->client_playas].players, ", ", lengthof(_network_player_info[0].players));
+ }
ttd_strlcat(_network_player_info[ci->client_playas].players, client_name, lengthof(_network_player_info[0].players));
}
diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp
index f6ef19fe3..08a145717 100644
--- a/src/network/network_udp.cpp
+++ b/src/network/network_udp.cpp
@@ -238,7 +238,7 @@ DEF_UDP_RECEIVE_COMMAND(Server, PACKET_UDP_CLIENT_GET_NEWGRFS)
* the current list and do not send the other data.
* The name could be an empty string, if so take the filename. */
packet_len += sizeof(c.grfid) + sizeof(c.md5sum) +
- min(strlen((f->name != NULL && strlen(f->name) > 0) ? f->name : f->filename) + 1, (size_t)NETWORK_GRF_NAME_LENGTH);
+ min(strlen((f->name != NULL && !StrEmpty(f->name)) ? f->name : f->filename) + 1, (size_t)NETWORK_GRF_NAME_LENGTH);
if (packet_len > SEND_MTU - 4) { // 4 is 3 byte header + grf count in reply
break;
}
@@ -254,7 +254,7 @@ 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 && strlen(in_reply[i]->name) > 0) ?
+ ttd_strlcpy(name, (in_reply[i]->name != NULL && !StrEmpty(in_reply[i]->name)) ?
in_reply[i]->name : in_reply[i]->filename, sizeof(name));
this->Send_GRFIdentifier(packet, in_reply[i]);
NetworkSend_string(packet, name);
@@ -395,7 +395,7 @@ DEF_UDP_RECEIVE_COMMAND(Client, PACKET_UDP_SERVER_NEWGRFS)
/* An empty name is not possible under normal circumstances
* and causes problems when showing the NewGRF list. */
- if (strlen(name) == 0) continue;
+ if (StrEmpty(name)) continue;
/* Finds the fake GRFConfig for the just read GRF ID and MD5sum tuple.
* If it exists and not resolved yet, then name of the fake GRF is