summaryrefslogtreecommitdiff
path: root/players.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-05-15 18:50:55 +0000
committertron <tron@openttd.org>2005-05-15 18:50:55 +0000
commitfea596567944fba8d9d4ead62d948db14690fdf1 (patch)
treead6dc27f46725e511e93e061f51683311027ec65 /players.c
parent6cd410afbb3cedff9f6d86fc30dbd4e67817ebc9 (diff)
downloadopenttd-fea596567944fba8d9d4ead62d948db14690fdf1.tar.xz
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
Diffstat (limited to 'players.c')
-rw-r--r--players.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/players.c b/players.c
index e196fbc13..01770c0b5 100644
--- a/players.c
+++ b/players.c
@@ -691,16 +691,18 @@ int32 CmdPlayerCtrl(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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 - When a client joins, we automatically set its 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? */
+ _cmd_text = ci->client_name;
_local_player = ci->client_playas - 1;
NetworkSend_Command(0, 0, 0, CMD_CHANGE_PRESIDENT_NAME, NULL);
_local_player = player_backup;