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

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