summaryrefslogtreecommitdiff
path: root/console_cmds.c
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2005-02-22 12:27:33 +0000
committerDarkvater <Darkvater@openttd.org>2005-02-22 12:27:33 +0000
commit76b016dd58ec4104ff1e6f65582d80297f431b42 (patch)
treed560bb40bacc591b62c55d3a826de3ea83647436 /console_cmds.c
parent1f683aa13d619346686a1a607191b81d4a6940e9 (diff)
downloadopenttd-76b016dd58ec4104ff1e6f65582d80297f431b42.tar.xz
(svn r1897) - Fix: [ 1120424 ] Set name overwrites same name. Renamings because your name is in use are virtual though so if name "b" is in use your name will become "b #1", renaming yourself again to "b" will become "b #2", and will toggle between these two.
Diffstat (limited to 'console_cmds.c')
-rw-r--r--console_cmds.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/console_cmds.c b/console_cmds.c
index e7850924d..6fd97804e 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -991,17 +991,20 @@ DEF_CONSOLE_CMD(ConSet) {
ci = NetworkFindClientInfoFromIndex(_network_own_client_index);
if (argc == 3 && ci != NULL) {
- if (!_network_server)
- SEND_COMMAND(PACKET_CLIENT_SET_NAME)(argv[2]);
- else {
- if (NetworkFindName(argv[2])) {
- NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, false, ci->client_name, argv[2]);
- ttd_strlcpy(ci->client_name, argv[2], sizeof(ci->client_name));
- NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
+ // Don't change the name if it is the same as the old name
+ if (strncmp(ci->client_name, argv[2], sizeof(_network_player_name)) != 0) {
+ if (!_network_server) {
+ SEND_COMMAND(PACKET_CLIENT_SET_NAME)(argv[2]);
+ } else {
+ if (NetworkFindName(argv[2])) {
+ NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, 1, false, ci->client_name, argv[2]);
+ ttd_strlcpy(ci->client_name, argv[2], sizeof(ci->client_name));
+ NetworkUpdateClientInfo(NETWORK_SERVER_INDEX);
+ }
}
+ /* Also keep track of the new name on the client itself */
+ ttd_strlcpy(_network_player_name, argv[2], sizeof(_network_player_name));
}
- /* Also keep track of the new name on the client itself */
- ttd_strlcpy(_network_player_name, argv[2], sizeof(_network_player_name));
} else {
IConsolePrint(_iconsole_color_default, "With 'set name' you can change your network-player name.");
IConsolePrint(_iconsole_color_warning, "Usage: set name \"<name>\".");