diff options
author | Darkvater <darkvater@openttd.org> | 2006-04-22 09:46:31 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2006-04-22 09:46:31 +0000 |
commit | ed96dcd86896a251e46932873804186aa5db7551 (patch) | |
tree | d17778b0172b265e34c0b0bf267266b0bf46fe32 /network.c | |
parent | 084acbf23cf3512de1e9f22e6118d3668a0c8843 (diff) | |
download | openttd-ed96dcd86896a251e46932873804186aa5db7551.tar.xz |
(svn r4521) - Fix: be consistent about the size of the player-name in MP. This hopefully fixes a crash on lesser OS's (eg Win98). Use ttd_strlcpy() to just copy over strings and properly terminate them because different implementations of snprintf() behave differently. Courtesy of TrueLight
Diffstat (limited to 'network.c')
-rw-r--r-- | network.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -92,11 +92,11 @@ NetworkClientState *NetworkFindClientStateFromIndex(uint16 client_index) // if the user did not send it yet, Client #<no> is used. void NetworkGetClientName(char *client_name, size_t size, const NetworkClientState *cs) { - NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs); - if (ci->client_name[0] == '\0') - snprintf(client_name, size, "Client #%d", cs->index); + const NetworkClientInfo *ci = DEREF_CLIENT_INFO(cs); + if (*ci->client_name == '\0') + snprintf(client_name, size, "Client #%4d", cs->index); else - snprintf(client_name, size, "%s", ci->client_name); + ttd_strlcpy(client_name, ci->client_name, size); } byte NetworkSpectatorCount(void) @@ -545,7 +545,7 @@ void NetworkCloseClient(NetworkClientState *cs) // We did not receive a leave message from this client... NetworkErrorCode errorno = NETWORK_ERROR_CONNECTION_LOST; char str[100]; - char client_name[NETWORK_NAME_LENGTH]; + char client_name[NETWORK_CLIENT_NAME_LENGTH]; NetworkClientState *new_cs; NetworkGetClientName(client_name, sizeof(client_name), cs); |