Initial implementation of ISteamFriends001 to ISteamFriends002

This commit is contained in:
universal963 2024-10-26 17:49:27 +08:00
parent 63552d7584
commit 132b7d8989
6 changed files with 351 additions and 1 deletions

View File

@ -28,6 +28,8 @@ struct Avatar_Numbers {
}; };
class Steam_Friends : class Steam_Friends :
public ISteamFriends001,
public ISteamFriends002,
public ISteamFriends003, public ISteamFriends003,
public ISteamFriends004, public ISteamFriends004,
public ISteamFriends005, public ISteamFriends005,
@ -60,6 +62,8 @@ public ISteamFriends
CSteamID lobby_id{}; CSteamID lobby_id{};
std::chrono::high_resolution_clock::time_point last_sent_friends{}; std::chrono::high_resolution_clock::time_point last_sent_friends{};
std::map<std::string, std::string> reg{};
std::string reg_nullptr{};
Friend *find_friend(CSteamID id); Friend *find_friend(CSteamID id);
@ -107,6 +111,11 @@ public:
// gets the status of the current user // gets the status of the current user
EPersonaState GetPersonaState(); EPersonaState GetPersonaState();
void SetPersonaState( EPersonaState ePersonaState );
bool AddFriend( CSteamID steamIDFriend );
bool RemoveFriend( CSteamID steamIDFriend );
bool HasFriend( CSteamID steamIDFriend );
// friend iteration // friend iteration
// takes a set of k_EFriendFlags, and returns the number of users the client knows about who meet that criteria // takes a set of k_EFriendFlags, and returns the number of users the client knows about who meet that criteria
@ -135,6 +144,8 @@ public:
// this will only be known by the local user if steamIDFriend is in their friends list; on the same game server; in a chat room or lobby; or in a small group with the local user // this will only be known by the local user if steamIDFriend is in their friends list; on the same game server; in a chat room or lobby; or in a small group with the local user
EPersonaState GetFriendPersonaState( CSteamID steamIDFriend ); EPersonaState GetFriendPersonaState( CSteamID steamIDFriend );
bool Deprecated_GetFriendGamePlayed( CSteamID steamIDFriend, int32 *pnGameID, uint32 *punGameIP, uint16 *pusGamePort )
// returns the name another user - guaranteed to not be NULL. // returns the name another user - guaranteed to not be NULL.
// same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user // same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user
@ -142,6 +153,24 @@ public:
// //
const char *GetFriendPersonaName( CSteamID steamIDFriend ); const char *GetFriendPersonaName( CSteamID steamIDFriend );
int32 AddFriendByName( const char *pchEmailOrAccountName );
int GetFriendCount();
CSteamID GetFriendByIndex( int iFriend );
void SendMsgToFriend( CSteamID steamIDFriend, EChatEntryType eChatEntryType, const char *pchMsgBody );
void SetFriendRegValue( CSteamID steamIDFriend, const char *pchKey, const char *pchValue );
const char *GetFriendRegValue( CSteamID steamIDFriend, const char *pchKey );
const char *GetFriendPersonaNameHistory( CSteamID steamIDFriend, int iPersonaName );
int GetChatMessage( CSteamID steamIDFriend, int iChatID, void *pvData, int cubData, EChatEntryType *peChatEntryType );
bool SendMsgToFriend( CSteamID steamIDFriend, EChatEntryType eChatEntryType, const void *pvMsgBody, int cubMsgBody );
int GetChatIDOfChatHistoryStart( CSteamID steamIDFriend );
void SetChatHistoryStart( CSteamID steamIDFriend, int iChatID );
void ClearChatHistory( CSteamID steamIDFriend );
bool InviteFriendByEmail( const char *pchEmailAccount );
int GetBlockedFriendCount();
bool GetFriendGamePlayed( CSteamID steamIDFriend, uint64 *pulGameID, uint32 *punGameIP, uint16 *pusGamePort );
bool GetFriendGamePlayed2( CSteamID steamIDFriend, uint64 *pulGameID, uint32 *punGameIP, uint16 *pusGamePort, uint16 *pusQueryPort );
// returns true if the friend is actually in a game, and fills in pFriendGameInfo with an extra details // returns true if the friend is actually in a game, and fills in pFriendGameInfo with an extra details
bool GetFriendGamePlayed( CSteamID steamIDFriend, STEAM_OUT_STRUCT() FriendGameInfo_t *pFriendGameInfo ); bool GetFriendGamePlayed( CSteamID steamIDFriend, STEAM_OUT_STRUCT() FriendGameInfo_t *pFriendGameInfo );
@ -191,6 +220,9 @@ public:
const char *GetClanName( CSteamID steamIDClan ); const char *GetClanName( CSteamID steamIDClan );
bool InviteFriendToClan( CSteamID steamIDFriend, CSteamID steamIDClan );
bool AcknowledgeInviteToClan( CSteamID steamIDClan, bool bAcceptOrDenyClanInvite );
const char *GetClanTag( CSteamID steamIDClan ); const char *GetClanTag( CSteamID steamIDClan );
// returns the most recent information we have about what's happening in a clan // returns the most recent information we have about what's happening in a clan

View File

@ -160,7 +160,11 @@ ISteamFriends *Steam_Client::GetISteamFriends( HSteamUser hSteamUser, HSteamPipe
PRINT_DEBUG("%s", pchVersion); PRINT_DEBUG("%s", pchVersion);
if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL; if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL;
if (strcmp(pchVersion, "SteamFriends003") == 0) { if (strcmp(pchVersion, "SteamFriends001") == 0) {
return reinterpret_cast<ISteamFriends *>(static_cast<ISteamFriends001 *>(steam_friends)); // sdk 0.99u
} else if (strcmp(pchVersion, "SteamFriends002") == 0) {
return reinterpret_cast<ISteamFriends *>(static_cast<ISteamFriends002 *>(steam_friends)); // sdk 0.99y
} else if (strcmp(pchVersion, "SteamFriends003") == 0) {
return reinterpret_cast<ISteamFriends *>(static_cast<ISteamFriends003 *>(steam_friends)); return reinterpret_cast<ISteamFriends *>(static_cast<ISteamFriends003 *>(steam_friends));
} else if (strcmp(pchVersion, "SteamFriends004") == 0) { } else if (strcmp(pchVersion, "SteamFriends004") == 0) {
return reinterpret_cast<ISteamFriends *>(static_cast<ISteamFriends004 *>(steam_friends)); return reinterpret_cast<ISteamFriends *>(static_cast<ISteamFriends004 *>(steam_friends));

View File

@ -237,6 +237,35 @@ EPersonaState Steam_Friends::GetPersonaState()
return k_EPersonaStateOnline; return k_EPersonaStateOnline;
} }
void Steam_Friends::SetPersonaState(EPersonaState ePersonaState)
{
PRINT_DEBUG_TODO();
}
bool Steam_Friends::AddFriend(CSteamID steamIDFriend)
{
PRINT_DEBUG_TODO();
if (steamIDFriend == k_steamIDNil)
return false;
// TODO
return true;
}
bool Steam_Friends::RemoveFriend(CSteamID steamIDFriend)
{
PRINT_DEBUG_TODO();
if (steamIDFriend == k_steamIDNil)
return false;
// TODO
return true;
}
bool Steam_Friends::HasFriend(CSteamID steamIDFriend)
{
PRINT_DEBUG("sdk 0.99u");
return HasFriend(steamIDFriend, (int)k_EFriendFlagImmediate);
}
// friend iteration // friend iteration
// takes a set of k_EFriendFlags, and returns the number of users the client knows about who meet that criteria // takes a set of k_EFriendFlags, and returns the number of users the client knows about who meet that criteria
@ -326,6 +355,16 @@ EPersonaState Steam_Friends::GetFriendPersonaState( CSteamID steamIDFriend )
return state; return state;
} }
bool Steam_Friends::Deprecated_GetFriendGamePlayed(CSteamID steamIDFriend, int32 *pnGameID, uint32 *punGameIP, uint16 *pusGamePort)
{
PRINT_DEBUG_ENTRY();
if (punGameIP)
*punGameIP = 0;
if (pusGamePort)
*pusGamePort = 0;
return true;
}
// returns the name another user - guaranteed to not be NULL. // returns the name another user - guaranteed to not be NULL.
// same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user // same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user
@ -347,6 +386,122 @@ const char* Steam_Friends::GetFriendPersonaName( CSteamID steamIDFriend )
return name; return name;
} }
int32 Steam_Friends::AddFriendByName(const char *pchEmailOrAccountName)
{
PRINT_DEBUG_TODO();
return 0;
}
int Steam_Friends::GetFriendCount()
{
PRINT_DEBUG("sdk 0.99u");
return GetFriendCount((int)k_EFriendFlagImmediate);
}
CSteamID Steam_Friends::GetFriendByIndex(int iFriend)
{
PRINT_DEBUG("sdk 0.99u");
return GetFriendByIndex(iFriend, (int)k_EFriendFlagImmediate);
}
void Steam_Friends::SendMsgToFriend(CSteamID steamIDFriend, EChatEntryType eChatEntryType, const char *pchMsgBody)
{
PRINT_DEBUG_TODO();
}
void Steam_Friends::SetFriendRegValue(CSteamID steamIDFriend, const char *pchKey, const char *pchValue)
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (!pchValue)
return; // real steam crashes though
if (!pchKey || !pchKey[0]) // tested on real steam
{
reg.clear();
reg_nullptr = std::string(pchValue);
}
else
{
reg[std::string(pchKey)] = std::string(pchValue);
// TODO: save it to disk, because real steam can get the string when app restarts
}
}
const char *Steam_Friends::GetFriendRegValue(CSteamID steamIDFriend, const char *pchKey)
{
PRINT_DEBUG_TODO();
std::lock_guard<std::recursive_mutex> lock(global_mutex);
// TODO: load data from disk, because real steam can get the string when app restarts
if (!pchKey || !pchKey[0])
{
return reg_nullptr.c_str();
}
else
{
auto it = reg.find(std::string(pchKey));
if (it == reg.end())
return "";
return it->second.c_str();
}
}
int Steam_Friends::GetChatMessage(CSteamID steamIDFriend, int iChatID, void *pvData, int cubData, EChatEntryType *peChatEntryType)
{
PRINT_DEBUG_TODO();
if (peChatEntryType)
*peChatEntryType = k_EChatEntryTypeInvalid;
return 0;
}
bool Steam_Friends::SendMsgToFriend(CSteamID steamIDFriend, EChatEntryType eChatEntryType, const void *pvMsgBody, int cubMsgBody)
{
PRINT_DEBUG_TODO();
return true;
}
int Steam_Friends::GetChatIDOfChatHistoryStart(CSteamID steamIDFriend)
{
PRINT_DEBUG_TODO();
return 0;
}
void Steam_Friends::SetChatHistoryStart(CSteamID steamIDFriend, int iChatID)
{
PRINT_DEBUG_TODO();
}
void Steam_Friends::ClearChatHistory(CSteamID steamIDFriend)
{
PRINT_DEBUG_TODO();
}
bool Steam_Friends::InviteFriendByEmail(const char *pchEmailAccount)
{
PRINT_DEBUG_TODO();
return false;
}
int Steam_Friends::GetBlockedFriendCount()
{
PRINT_DEBUG_ENTRY();
return GetFriendCount((int)k_EFriendFlagBlocked);
}
bool Steam_Friends::GetFriendGamePlayed(CSteamID steamIDFriend, uint64 *pulGameID, uint32 *punGameIP, uint16 *pusGamePort)
{
PRINT_DEBUG("sdk 0.99u");
return GetFriendGamePlayed(steamIDFriend, pulGameID, punGameIP, pusGamePort, NULL);
}
bool Steam_Friends::GetFriendGamePlayed2(CSteamID steamIDFriend, uint64 *pulGameID, uint32 *punGameIP, uint16 *pusGamePort, uint16 *pusQueryPort)
{
PRINT_DEBUG_ENTRY();
return GetFriendGamePlayed(steamIDFriend, pulGameID, punGameIP, pusGamePort, pusQueryPort);
}
// returns true if the friend is actually in a game, and fills in pFriendGameInfo with an extra details // returns true if the friend is actually in a game, and fills in pFriendGameInfo with an extra details
bool Steam_Friends::GetFriendGamePlayed( CSteamID steamIDFriend, STEAM_OUT_STRUCT() FriendGameInfo_t *pFriendGameInfo ) bool Steam_Friends::GetFriendGamePlayed( CSteamID steamIDFriend, STEAM_OUT_STRUCT() FriendGameInfo_t *pFriendGameInfo )
@ -530,6 +685,18 @@ const char* Steam_Friends::GetClanName( CSteamID steamIDClan )
return ""; return "";
} }
bool Steam_Friends::InviteFriendToClan(CSteamID steamIDFriend, CSteamID steamIDClan)
{
PRINT_DEBUG_TODO();
return false;
}
bool Steam_Friends::AcknowledgeInviteToClan(CSteamID steamIDClan, bool bAcceptOrDenyClanInvite)
{
PRINT_DEBUG_TODO();
return false;
}
const char* Steam_Friends::GetClanTag( CSteamID steamIDClan ) const char* Steam_Friends::GetClanTag( CSteamID steamIDClan )
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG_ENTRY();

View File

@ -0,0 +1,52 @@
#ifndef ISTEAMFRIENDS001_H
#define ISTEAMFRIENDS001_H
#ifdef STEAM_WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// Purpose: interface to accessing information about individual users,
// that can be a friend, in a group, on a game server or in a lobby with the local user
//-----------------------------------------------------------------------------
class ISteamFriends001
{
public:
// returns the local players name - guaranteed to not be NULL.
// this is the same name as on the users community profile page
// this is stored in UTF-8 format
// like all the other interface functions that return a char *, it's important that this pointer is not saved
// off; it will eventually be free'd or re-allocated
virtual const char *GetPersonaName() = 0;
virtual void SetPersonaName_old( const char *pchPersonaName ) = 0;
virtual EPersonaState GetPersonaState() = 0;
virtual void SetPersonaState( EPersonaState ePersonaState ) = 0;
virtual bool AddFriend( CSteamID steamIDFriend ) = 0;
virtual bool RemoveFriend( CSteamID steamIDFriend ) = 0;
virtual bool HasFriend( CSteamID steamIDFriend ) = 0;
virtual EFriendRelationship GetFriendRelationship( CSteamID steamIDFriend ) = 0;
virtual EPersonaState GetFriendPersonaState( CSteamID steamIDFriend ) = 0;
virtual bool Deprecated_GetFriendGamePlayed( CSteamID steamIDFriend, int32 *pnGameID, uint32 *punGameIP, uint16 *pusGamePort ) = 0;
virtual const char *GetFriendPersonaName( CSteamID steamIDFriend ) = 0;
virtual int32 AddFriendByName( const char *pchEmailOrAccountName ) = 0;
virtual int GetFriendCount() = 0;
virtual CSteamID GetFriendByIndex( int iFriend ) = 0;
virtual void SendMsgToFriend( CSteamID steamIDFriend, EChatEntryType eChatEntryType, const char *pchMsgBody ) = 0;
virtual void SetFriendRegValue( CSteamID steamIDFriend, const char *pchKey, const char *pchValue ) = 0;
virtual const char *GetFriendRegValue( CSteamID steamIDFriend, const char *pchKey ) = 0;
virtual const char *GetFriendPersonaNameHistory( CSteamID steamIDFriend, int iPersonaName ) = 0;
virtual int GetChatMessage( CSteamID steamIDFriend, int iChatID, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0;
virtual bool SendMsgToFriend( CSteamID steamIDFriend, EChatEntryType eChatEntryType, const void *pvMsgBody, int cubMsgBody ) = 0;
virtual int GetChatIDOfChatHistoryStart( CSteamID steamIDFriend ) = 0;
virtual void SetChatHistoryStart( CSteamID steamIDFriend, int iChatID ) = 0;
virtual void ClearChatHistory( CSteamID steamIDFriend ) = 0;
virtual bool InviteFriendByEmail( const char *pchEmailAccount ) = 0;
virtual int GetBlockedFriendCount() = 0;
virtual bool GetFriendGamePlayed( CSteamID steamIDFriend, uint64 *pulGameID, uint32 *punGameIP, uint16 *pusGamePort ) = 0;
virtual bool GetFriendGamePlayed2( CSteamID steamIDFriend, uint64 *pulGameID, uint32 *punGameIP, uint16 *pusGamePort, uint16 *pusQueryPort ) = 0;
};
#endif // ISTEAMFRIENDS001_H

View File

@ -0,0 +1,93 @@
#ifndef ISTEAMFRIENDS002_H
#define ISTEAMFRIENDS002_H
#ifdef STEAM_WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// Purpose: interface to accessing information about individual users,
// that can be a friend, in a group, on a game server or in a lobby with the local user
//-----------------------------------------------------------------------------
class ISteamFriends002
{
public:
// returns the local players name - guaranteed to not be NULL.
// this is the same name as on the users community profile page
// this is stored in UTF-8 format
// like all the other interface functions that return a char *, it's important that this pointer is not saved
// off; it will eventually be free'd or re-allocated
virtual const char *GetPersonaName() = 0;
// sets the player name, stores it on the server and publishes the changes to all friends who are online
virtual void SetPersonaName_old( const char *pchPersonaName ) = 0;
// gets the status of the current user
virtual EPersonaState GetPersonaState() = 0;
virtual void SetPersonaState( EPersonaState ePersonaState ) = 0;
// friend iteration
// takes a set of k_EFriendFlags, and returns the number of users the client knows about who meet that criteria
// then GetFriendByIndex() can then be used to return the id's of each of those users
virtual int GetFriendCount( int iFriendFlags ) = 0;
// returns the steamID of a user
// iFriend is a index of range [0, GetFriendCount())
// iFriendsFlags must be the same value as used in GetFriendCount()
// the returned CSteamID can then be used by all the functions below to access details about the user
virtual CSteamID GetFriendByIndex( int iFriend, int iFriendFlags ) = 0;
// returns a relationship to a user
virtual EFriendRelationship GetFriendRelationship( CSteamID steamIDFriend ) = 0;
// returns the current status of the specified user
// this will only be known by the local user if steamIDFriend is in their friends list; on the same game server; in a chat room or lobby; or in a small group with the local user
virtual EPersonaState GetFriendPersonaState( CSteamID steamIDFriend ) = 0;
// returns the name another user - guaranteed to not be NULL.
// same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user
// note that on first joining a lobby, chat room or game server the local user will not known the name of the other users automatically; that information will arrive asyncronously
//
virtual const char *GetFriendPersonaName( CSteamID steamIDFriend ) = 0;
virtual void SetFriendRegValue( CSteamID steamIDFriend, const char *pchKey, const char *pchValue ) = 0;
virtual const char *GetFriendRegValue( CSteamID steamIDFriend, const char *pchKey ) = 0;
// returns true if the friend is actually in a game
virtual bool GetFriendGamePlayed( CSteamID steamIDFriend, uint64 *pulGameID, uint32 *punGameIP, uint16 *pusGamePort, uint16 *pusQueryPort ) = 0;
// accesses old friends names - returns an empty string when their are no more items in the history
virtual const char *GetFriendPersonaNameHistory( CSteamID steamIDFriend, int iPersonaName ) = 0;
// returns true if the specified user meets any of the criteria specified in iFriendFlags
// iFriendFlags can be the union (binary or, |) of one or more k_EFriendFlags values
virtual bool AddFriend( CSteamID steamIDFriend ) = 0;
virtual bool RemoveFriend( CSteamID steamIDFriend ) = 0;
virtual bool HasFriend( CSteamID steamIDFriend, int iFriendFlags ) = 0;
virtual int32 AddFriendByName( const char *pchEmailOrAccountName ) = 0;
virtual bool InviteFriendByEmail( const char *pchEmailAccount ) = 0;
virtual int GetChatMessage( CSteamID steamIDFriend, int iChatID, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0;
virtual bool SendMsgToFriend( CSteamID steamIDFriend, EChatEntryType eChatEntryType, const void *pvMsgBody, int cubMsgBody ) = 0;
virtual int GetChatIDOfChatHistoryStart( CSteamID steamIDFriend ) = 0;
virtual void SetChatHistoryStart( CSteamID steamIDFriend, int iChatID ) = 0;
virtual void ClearChatHistory( CSteamID steamIDFriend ) = 0;
// clan (group) iteration and access functions
virtual int GetClanCount() = 0;
virtual CSteamID GetClanByIndex( int iClan ) = 0;
virtual const char *GetClanName( CSteamID steamIDClan ) = 0;
virtual bool InviteFriendToClan( CSteamID steamIDFriend, CSteamID steamIDClan ) = 0;
virtual bool AcknowledgeInviteToClan( CSteamID steamIDClan, bool bAcceptOrDenyClanInvite ) = 0;
// iterators for getting users in a chat room, lobby, game server or clan
// note that large clans that cannot be iterated by the local user
// steamIDSource can be the steamID of a group, game server, lobby or chat room
virtual int GetFriendCountFromSource( CSteamID steamIDSource ) = 0;
virtual CSteamID GetFriendFromSourceByIndex( CSteamID steamIDSource, int iFriend ) = 0;
};
#endif // ISTEAMFRIENDS002_H

View File

@ -58,6 +58,8 @@
#include "isteamuser021.h" #include "isteamuser021.h"
#include "isteamuser022.h" #include "isteamuser022.h"
#include "isteamfriends.h" #include "isteamfriends.h"
#include "isteamfriends001.h"
#include "isteamfriends002.h"
#include "isteamfriends003.h" #include "isteamfriends003.h"
#include "isteamfriends004.h" #include "isteamfriends004.h"
#include "isteamfriends005.h" #include "isteamfriends005.h"