mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-24 09:24:15 +08:00
* special function for the overlay Steam_Friends::get_friend_rich_presence_silent
to avoid spamming the debug log
* refactor private method name
This commit is contained in:
parent
f660b29100
commit
6fbc37630b
@ -67,7 +67,7 @@ public ISteamFriends
|
||||
|
||||
void rich_presence_updated(CSteamID id, AppId_t appid);
|
||||
|
||||
bool isAppIdCompatible(Friend *f);
|
||||
bool is_appid_compatible(Friend *f);
|
||||
|
||||
struct Avatar_Numbers add_friend_avatars(CSteamID id);
|
||||
|
||||
@ -315,6 +315,9 @@ public:
|
||||
|
||||
void ClearRichPresence();
|
||||
|
||||
// the overlay will keep calling GetFriendRichPresence() and spam the debug log, hence this function
|
||||
const char *get_friend_rich_presence_silent( CSteamID steamIDFriend, const char *pchKey );
|
||||
|
||||
const char *GetFriendRichPresence( CSteamID steamIDFriend, const char *pchKey );
|
||||
|
||||
int GetFriendRichPresenceKeyCount( CSteamID steamIDFriend );
|
||||
|
@ -45,7 +45,7 @@ void Steam_Friends::rich_presence_updated(CSteamID id, AppId_t appid)
|
||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||
}
|
||||
|
||||
bool Steam_Friends::isAppIdCompatible(Friend *f)
|
||||
bool Steam_Friends::is_appid_compatible(Friend *f)
|
||||
{
|
||||
if (settings->is_lobby_connect) return true;
|
||||
if (f == &us) return true;
|
||||
@ -826,9 +826,9 @@ void Steam_Friends::ClearRichPresence()
|
||||
|
||||
}
|
||||
|
||||
const char* Steam_Friends::GetFriendRichPresence( CSteamID steamIDFriend, const char *pchKey )
|
||||
// the overlay will keep calling GetFriendRichPresence() and spam the debug log, hence this function
|
||||
const char* Steam_Friends::get_friend_rich_presence_silent( CSteamID steamIDFriend, const char *pchKey )
|
||||
{
|
||||
PRINT_DEBUG("%llu '%s'", steamIDFriend.ConvertToUint64(), pchKey);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
const char *value = "";
|
||||
|
||||
@ -839,11 +839,21 @@ const char* Steam_Friends::GetFriendRichPresence( CSteamID steamIDFriend, const
|
||||
f = find_friend(steamIDFriend);
|
||||
}
|
||||
|
||||
if (f && isAppIdCompatible(f)) {
|
||||
if (f && is_appid_compatible(f)) {
|
||||
auto result = f->rich_presence().find(pchKey);
|
||||
if (result != f->rich_presence().end()) value = result->second.c_str();
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
const char* Steam_Friends::GetFriendRichPresence( CSteamID steamIDFriend, const char *pchKey )
|
||||
{
|
||||
PRINT_DEBUG("%llu '%s'", steamIDFriend.ConvertToUint64(), pchKey);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
|
||||
const char *value = get_friend_rich_presence_silent(steamIDFriend, pchKey);
|
||||
|
||||
PRINT_DEBUG("returned '%s'", value);
|
||||
return value;
|
||||
}
|
||||
@ -861,7 +871,7 @@ int Steam_Friends::GetFriendRichPresenceKeyCount( CSteamID steamIDFriend )
|
||||
f = find_friend(steamIDFriend);
|
||||
}
|
||||
|
||||
if (f && isAppIdCompatible(f)) num = f->rich_presence().size();
|
||||
if (f && is_appid_compatible(f)) num = f->rich_presence().size();
|
||||
|
||||
return num;
|
||||
}
|
||||
@ -879,7 +889,7 @@ const char* Steam_Friends::GetFriendRichPresenceKeyByIndex( CSteamID steamIDFrie
|
||||
f = find_friend(steamIDFriend);
|
||||
}
|
||||
|
||||
if (f && isAppIdCompatible(f) && f->rich_presence().size() > iKey && iKey >= 0) {
|
||||
if (f && is_appid_compatible(f) && f->rich_presence().size() > iKey && iKey >= 0) {
|
||||
auto friend_data = f->rich_presence().begin();
|
||||
for (int i = 0; i < iKey; ++i) ++friend_data;
|
||||
key = friend_data->first.c_str();
|
||||
@ -1234,7 +1244,7 @@ void Steam_Friends::Callback(Common_Message *msg)
|
||||
|
||||
if (map1 != map2) {
|
||||
//The App ID of the game. This should always be the current game.
|
||||
if (isAppIdCompatible(f)) {
|
||||
if (is_appid_compatible(f)) {
|
||||
rich_presence_updated((uint64)msg->friend_().id(), (uint64)msg->friend_().appid());
|
||||
}
|
||||
}
|
||||
|
@ -652,7 +652,7 @@ bool Steam_Overlay::is_friend_joinable(std::pair<const Friend, friend_window_sta
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
Steam_Friends* steamFriends = get_steam_client()->steam_friends;
|
||||
|
||||
if (std::string(steamFriends->GetFriendRichPresence((uint64)f.first.id(), "connect")).length() > 0 ) {
|
||||
if (std::string(steamFriends->get_friend_rich_presence_silent((uint64)f.first.id(), "connect")).length() > 0 ) {
|
||||
PRINT_DEBUG("%" PRIu64 " true (connect string)", f.first.id());
|
||||
return true;
|
||||
}
|
||||
@ -672,7 +672,7 @@ bool Steam_Overlay::got_lobby()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
Steam_Friends* steamFriends = get_steam_client()->steam_friends;
|
||||
if (std::string(steamFriends->GetFriendRichPresence(settings->get_local_steam_id(), "connect")).length() > 0)
|
||||
if (std::string(steamFriends->get_friend_rich_presence_silent(settings->get_local_steam_id(), "connect")).length() > 0)
|
||||
return true;
|
||||
|
||||
if (settings->get_lobby().IsValid())
|
||||
@ -1152,7 +1152,7 @@ void Steam_Overlay::post_achievement_notification(Overlay_Achievement &ach)
|
||||
|
||||
void Steam_Overlay::invite_friend(uint64 friend_id, class Steam_Friends* steamFriends, class Steam_Matchmaking* steamMatchmaking)
|
||||
{
|
||||
std::string connect_str = steamFriends->GetFriendRichPresence(settings->get_local_steam_id(), "connect");
|
||||
std::string connect_str = steamFriends->get_friend_rich_presence_silent(settings->get_local_steam_id(), "connect");
|
||||
if (connect_str.length() > 0) {
|
||||
steamFriends->InviteUserToGame(friend_id, connect_str.c_str());
|
||||
PRINT_DEBUG("sent game invitation to friend with id = %llu", friend_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user