lobby dataupdate is called even when the value does not change.

This commit is contained in:
Mr_Goldberg 2020-02-14 15:02:54 -05:00
parent 7e136bba14
commit 767fee6840
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
1 changed files with 10 additions and 9 deletions

View File

@ -113,7 +113,7 @@ void send_lobby_data()
}
}
void trigger_lobby_dataupdate(CSteamID lobby, CSteamID member, bool success, double cb_timeout=0.0)
void trigger_lobby_dataupdate(CSteamID lobby, CSteamID member, bool success, double cb_timeout=0.0, bool send_changed_lobby=true)
{
PRINT_DEBUG("Lobby dataupdate %llu %llu\n", lobby.ConvertToUint64(), member.ConvertToUint64());
LobbyDataUpdate_t data;
@ -132,10 +132,12 @@ void trigger_lobby_dataupdate(CSteamID lobby, CSteamID member, bool success, dou
Lobby *l = get_lobby(lobby);
if (l && l->owner() == settings->get_local_steam_id().ConvertToUint64()) {
Common_Message msg = Common_Message();
msg.set_source_id(settings->get_local_steam_id().ConvertToUint64());
msg.set_allocated_lobby(new Lobby(*l));
network->sendToAllIndividuals(&msg, true);
if (send_changed_lobby) {
Common_Message msg = Common_Message();
msg.set_source_id(settings->get_local_steam_id().ConvertToUint64());
msg.set_allocated_lobby(new Lobby(*l));
network->sendToAllIndividuals(&msg, true);
}
}
}
@ -774,10 +776,9 @@ bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchVal
}
auto result = lobby->values().find(pchKey);
if (result == lobby->values().end() || result->second != std::string(pchValue)) {
(*lobby->mutable_values())[pchKey] = pchValue;
trigger_lobby_dataupdate(steamIDLobby, steamIDLobby, true);
}
bool changed = (result == lobby->values().end()) || (result->second != std::string(pchValue));
(*lobby->mutable_values())[pchKey] = pchValue;
trigger_lobby_dataupdate(steamIDLobby, steamIDLobby, true, 0.0, changed);
return true;
}