* Send the server our name as callback from the setting. * @param newname The new client name. */
| 1290 | * @param newname The new client name. |
| 1291 | */ |
| 1292 | void NetworkUpdateClientName(const std::string &client_name) |
| 1293 | { |
| 1294 | NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(_network_own_client_id); |
| 1295 | if (ci == nullptr) return; |
| 1296 | |
| 1297 | /* Don't change the name if it is the same as the old name */ |
| 1298 | if (client_name == ci->client_name) return; |
| 1299 | |
| 1300 | if (!_network_server) { |
| 1301 | MyClient::SendSetName(client_name); |
| 1302 | } else { |
| 1303 | /* Copy to a temporary buffer so no #n gets added after our name in the settings when there are duplicate names. */ |
| 1304 | std::string temporary_name = client_name; |
| 1305 | if (NetworkMakeClientNameUnique(temporary_name)) { |
| 1306 | NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, temporary_name); |
| 1307 | ci->client_name = std::move(temporary_name); |
| 1308 | NetworkUpdateClientInfo(CLIENT_ID_SERVER); |
| 1309 | } |
| 1310 | } |
| 1311 | } |
| 1312 | |
| 1313 | /** |
| 1314 | * Send a chat message. |
nothing calls this directly
no test coverage detected