Send initial presence for offline friends.

This commit is contained in:
RipleyTom 2024-02-28 05:21:51 +01:00 committed by Megamouse
parent 2cbd983b4c
commit 573734fab8
2 changed files with 19 additions and 16 deletions

View file

@ -888,15 +888,12 @@ namespace np
for (auto& [npid, pr_info] : current_presences) for (auto& [npid, pr_info] : current_presences)
{ {
// Only communicates info about online users
if (!pr_info.online)
{
continue;
}
basic_event to_add{}; basic_event to_add{};
strcpy_trunc(to_add.from.userId.handle.data, npid); strcpy_trunc(to_add.from.userId.handle.data, npid);
strcpy_trunc(to_add.from.name.data, npid); strcpy_trunc(to_add.from.name.data, npid);
if (pr_info.online)
{
if (std::memcmp(pr_info.pr_com_id.data, basic_handler.context.data, sizeof(pr_info.pr_com_id.data)) == 0) if (std::memcmp(pr_info.pr_com_id.data, basic_handler.context.data, sizeof(pr_info.pr_com_id.data)) == 0)
{ {
to_add.event = SCE_NP_BASIC_EVENT_PRESENCE; to_add.event = SCE_NP_BASIC_EVENT_PRESENCE;
@ -913,6 +910,11 @@ namespace np
to_add.event = SCE_NP_BASIC_EVENT_OFFLINE; to_add.event = SCE_NP_BASIC_EVENT_OFFLINE;
} }
} }
}
else
{
to_add.event = SCE_NP_BASIC_EVENT_OFFLINE;
}
queue_basic_event(to_add); queue_basic_event(to_add);
send_basic_event(to_add.event, 0, 0); send_basic_event(to_add.event, 0, 0);

View file

@ -1261,7 +1261,8 @@ namespace rpcn
std::map<std::string, friend_online_data> rpcn_client::get_presence_states() std::map<std::string, friend_online_data> rpcn_client::get_presence_states()
{ {
std::lock_guard lock(mutex_friends); std::scoped_lock lock(mutex_friends, mutex_presence_updates);
presence_updates.clear();
return friend_infos.friends; return friend_infos.friends;
} }