Codechange: Prefer string equality instead of comparison. (#14727)

This commit is contained in:
Peter Nelson
2025-10-24 20:30:03 +01:00
committed by dP
parent c9af1c1c7a
commit d284e02a87
15 changed files with 37 additions and 44 deletions
+12 -12
View File
@@ -563,7 +563,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CLIENT_INFO(Pac
ci = NetworkClientInfo::GetByClientID(client_id);
if (ci != nullptr) {
if (playas == ci->client_playas && name.compare(ci->client_name) != 0) {
if (playas == ci->client_playas && name != ci->client_name) {
/* Client name changed, display the change */
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, name);
} else if (playas != ci->client_playas) {
@@ -1346,17 +1346,17 @@ void NetworkUpdateClientName(const std::string &client_name)
if (ci == nullptr) return;
/* Don't change the name if it is the same as the old name */
if (client_name.compare(ci->client_name) != 0) {
if (!_network_server) {
MyClient::SendSetName(client_name);
} else {
/* Copy to a temporary buffer so no #n gets added after our name in the settings when there are duplicate names. */
std::string temporary_name = client_name;
if (NetworkMakeClientNameUnique(temporary_name)) {
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, temporary_name);
ci->client_name = std::move(temporary_name);
NetworkUpdateClientInfo(CLIENT_ID_SERVER);
}
if (client_name == ci->client_name) return;
if (!_network_server) {
MyClient::SendSetName(client_name);
} else {
/* Copy to a temporary buffer so no #n gets added after our name in the settings when there are duplicate names. */
std::string temporary_name = client_name;
if (NetworkMakeClientNameUnique(temporary_name)) {
NetworkTextMessage(NETWORK_ACTION_NAME_CHANGE, CC_DEFAULT, false, ci->client_name, temporary_name);
ci->client_name = std::move(temporary_name);
NetworkUpdateClientInfo(CLIENT_ID_SERVER);
}
}
}