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,31 +888,33 @@ namespace np
for (auto& [npid, pr_info] : current_presences)
{
// Only communicates info about online users
if (!pr_info.online)
{
continue;
}
basic_event to_add{};
strcpy_trunc(to_add.from.userId.handle.data, npid);
strcpy_trunc(to_add.from.name.data, npid);
if (std::memcmp(pr_info.pr_com_id.data, basic_handler.context.data, sizeof(pr_info.pr_com_id.data)) == 0)
if (pr_info.online)
{
to_add.event = SCE_NP_BASIC_EVENT_PRESENCE;
to_add.data = std::move(pr_info.pr_data);
}
else
{
if (basic_handler.context_sensitive)
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_OUT_OF_CONTEXT;
to_add.event = SCE_NP_BASIC_EVENT_PRESENCE;
to_add.data = std::move(pr_info.pr_data);
}
else
{
to_add.event = SCE_NP_BASIC_EVENT_OFFLINE;
if (basic_handler.context_sensitive)
{
to_add.event = SCE_NP_BASIC_EVENT_OUT_OF_CONTEXT;
}
else
{
to_add.event = SCE_NP_BASIC_EVENT_OFFLINE;
}
}
}
else
{
to_add.event = SCE_NP_BASIC_EVENT_OFFLINE;
}
queue_basic_event(to_add);
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::lock_guard lock(mutex_friends);
std::scoped_lock lock(mutex_friends, mutex_presence_updates);
presence_updates.clear();
return friend_infos.friends;
}