summaryrefslogtreecommitdiff
path: root/players.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-05-11 12:46:19 +0000
committerDarkvater <Darkvater@openttd.org>2005-05-11 12:46:19 +0000
commit7648e9290bba72adceee320366a2fdd0d42ce8c6 (patch)
treeeae5566ea27edecc49e426270a4ef77af6965b32 /players.c
parentb43331c931e2e8f8586080c9d8bee022bfe3aa5b (diff)
downloadopenttd-7648e9290bba72adceee320366a2fdd0d42ce8c6.tar.xz
(svn r2291) - Fix (regression): When a client joined it changed the server-player's name. Funny effect; but not desired. Thanks for pointing it out Tron. It needed a bit of hacking, but is not less of a hack than the one used before :)
Diffstat (limited to 'players.c')
-rw-r--r--players.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/players.c b/players.c
index eb5733494..7c1b4f92b 100644
--- a/players.c
+++ b/players.c
@@ -672,12 +672,22 @@ int32 CmdPlayerCtrl(int x, int y, uint32 flags, uint32 p1, uint32 p2)
NetworkUpdateClientInfo(ci->client_index);
if (ci->client_playas != 0 && ci->client_playas <= MAX_PLAYERS) {
+ PlayerID player_backup = _local_player;
_network_player_info[p->index].months_empty = 0;
+ /* XXX - When a client joins, we automatically set it's name to the player's
+ * name (for some reason). As it stands now only the server knows the client's
+ * name, so it needs to send out a "broadcast" to do this. To achieve this we send
+ * a network command. However, it uses _local_player to execute the command as.
+ * To prevent abuse (eg. only yourself can change your name/company), we 'cheat'
+ * by impersonation _local_player as the server. Not the best solution; but it
+ * works.
+ * TODO: Perhaps this could be improved by when the client is ready with joining
+ * to let it send itself the command, and not the server? For example in network_client.c:534? */
memcpy(_decode_parameters, ci->client_name, 32);
- /* XXX - What are the consequents of this? It is needed, but is it bad? */
- _docommand_recursive = 0;
- DoCommandP(0, ci->client_playas-1, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
+ _local_player = ci->client_playas - 1;
+ NetworkSend_Command(0, 0, 0, CMD_CHANGE_PRESIDENT_NAME, NULL);
+ _local_player = player_backup;
}
}
} else {