From b034ee878166f92848d414eda3afc94a77a6ad93 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Tue, 18 Jun 2019 00:25:56 +0200 Subject: [PATCH] Changed param source in strncpy In strncpy its the destination size that should be in the 3rd parameter. --- dll/net.proto | 6 +++++- dll/steam_friends.h | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/dll/net.proto b/dll/net.proto index a6d6414..9808822 100644 --- a/dll/net.proto +++ b/dll/net.proto @@ -176,10 +176,14 @@ message Auth_Ticket { message Friend_Messages { enum Types { LOBBY_INVITE = 0; + GAME_INVITE = 1; } Types type = 1; - uint64 lobby_id = 2; + oneof invite_data { + uint64 lobby_id = 2; + bytes connect_str = 3; + } } message Common_Message { diff --git a/dll/steam_friends.h b/dll/steam_friends.h index 039b5a1..105186d 100644 --- a/dll/steam_friends.h +++ b/dll/steam_friends.h @@ -545,6 +545,7 @@ void SetPlayedWith( CSteamID steamIDUserPlayedWith ) void ActivateGameOverlayInviteDialog( CSteamID steamIDLobby ) { PRINT_DEBUG("Steam_Friends::ActivateGameOverlayInviteDialog\n"); + // TODO: Here open the overlay } // gets the small (32x32) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set @@ -775,8 +776,14 @@ void RequestFriendRichPresence( CSteamID steamIDFriend ) bool InviteUserToGame( CSteamID steamIDFriend, const char *pchConnectString ) { PRINT_DEBUG("Steam_Friends::InviteUserToGame\n"); - //TODO - return true; + Common_Message msg; + Friend_Messages *friend_messages = new Friend_Messages(); + friend_messages->set_type(Friend_Messages::GAME_INVITE); + friend_messages->set_connect_str(pchConnectString); + msg.set_allocated_friend_messages(friend_messages); + msg.set_source_id(settings->get_local_steam_id().ConvertToUint64()); + msg.set_dest_id(steamIDFriend.ConvertToUint64()); + return network->sendTo(&msg, true); } @@ -1021,6 +1028,15 @@ void Callback(Common_Message *msg) data.m_steamIDFriend = CSteamID((uint64)msg->source_id()); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); } + + if (msg->friend_messages().type() == Friend_Messages::GAME_INVITE) { + PRINT_DEBUG("Steam_Friends Got Game Invite\n"); + std::string const& connect_str = msg->friend_messages().connect_str(); + GameRichPresenceJoinRequested_t data; + data.m_steamIDFriend = CSteamID((uint64)msg->source_id()); + strncpy(data.m_rgchConnect, connect_str.c_str(), k_cchMaxRichPresenceValueLength); + callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); + } } }