Index: src/console_cmds.cpp =================================================================== --- src/console_cmds.cpp (revision 15195) +++ src/console_cmds.cpp (working copy) @@ -555,6 +555,38 @@ return true; } +DEF_CONSOLE_CMD(ConClientNickChange) +{ + NetworkClientInfo *ci; + ClientID client_id; + + if (argc != 3) { + IConsoleHelp("Change the nickname of a connected client. Usage: 'client_name '"); + IConsoleHelp("For client-id's, see the command 'clients'"); + return true; + } + + client_id = (ClientID)atoi(argv[1]); + + if (client_id == CLIENT_ID_SERVER) { + IConsoleError("Please use the command 'name' to change your own name!"); + return true; + } + + ci = NetworkFindClientInfoFromClientID(client_id); + + if (ci == NULL) { + IConsoleError("Client not found"); + return true; + } + + if (!NetworkServerChangeClientName(client_id, argv[2])) { + IConsoleError("Cannot use new name"); + } + + return true; +} + DEF_CONSOLE_CMD(ConKick) { NetworkClientInfo *ci; @@ -1690,6 +1722,8 @@ IConsoleCmdRegister("reset_company", ConResetCompany); IConsoleCmdHookAdd("reset_company", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); IConsoleAliasRegister("clean_company", "reset_company %A"); + IConsoleCmdRegister("client_name", ConClientNickChange); + IConsoleCmdHookAdd("client_name", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); IConsoleCmdRegister("kick", ConKick); IConsoleCmdHookAdd("kick", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); IConsoleCmdRegister("ban", ConBan); Index: src/network/network_func.h =================================================================== --- src/network/network_func.h (revision 15195) +++ src/network/network_func.h (working copy) @@ -50,6 +50,7 @@ void NetworkServerChangeOwner(Owner current_owner, Owner new_owner); void NetworkServerShowStatusToConsole(); bool NetworkServerStart(); +bool NetworkServerChangeClientName(ClientID client_id, char new_name[NETWORK_CLIENT_NAME_LENGTH]); NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index); NetworkClientInfo *NetworkFindClientInfoFromClientID(ClientID client_id); Index: src/network/network_server.cpp =================================================================== --- src/network/network_server.cpp (revision 15195) +++ src/network/network_server.cpp (working copy) @@ -1442,6 +1442,22 @@ return found_name; } +bool NetworkServerChangeClientName(ClientID client_id, char new_name[NETWORK_CLIENT_NAME_LENGTH]) +{ + NetworkClientInfo *ci = NetworkFindClientInfoFromClientID(client_id); + + if (!NetworkFindName(new_name)) { + return false; + } + + NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, true, ci->client_name, new_name); + + strecpy(ci->client_name, new_name, lastof(ci->client_name)); + + NetworkUpdateClientInfo(client_id); + return true; +} + // Reads a packet from the stream bool NetworkServer_ReadPackets(NetworkClientSocket *cs) {