More accurate SetLobbyData.

merge-requests/50/head
Mr_Goldberg 2022-09-06 13:30:20 -04:00
parent 7e1824290a
commit 802d8bcc8f
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
1 changed files with 10 additions and 7 deletions

View File

@ -809,17 +809,20 @@ bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchVal
std::lock_guard<std::recursive_mutex> lock(global_mutex);
Lobby *lobby = get_lobby(steamIDLobby);
if (!lobby || lobby->owner() != settings->get_local_steam_id().ConvertToUint64() || lobby->deleted()) {
if (!lobby || lobby->deleted()) {
return false;
}
auto result = caseinsensitive_find(lobby->values(), pchKey);
bool changed = true;
if (result == lobby->values().end()) {
(*lobby->mutable_values())[pchKey] = pchValue;
} else {
if (result->second == std::string(pchValue)) changed = false;
(*lobby->mutable_values())[result->first] = pchValue;
//callback is always triggered when setlobbydata is called from non owner however no data is actually changed.
if (lobby->owner() == settings->get_local_steam_id().ConvertToUint64()) {
auto result = caseinsensitive_find(lobby->values(), pchKey);
if (result == lobby->values().end()) {
(*lobby->mutable_values())[pchKey] = pchValue;
} else {
if (result->second == std::string(pchValue)) changed = false;
(*lobby->mutable_values())[result->first] = pchValue;
}
}
if (changed)