summaryrefslogtreecommitdiff
path: root/network_client.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-15 15:19:51 +0000
committertruelight <truelight@openttd.org>2004-12-15 15:19:51 +0000
commit29b844a408c3aaaf747f63b377bbfe15c597551f (patch)
tree89befd7f731a8422e3db185aa041d725963b7aad /network_client.c
parentc8ca2a860412b7fb85bb56e1fc0c7a93b0d0ec6f (diff)
downloadopenttd-29b844a408c3aaaf747f63b377bbfe15c597551f.tar.xz
(svn r1096) -Fix: [Network] PlayAs is now registered correctly
-Codewise: [Network] Cleaned some code, removed some comment, changed some wrong comment
Diffstat (limited to 'network_client.c')
-rw-r--r--network_client.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/network_client.c b/network_client.c
index 72342014b..ab87aae7d 100644
--- a/network_client.c
+++ b/network_client.c
@@ -65,7 +65,7 @@ DEF_CLIENT_SEND_COMMAND(PACKET_CLIENT_JOIN)
p = NetworkSend_Init(PACKET_CLIENT_JOIN);
NetworkSend_string(p, _openttd_revision);
NetworkSend_string(p, _network_player_name); // Player name
- NetworkSend_uint8(p, _network_playas); // Password
+ NetworkSend_uint8(p, _network_playas); // PlayAs
NetworkSend_uint8(p, NETLANG_ANY); // Language
NetworkSend_string(p, _network_unique_id);
NetworkSend_Packet(p, MY_CLIENT);
@@ -317,15 +317,19 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
{
NetworkClientInfo *ci;
uint16 index = NetworkRecv_uint16(p);
+ byte playas = NetworkRecv_uint8(p);
+ char name[NETWORK_NAME_LENGTH];
+ char unique_id[NETWORK_NAME_LENGTH];
- ci = NetworkFindClientInfoFromIndex(index);
- if (ci != NULL) {
- byte playas;
- char name[NETWORK_NAME_LENGTH];
+ NetworkRecv_string(p, name, sizeof(name));
+ NetworkRecv_string(p, unique_id, sizeof(unique_id));
- playas = NetworkRecv_uint8(p);
- NetworkRecv_string(p, name, sizeof(name));
+ /* Do we receive a change of data? Most likely we changed playas */
+ if (index == _network_own_client_index)
+ _network_playas = playas;
+ ci = NetworkFindClientInfoFromIndex(index);
+ if (ci != NULL) {
if (playas == ci->client_playas && strcmp(name, ci->client_name) != 0) {
// Client name changed, display the change
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, ci->client_name, name);
@@ -336,6 +340,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
ci->client_playas = playas;
ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name));
+
return NETWORK_RECV_STATUS_OKAY;
}
@@ -343,9 +348,11 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_CLIENT_INFO)
ci = NetworkFindClientInfoFromIndex(NETWORK_EMPTY_INDEX);
if (ci != NULL) {
ci->client_index = index;
- ci->client_playas = NetworkRecv_uint8(p);
- NetworkRecv_string(p, ci->client_name, sizeof(ci->client_name));
- NetworkRecv_string(p, ci->unique_id, sizeof(ci->unique_id));
+ ci->client_playas = playas;
+
+ ttd_strlcpy(ci->client_name, name, sizeof(ci->client_name));
+ ttd_strlcpy(ci->unique_id, unique_id, sizeof(ci->unique_id));
+
return NETWORK_RECV_STATUS_OKAY;
}