np: avoid crash with simulated np (req_ticket, friends/block list)

This commit is contained in:
InvoxiPlayGames 2025-01-19 11:40:53 +00:00
parent 10e0fb2b54
commit 1018e6a7dd
2 changed files with 31 additions and 2 deletions

View file

@ -1470,12 +1470,26 @@ namespace np
u32 np_handler::get_num_friends()
{
return get_rpcn()->get_num_friends();
if (g_cfg.net.psn_status != np_psn_status::psn_rpcn)
{
return 0;
}
else
{
return get_rpcn()->get_num_friends();
}
}
u32 np_handler::get_num_blocks()
{
return get_rpcn()->get_num_blocks();
if (g_cfg.net.psn_status != np_psn_status::psn_rpcn)
{
return 0;
}
else
{
return get_rpcn()->get_num_blocks();
}
}
std::pair<error_code, std::optional<SceNpId>> np_handler::get_friend_by_index(u32 index)

View file

@ -765,6 +765,21 @@ namespace np
cookie_vec.assign(cookie, cookie + cookie_size);
}
if (g_cfg.net.psn_status != np_psn_status::psn_rpcn)
{
// TODO(InvoxiPlayGames): generate ticket data that is valid, for games that need to dig into the data
std::vector<u8> ticketdata = {0x41, 0x42, 0x43, 0x44};
current_ticket = ticket(std::move(ticketdata));
auto ticket_size = static_cast<s32>(current_ticket.size());
sysutil_register_cb([manager_cb = this->manager_cb, ticket_size, manager_cb_arg = this->manager_cb_arg](ppu_thread& cb_ppu) -> s32
{
manager_cb(cb_ppu, SCE_NP_MANAGER_EVENT_GOT_TICKET, ticket_size, manager_cb_arg);
return 0;
});
return;
}
if (!get_rpcn()->req_ticket(req_id, service_id_str, cookie_vec))
{
rpcn_log.error("Disconnecting from RPCN!");