* Change the client name of the given client * @param client_id the client to change the name of * @param new_name the new name for the client * @return true iff the name was changed */
| 1645 | * @return true iff the name was changed |
| 1646 | */ |
| 1647 | bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_name) |
| 1648 | { |
| 1649 | /* Check if the name's already in use */ |
| 1650 | for (NetworkClientInfo *ci : NetworkClientInfo::Iterate()) { |
| 1651 | if (ci->client_name == new_name) return false; |
| 1652 | } |
| 1653 | |
| 1654 | NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id); |
| 1655 | if (ci == nullptr) return false; |
| 1656 | |
| 1657 | NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, true, ci->client_name, new_name); |
| 1658 | |
| 1659 | ci->client_name = new_name; |
| 1660 | |
| 1661 | NetworkUpdateClientInfo(client_id); |
| 1662 | return true; |
| 1663 | } |
| 1664 | |
| 1665 | /** |
| 1666 | * Handle the command-queue of a socket. |
no test coverage detected