From 2a373bbf796f3e265459fd4481c2cbc16cc5d3c7 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Fri, 2 Aug 2019 23:01:24 +0200 Subject: [PATCH] Now I set the invite instead of adding it. You should send a lobby invite or a rich invite, but not both. --- dll/steam_friends.h | 4 ++-- overlay_experimental/steam_overlay.cpp | 8 ++++++-- overlay_experimental/steam_overlay.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dll/steam_friends.h b/dll/steam_friends.h index e6f6501..295851d 100644 --- a/dll/steam_friends.h +++ b/dll/steam_friends.h @@ -1037,7 +1037,7 @@ void Callback(Common_Message *msg) PRINT_DEBUG("Steam_Friends Got Lobby Invite\n"); //TODO: the user should accept the invite first but we auto accept it because there's no gui yet // Then we will handle it ! - overlay->AddLobbyInvite(*find_friend(msg->source_id()), msg->friend_messages().lobby_id()); + overlay->SetLobbyInvite(*find_friend(msg->source_id()), msg->friend_messages().lobby_id()); //GameLobbyJoinRequested_t data; //data.m_steamIDLobby = CSteamID((uint64)msg->friend_messages().lobby_id()); @@ -1049,7 +1049,7 @@ void Callback(Common_Message *msg) PRINT_DEBUG("Steam_Friends Got Game Invite\n"); //TODO: I'm pretty sure that the user should accept the invite before this is posted but we do like above // Then we will handle it ! - overlay->AddRichInvite(*find_friend(msg->source_id()), msg->friend_messages().connect_str().c_str()); + overlay->SetRichInvite(*find_friend(msg->source_id()), msg->friend_messages().connect_str().c_str()); //std::string const& connect_str = msg->friend_messages().connect_str(); //GameRichPresenceJoinRequested_t data = {}; diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index 1e12f75..3e46414 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -230,7 +230,7 @@ void Steam_Overlay::ShowOverlay(bool state) overlay_state_changed = true; } -void Steam_Overlay::AddLobbyInvite(Friend friendId, uint64 lobbyId) +void Steam_Overlay::SetLobbyInvite(Friend friendId, uint64 lobbyId) { std::lock_guard lock(global_mutex); auto i = friends.find(friendId); @@ -239,10 +239,12 @@ void Steam_Overlay::AddLobbyInvite(Friend friendId, uint64 lobbyId) auto& frd = i->second; frd.lobbyId = lobbyId; frd.window_state |= window_state_lobby_invite; + // Make sure don't have rich presence invite and a lobby invite (it should not happen but who knows) + frd.window_state &= ~window_state_rich_invite; } } -void Steam_Overlay::AddRichInvite(Friend friendId, const char* connect_str) +void Steam_Overlay::SetRichInvite(Friend friendId, const char* connect_str) { std::lock_guard lock(global_mutex); auto i = friends.find(friendId); @@ -251,6 +253,8 @@ void Steam_Overlay::AddRichInvite(Friend friendId, const char* connect_str) auto& frd = i->second; strncpy(frd.connect, connect_str, k_cchMaxRichPresenceValueLength - 1); frd.window_state |= window_state_rich_invite; + // Make sure don't have rich presence invite and a lobby invite (it should not happen but who knows) + frd.window_state &= ~window_state_lobby_invite; } } diff --git a/overlay_experimental/steam_overlay.h b/overlay_experimental/steam_overlay.h index 15efdfc..fc879ef 100644 --- a/overlay_experimental/steam_overlay.h +++ b/overlay_experimental/steam_overlay.h @@ -102,8 +102,8 @@ public: void ShowOverlay(bool state); - void AddLobbyInvite(Friend friendId, uint64 lobbyId); - void AddRichInvite(Friend friendId, const char* connect_str); + void SetLobbyInvite(Friend friendId, uint64 lobbyId); + void SetRichInvite(Friend friendId, const char* connect_str); void FriendConnect(Friend _friend); void FriendDisconnect(Friend _friend);