mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
rpcn: new allocator + refactoring of np_handler
This commit is contained in:
parent
704e74b904
commit
516cb959cb
@ -377,6 +377,9 @@ target_sources(rpcs3_emu PRIVATE
|
||||
NP/fb_helpers.cpp
|
||||
NP/np_contexts.cpp
|
||||
NP/np_handler.cpp
|
||||
NP/np_helpers.cpp
|
||||
NP/np_notifications.cpp
|
||||
NP/np_requests.cpp
|
||||
NP/signaling_handler.cpp
|
||||
NP/np_structs_extra.cpp
|
||||
NP/rpcn_client.cpp
|
||||
|
@ -93,7 +93,7 @@ error_code cellNetCtlInit()
|
||||
{
|
||||
cellNetCtl.warning("cellNetCtlInit()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (nph.is_netctl_init)
|
||||
{
|
||||
@ -109,7 +109,7 @@ void cellNetCtlTerm()
|
||||
{
|
||||
cellNetCtl.warning("cellNetCtlTerm()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
nph.is_netctl_init = false;
|
||||
}
|
||||
@ -118,7 +118,7 @@ error_code cellNetCtlGetState(vm::ptr<s32> state)
|
||||
{
|
||||
cellNetCtl.trace("cellNetCtlGetState(state=*0x%x)", state);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
@ -139,7 +139,7 @@ error_code cellNetCtlAddHandler(vm::ptr<cellNetCtlHandler> handler, vm::ptr<void
|
||||
{
|
||||
cellNetCtl.todo("cellNetCtlAddHandler(handler=*0x%x, arg=*0x%x, hid=*0x%x)", handler, arg, hid);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
@ -158,7 +158,7 @@ error_code cellNetCtlDelHandler(s32 hid)
|
||||
{
|
||||
cellNetCtl.todo("cellNetCtlDelHandler(hid=0x%x)", hid);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
@ -177,7 +177,7 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
||||
{
|
||||
cellNetCtl.warning("cellNetCtlGetInfo(code=0x%x (%s), info=*0x%x)", code, InfoCodeToName(code), info);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
@ -209,9 +209,9 @@ error_code cellNetCtlGetInfo(s32 code, vm::ptr<CellNetCtlInfo> info)
|
||||
case CELL_NET_CTL_INFO_LINK_TYPE: info->link_type = CELL_NET_CTL_LINK_TYPE_10BASE_FULL; break;
|
||||
case CELL_NET_CTL_INFO_IP_CONFIG: info->ip_config = CELL_NET_CTL_IP_STATIC; break;
|
||||
case CELL_NET_CTL_INFO_DEFAULT_ROUTE: strcpy_trunc(info->default_route, "192.168.1.1"); break;
|
||||
case CELL_NET_CTL_INFO_PRIMARY_DNS: strcpy_trunc(info->primary_dns, np_handler::ip_to_string(nph.get_dns_ip())); break;
|
||||
case CELL_NET_CTL_INFO_SECONDARY_DNS: strcpy_trunc(info->secondary_dns, np_handler::ip_to_string(nph.get_dns_ip())); break;
|
||||
case CELL_NET_CTL_INFO_IP_ADDRESS: strcpy_trunc(info->ip_address, np_handler::ip_to_string(nph.get_local_ip_addr())); break;
|
||||
case CELL_NET_CTL_INFO_PRIMARY_DNS: strcpy_trunc(info->primary_dns, np::ip_to_string(nph.get_dns_ip())); break;
|
||||
case CELL_NET_CTL_INFO_SECONDARY_DNS: strcpy_trunc(info->secondary_dns, np::ip_to_string(nph.get_dns_ip())); break;
|
||||
case CELL_NET_CTL_INFO_IP_ADDRESS: strcpy_trunc(info->ip_address, np::ip_to_string(nph.get_local_ip_addr())); break;
|
||||
case CELL_NET_CTL_INFO_NETMASK: strcpy_trunc(info->netmask, "255.255.255.255"); break;
|
||||
case CELL_NET_CTL_INFO_HTTP_PROXY_CONFIG: info->http_proxy_config = 0; break;
|
||||
case CELL_NET_CTL_INFO_DHCP_HOSTNAME: strcpy_trunc(info->dhcp_hostname, nph.get_hostname()); break;
|
||||
@ -238,7 +238,7 @@ error_code cellNetCtlNetStartDialogLoadAsync(vm::cptr<CellNetCtlNetStartDialogPa
|
||||
{
|
||||
cellNetCtl.error("cellNetCtlNetStartDialogLoadAsync(param=*0x%x)", param);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
@ -270,7 +270,7 @@ error_code cellNetCtlNetStartDialogAbortAsync()
|
||||
{
|
||||
cellNetCtl.error("cellNetCtlNetStartDialogAbortAsync()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
@ -284,7 +284,7 @@ error_code cellNetCtlNetStartDialogUnloadAsync(vm::ptr<CellNetCtlNetStartDialogR
|
||||
{
|
||||
cellNetCtl.warning("cellNetCtlNetStartDialogUnloadAsync(result=*0x%x)", result);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
@ -311,7 +311,7 @@ error_code cellNetCtlGetNatInfo(vm::ptr<CellNetCtlNatInfo> natInfo)
|
||||
{
|
||||
cellNetCtl.warning("cellNetCtlGetNatInfo(natInfo=*0x%x)", natInfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_netctl_init)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -178,7 +178,7 @@ error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr<SceNpMatchin
|
||||
error_code sceNpMatching2Term(ppu_thread& ppu);
|
||||
error_code sceNpMatching2Term2();
|
||||
|
||||
error_code generic_match2_error_check(const named_thread<np_handler>& nph, SceNpMatching2ContextId ctxId, vm::cptr<void> reqParam, vm::ptr<SceNpMatching2RequestId> assignedReqId)
|
||||
error_code generic_match2_error_check(const named_thread<np::np_handler>& nph, SceNpMatching2ContextId ctxId, vm::cptr<void> reqParam, vm::ptr<SceNpMatching2RequestId> assignedReqId)
|
||||
{
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -207,7 +207,7 @@ error_code sceNp2Init(u32 poolsize, vm::ptr<void> poolptr)
|
||||
{
|
||||
sceNp2.warning("sceNp2Init(poolsize=0x%x, poolptr=*0x%x)", poolsize, poolptr);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
{
|
||||
std::lock_guard lock(nph.mutex_status);
|
||||
@ -239,7 +239,7 @@ error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr<SceNpMatchin
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2Init2(stackSize=0x%x, priority=%d, param=*0x%x)", stackSize, priority, param);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_init)
|
||||
{
|
||||
@ -265,7 +265,7 @@ error_code sceNp2Term(ppu_thread& ppu)
|
||||
{
|
||||
sceNp2.warning("sceNp2Term()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
{
|
||||
std::lock_guard lock(nph.mutex_status);
|
||||
@ -295,7 +295,7 @@ error_code sceNpMatching2Term2()
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2Term2()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
{
|
||||
std::lock_guard lock(nph.mutex_status);
|
||||
@ -321,7 +321,7 @@ error_code sceNpMatching2DestroyContext(SceNpMatching2ContextId ctxId)
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2DestroyContext(ctxId=%d)", ctxId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -339,7 +339,7 @@ error_code sceNpMatching2LeaveLobby(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2LeaveLobby(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -352,7 +352,7 @@ error_code sceNpMatching2RegisterLobbyMessageCallback(SceNpMatching2ContextId ct
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2RegisterLobbyMessageCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -367,7 +367,7 @@ error_code sceNpMatching2GetWorldInfoList(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2GetWorldInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -387,7 +387,7 @@ error_code sceNpMatching2RegisterLobbyEventCallback(SceNpMatching2ContextId ctxI
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2RegisterLobbyEventCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -402,7 +402,7 @@ error_code sceNpMatching2GetLobbyMemberDataInternalList(SceNpMatching2ContextId
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetLobbyMemberDataInternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -416,7 +416,7 @@ error_code sceNpMatching2SearchRoom(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SearchRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -432,7 +432,7 @@ error_code sceNpMatching2SignalingGetConnectionStatus(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SignalingGetConnectionStatus(ctxId=%d, roomId=%d, memberId=%d, connStatus=*0x%x, peerAddr=*0x%x, peerPort=*0x%x)", ctxId, roomId, memberId, connStatus, peerAddr, peerPort);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -468,7 +468,7 @@ error_code sceNpMatching2SetUserInfo(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SetUserInfo(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -481,7 +481,7 @@ error_code sceNpMatching2GetClanLobbyId(SceNpMatching2ContextId ctxId, SceNpClan
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetClanLobbyId(ctxId=%d, clanId=%d, lobbyId=*0x%x)", ctxId, clanId, lobbyId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -496,7 +496,7 @@ error_code sceNpMatching2GetLobbyMemberDataInternal(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetLobbyMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -509,7 +509,7 @@ error_code sceNpMatching2ContextStart(SceNpMatching2ContextId ctxId)
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2ContextStart(ctxId=%d)", ctxId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -537,7 +537,7 @@ error_code sceNpMatching2CreateServerContext(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2CreateServerContext(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -557,7 +557,7 @@ error_code sceNpMatching2GetMemoryInfo(vm::ptr<SceNpMatching2MemoryInfo> memInfo
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetMemoryInfo(memInfo=*0x%x)", memInfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -572,7 +572,7 @@ error_code sceNpMatching2LeaveRoom(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2LeaveRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -588,7 +588,7 @@ error_code sceNpMatching2SetRoomDataExternal(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SetRoomDataExternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -604,7 +604,7 @@ error_code sceNpMatching2SignalingGetConnectionInfo(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingGetConnectionInfo(ctxId=%d, roomId=%d, memberId=%d, code=%d, connInfo=*0x%x)", ctxId, roomId, memberId, code, connInfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -665,7 +665,7 @@ error_code sceNpMatching2SendRoomMessage(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SendRoomMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -681,7 +681,7 @@ error_code sceNpMatching2JoinLobby(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2JoinLobby(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -695,7 +695,7 @@ error_code sceNpMatching2GetRoomMemberDataExternalList(SceNpMatching2ContextId c
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetRoomMemberDataExternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -708,7 +708,7 @@ error_code sceNpMatching2AbortRequest(SceNpMatching2ContextId ctxId, SceNpMatchi
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2AbortRequest(ctxId=%d, reqId=%d)", ctxId, reqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -723,7 +723,7 @@ error_code sceNpMatching2GetServerInfo(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2GetServerInfo(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -738,7 +738,7 @@ error_code sceNpMatching2GetEventData(SceNpMatching2ContextId ctxId, SceNpMatchi
|
||||
{
|
||||
sceNp2.notice("sceNpMatching2GetEventData(ctxId=%d, eventKey=%d, buf=*0x%x, bufLen=%d)", ctxId, eventKey, buf, bufLen);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -750,14 +750,14 @@ error_code sceNpMatching2GetEventData(SceNpMatching2ContextId ctxId, SceNpMatchi
|
||||
return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return not_an_error(nph.get_match2_event(eventKey, static_cast<u8 *>(buf.get_ptr()), bufLen));
|
||||
return not_an_error(nph.get_match2_event(eventKey, buf.addr(), bufLen));
|
||||
}
|
||||
|
||||
error_code sceNpMatching2GetRoomSlotInfoLocal(SceNpMatching2ContextId ctxId, const SceNpMatching2RoomId roomId, vm::ptr<SceNpMatching2RoomSlotInfo> roomSlotInfo)
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetRoomSlotInfoLocal(ctxId=%d, roomId=%d, roomSlotInfo=*0x%x)", ctxId, roomId, roomSlotInfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -772,7 +772,7 @@ error_code sceNpMatching2SendLobbyChatMessage(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SendLobbyChatMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -785,7 +785,7 @@ error_code sceNpMatching2AbortContextStart(SceNpMatching2ContextId ctxId)
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2AbortContextStart(ctxId=%d)", ctxId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -799,7 +799,7 @@ error_code sceNpMatching2GetRoomMemberIdListLocal(SceNpMatching2ContextId ctxId,
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetRoomMemberIdListLocal(ctxId=%d, roomId=%d, sortMethod=%d, memberId=*0x%x, memberIdNum=%d)", ctxId, roomId, sortMethod, memberId, memberIdNum);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -814,7 +814,7 @@ error_code sceNpMatching2JoinRoom(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2JoinRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -831,7 +831,7 @@ error_code sceNpMatching2GetRoomMemberDataInternalLocal(SceNpMatching2ContextId
|
||||
sceNp2.todo("sceNpMatching2GetRoomMemberDataInternalLocal(ctxId=%d, roomId=%d, memberId=%d, attrId=*0x%x, attrIdNum=%d, member=*0x%x, buf=*0x%x, bufLen=%d)", ctxId, roomId, memberId, attrId,
|
||||
attrIdNum, member, buf, bufLen);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -845,7 +845,7 @@ error_code sceNpMatching2GetCbQueueInfo(SceNpMatching2ContextId ctxId, vm::ptr<S
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetCbQueueInfo(ctxId=%d, queueInfo=*0x%x)", ctxId, queueInfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -860,7 +860,7 @@ error_code sceNpMatching2KickoutRoomMember(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2KickoutRoomMember(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -873,7 +873,7 @@ error_code sceNpMatching2ContextStartAsync(SceNpMatching2ContextId ctxId, u32 ti
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2ContextStartAsync(ctxId=%d, timeout=%d)", ctxId, timeout);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -906,7 +906,7 @@ error_code sceNpMatching2SetSignalingOptParam(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SetSignalingOptParam(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -919,7 +919,7 @@ error_code sceNpMatching2RegisterContextCallback(SceNpMatching2ContextId ctxId,
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2RegisterContextCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -946,7 +946,7 @@ error_code sceNpMatching2SendRoomChatMessage(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SendRoomChatMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -960,7 +960,7 @@ error_code sceNpMatching2SetRoomDataInternal(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SetRoomDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -976,7 +976,7 @@ error_code sceNpMatching2GetRoomDataInternal(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2GetRoomDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -992,7 +992,7 @@ error_code sceNpMatching2SignalingGetPingInfo(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SignalingGetPingInfo(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1007,7 +1007,7 @@ error_code sceNpMatching2GetServerIdListLocal(SceNpMatching2ContextId ctxId, vm:
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetServerIdListLocal(ctxId=%d, serverId=*0x%x, serverIdNum=%d)", ctxId, serverId, serverIdNum);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1057,7 +1057,7 @@ error_code sceNpMatching2GrantRoomOwner(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GrantRoomOwner(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1071,7 +1071,7 @@ error_code sceNpMatching2CreateContext(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2CreateContext(npId=*0x%x, commId=*0x%x(%s), passPhrase=*0x%x, ctxId=*0x%x, option=%d)", npId, commId, commId ? commId->data : "", ctxId, option);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1092,7 +1092,7 @@ error_code sceNpMatching2GetSignalingOptParamLocal(SceNpMatching2ContextId ctxId
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetSignalingOptParamLocal(ctxId=%d, roomId=%d, signalingOptParam=*0x%x)", ctxId, roomId, signalingOptParam);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1106,7 +1106,7 @@ error_code sceNpMatching2RegisterSignalingCallback(SceNpMatching2ContextId ctxId
|
||||
{
|
||||
sceNp2.notice("sceNpMatching2RegisterSignalingCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1123,7 +1123,7 @@ error_code sceNpMatching2ClearEventData(SceNpMatching2ContextId ctxId, SceNpMatc
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2ClearEventData(ctxId=%d, eventKey=%d)", ctxId, eventKey);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1138,7 +1138,7 @@ error_code sceNpMatching2GetUserInfoList(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetUserInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1152,7 +1152,7 @@ error_code sceNpMatching2GetRoomMemberDataInternal(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetRoomMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1166,7 +1166,7 @@ error_code sceNpMatching2SetRoomMemberDataInternal(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SetRoomMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1182,7 +1182,7 @@ error_code sceNpMatching2JoinProhibitiveRoom(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2JoinProhibitiveRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1198,7 +1198,7 @@ error_code sceNpMatching2SignalingSetCtxOpt(SceNpMatching2ContextId ctxId, s32 o
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingSetCtxOpt(ctxId=%d, optname=%d, optval=%d)", ctxId, optname, optval);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1213,7 +1213,7 @@ error_code sceNpMatching2DeleteServerContext(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2DeleteServerContext(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1226,7 +1226,7 @@ error_code sceNpMatching2SetDefaultRequestOptParam(SceNpMatching2ContextId ctxId
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2SetDefaultRequestOptParam(ctxId=%d, optParam=*0x%x)", ctxId, optParam);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1251,7 +1251,7 @@ error_code sceNpMatching2RegisterRoomEventCallback(SceNpMatching2ContextId ctxId
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2RegisterRoomEventCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1269,7 +1269,7 @@ error_code sceNpMatching2GetRoomPasswordLocal(SceNpMatching2ContextId ctxId, Sce
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetRoomPasswordLocal(ctxId=%d, roomId=%d, withPassword=*0x%x, roomPassword=*0x%x)", ctxId, roomId, withPassword, roomPassword);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1284,7 +1284,7 @@ error_code sceNpMatching2GetRoomDataExternalList(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2GetRoomDataExternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1300,7 +1300,7 @@ error_code sceNpMatching2CreateJoinRoom(
|
||||
{
|
||||
sceNp2.warning("sceNpMatching2CreateJoinRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1315,7 +1315,7 @@ error_code sceNpMatching2SignalingGetCtxOpt(SceNpMatching2ContextId ctxId, s32 o
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingGetCtxOpt(ctxId=%d, optname=%d, optval=*0x%x)", ctxId, optname, optval);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1330,7 +1330,7 @@ error_code sceNpMatching2GetLobbyInfoList(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetLobbyInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1344,7 +1344,7 @@ error_code sceNpMatching2GetLobbyMemberIdListLocal(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2GetLobbyMemberIdListLocal(ctxId=%d, lobbyId=%d, memberId=*0x%x, memberIdNum=%d, me=*0x%x)", ctxId, lobbyId, memberId, memberIdNum, me);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1359,7 +1359,7 @@ error_code sceNpMatching2SendLobbyInvitation(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SendLobbyInvitation(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1372,7 +1372,7 @@ error_code sceNpMatching2ContextStop(SceNpMatching2ContextId ctxId)
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2ContextStop(ctxId=%d)", ctxId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1403,7 +1403,7 @@ error_code sceNpMatching2SetLobbyMemberDataInternal(
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SetLobbyMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK)
|
||||
{
|
||||
return res;
|
||||
@ -1416,7 +1416,7 @@ error_code sceNpMatching2RegisterRoomMessageCallback(SceNpMatching2ContextId ctx
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2RegisterRoomMessageCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1434,7 +1434,7 @@ error_code sceNpMatching2SignalingCancelPeerNetInfo(SceNpMatching2ContextId ctxI
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingCancelPeerNetInfo(ctxId=%d, reqId=%d)", ctxId, reqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1448,7 +1448,7 @@ error_code sceNpMatching2SignalingGetLocalNetInfo(vm::ptr<SceNpMatching2Signalin
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingGetLocalNetInfo(netinfo=*0x%x)", netinfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1468,7 +1468,7 @@ error_code sceNpMatching2SignalingGetPeerNetInfo(SceNpMatching2ContextId ctxId,
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingGetPeerNetInfo(ctxId=%d, roomId=%d, roomMemberId=%d, reqId=*0x%x)", ctxId, roomId, roomMemberId, reqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1487,7 +1487,7 @@ error_code sceNpMatching2SignalingGetPeerNetInfoResult(SceNpMatching2ContextId c
|
||||
{
|
||||
sceNp2.todo("sceNpMatching2SignalingGetPeerNetInfoResult(ctxId=%d, reqId=%d, netinfo=*0x%x)", ctxId, reqId, netinfo);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP2_Match2_init)
|
||||
{
|
||||
@ -1507,7 +1507,7 @@ error_code sceNpAuthOAuthInit()
|
||||
{
|
||||
sceNp2.todo("sceNpAuthOAuthInit()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (nph.is_NP_Auth_init)
|
||||
{
|
||||
@ -1523,7 +1523,7 @@ error_code sceNpAuthOAuthTerm()
|
||||
{
|
||||
sceNp2.todo("sceNpAuthOAuthTerm()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
// TODO: check if this might throw SCE_NP_OAUTH_ERROR_NOT_INITIALIZED
|
||||
nph.is_NP_Auth_init = false;
|
||||
@ -1535,7 +1535,7 @@ error_code sceNpAuthCreateOAuthRequest()
|
||||
{
|
||||
sceNp2.todo("sceNpAuthCreateOAuthRequest()");
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP_Auth_init)
|
||||
{
|
||||
@ -1549,7 +1549,7 @@ error_code sceNpAuthDeleteOAuthRequest(SceNpAuthOAuthRequestId reqId)
|
||||
{
|
||||
sceNp2.todo("sceNpAuthDeleteOAuthRequest(reqId=%d)", reqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP_Auth_init)
|
||||
{
|
||||
@ -1563,7 +1563,7 @@ error_code sceNpAuthAbortOAuthRequest(SceNpAuthOAuthRequestId reqId)
|
||||
{
|
||||
sceNp2.todo("sceNpAuthAbortOAuthRequest(reqId=%d)", reqId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP_Auth_init)
|
||||
{
|
||||
@ -1577,7 +1577,7 @@ error_code sceNpAuthGetAuthorizationCode(SceNpAuthOAuthRequestId reqId, vm::cptr
|
||||
{
|
||||
sceNp2.todo("sceNpAuthGetAuthorizationCode(reqId=%d, param=*0x%x, authCode=*0x%x, issuerId=%d)", reqId, param, authCode, issuerId);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (!nph.is_NP_Auth_init)
|
||||
{
|
||||
|
@ -1413,7 +1413,7 @@ struct SceNpMatching2RoomMessageInfo
|
||||
u8 padding[2];
|
||||
vm::bptr<SceNpMatching2RoomMessageDestination> dst;
|
||||
vm::bptr<SceNpUserInfo2> srcMember;
|
||||
vm::bcptr<void> msg;
|
||||
vm::bptr<void> msg;
|
||||
be_t<u32> msgLen;
|
||||
};
|
||||
|
||||
|
@ -179,7 +179,7 @@ error_code sceNpSnsFbGetAccessToken(u32 handle, vm::cptr<SceNpSnsFbAccessTokenPa
|
||||
return SCE_NP_SNS_FB_ERROR_UNKNOWN_HANDLE;
|
||||
}
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (nph.get_psn_status() == SCE_NP_MANAGER_STATUS_OFFLINE)
|
||||
{
|
||||
@ -306,7 +306,7 @@ error_code sceNpSnsFbGetLongAccessToken(u32 handle, vm::cptr<SceNpSnsFbAccessTok
|
||||
return SCE_NP_SNS_FB_ERROR_UNKNOWN_HANDLE;
|
||||
}
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
if (nph.get_psn_status() == SCE_NP_MANAGER_STATUS_OFFLINE)
|
||||
{
|
||||
|
@ -1695,7 +1695,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
|
||||
|
||||
if (psa_in->sin_port == 53)
|
||||
{
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
// Hack for DNS
|
||||
name.sin_port = std::bit_cast<u16, be_t<u16>>(53);
|
||||
@ -2286,7 +2286,7 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr<void> buf, u32
|
||||
|
||||
//if (!(sock.events & lv2_socket::poll::read))
|
||||
{
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (nph.is_dns(s) && nph.is_dns_queue(s))
|
||||
{
|
||||
const auto packet = nph.get_dns_packet(s);
|
||||
@ -2708,7 +2708,7 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr<void> buf, u32 l
|
||||
|
||||
//if (!(sock.events & lv2_socket::poll::write))
|
||||
{
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (addr && type == SYS_NET_SOCK_DGRAM && psa_in->sin_port == 53)
|
||||
{
|
||||
nph.add_dns_spy(s);
|
||||
@ -3217,7 +3217,7 @@ error_code sys_net_bnet_close(ppu_thread& ppu, s32 s)
|
||||
}
|
||||
}
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
nph.remove_dns_spy(s);
|
||||
|
||||
return CELL_OK;
|
||||
@ -3309,7 +3309,7 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr<sys_net_pollfd> fds, s32 n
|
||||
else
|
||||
{
|
||||
// Check for fake packet for dns interceptions
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
if (fds_buf[i].events & SYS_NET_POLLIN && nph.is_dns(fds_buf[i].fd) && nph.is_dns_queue(fds_buf[i].fd))
|
||||
fds_buf[i].revents |= SYS_NET_POLLIN;
|
||||
|
||||
@ -3754,8 +3754,8 @@ error_code sys_net_infoctl(ppu_thread& ppu, s32 cmd, vm::ptr<void> arg)
|
||||
char buffer[nameserver.size() + 80]{};
|
||||
std::memcpy(buffer, nameserver.data(), nameserver.size());
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
const auto dns_str = np_handler::ip_to_string(nph.get_dns_ip());
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
const auto dns_str = np::ip_to_string(nph.get_dns_ip());
|
||||
std::memcpy(buffer + nameserver.size() - 1, dns_str.data(), dns_str.size());
|
||||
|
||||
std::string_view name{buffer};
|
||||
|
@ -3,529 +3,489 @@
|
||||
|
||||
LOG_CHANNEL(rpcn_log, "rpcn");
|
||||
|
||||
void np_handler::BinAttr_to_SceNpMatching2BinAttr(const BinAttr* bin_attr, SceNpMatching2BinAttr* binattr_info)
|
||||
namespace np
|
||||
{
|
||||
binattr_info->id = bin_attr->id();
|
||||
binattr_info->size = bin_attr->data()->size();
|
||||
binattr_info->ptr = allocate(binattr_info->size);
|
||||
for (flatbuffers::uoffset_t i = 0; i < bin_attr->data()->size(); i++)
|
||||
void np_handler::BinAttr_to_SceNpMatching2BinAttr(event_data& edata, const BinAttr* bin_attr, SceNpMatching2BinAttr* binattr_info)
|
||||
{
|
||||
binattr_info->ptr[i] = bin_attr->data()->Get(i);
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::BinAttrs_to_SceNpMatching2BinAttr(const flatbuffers::Vector<flatbuffers::Offset<BinAttr>>* fb_attr, vm::ptr<SceNpMatching2BinAttr> binattr_info)
|
||||
{
|
||||
for (flatbuffers::uoffset_t i = 0; i < fb_attr->size(); i++)
|
||||
{
|
||||
auto fb_attr_this = fb_attr->Get(i);
|
||||
auto binattr_info_this = binattr_info + i;
|
||||
|
||||
BinAttr_to_SceNpMatching2BinAttr(fb_attr_this, binattr_info_this.get_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomMemberBinAttrInternal_to_SceNpMatching2RoomMemberBinAttrInternal(const RoomMemberBinAttrInternal* fb_attr, vm::ptr<SceNpMatching2RoomMemberBinAttrInternal> binattr_info)
|
||||
{
|
||||
binattr_info->updateDate.tick = fb_attr->updateDate();
|
||||
BinAttr_to_SceNpMatching2BinAttr(fb_attr->data(), &binattr_info->data);
|
||||
}
|
||||
|
||||
void np_handler::RoomBinAttrInternal_to_SceNpMatching2RoomBinAttrInternal(const BinAttrInternal* fb_attr, vm::ptr<SceNpMatching2RoomBinAttrInternal> binattr_info)
|
||||
{
|
||||
binattr_info->updateDate.tick = fb_attr->updateDate();
|
||||
binattr_info->updateMemberId = fb_attr->updateMemberId();
|
||||
BinAttr_to_SceNpMatching2BinAttr(fb_attr->data(), &binattr_info->data);
|
||||
}
|
||||
|
||||
void np_handler::RoomGroups_to_SceNpMatching2RoomGroup(const flatbuffers::Vector<flatbuffers::Offset<RoomGroup>>* fb_group, vm::ptr<SceNpMatching2RoomGroup> group_info)
|
||||
{
|
||||
for (flatbuffers::uoffset_t i = 0; i < fb_group->size(); i++)
|
||||
{
|
||||
auto group = fb_group->Get(i);
|
||||
group_info[i].groupId = group->groupId();
|
||||
group_info[i].withPassword = group->withPassword();
|
||||
group_info[i].withLabel = group->withLabel();
|
||||
if (group->label())
|
||||
binattr_info->id = bin_attr->id();
|
||||
binattr_info->size = bin_attr->data()->size();
|
||||
auto* ptr = edata.allocate<u8>(binattr_info->size, binattr_info->ptr);
|
||||
for (flatbuffers::uoffset_t i = 0; i < bin_attr->data()->size(); i++)
|
||||
{
|
||||
for (flatbuffers::uoffset_t l_index = 0; l_index < group->label()->size(); l_index++)
|
||||
ptr[i] = bin_attr->data()->Get(i);
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::BinAttrs_to_SceNpMatching2BinAttrs(event_data& edata, const flatbuffers::Vector<flatbuffers::Offset<BinAttr>>* fb_attr, SceNpMatching2BinAttr* binattr_info)
|
||||
{
|
||||
for (flatbuffers::uoffset_t i = 0; i < fb_attr->size(); i++)
|
||||
{
|
||||
auto cur_fb_attr = fb_attr->Get(i);
|
||||
auto cur_binattr = binattr_info + i;
|
||||
|
||||
BinAttr_to_SceNpMatching2BinAttr(edata, cur_fb_attr, cur_binattr);
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomMemberBinAttrInternal_to_SceNpMatching2RoomMemberBinAttrInternal(event_data& edata, const RoomMemberBinAttrInternal* fb_attr, SceNpMatching2RoomMemberBinAttrInternal* binattr_info)
|
||||
{
|
||||
binattr_info->updateDate.tick = fb_attr->updateDate();
|
||||
BinAttr_to_SceNpMatching2BinAttr(edata, fb_attr->data(), &binattr_info->data);
|
||||
}
|
||||
|
||||
void np_handler::RoomBinAttrInternal_to_SceNpMatching2RoomBinAttrInternal(event_data& edata, const BinAttrInternal* fb_attr, SceNpMatching2RoomBinAttrInternal* binattr_info)
|
||||
{
|
||||
binattr_info->updateDate.tick = fb_attr->updateDate();
|
||||
binattr_info->updateMemberId = fb_attr->updateMemberId();
|
||||
BinAttr_to_SceNpMatching2BinAttr(edata, fb_attr->data(), &binattr_info->data);
|
||||
}
|
||||
|
||||
void np_handler::RoomGroup_to_SceNpMatching2RoomGroup(const RoomGroup* fb_group, SceNpMatching2RoomGroup* sce_group)
|
||||
{
|
||||
sce_group->groupId = fb_group->groupId();
|
||||
sce_group->withPassword = fb_group->withPassword();
|
||||
sce_group->withLabel = fb_group->withLabel();
|
||||
if (fb_group->label())
|
||||
{
|
||||
for (flatbuffers::uoffset_t l_index = 0; l_index < fb_group->label()->size(); l_index++)
|
||||
{
|
||||
group_info[i].label.data[l_index] = group->label()->Get(l_index);
|
||||
sce_group->label.data[l_index] = fb_group->label()->Get(l_index);
|
||||
}
|
||||
}
|
||||
group_info[i].slotNum = group->slotNum();
|
||||
group_info[i].curGroupMemberNum = group->curGroupMemberNum();
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::UserInfo2_to_SceNpUserInfo2(const UserInfo2* user, SceNpUserInfo2* user_info)
|
||||
{
|
||||
if (user->npId())
|
||||
std::memcpy(user_info->npId.handle.data, user->npId()->c_str(), std::min<usz>(16, user->npId()->size()));
|
||||
|
||||
if (user->onlineName())
|
||||
{
|
||||
user_info->onlineName.set(allocate(sizeof(SceNpOnlineName)));
|
||||
std::memcpy(user_info->onlineName->data, user->onlineName()->c_str(), std::min<usz>(48, user->onlineName()->size()));
|
||||
}
|
||||
if (user->avatarUrl())
|
||||
{
|
||||
user_info->avatarUrl.set(allocate(sizeof(SceNpAvatarUrl)));
|
||||
std::memcpy(user_info->avatarUrl->data, user->avatarUrl()->c_str(), std::min<usz>(127, user->avatarUrl()->size()));
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomDataExternal_to_SceNpMatching2RoomDataExternal(const RoomDataExternal* room, SceNpMatching2RoomDataExternal* room_info)
|
||||
{
|
||||
room_info->serverId = room->serverId();
|
||||
room_info->worldId = room->worldId();
|
||||
room_info->publicSlotNum = room->publicSlotNum();
|
||||
room_info->privateSlotNum = room->privateSlotNum();
|
||||
room_info->lobbyId = room->lobbyId();
|
||||
room_info->roomId = room->roomId();
|
||||
room_info->openPublicSlotNum = room->openPublicSlotNum();
|
||||
room_info->maxSlot = room->maxSlot();
|
||||
room_info->openPrivateSlotNum = room->openPrivateSlotNum();
|
||||
room_info->curMemberNum = room->curMemberNum();
|
||||
room_info->passwordSlotMask = room->passwordSlotMask();
|
||||
|
||||
if (auto owner = room->owner())
|
||||
{
|
||||
vm::ptr<SceNpUserInfo2> owner_info(allocate(sizeof(SceNpUserInfo2)));
|
||||
UserInfo2_to_SceNpUserInfo2(owner, owner_info.get_ptr());
|
||||
room_info->owner = owner_info;
|
||||
sce_group->slotNum = fb_group->slotNum();
|
||||
sce_group->curGroupMemberNum = fb_group->curGroupMemberNum();
|
||||
}
|
||||
|
||||
if (room->roomGroup() && room->roomGroup()->size() != 0)
|
||||
void np_handler::RoomGroups_to_SceNpMatching2RoomGroups(const flatbuffers::Vector<flatbuffers::Offset<RoomGroup>>* fb_groups, SceNpMatching2RoomGroup* sce_groups)
|
||||
{
|
||||
room_info->roomGroupNum = room->roomGroup()->size();
|
||||
vm::ptr<SceNpMatching2RoomGroup> group_info(allocate(sizeof(SceNpMatching2RoomGroup) * room_info->roomGroupNum));
|
||||
RoomGroups_to_SceNpMatching2RoomGroup(room->roomGroup(), group_info);
|
||||
room_info->roomGroup = group_info;
|
||||
}
|
||||
|
||||
room_info->flagAttr = room->flagAttr();
|
||||
|
||||
if (room->roomSearchableIntAttrExternal() && room->roomSearchableIntAttrExternal()->size() != 0)
|
||||
{
|
||||
room_info->roomSearchableIntAttrExternalNum = room->roomSearchableIntAttrExternal()->size();
|
||||
vm::ptr<SceNpMatching2IntAttr> intattr_info(allocate(sizeof(SceNpMatching2IntAttr) * room_info->roomSearchableIntAttrExternalNum));
|
||||
for (flatbuffers::uoffset_t a_index = 0; a_index < room->roomSearchableIntAttrExternal()->size(); a_index++)
|
||||
for (flatbuffers::uoffset_t i = 0; i < fb_groups->size(); i++)
|
||||
{
|
||||
auto int_attr = room->roomSearchableIntAttrExternal()->Get(a_index);
|
||||
intattr_info[a_index].id = int_attr->id();
|
||||
intattr_info[a_index].num = int_attr->num();
|
||||
const auto* fb_group = fb_groups->Get(i);
|
||||
SceNpMatching2RoomGroup* sce_group = &sce_groups[i];
|
||||
RoomGroup_to_SceNpMatching2RoomGroup(fb_group, sce_group);
|
||||
}
|
||||
room_info->roomSearchableIntAttrExternal = intattr_info;
|
||||
}
|
||||
|
||||
if (room->roomSearchableBinAttrExternal() && room->roomSearchableBinAttrExternal()->size() != 0)
|
||||
void np_handler::UserInfo2_to_SceNpUserInfo2(event_data& edata, const UserInfo2* user, SceNpUserInfo2* user_info)
|
||||
{
|
||||
room_info->roomSearchableBinAttrExternalNum = room->roomSearchableBinAttrExternal()->size();
|
||||
vm::ptr<SceNpMatching2BinAttr> binattr_info(allocate(sizeof(SceNpMatching2BinAttr) * room_info->roomSearchableBinAttrExternalNum));
|
||||
BinAttrs_to_SceNpMatching2BinAttr(room->roomSearchableBinAttrExternal(), binattr_info);
|
||||
room_info->roomSearchableBinAttrExternal = binattr_info;
|
||||
}
|
||||
if (user->npId())
|
||||
std::memcpy(user_info->npId.handle.data, user->npId()->c_str(), std::min<usz>(16, user->npId()->size()));
|
||||
|
||||
if (room->roomBinAttrExternal() && room->roomBinAttrExternal()->size() != 0)
|
||||
{
|
||||
room_info->roomBinAttrExternalNum = room->roomBinAttrExternal()->size();
|
||||
vm::ptr<SceNpMatching2BinAttr> binattr_info(allocate(sizeof(SceNpMatching2BinAttr) * room_info->roomBinAttrExternalNum));
|
||||
BinAttrs_to_SceNpMatching2BinAttr(room->roomBinAttrExternal(), binattr_info);
|
||||
room_info->roomBinAttrExternal = binattr_info;
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::SearchRoomResponse_to_SceNpMatching2SearchRoomResponse(const SearchRoomResponse* resp, SceNpMatching2SearchRoomResponse* search_resp)
|
||||
{
|
||||
search_resp->range.size = resp->size();
|
||||
search_resp->range.startIndex = resp->startIndex();
|
||||
search_resp->range.total = resp->total();
|
||||
|
||||
if (resp->rooms() && resp->rooms()->size() != 0)
|
||||
{
|
||||
vm::addr_t previous_next = vm::cast<u32>(0);
|
||||
for (flatbuffers::uoffset_t i = 0; i < resp->rooms()->size(); i++)
|
||||
if (user->onlineName())
|
||||
{
|
||||
auto* room = resp->rooms()->Get(i);
|
||||
vm::ptr<SceNpMatching2RoomDataExternal> room_info(allocate(sizeof(SceNpMatching2RoomDataExternal)));
|
||||
auto* ptr = edata.allocate<SceNpOnlineName>(sizeof(SceNpOnlineName), user_info->onlineName);
|
||||
std::memcpy(ptr->data, user->onlineName()->c_str(), std::min<usz>(48, user->onlineName()->size()));
|
||||
}
|
||||
if (user->avatarUrl())
|
||||
{
|
||||
auto* ptr = edata.allocate<SceNpAvatarUrl>(sizeof(SceNpAvatarUrl), user_info->avatarUrl);
|
||||
std::memcpy(ptr->data, user->avatarUrl()->c_str(), std::min<usz>(127, user->avatarUrl()->size()));
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
void np_handler::RoomDataExternal_to_SceNpMatching2RoomDataExternal(event_data& edata, const RoomDataExternal* room, SceNpMatching2RoomDataExternal* room_info)
|
||||
{
|
||||
room_info->serverId = room->serverId();
|
||||
room_info->worldId = room->worldId();
|
||||
room_info->publicSlotNum = room->publicSlotNum();
|
||||
room_info->privateSlotNum = room->privateSlotNum();
|
||||
room_info->lobbyId = room->lobbyId();
|
||||
room_info->roomId = room->roomId();
|
||||
room_info->openPublicSlotNum = room->openPublicSlotNum();
|
||||
room_info->maxSlot = room->maxSlot();
|
||||
room_info->openPrivateSlotNum = room->openPrivateSlotNum();
|
||||
room_info->curMemberNum = room->curMemberNum();
|
||||
room_info->passwordSlotMask = room->passwordSlotMask();
|
||||
|
||||
if (auto owner = room->owner())
|
||||
{
|
||||
auto* ptr_owner = edata.allocate<SceNpUserInfo2>(sizeof(SceNpUserInfo2), room_info->owner);
|
||||
UserInfo2_to_SceNpUserInfo2(edata, owner, ptr_owner);
|
||||
}
|
||||
|
||||
if (room->roomGroup() && room->roomGroup()->size() != 0)
|
||||
{
|
||||
room_info->roomGroupNum = room->roomGroup()->size();
|
||||
auto* ptr_groups = edata.allocate<SceNpMatching2RoomGroup>(sizeof(SceNpMatching2RoomGroup) * room_info->roomGroupNum, room_info->roomGroup);
|
||||
RoomGroups_to_SceNpMatching2RoomGroups(room->roomGroup(), ptr_groups);
|
||||
}
|
||||
|
||||
room_info->flagAttr = room->flagAttr();
|
||||
|
||||
if (room->roomSearchableIntAttrExternal() && room->roomSearchableIntAttrExternal()->size() != 0)
|
||||
{
|
||||
room_info->roomSearchableIntAttrExternalNum = room->roomSearchableIntAttrExternal()->size();
|
||||
auto* ptr_int_attr = edata.allocate<SceNpMatching2IntAttr>(sizeof(SceNpMatching2IntAttr) * room_info->roomSearchableIntAttrExternalNum, room_info->roomSearchableIntAttrExternal);
|
||||
for (flatbuffers::uoffset_t a_index = 0; a_index < room->roomSearchableIntAttrExternal()->size(); a_index++)
|
||||
{
|
||||
vm::ptr<SceNpMatching2RoomDataExternal> prev_room(previous_next);
|
||||
prev_room->next.set(room_info.addr());
|
||||
auto fb_int_attr = room->roomSearchableIntAttrExternal()->Get(a_index);
|
||||
ptr_int_attr[a_index].id = fb_int_attr->id();
|
||||
ptr_int_attr[a_index].num = fb_int_attr->num();
|
||||
}
|
||||
}
|
||||
|
||||
if (room->roomSearchableBinAttrExternal() && room->roomSearchableBinAttrExternal()->size() != 0)
|
||||
{
|
||||
room_info->roomSearchableBinAttrExternalNum = room->roomSearchableBinAttrExternal()->size();
|
||||
auto* ptr_bin_attr = edata.allocate<SceNpMatching2BinAttr>(sizeof(SceNpMatching2BinAttr) * room_info->roomSearchableBinAttrExternalNum, room_info->roomSearchableBinAttrExternal);
|
||||
BinAttrs_to_SceNpMatching2BinAttrs(edata, room->roomSearchableBinAttrExternal(), ptr_bin_attr);
|
||||
}
|
||||
|
||||
if (room->roomBinAttrExternal() && room->roomBinAttrExternal()->size() != 0)
|
||||
{
|
||||
room_info->roomBinAttrExternalNum = room->roomBinAttrExternal()->size();
|
||||
auto* ptr_bin_attr = edata.allocate<SceNpMatching2BinAttr>(sizeof(SceNpMatching2BinAttr) * room_info->roomBinAttrExternalNum, room_info->roomBinAttrExternal);
|
||||
BinAttrs_to_SceNpMatching2BinAttrs(edata, room->roomBinAttrExternal(), ptr_bin_attr);
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::SearchRoomResponse_to_SceNpMatching2SearchRoomResponse(event_data& edata, const SearchRoomResponse* resp, SceNpMatching2SearchRoomResponse* search_resp)
|
||||
{
|
||||
search_resp->range.size = resp->size();
|
||||
search_resp->range.startIndex = resp->startIndex();
|
||||
search_resp->range.total = resp->total();
|
||||
|
||||
if (resp->rooms() && resp->rooms()->size() != 0)
|
||||
{
|
||||
SceNpMatching2RoomDataExternal* prev_room = nullptr;
|
||||
for (flatbuffers::uoffset_t i = 0; i < resp->rooms()->size(); i++)
|
||||
{
|
||||
auto* fb_room = resp->rooms()->Get(i);
|
||||
SceNpMatching2RoomDataExternal* cur_room;
|
||||
|
||||
cur_room = (i > 0) ? edata.allocate<SceNpMatching2RoomDataExternal>(sizeof(SceNpMatching2RoomDataExternal), prev_room->next) :
|
||||
edata.allocate<SceNpMatching2RoomDataExternal>(sizeof(SceNpMatching2RoomDataExternal), search_resp->roomDataExternal);
|
||||
|
||||
RoomDataExternal_to_SceNpMatching2RoomDataExternal(edata, fb_room, cur_room);
|
||||
prev_room = cur_room;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::GetRoomDataExternalListResponse_to_SceNpMatching2GetRoomDataExternalListResponse(event_data& edata, const GetRoomDataExternalListResponse* resp, SceNpMatching2GetRoomDataExternalListResponse* get_resp)
|
||||
{
|
||||
get_resp->roomDataExternalNum = resp->rooms() ? resp->rooms()->size() : 0;
|
||||
|
||||
SceNpMatching2RoomDataExternal* prev_room = nullptr;
|
||||
for (std::size_t i = 0; i < get_resp->roomDataExternalNum; i++)
|
||||
{
|
||||
auto* fb_room = resp->rooms()->Get(i);
|
||||
SceNpMatching2RoomDataExternal* cur_room;
|
||||
|
||||
cur_room = (i > 0) ? edata.allocate<SceNpMatching2RoomDataExternal>(sizeof(SceNpMatching2RoomDataExternal), prev_room->next) :
|
||||
edata.allocate<SceNpMatching2RoomDataExternal>(sizeof(SceNpMatching2RoomDataExternal), get_resp->roomDataExternal);
|
||||
|
||||
RoomDataExternal_to_SceNpMatching2RoomDataExternal(edata, fb_room, cur_room);
|
||||
prev_room = cur_room;
|
||||
}
|
||||
}
|
||||
|
||||
u16 np_handler::RoomDataInternal_to_SceNpMatching2RoomDataInternal(event_data& edata, const RoomDataInternal* resp, SceNpMatching2RoomDataInternal* room_info, const SceNpId& npid)
|
||||
{
|
||||
u16 member_id = 0;
|
||||
room_info->serverId = resp->serverId();
|
||||
room_info->worldId = resp->worldId();
|
||||
room_info->lobbyId = resp->lobbyId();
|
||||
room_info->roomId = resp->roomId();
|
||||
room_info->passwordSlotMask = resp->passwordSlotMask();
|
||||
room_info->maxSlot = resp->maxSlot();
|
||||
room_info->memberList.membersNum = resp->memberList()->size();
|
||||
|
||||
if (resp->roomGroup() && resp->roomGroup()->size() != 0)
|
||||
{
|
||||
room_info->roomGroupNum = resp->roomGroup()->size();
|
||||
auto* ptr_groups = edata.allocate<SceNpMatching2RoomGroup>(sizeof(SceNpMatching2RoomGroup) * room_info->roomGroupNum, room_info->roomGroup);
|
||||
RoomGroups_to_SceNpMatching2RoomGroups(resp->roomGroup(), ptr_groups);
|
||||
}
|
||||
|
||||
room_info->memberList.membersNum = static_cast<u32>(resp->memberList()->size());
|
||||
|
||||
SceNpMatching2RoomMemberDataInternal* prev_member = nullptr;
|
||||
for (flatbuffers::uoffset_t i = 0; i < resp->memberList()->size(); i++)
|
||||
{
|
||||
auto fb_member = resp->memberList()->Get(i);
|
||||
SceNpMatching2RoomMemberDataInternal* member_info;
|
||||
|
||||
member_info = (i > 0) ? edata.allocate<SceNpMatching2RoomMemberDataInternal>(sizeof(SceNpMatching2RoomMemberDataInternal), prev_member->next) :
|
||||
edata.allocate<SceNpMatching2RoomMemberDataInternal>(sizeof(SceNpMatching2RoomMemberDataInternal), room_info->memberList.members);
|
||||
|
||||
RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(edata, fb_member, room_info, member_info);
|
||||
|
||||
if (strcmp(member_info->userInfo.npId.handle.data, npid.handle.data) == 0)
|
||||
{
|
||||
room_info->memberList.me = (i > 0) ? prev_member->next : room_info->memberList.members;
|
||||
edata.add_relocation<SceNpMatching2RoomMemberDataInternal>(room_info->memberList.me);
|
||||
member_id = member_info->memberId;
|
||||
}
|
||||
|
||||
if (member_info->memberId == resp->ownerId())
|
||||
{
|
||||
room_info->memberList.owner = (i > 0) ? prev_member->next : room_info->memberList.members;
|
||||
edata.add_relocation<SceNpMatching2RoomMemberDataInternal>(room_info->memberList.owner);
|
||||
}
|
||||
|
||||
prev_member = member_info;
|
||||
}
|
||||
|
||||
room_info->flagAttr = resp->flagAttr();
|
||||
|
||||
if (resp->roomBinAttrInternal() && resp->roomBinAttrInternal()->size() != 0)
|
||||
{
|
||||
room_info->roomBinAttrInternalNum = resp->roomBinAttrInternal()->size();
|
||||
auto* ptr_bin_attr = edata.allocate<SceNpMatching2RoomBinAttrInternal>(sizeof(SceNpMatching2RoomBinAttrInternal) * room_info->roomBinAttrInternalNum, room_info->roomBinAttrInternal);
|
||||
|
||||
for (u32 b_index = 0; b_index < room_info->roomBinAttrInternalNum; b_index++)
|
||||
{
|
||||
auto fb_bin_attr = resp->roomBinAttrInternal()->Get(b_index);
|
||||
ptr_bin_attr[b_index].updateDate.tick = fb_bin_attr->updateDate();
|
||||
ptr_bin_attr[b_index].updateMemberId = fb_bin_attr->updateMemberId();
|
||||
|
||||
ptr_bin_attr[b_index].data.id = fb_bin_attr->data()->id();
|
||||
ptr_bin_attr[b_index].data.size = fb_bin_attr->data()->data()->size();
|
||||
auto* ptr_bin_attr_data = edata.allocate<u8>(ptr_bin_attr[b_index].data.size, ptr_bin_attr[b_index].data.ptr);
|
||||
for (flatbuffers::uoffset_t tmp_index = 0; tmp_index < ptr_bin_attr[b_index].data.size; tmp_index++)
|
||||
{
|
||||
ptr_bin_attr_data[tmp_index] = fb_bin_attr->data()->data()->Get(tmp_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return member_id;
|
||||
}
|
||||
|
||||
void np_handler::RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(event_data& edata, const RoomMemberDataInternal* member_data, const SceNpMatching2RoomDataInternal* room_info, SceNpMatching2RoomMemberDataInternal* sce_member_data)
|
||||
{
|
||||
UserInfo2_to_SceNpUserInfo2(edata, member_data->userInfo(), &sce_member_data->userInfo);
|
||||
sce_member_data->joinDate.tick = member_data->joinDate();
|
||||
sce_member_data->memberId = member_data->memberId();
|
||||
sce_member_data->teamId = member_data->teamId();
|
||||
|
||||
if (const auto* fb_roomgroup = member_data->roomGroup())
|
||||
{
|
||||
if (room_info)
|
||||
{
|
||||
// If we have SceNpMatching2RoomDataInternal available we point the pointers to the group there
|
||||
sce_member_data->roomGroup = room_info->roomGroup + (fb_roomgroup->groupId() - 1);
|
||||
edata.add_relocation<SceNpMatching2RoomGroup>(sce_member_data->roomGroup);
|
||||
}
|
||||
else
|
||||
{
|
||||
search_resp->roomDataExternal = room_info;
|
||||
}
|
||||
|
||||
previous_next = vm::cast(room_info.addr());
|
||||
|
||||
RoomDataExternal_to_SceNpMatching2RoomDataExternal(room, room_info.get_ptr());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
search_resp->roomDataExternal.set(0);
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::GetRoomDataExternalListResponse_to_SceNpMatching2GetRoomDataExternalListResponse(const GetRoomDataExternalListResponse* resp, SceNpMatching2GetRoomDataExternalListResponse* get_resp)
|
||||
{
|
||||
get_resp->roomDataExternalNum = resp->rooms() ? resp->rooms()->size() : 0;
|
||||
get_resp->roomDataExternal.set(0);
|
||||
|
||||
vm::addr_t previous_next = vm::cast<u32>(0);
|
||||
for (std::size_t i = 0; i < get_resp->roomDataExternalNum; i++)
|
||||
{
|
||||
auto* room = resp->rooms()->Get(i);
|
||||
vm::ptr<SceNpMatching2RoomDataExternal> room_info(allocate(sizeof(SceNpMatching2RoomDataExternal)));
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
vm::ptr<SceNpMatching2RoomDataExternal> prev_room(previous_next);
|
||||
prev_room->next.set(room_info.addr());
|
||||
}
|
||||
else
|
||||
{
|
||||
get_resp->roomDataExternal = room_info;
|
||||
}
|
||||
|
||||
previous_next = vm::cast(room_info.addr());
|
||||
|
||||
RoomDataExternal_to_SceNpMatching2RoomDataExternal(room, room_info.get_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
u16 np_handler::RoomDataInternal_to_SceNpMatching2RoomDataInternal(const RoomDataInternal* resp, SceNpMatching2RoomDataInternal* room_info, const SceNpId& npid)
|
||||
{
|
||||
u16 member_id = 0;
|
||||
room_info->serverId = resp->serverId();
|
||||
room_info->worldId = resp->worldId();
|
||||
room_info->lobbyId = resp->lobbyId();
|
||||
room_info->roomId = resp->roomId();
|
||||
room_info->passwordSlotMask = resp->passwordSlotMask();
|
||||
room_info->maxSlot = resp->maxSlot();
|
||||
room_info->memberList.membersNum = resp->memberList()->size();
|
||||
|
||||
if (resp->roomGroup() && resp->roomGroup()->size() != 0)
|
||||
{
|
||||
room_info->roomGroupNum = resp->roomGroup()->size();
|
||||
vm::ptr<SceNpMatching2RoomGroup> group_info(allocate(sizeof(SceNpMatching2RoomGroup) * room_info->roomGroupNum));
|
||||
RoomGroups_to_SceNpMatching2RoomGroup(resp->roomGroup(), group_info);
|
||||
room_info->roomGroup = group_info;
|
||||
}
|
||||
|
||||
vm::ptr<SceNpMatching2RoomMemberDataInternal> prev_member;
|
||||
for (flatbuffers::uoffset_t i = 0; i < resp->memberList()->size(); i++)
|
||||
{
|
||||
auto member = resp->memberList()->Get(i);
|
||||
vm::ptr<SceNpMatching2RoomMemberDataInternal> member_info(allocate(sizeof(SceNpMatching2RoomMemberDataInternal)));
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
prev_member->next = member_info;
|
||||
}
|
||||
else
|
||||
{
|
||||
room_info->memberList.members = member_info;
|
||||
room_info->memberList.membersNum = static_cast<u32>(resp->memberList()->size());
|
||||
}
|
||||
|
||||
prev_member = member_info;
|
||||
RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(member, room_info, member_info.get_ptr());
|
||||
}
|
||||
|
||||
vm::ptr<SceNpMatching2RoomMemberDataInternal> ptr = room_info->memberList.members;
|
||||
while (ptr)
|
||||
{
|
||||
if (strcmp(ptr->userInfo.npId.handle.data, npid.handle.data) == 0)
|
||||
{
|
||||
room_info->memberList.me = ptr;
|
||||
member_id = ptr->memberId;
|
||||
break;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
ptr = room_info->memberList.members;
|
||||
while (ptr)
|
||||
{
|
||||
if (ptr->memberId == resp->ownerId())
|
||||
{
|
||||
room_info->memberList.owner = ptr;
|
||||
break;
|
||||
}
|
||||
ptr = ptr->next;
|
||||
}
|
||||
|
||||
room_info->flagAttr = resp->flagAttr();
|
||||
|
||||
if (resp->roomBinAttrInternal() && resp->roomBinAttrInternal()->size() != 0)
|
||||
{
|
||||
room_info->roomBinAttrInternalNum = resp->roomBinAttrInternal()->size();
|
||||
vm::ptr<SceNpMatching2RoomBinAttrInternal> binattrint_info(allocate(sizeof(SceNpMatching2RoomBinAttrInternal) * room_info->roomBinAttrInternalNum));
|
||||
|
||||
for (u32 b_index = 0; b_index < room_info->roomBinAttrInternalNum; b_index++)
|
||||
{
|
||||
auto battr = resp->roomBinAttrInternal()->Get(b_index);
|
||||
binattrint_info[b_index].updateDate.tick = battr->updateDate();
|
||||
binattrint_info[b_index].updateMemberId = battr->updateMemberId();
|
||||
|
||||
binattrint_info[b_index].data.id = battr->data()->id();
|
||||
binattrint_info[b_index].data.size = battr->data()->data()->size();
|
||||
binattrint_info[b_index].data.ptr = allocate(binattrint_info[b_index].data.size);
|
||||
for (flatbuffers::uoffset_t tmp_index = 0; tmp_index < binattrint_info[b_index].data.size; tmp_index++)
|
||||
{
|
||||
binattrint_info[b_index].data.ptr[tmp_index] = battr->data()->data()->Get(tmp_index);
|
||||
// Otherwise we allocate for it
|
||||
auto* ptr_group = edata.allocate<SceNpMatching2RoomGroup>(sizeof(SceNpMatching2RoomGroup), sce_member_data->roomGroup);
|
||||
RoomGroup_to_SceNpMatching2RoomGroup(fb_roomgroup, ptr_group);
|
||||
}
|
||||
}
|
||||
|
||||
room_info->roomBinAttrInternal = binattrint_info;
|
||||
}
|
||||
sce_member_data->natType = member_data->natType();
|
||||
sce_member_data->flagAttr = member_data->flagAttr();
|
||||
|
||||
return member_id;
|
||||
}
|
||||
|
||||
void np_handler::RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(const RoomMemberDataInternal* member_data, const SceNpMatching2RoomDataInternal* room_info, SceNpMatching2RoomMemberDataInternal* sce_member_data)
|
||||
{
|
||||
UserInfo2_to_SceNpUserInfo2(member_data->userInfo(), &sce_member_data->userInfo);
|
||||
sce_member_data->joinDate.tick = member_data->joinDate();
|
||||
sce_member_data->memberId = member_data->memberId();
|
||||
sce_member_data->teamId = member_data->teamId();
|
||||
|
||||
// Look for id
|
||||
if (member_data->roomGroup() != 0 && room_info)
|
||||
{
|
||||
bool found = false;
|
||||
for (u32 g_index = 0; g_index < room_info->roomGroupNum; g_index++)
|
||||
if (member_data->roomMemberBinAttrInternal() && member_data->roomMemberBinAttrInternal()->size() != 0)
|
||||
{
|
||||
if (room_info->roomGroup[g_index].groupId == member_data->roomGroup())
|
||||
sce_member_data->roomMemberBinAttrInternalNum = member_data->roomMemberBinAttrInternal()->size();
|
||||
auto* sce_binattrs = edata.allocate<SceNpMatching2RoomMemberBinAttrInternal>(sizeof(SceNpMatching2RoomMemberBinAttrInternal) * sce_member_data->roomMemberBinAttrInternalNum, sce_member_data->roomMemberBinAttrInternal);
|
||||
for (u32 b_index = 0; b_index < sce_member_data->roomMemberBinAttrInternalNum; b_index++)
|
||||
{
|
||||
sce_member_data->roomGroup = vm::cast(room_info->roomGroup.addr() + (u32{sizeof(SceNpMatching2RoomGroup)} * g_index));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ensure(found);
|
||||
}
|
||||
const auto fb_battr = member_data->roomMemberBinAttrInternal()->Get(b_index);
|
||||
sce_binattrs[b_index].updateDate.tick = fb_battr->updateDate();
|
||||
|
||||
sce_member_data->natType = member_data->natType();
|
||||
sce_member_data->flagAttr = member_data->flagAttr();
|
||||
|
||||
if (member_data->roomMemberBinAttrInternal() && member_data->roomMemberBinAttrInternal()->size() != 0)
|
||||
{
|
||||
sce_member_data->roomMemberBinAttrInternalNum = member_data->roomMemberBinAttrInternal()->size();
|
||||
vm::ptr<SceNpMatching2RoomMemberBinAttrInternal> binattr_info(allocate(sizeof(SceNpMatching2RoomMemberBinAttrInternal) * sce_member_data->roomMemberBinAttrInternalNum));
|
||||
for (u32 b_index = 0; b_index < sce_member_data->roomMemberBinAttrInternalNum; b_index++)
|
||||
{
|
||||
const auto battr = member_data->roomMemberBinAttrInternal()->Get(b_index);
|
||||
binattr_info[b_index].updateDate.tick = battr->updateDate();
|
||||
|
||||
binattr_info[b_index].data.id = battr->data()->id();
|
||||
binattr_info[b_index].data.size = battr->data()->data()->size();
|
||||
binattr_info[b_index].data.ptr = allocate(binattr_info[b_index].data.size);
|
||||
for (flatbuffers::uoffset_t tmp_index = 0; tmp_index < binattr_info[b_index].data.size; tmp_index++)
|
||||
{
|
||||
binattr_info[b_index].data.ptr[tmp_index] = battr->data()->data()->Get(tmp_index);
|
||||
}
|
||||
}
|
||||
sce_member_data->roomMemberBinAttrInternal = binattr_info;
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(const RoomMemberUpdateInfo* update_info, SceNpMatching2RoomMemberUpdateInfo* sce_update_info)
|
||||
{
|
||||
sce_update_info->eventCause = 0;
|
||||
if (update_info->optData())
|
||||
{
|
||||
sce_update_info->optData.length = update_info->optData()->data()->size();
|
||||
for (usz i = 0; i < 16; i++)
|
||||
{
|
||||
sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (update_info->roomMemberDataInternal())
|
||||
{
|
||||
auto member = update_info->roomMemberDataInternal();
|
||||
vm::ptr<SceNpMatching2RoomMemberDataInternal> member_info(allocate(sizeof(SceNpMatching2RoomMemberDataInternal)));
|
||||
sce_update_info->roomMemberDataInternal = member_info;
|
||||
|
||||
// TODO: Pass room_info
|
||||
RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(member, nullptr, member_info.get_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomUpdateInfo_to_SceNpMatching2RoomUpdateInfo(const RoomUpdateInfo* update_info, SceNpMatching2RoomUpdateInfo* sce_update_info)
|
||||
{
|
||||
sce_update_info->errorCode = 0;
|
||||
sce_update_info->eventCause = 0;
|
||||
if (update_info->optData())
|
||||
{
|
||||
sce_update_info->optData.length = update_info->optData()->data()->size();
|
||||
for (usz i = 0; i < 16; i++)
|
||||
{
|
||||
sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomDataInternalUpdateInfo_to_SceNpMatching2RoomDataInternalUpdateInfo(const RoomDataInternalUpdateInfo* update_info, SceNpMatching2RoomDataInternalUpdateInfo* sce_update_info, const SceNpId& npid)
|
||||
{
|
||||
vm::ptr<SceNpMatching2RoomDataInternal> room_data(allocate(sizeof(SceNpMatching2RoomDataInternal)));
|
||||
sce_update_info->newRoomDataInternal = room_data;
|
||||
RoomDataInternal_to_SceNpMatching2RoomDataInternal(update_info->newRoomDataInternal(), sce_update_info->newRoomDataInternal.get_ptr(), npid);
|
||||
|
||||
if (sce_update_info->newRoomDataInternal->flagAttr != update_info->prevFlagAttr())
|
||||
{
|
||||
sce_update_info->newFlagAttr = sce_update_info->newRoomDataInternal.ptr(&SceNpMatching2RoomDataInternal::flagAttr);
|
||||
|
||||
vm::ptr<SceNpMatching2FlagAttr> prev_flag_attr(allocate(sizeof(SceNpMatching2FlagAttr)));
|
||||
*prev_flag_attr = update_info->prevFlagAttr();
|
||||
sce_update_info->prevFlagAttr = prev_flag_attr;
|
||||
}
|
||||
|
||||
if (sce_update_info->newRoomDataInternal->passwordSlotMask != update_info->prevRoomPasswordSlotMask())
|
||||
{
|
||||
sce_update_info->newRoomPasswordSlotMask = sce_update_info->newRoomDataInternal.ptr(&SceNpMatching2RoomDataInternal::passwordSlotMask);
|
||||
|
||||
vm::ptr<SceNpMatching2RoomPasswordSlotMask> prev_room_password_slot_mask(allocate(sizeof(SceNpMatching2RoomPasswordSlotMask)));
|
||||
*prev_room_password_slot_mask = update_info->prevRoomPasswordSlotMask();
|
||||
sce_update_info->prevRoomPasswordSlotMask = prev_room_password_slot_mask;
|
||||
}
|
||||
|
||||
if (update_info->newRoomGroup() && update_info->newRoomGroup()->size() != 0)
|
||||
{
|
||||
rpcn_log.todo("RoomDataInternalUpdateInfo::newRoomGroup");
|
||||
// TODO
|
||||
//sce_update_info->newRoomGroupNum = update_info->newRoomGroup()->size();
|
||||
//vm::ptr<SceNpMatching2RoomGroup> group_info(allocate(sizeof(SceNpMatching2RoomGroup) * sce_update_info->newRoomGroupNum));
|
||||
//RoomGroups_to_SceNpMatching2RoomGroup(update_info->newRoomGroup(), group_info);
|
||||
//sce_update_info->newRoomGroup = group_info;
|
||||
}
|
||||
|
||||
if (update_info->newRoomBinAttrInternal() && update_info->newRoomBinAttrInternal()->size() != 0)
|
||||
{
|
||||
const auto get_ptr_for_binattr = [&](u16 binattr_id) -> vm::ptr<SceNpMatching2RoomBinAttrInternal> {
|
||||
vm::ptr<SceNpMatching2RoomBinAttrInternal> ret_ptr = sce_update_info->newRoomDataInternal->roomBinAttrInternal;
|
||||
while (ret_ptr->data.id != binattr_id)
|
||||
{
|
||||
ret_ptr++;
|
||||
}
|
||||
return ret_ptr;
|
||||
};
|
||||
|
||||
sce_update_info->newRoomBinAttrInternalNum = update_info->newRoomBinAttrInternal()->size();
|
||||
vm::bpptr<SceNpMatching2RoomBinAttrInternal> binattr_info_array(allocate(4 * sce_update_info->newRoomBinAttrInternalNum));
|
||||
for (uint i = 0; i < sce_update_info->newRoomBinAttrInternalNum; ++i)
|
||||
{
|
||||
binattr_info_array[i] = get_ptr_for_binattr(update_info->newRoomBinAttrInternal()->Get(i));
|
||||
}
|
||||
sce_update_info->newRoomBinAttrInternal = binattr_info_array;
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo(const RoomMemberDataInternalUpdateInfo* update_info, SceNpMatching2RoomMemberDataInternalUpdateInfo* sce_update_info)
|
||||
{
|
||||
vm::ptr<SceNpMatching2RoomMemberDataInternal> room_member_data(allocate(sizeof(SceNpMatching2RoomMemberDataInternal)));
|
||||
sce_update_info->newRoomMemberDataInternal = room_member_data;
|
||||
RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(update_info->newRoomMemberDataInternal(), nullptr, sce_update_info->newRoomMemberDataInternal.get_ptr());
|
||||
|
||||
if (sce_update_info->newRoomMemberDataInternal->flagAttr != update_info->prevFlagAttr())
|
||||
{
|
||||
sce_update_info->newFlagAttr = sce_update_info->newRoomMemberDataInternal.ptr(&SceNpMatching2RoomMemberDataInternal::flagAttr);
|
||||
|
||||
vm::ptr<SceNpMatching2FlagAttr> prev_flag_attr(allocate(sizeof(SceNpMatching2FlagAttr)));
|
||||
*prev_flag_attr = update_info->prevFlagAttr();
|
||||
sce_update_info->prevFlagAttr = prev_flag_attr;
|
||||
}
|
||||
|
||||
if (sce_update_info->newRoomMemberDataInternal->teamId != update_info->prevTeamId())
|
||||
{
|
||||
sce_update_info->newTeamId = sce_update_info->newRoomMemberDataInternal.ptr(&SceNpMatching2RoomMemberDataInternal::teamId);
|
||||
}
|
||||
|
||||
if (update_info->newRoomMemberBinAttrInternal() && update_info->newRoomMemberBinAttrInternal()->size() != 0)
|
||||
{
|
||||
sce_update_info->newRoomMemberBinAttrInternalNum = update_info->newRoomMemberBinAttrInternal()->size();
|
||||
vm::bpptr<SceNpMatching2RoomMemberBinAttrInternal> binattr_info_array(allocate(4 * sce_update_info->newRoomMemberBinAttrInternalNum));
|
||||
|
||||
auto get_binattr_vmptr = [&](u16 wanted_id) -> vm::ptr<SceNpMatching2RoomMemberBinAttrInternal> {
|
||||
for (u32 i = 0; i < sce_update_info->newRoomMemberDataInternal->roomMemberBinAttrInternalNum; i++)
|
||||
{
|
||||
if (sce_update_info->newRoomMemberDataInternal->roomMemberBinAttrInternal[i].data.id == wanted_id)
|
||||
sce_binattrs[b_index].data.id = fb_battr->data()->id();
|
||||
sce_binattrs[b_index].data.size = fb_battr->data()->data()->size();
|
||||
auto* sce_binattr_data = edata.allocate<u8>(sce_binattrs[b_index].data.size, sce_binattrs[b_index].data.ptr);
|
||||
for (flatbuffers::uoffset_t tmp_index = 0; tmp_index < sce_binattrs[b_index].data.size; tmp_index++)
|
||||
{
|
||||
return sce_update_info->newRoomMemberDataInternal->roomMemberBinAttrInternal + i;
|
||||
sce_binattr_data[tmp_index] = fb_battr->data()->data()->Get(tmp_index);
|
||||
}
|
||||
}
|
||||
|
||||
rpcn_log.fatal("RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo: Invalid data from server!");
|
||||
return vm::null;
|
||||
};
|
||||
|
||||
for (uint i = 0; i < sce_update_info->newRoomMemberBinAttrInternalNum; ++i)
|
||||
{
|
||||
binattr_info_array[i] = get_binattr_vmptr(update_info->newRoomMemberBinAttrInternal()->Get(i));
|
||||
}
|
||||
sce_update_info->newRoomMemberBinAttrInternal = binattr_info_array;
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::GetPingInfoResponse_to_SceNpMatching2SignalingGetPingInfoResponse(const GetPingInfoResponse* resp, SceNpMatching2SignalingGetPingInfoResponse* sce_resp)
|
||||
{
|
||||
sce_resp->serverId = resp->serverId();
|
||||
sce_resp->worldId = resp->worldId();
|
||||
sce_resp->roomId = resp->roomId();
|
||||
sce_resp->rtt = resp->rtt();
|
||||
}
|
||||
|
||||
void np_handler::RoomMessageInfo_to_SceNpMatching2RoomMessageInfo(const RoomMessageInfo* mi, SceNpMatching2RoomMessageInfo* sce_mi)
|
||||
{
|
||||
sce_mi->filtered = mi->filtered();
|
||||
sce_mi->castType = mi->castType();
|
||||
|
||||
if (sce_mi->castType != SCE_NP_MATCHING2_CASTTYPE_BROADCAST)
|
||||
{
|
||||
vm::ptr<SceNpMatching2RoomMessageDestination> dst_info(allocate(sizeof(SceNpMatching2RoomMessageDestination)));
|
||||
sce_mi->dst = dst_info;
|
||||
}
|
||||
|
||||
switch (sce_mi->castType)
|
||||
void np_handler::RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(event_data& edata, const RoomMemberUpdateInfo* update_info, SceNpMatching2RoomMemberUpdateInfo* sce_update_info)
|
||||
{
|
||||
case SCE_NP_MATCHING2_CASTTYPE_BROADCAST: break;
|
||||
case SCE_NP_MATCHING2_CASTTYPE_UNICAST: sce_mi->dst->unicastTarget = mi->dst()->Get(0); break;
|
||||
case SCE_NP_MATCHING2_CASTTYPE_MULTICAST:
|
||||
{
|
||||
sce_mi->dst->multicastTarget.memberIdNum = mi->dst()->size();
|
||||
vm::ptr<be_t<u16>> member_list(allocate(sizeof(u16) * mi->dst()->size()));
|
||||
sce_mi->dst->multicastTarget.memberId = member_list;
|
||||
for (u32 i = 0; i < mi->dst()->size(); i++)
|
||||
sce_update_info->eventCause = 0;
|
||||
if (update_info->optData())
|
||||
{
|
||||
sce_mi->dst->multicastTarget.memberId[i] = mi->dst()->Get(i);
|
||||
sce_update_info->optData.length = update_info->optData()->data()->size();
|
||||
for (usz i = 0; i < 16; i++)
|
||||
{
|
||||
sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCE_NP_MATCHING2_CASTTYPE_MULTICAST_TEAM: sce_mi->dst->multicastTargetTeamId = mi->dst()->Get(0); break;
|
||||
default: ensure(false);
|
||||
}
|
||||
|
||||
if (auto src_member = mi->srcMember())
|
||||
{
|
||||
vm::ptr<SceNpUserInfo2> src_info(allocate(sizeof(SceNpUserInfo2)));
|
||||
UserInfo2_to_SceNpUserInfo2(src_member, src_info.get_ptr());
|
||||
sce_mi->srcMember = src_info;
|
||||
}
|
||||
|
||||
if (auto msg = mi->msg())
|
||||
{
|
||||
sce_mi->msgLen = msg->size();
|
||||
vm::ptr<u8> msg_data(allocate(msg->size()));
|
||||
for (u32 i = 0; i < msg->size(); i++)
|
||||
if (update_info->roomMemberDataInternal())
|
||||
{
|
||||
msg_data[i] = msg->Get(i);
|
||||
auto fb_member = update_info->roomMemberDataInternal();
|
||||
auto* ptr_roomemberinternal = edata.allocate<SceNpMatching2RoomMemberDataInternal>(sizeof(SceNpMatching2RoomMemberDataInternal), sce_update_info->roomMemberDataInternal);
|
||||
|
||||
// TODO: Pass room_info
|
||||
RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(edata, fb_member, nullptr, ptr_roomemberinternal);
|
||||
}
|
||||
sce_mi->msg = msg_data;
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomUpdateInfo_to_SceNpMatching2RoomUpdateInfo(const RoomUpdateInfo* update_info, SceNpMatching2RoomUpdateInfo* sce_update_info)
|
||||
{
|
||||
sce_update_info->errorCode = 0;
|
||||
sce_update_info->eventCause = 0;
|
||||
if (update_info->optData())
|
||||
{
|
||||
sce_update_info->optData.length = update_info->optData()->data()->size();
|
||||
for (usz i = 0; i < 16; i++)
|
||||
{
|
||||
sce_update_info->optData.data[i] = update_info->optData()->data()->Get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomDataInternalUpdateInfo_to_SceNpMatching2RoomDataInternalUpdateInfo(event_data& edata, const RoomDataInternalUpdateInfo* update_info, SceNpMatching2RoomDataInternalUpdateInfo* sce_update_info, const SceNpId& npid)
|
||||
{
|
||||
auto* sce_room_data = edata.allocate<SceNpMatching2RoomDataInternal>(sizeof(SceNpMatching2RoomDataInternal), sce_update_info->newRoomDataInternal);
|
||||
RoomDataInternal_to_SceNpMatching2RoomDataInternal(edata, update_info->newRoomDataInternal(), sce_room_data, npid);
|
||||
|
||||
if (sce_room_data->flagAttr != update_info->prevFlagAttr())
|
||||
{
|
||||
sce_update_info->newFlagAttr = sce_update_info->newRoomDataInternal.ptr(&SceNpMatching2RoomDataInternal::flagAttr);
|
||||
edata.add_relocation<u32>(sce_update_info->newFlagAttr);
|
||||
auto* ptr_sce_prevflag = edata.allocate<SceNpMatching2FlagAttr>(sizeof(SceNpMatching2FlagAttr), sce_update_info->prevFlagAttr);
|
||||
*ptr_sce_prevflag = update_info->prevFlagAttr();
|
||||
}
|
||||
|
||||
if (sce_room_data->passwordSlotMask != update_info->prevRoomPasswordSlotMask())
|
||||
{
|
||||
sce_update_info->newRoomPasswordSlotMask = sce_update_info->newRoomDataInternal.ptr(&SceNpMatching2RoomDataInternal::passwordSlotMask);
|
||||
edata.add_relocation<u64>(sce_update_info->newRoomPasswordSlotMask);
|
||||
auto* ptr_sce_prevpass = edata.allocate<SceNpMatching2RoomPasswordSlotMask>(sizeof(SceNpMatching2RoomPasswordSlotMask), sce_update_info->prevRoomPasswordSlotMask);
|
||||
*ptr_sce_prevpass = update_info->prevRoomPasswordSlotMask();
|
||||
}
|
||||
|
||||
if (update_info->newRoomGroup() && update_info->newRoomGroup()->size() != 0)
|
||||
{
|
||||
rpcn_log.todo("RoomDataInternalUpdateInfo::newRoomGroup");
|
||||
// TODO
|
||||
//sce_update_info->newRoomGroupNum = update_info->newRoomGroup()->size();
|
||||
//vm::ptr<SceNpMatching2RoomGroup> group_info(allocate(sizeof(SceNpMatching2RoomGroup) * sce_update_info->newRoomGroupNum));
|
||||
//RoomGroups_to_SceNpMatching2RoomGroup(update_info->newRoomGroup(), group_info);
|
||||
//sce_update_info->newRoomGroup = group_info;
|
||||
}
|
||||
|
||||
if (update_info->newRoomBinAttrInternal() && update_info->newRoomBinAttrInternal()->size() != 0)
|
||||
{
|
||||
const auto get_ptr_for_binattr = [&](u16 binattr_id) -> vm::bptr<SceNpMatching2RoomBinAttrInternal>
|
||||
{
|
||||
vm::bptr<SceNpMatching2RoomBinAttrInternal> ret_ptr = sce_room_data->roomBinAttrInternal;
|
||||
for (u32 i = 0; i < sce_room_data->roomBinAttrInternalNum; i++)
|
||||
{
|
||||
if (ret_ptr->data.id == binattr_id)
|
||||
return ret_ptr;
|
||||
|
||||
ret_ptr++;
|
||||
}
|
||||
rpcn_log.fatal("RoomDataInternalUpdateInfo_to_SceNpMatching2RoomDataInternalUpdateInfo: Couldn't find matching roomBinAttrInternal!");
|
||||
return vm::null;
|
||||
};
|
||||
|
||||
sce_update_info->newRoomBinAttrInternalNum = update_info->newRoomBinAttrInternal()->size();
|
||||
edata.allocate_ptr_array<SceNpMatching2RoomBinAttrInternal>(sce_update_info->newRoomBinAttrInternalNum, sce_update_info->newRoomBinAttrInternal);
|
||||
for (u32 i = 0; i < sce_update_info->newRoomBinAttrInternalNum; i++)
|
||||
{
|
||||
sce_update_info->newRoomBinAttrInternal[i] = get_ptr_for_binattr(update_info->newRoomBinAttrInternal()->Get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo(event_data &edata, const RoomMemberDataInternalUpdateInfo* update_info, SceNpMatching2RoomMemberDataInternalUpdateInfo* sce_update_info)
|
||||
{
|
||||
auto* sce_room_member_data = edata.allocate<SceNpMatching2RoomMemberDataInternal>(sizeof(SceNpMatching2RoomMemberDataInternal), sce_update_info->newRoomMemberDataInternal);
|
||||
RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(edata, update_info->newRoomMemberDataInternal(), nullptr, sce_room_member_data);
|
||||
|
||||
if (sce_update_info->newRoomMemberDataInternal->flagAttr != update_info->prevFlagAttr())
|
||||
{
|
||||
sce_update_info->newFlagAttr = sce_update_info->newRoomMemberDataInternal.ptr(&SceNpMatching2RoomMemberDataInternal::flagAttr);
|
||||
edata.add_relocation<u32>(sce_update_info->newFlagAttr);
|
||||
auto* ptr_sce_prevflag = edata.allocate<SceNpMatching2FlagAttr>(sizeof(SceNpMatching2FlagAttr), sce_update_info->prevFlagAttr);
|
||||
*ptr_sce_prevflag = update_info->prevFlagAttr();
|
||||
}
|
||||
|
||||
if (sce_update_info->newRoomMemberDataInternal->teamId != update_info->prevTeamId())
|
||||
{
|
||||
sce_update_info->newTeamId = sce_update_info->newRoomMemberDataInternal.ptr(&SceNpMatching2RoomMemberDataInternal::teamId);
|
||||
edata.add_relocation<u8>(sce_update_info->newTeamId);
|
||||
}
|
||||
|
||||
if (update_info->newRoomMemberBinAttrInternal() && update_info->newRoomMemberBinAttrInternal()->size() != 0)
|
||||
{
|
||||
const auto get_ptr_for_binattr = [&](u16 binattr_id) -> vm::bptr<SceNpMatching2RoomMemberBinAttrInternal>
|
||||
{
|
||||
vm::bptr<SceNpMatching2RoomMemberBinAttrInternal> ret_ptr = sce_room_member_data->roomMemberBinAttrInternal;
|
||||
for (u32 i = 0; i < sce_room_member_data->roomMemberBinAttrInternalNum; i++)
|
||||
{
|
||||
if (ret_ptr->data.id == binattr_id)
|
||||
return ret_ptr;
|
||||
|
||||
ret_ptr++;
|
||||
}
|
||||
rpcn_log.fatal("RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo: Couldn't find matching roomMemberBinAttrInternal!");
|
||||
return vm::null;
|
||||
};
|
||||
|
||||
sce_update_info->newRoomMemberBinAttrInternalNum = update_info->newRoomMemberBinAttrInternal()->size();
|
||||
edata.allocate_ptr_array<SceNpMatching2RoomMemberBinAttrInternal>(sce_update_info->newRoomMemberBinAttrInternalNum, sce_update_info->newRoomMemberBinAttrInternal);
|
||||
for (u32 i = 0; i < sce_update_info->newRoomMemberBinAttrInternalNum; i++)
|
||||
{
|
||||
sce_update_info->newRoomMemberBinAttrInternal[i] = get_ptr_for_binattr(update_info->newRoomMemberBinAttrInternal()->Get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::GetPingInfoResponse_to_SceNpMatching2SignalingGetPingInfoResponse(const GetPingInfoResponse* resp, SceNpMatching2SignalingGetPingInfoResponse* sce_resp)
|
||||
{
|
||||
sce_resp->serverId = resp->serverId();
|
||||
sce_resp->worldId = resp->worldId();
|
||||
sce_resp->roomId = resp->roomId();
|
||||
sce_resp->rtt = resp->rtt();
|
||||
}
|
||||
|
||||
void np_handler::RoomMessageInfo_to_SceNpMatching2RoomMessageInfo(event_data& edata, const RoomMessageInfo* mi, SceNpMatching2RoomMessageInfo* sce_mi)
|
||||
{
|
||||
sce_mi->filtered = mi->filtered();
|
||||
sce_mi->castType = mi->castType();
|
||||
|
||||
if (sce_mi->castType != SCE_NP_MATCHING2_CASTTYPE_BROADCAST)
|
||||
{
|
||||
edata.allocate<SceNpMatching2RoomMessageDestination>(sizeof(SceNpMatching2RoomMessageDestination), sce_mi->dst);
|
||||
}
|
||||
|
||||
switch (sce_mi->castType)
|
||||
{
|
||||
case SCE_NP_MATCHING2_CASTTYPE_BROADCAST: break;
|
||||
case SCE_NP_MATCHING2_CASTTYPE_UNICAST: sce_mi->dst->unicastTarget = mi->dst()->Get(0); break;
|
||||
case SCE_NP_MATCHING2_CASTTYPE_MULTICAST:
|
||||
{
|
||||
sce_mi->dst->multicastTarget.memberIdNum = mi->dst()->size();
|
||||
edata.allocate<u16>(sizeof(u16) * mi->dst()->size(), sce_mi->dst->multicastTarget.memberId);
|
||||
for (u32 i = 0; i < mi->dst()->size(); i++)
|
||||
{
|
||||
sce_mi->dst->multicastTarget.memberId[i] = mi->dst()->Get(i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SCE_NP_MATCHING2_CASTTYPE_MULTICAST_TEAM: sce_mi->dst->multicastTargetTeamId = mi->dst()->Get(0); break;
|
||||
default: ensure(false);
|
||||
}
|
||||
|
||||
if (auto src_member = mi->srcMember())
|
||||
{
|
||||
auto* ptr_sce_userinfo = edata.allocate<SceNpUserInfo2>(sizeof(SceNpUserInfo2), sce_mi->srcMember);
|
||||
UserInfo2_to_SceNpUserInfo2(edata, src_member, ptr_sce_userinfo);
|
||||
}
|
||||
|
||||
if (auto msg = mi->msg())
|
||||
{
|
||||
sce_mi->msgLen = msg->size();
|
||||
auto* ptr_msg_data = static_cast<u8 *>(edata.allocate<void>(msg->size(), sce_mi->msg));
|
||||
for (u32 i = 0; i < msg->size(); i++)
|
||||
{
|
||||
ptr_msg_data[i] = msg->Get(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace np
|
||||
|
@ -43,7 +43,7 @@ table RoomMemberDataInternal {
|
||||
joinDate:uint64;
|
||||
memberId:uint16;
|
||||
teamId:uint8;
|
||||
roomGroup:uint8;
|
||||
roomGroup:RoomGroup;
|
||||
natType:uint8;
|
||||
flagAttr:uint32;
|
||||
roomMemberBinAttrInternal:[RoomMemberBinAttrInternal];
|
||||
|
@ -590,8 +590,8 @@ struct RoomMemberDataInternal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tab
|
||||
uint8_t teamId() const {
|
||||
return GetField<uint8_t>(VT_TEAMID, 0);
|
||||
}
|
||||
uint8_t roomGroup() const {
|
||||
return GetField<uint8_t>(VT_ROOMGROUP, 0);
|
||||
const RoomGroup *roomGroup() const {
|
||||
return GetPointer<const RoomGroup *>(VT_ROOMGROUP);
|
||||
}
|
||||
uint8_t natType() const {
|
||||
return GetField<uint8_t>(VT_NATTYPE, 0);
|
||||
@ -609,7 +609,8 @@ struct RoomMemberDataInternal FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tab
|
||||
VerifyField<uint64_t>(verifier, VT_JOINDATE) &&
|
||||
VerifyField<uint16_t>(verifier, VT_MEMBERID) &&
|
||||
VerifyField<uint8_t>(verifier, VT_TEAMID) &&
|
||||
VerifyField<uint8_t>(verifier, VT_ROOMGROUP) &&
|
||||
VerifyOffset(verifier, VT_ROOMGROUP) &&
|
||||
verifier.VerifyTable(roomGroup()) &&
|
||||
VerifyField<uint8_t>(verifier, VT_NATTYPE) &&
|
||||
VerifyField<uint32_t>(verifier, VT_FLAGATTR) &&
|
||||
VerifyOffset(verifier, VT_ROOMMEMBERBINATTRINTERNAL) &&
|
||||
@ -635,8 +636,8 @@ struct RoomMemberDataInternalBuilder {
|
||||
void add_teamId(uint8_t teamId) {
|
||||
fbb_.AddElement<uint8_t>(RoomMemberDataInternal::VT_TEAMID, teamId, 0);
|
||||
}
|
||||
void add_roomGroup(uint8_t roomGroup) {
|
||||
fbb_.AddElement<uint8_t>(RoomMemberDataInternal::VT_ROOMGROUP, roomGroup, 0);
|
||||
void add_roomGroup(flatbuffers::Offset<RoomGroup> roomGroup) {
|
||||
fbb_.AddOffset(RoomMemberDataInternal::VT_ROOMGROUP, roomGroup);
|
||||
}
|
||||
void add_natType(uint8_t natType) {
|
||||
fbb_.AddElement<uint8_t>(RoomMemberDataInternal::VT_NATTYPE, natType, 0);
|
||||
@ -664,7 +665,7 @@ inline flatbuffers::Offset<RoomMemberDataInternal> CreateRoomMemberDataInternal(
|
||||
uint64_t joinDate = 0,
|
||||
uint16_t memberId = 0,
|
||||
uint8_t teamId = 0,
|
||||
uint8_t roomGroup = 0,
|
||||
flatbuffers::Offset<RoomGroup> roomGroup = 0,
|
||||
uint8_t natType = 0,
|
||||
uint32_t flagAttr = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<RoomMemberBinAttrInternal>>> roomMemberBinAttrInternal = 0) {
|
||||
@ -672,10 +673,10 @@ inline flatbuffers::Offset<RoomMemberDataInternal> CreateRoomMemberDataInternal(
|
||||
builder_.add_joinDate(joinDate);
|
||||
builder_.add_roomMemberBinAttrInternal(roomMemberBinAttrInternal);
|
||||
builder_.add_flagAttr(flagAttr);
|
||||
builder_.add_roomGroup(roomGroup);
|
||||
builder_.add_userInfo(userInfo);
|
||||
builder_.add_memberId(memberId);
|
||||
builder_.add_natType(natType);
|
||||
builder_.add_roomGroup(roomGroup);
|
||||
builder_.add_teamId(teamId);
|
||||
return builder_.Finish();
|
||||
}
|
||||
@ -686,7 +687,7 @@ inline flatbuffers::Offset<RoomMemberDataInternal> CreateRoomMemberDataInternalD
|
||||
uint64_t joinDate = 0,
|
||||
uint16_t memberId = 0,
|
||||
uint8_t teamId = 0,
|
||||
uint8_t roomGroup = 0,
|
||||
flatbuffers::Offset<RoomGroup> roomGroup = 0,
|
||||
uint8_t natType = 0,
|
||||
uint32_t flagAttr = 0,
|
||||
const std::vector<flatbuffers::Offset<RoomMemberBinAttrInternal>> *roomMemberBinAttrInternal = nullptr) {
|
||||
|
119
rpcs3/Emu/NP/np_allocator.h
Normal file
119
rpcs3/Emu/NP/np_allocator.h
Normal file
@ -0,0 +1,119 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "Emu/Memory/vm_ptr.h"
|
||||
#include "Utilities/mutex.h"
|
||||
#include "util/asm.hpp"
|
||||
#include "util/logs.hpp"
|
||||
|
||||
LOG_CHANNEL(np_mem_allocator);
|
||||
|
||||
namespace np
|
||||
{
|
||||
class memory_allocator
|
||||
{
|
||||
public:
|
||||
memory_allocator() = default;
|
||||
memory_allocator(const memory_allocator&) = delete;
|
||||
memory_allocator& operator=(const memory_allocator&) = delete;
|
||||
|
||||
void setup(vm::ptr<void> ptr_pool, u32 size)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
m_pool = ptr_pool;
|
||||
m_size = size;
|
||||
m_avail = size;
|
||||
m_allocs.clear();
|
||||
}
|
||||
|
||||
void release()
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
m_pool = vm::null;
|
||||
m_size = 0;
|
||||
m_avail = 0;
|
||||
m_allocs.clear();
|
||||
}
|
||||
|
||||
u32 allocate(u32 size)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
if (!size)
|
||||
{
|
||||
np_mem_allocator.error("Can't allocate 0 size buffer!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Align allocs
|
||||
const u32 alloc_size = utils::align(size, 4);
|
||||
if (alloc_size > m_avail)
|
||||
{
|
||||
np_mem_allocator.error("Not enough memory available in NP pool!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 last_free = 0;
|
||||
bool found_space = false;
|
||||
|
||||
for (auto& a : m_allocs)
|
||||
{
|
||||
if ((a.first - last_free) >= alloc_size)
|
||||
{
|
||||
found_space = true;
|
||||
break;
|
||||
}
|
||||
|
||||
last_free = a.first + a.second;
|
||||
}
|
||||
|
||||
if (!found_space)
|
||||
{
|
||||
if ((m_size - last_free) < alloc_size)
|
||||
{
|
||||
np_mem_allocator.error("Not enough memory available in NP pool(continuous block)!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
m_allocs.emplace(last_free, alloc_size);
|
||||
m_avail -= alloc_size;
|
||||
|
||||
memset((static_cast<u8*>(m_pool.get_ptr())) + last_free, 0, alloc_size);
|
||||
|
||||
np_mem_allocator.trace("Allocation off:%d size:%d psize:%d, pavail:%d", last_free, alloc_size, m_size, m_avail);
|
||||
|
||||
return m_pool.addr() + last_free;
|
||||
}
|
||||
|
||||
void free(u32 addr)
|
||||
{
|
||||
ensure(addr >= m_pool.addr() && addr < (m_pool.addr() + m_size), "memory_allocator::free: addr is out of bounds!");
|
||||
|
||||
const u32 offset = addr - m_pool.addr();
|
||||
ensure(m_allocs.contains(offset), "memory_allocator::free: m_allocs doesn't contain the allocation!");
|
||||
|
||||
m_allocs.erase(offset);
|
||||
}
|
||||
|
||||
void shrink_allocation(u32 addr, u32 new_size)
|
||||
{
|
||||
std::lock_guard lock(m_mutex);
|
||||
|
||||
ensure(addr >= m_pool.addr() && addr < (m_pool.addr() + m_size), "memory_allocator::reduce_allocation: addr is out of bounds!");
|
||||
|
||||
const u32 offset = addr - m_pool.addr();
|
||||
ensure(m_allocs.contains(offset), "memory_allocator::reduce_allocation: m_allocs doesn't contain the allocation!");
|
||||
ensure(m_allocs[offset] >= new_size, "memory_allocator::reduce_allocation: New size is bigger than current allocation!");
|
||||
|
||||
m_allocs[offset] = new_size;
|
||||
}
|
||||
|
||||
private:
|
||||
shared_mutex m_mutex;
|
||||
vm::ptr<void> m_pool{};
|
||||
u32 m_size = 0;
|
||||
u32 m_avail = 0;
|
||||
std::map<u32, u32> m_allocs{}; // offset/size
|
||||
};
|
||||
} // namespace np
|
106
rpcs3/Emu/NP/np_event_data.h
Normal file
106
rpcs3/Emu/NP/np_event_data.h
Normal file
@ -0,0 +1,106 @@
|
||||
#pragma once
|
||||
|
||||
#include "Emu/Memory/vm_ptr.h"
|
||||
#include "util/asm.hpp"
|
||||
|
||||
namespace np
|
||||
{
|
||||
class event_data
|
||||
{
|
||||
public:
|
||||
event_data(u32 vm_addr, u32 initial_size, u32 max_size)
|
||||
: m_max_size(max_size), m_cur_size(utils::align(initial_size, 4))
|
||||
{
|
||||
m_data_ptr.set(vm_addr);
|
||||
}
|
||||
|
||||
u8* data()
|
||||
{
|
||||
return m_data_ptr.get_ptr();
|
||||
}
|
||||
|
||||
const u8* data() const
|
||||
{
|
||||
return m_data_ptr.get_ptr();
|
||||
}
|
||||
|
||||
u32 size() const
|
||||
{
|
||||
return m_cur_size;
|
||||
}
|
||||
|
||||
u32 addr() const
|
||||
{
|
||||
return m_data_ptr.addr();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void add_relocation(vm::bptr<T>& dest)
|
||||
{
|
||||
u8* dest_ptr = reinterpret_cast<u8*>(&dest);
|
||||
ensure(dest_ptr >= m_data_ptr.get_ptr() && dest_ptr < (m_data_ptr.get_ptr() + m_cur_size), "event_data::allocate: dest is out of bounds!");
|
||||
|
||||
m_relocs.push_back(static_cast<u32>(dest_ptr - m_data_ptr.get_ptr()));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* allocate(u32 size, vm::bptr<T>& dest)
|
||||
{
|
||||
const u32 to_alloc = utils::align(size, 4);
|
||||
ensure((m_cur_size + to_alloc) <= m_max_size, "event_data::allocate: size would overflow the allocated buffer!");
|
||||
|
||||
u8* dest_ptr = reinterpret_cast<u8*>(&dest);
|
||||
ensure(dest_ptr >= m_data_ptr.get_ptr() && dest_ptr < (m_data_ptr.get_ptr() + m_cur_size), "event_data::allocate: dest is out of bounds!");
|
||||
|
||||
const u32 offset_alloc = m_cur_size;
|
||||
|
||||
// Set the vm::bptr to new allocated portion of memory
|
||||
dest.set(m_data_ptr.addr() + offset_alloc);
|
||||
// Save the relocation offset
|
||||
m_relocs.push_back(static_cast<u32>(dest_ptr - m_data_ptr.get_ptr()));
|
||||
// Update currently allocated space
|
||||
m_cur_size += to_alloc;
|
||||
// Return actual pointer to allocated
|
||||
return reinterpret_cast<T*>(m_data_ptr.get_ptr() + offset_alloc);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void allocate_ptr_array(u32 num_pointers, vm::bpptr<T>& dest)
|
||||
{
|
||||
const u32 to_alloc = num_pointers * sizeof(u32);
|
||||
ensure((m_cur_size + to_alloc) <= m_max_size, "event_data::allocate: size would overflow the allocated buffer!");
|
||||
|
||||
u8* dest_ptr = reinterpret_cast<u8*>(&dest);
|
||||
ensure(dest_ptr >= m_data_ptr.get_ptr() && dest_ptr < (m_data_ptr.get_ptr() + m_cur_size), "event_data::allocate_ptr_array: dest is out of bounds!");
|
||||
|
||||
const u32 offset_alloc = m_cur_size;
|
||||
|
||||
// Set the vm::bpptr to relative offset
|
||||
dest.set(m_data_ptr.addr() + offset_alloc);
|
||||
// Save the relocation offset
|
||||
m_relocs.push_back(static_cast<u32>(dest_ptr - m_data_ptr.get_ptr()));
|
||||
// Add all the pointers to the relocation
|
||||
for (u32 i = 0; i < num_pointers; i++)
|
||||
{
|
||||
m_relocs.push_back(offset_alloc + (i * 4));
|
||||
}
|
||||
// Update currently allocated space
|
||||
m_cur_size += to_alloc;
|
||||
}
|
||||
|
||||
void apply_relocations(u32 new_addr)
|
||||
{
|
||||
u32 diff_offset = new_addr - m_data_ptr.addr();
|
||||
for (const auto offset : m_relocs)
|
||||
{
|
||||
auto* ptr = reinterpret_cast<be_t<u32>*>(m_data_ptr.get_ptr() + offset);
|
||||
*ptr += diff_offset;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
vm::bptr<u8> m_data_ptr;
|
||||
u32 m_max_size, m_cur_size;
|
||||
std::vector<u32> m_relocs;
|
||||
};
|
||||
} // namespace np
|
File diff suppressed because it is too large
Load Diff
@ -11,242 +11,246 @@
|
||||
#include "Emu/NP/rpcn_client.h"
|
||||
#include "generated/np2_structs_generated.h"
|
||||
#include "signaling_handler.h"
|
||||
#include "np_event_data.h"
|
||||
#include "np_allocator.h"
|
||||
|
||||
class np_handler
|
||||
namespace np
|
||||
{
|
||||
public:
|
||||
np_handler();
|
||||
|
||||
const std::array<u8, 6>& get_ether_addr() const;
|
||||
const std::string& get_hostname() const;
|
||||
u32 get_local_ip_addr() const;
|
||||
u32 get_public_ip_addr() const;
|
||||
u32 get_dns_ip() const;
|
||||
|
||||
s32 get_psn_status() const;
|
||||
s32 get_net_status() const;
|
||||
|
||||
const SceNpId& get_npid() const;
|
||||
const SceNpOnlineId& get_online_id() const;
|
||||
const SceNpOnlineName& get_online_name() const;
|
||||
const SceNpAvatarUrl& get_avatar_url() const;
|
||||
|
||||
// Public helpers
|
||||
static std::string ip_to_string(u32 addr);
|
||||
static std::string ether_to_string(std::array<u8, 6>& ether);
|
||||
// Helpers for setting various structures from string
|
||||
static void string_to_npid(const std::string& str, SceNpId* npid);
|
||||
static void string_to_online_name(const std::string& str, SceNpOnlineName* online_name);
|
||||
static void string_to_avatar_url(const std::string& str, SceNpAvatarUrl* avatar_url);
|
||||
static void string_to_communication_id(const std::string& str, SceNpCommunicationId* comm_id);
|
||||
|
||||
// DNS hooking functions
|
||||
void add_dns_spy(u32 sock);
|
||||
void remove_dns_spy(u32 sock);
|
||||
bool is_dns(u32 sock) const;
|
||||
bool is_dns_queue(u32 sock) const;
|
||||
std::vector<u8> get_dns_packet(u32 sock);
|
||||
s32 analyze_dns_packet(s32 s, const u8* buf, u32 len);
|
||||
|
||||
// handles async messages from server(only needed for RPCN)
|
||||
void operator()();
|
||||
|
||||
void init_NP(u32 poolsize, vm::ptr<void> poolptr);
|
||||
void terminate_NP();
|
||||
|
||||
bool is_netctl_init = false;
|
||||
bool is_NP_init = false;
|
||||
bool is_NP_Lookup_init = false;
|
||||
bool is_NP_Score_init = false;
|
||||
bool is_NP2_init = false;
|
||||
bool is_NP2_Match2_init = false;
|
||||
bool is_NP_Auth_init = false;
|
||||
|
||||
// NP Handlers/Callbacks
|
||||
// Seems to be global
|
||||
vm::ptr<SceNpManagerCallback> manager_cb{}; // Connection status and tickets
|
||||
vm::ptr<void> manager_cb_arg{};
|
||||
|
||||
// Basic event handler;
|
||||
struct
|
||||
{
|
||||
SceNpCommunicationId context{};
|
||||
vm::ptr<SceNpBasicEventHandler> handler_func;
|
||||
vm::ptr<void> handler_arg;
|
||||
bool registered = false;
|
||||
bool context_sensitive = false;
|
||||
} basic_handler;
|
||||
struct basic_event
|
||||
{
|
||||
s32 event = 0;
|
||||
SceNpUserInfo from{};
|
||||
std::vector<u8> data;
|
||||
};
|
||||
void queue_basic_event(basic_event to_queue);
|
||||
bool send_basic_event(s32 event, s32 retCode, u32 reqId);
|
||||
error_code get_basic_event(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<s32> data, vm::ptr<u32> size);
|
||||
std::optional<std::shared_ptr<std::pair<std::string, message_data>>> get_message(u64 id);
|
||||
|
||||
// Those should probably be under match2 ctx
|
||||
vm::ptr<SceNpMatching2RoomEventCallback> room_event_cb{}; // Room events
|
||||
u16 room_event_cb_ctx = 0;
|
||||
vm::ptr<void> room_event_cb_arg{};
|
||||
vm::ptr<SceNpMatching2RoomMessageCallback> room_msg_cb{};
|
||||
u16 room_msg_cb_ctx = 0;
|
||||
vm::ptr<void> room_msg_cb_arg{};
|
||||
// Helper functions
|
||||
std::string ip_to_string(u32 addr);
|
||||
std::string ether_to_string(std::array<u8, 6>& ether);
|
||||
|
||||
// Synchronous requests
|
||||
std::vector<SceNpMatching2ServerId> get_match2_server_list(SceNpMatching2ContextId);
|
||||
// Asynchronous requests
|
||||
u32 get_server_status(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id);
|
||||
u32 create_server_context(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id);
|
||||
u32 get_world_list(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id);
|
||||
u32 create_join_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2CreateJoinRoomRequest* req);
|
||||
u32 join_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2JoinRoomRequest* req);
|
||||
u32 leave_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2LeaveRoomRequest* req);
|
||||
u32 search_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SearchRoomRequest* req);
|
||||
u32 get_roomdata_external_list(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2GetRoomDataExternalListRequest* req);
|
||||
u32 set_roomdata_external(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomDataExternalRequest* req);
|
||||
u32 get_roomdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2GetRoomDataInternalRequest* req);
|
||||
u32 set_roomdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomDataInternalRequest* req);
|
||||
u32 set_roommemberdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomMemberDataInternalRequest* req);
|
||||
u32 get_ping_info(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SignalingGetPingInfoRequest* req);
|
||||
u32 send_room_message(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SendRoomMessageRequest* req);
|
||||
void string_to_npid(const std::string& str, SceNpId* npid);
|
||||
void string_to_online_name(const std::string& str, SceNpOnlineName* online_name);
|
||||
void string_to_avatar_url(const std::string& str, SceNpAvatarUrl* avatar_url);
|
||||
void string_to_communication_id(const std::string& str, SceNpCommunicationId* comm_id);
|
||||
|
||||
u32 get_match2_event(SceNpMatching2EventKey event_key, u8* dest, u32 size);
|
||||
|
||||
// Friend stuff
|
||||
u32 get_num_friends();
|
||||
u32 get_num_blocks();
|
||||
|
||||
// Misc stuff
|
||||
void req_ticket(u32 version, const SceNpId* npid, const char* service_id, const u8* cookie, u32 cookie_size, const char* entitlement_id, u32 consumed_count);
|
||||
const std::vector<u8>& get_ticket() const
|
||||
class np_handler
|
||||
{
|
||||
return current_ticket;
|
||||
}
|
||||
u32 add_players_to_history(vm::cptr<SceNpId> npids, u32 count);
|
||||
public:
|
||||
np_handler();
|
||||
|
||||
// For signaling
|
||||
void req_sign_infos(const std::string& npid, u32 conn_id);
|
||||
const std::array<u8, 6>& get_ether_addr() const;
|
||||
const std::string& get_hostname() const;
|
||||
u32 get_local_ip_addr() const;
|
||||
u32 get_public_ip_addr() const;
|
||||
u32 get_dns_ip() const;
|
||||
|
||||
// Mutex for NP status change
|
||||
shared_mutex mutex_status;
|
||||
s32 get_psn_status() const;
|
||||
s32 get_net_status() const;
|
||||
|
||||
static constexpr std::string_view thread_name = "NP Handler Thread";
|
||||
const SceNpId& get_npid() const;
|
||||
const SceNpOnlineId& get_online_id() const;
|
||||
const SceNpOnlineName& get_online_name() const;
|
||||
const SceNpAvatarUrl& get_avatar_url() const;
|
||||
|
||||
private:
|
||||
// Various generic helpers
|
||||
void discover_ip_address();
|
||||
bool discover_ether_address();
|
||||
bool error_and_disconnect(const std::string& error_msg);
|
||||
// DNS hooking functions
|
||||
void add_dns_spy(u32 sock);
|
||||
void remove_dns_spy(u32 sock);
|
||||
bool is_dns(u32 sock) const;
|
||||
bool is_dns_queue(u32 sock) const;
|
||||
std::vector<u8> get_dns_packet(u32 sock);
|
||||
s32 analyze_dns_packet(s32 s, const u8* buf, u32 len);
|
||||
|
||||
// Notification handlers
|
||||
void notif_user_joined_room(std::vector<u8>& data);
|
||||
void notif_user_left_room(std::vector<u8>& data);
|
||||
void notif_room_destroyed(std::vector<u8>& data);
|
||||
void notif_updated_room_data_internal(std::vector<u8>& data);
|
||||
void notif_updated_room_member_data_internal(std::vector<u8>& data);
|
||||
void notif_p2p_connect(std::vector<u8>& data);
|
||||
void notif_room_message_received(std::vector<u8>& data);
|
||||
// handles async messages from server(only needed for RPCN)
|
||||
void operator()();
|
||||
|
||||
// Reply handlers
|
||||
bool reply_get_world_list(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_create_join_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_join_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_leave_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_search_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_get_roomdata_external_list(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_set_roomdata_external(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_get_roomdata_internal(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_set_roomdata_internal(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_set_roommemberdata_internal(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_get_ping_info(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_send_room_message(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_req_sign_infos(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_req_ticket(u32 req_id, std::vector<u8>& reply_data);
|
||||
void init_NP(u32 poolsize, vm::ptr<void> poolptr);
|
||||
void terminate_NP();
|
||||
|
||||
// Helper functions(fb=>np2)
|
||||
void BinAttr_to_SceNpMatching2BinAttr(const BinAttr* bin_attr, SceNpMatching2BinAttr* binattr_info);
|
||||
void BinAttrs_to_SceNpMatching2BinAttr(const flatbuffers::Vector<flatbuffers::Offset<BinAttr>>* fb_attr, vm::ptr<SceNpMatching2BinAttr> binattr_info);
|
||||
void RoomMemberBinAttrInternal_to_SceNpMatching2RoomMemberBinAttrInternal(const RoomMemberBinAttrInternal* fb_attr, vm::ptr<SceNpMatching2RoomMemberBinAttrInternal> binattr_info);
|
||||
void RoomBinAttrInternal_to_SceNpMatching2RoomBinAttrInternal(const BinAttrInternal* fb_attr, vm::ptr<SceNpMatching2RoomBinAttrInternal> binattr_info);
|
||||
void RoomGroups_to_SceNpMatching2RoomGroup(const flatbuffers::Vector<flatbuffers::Offset<RoomGroup>>* fb_group, vm::ptr<SceNpMatching2RoomGroup> group_info);
|
||||
void UserInfo2_to_SceNpUserInfo2(const UserInfo2* user, SceNpUserInfo2* user_info);
|
||||
void RoomDataExternal_to_SceNpMatching2RoomDataExternal(const RoomDataExternal* room, SceNpMatching2RoomDataExternal* room_info);
|
||||
void SearchRoomResponse_to_SceNpMatching2SearchRoomResponse(const SearchRoomResponse* resp, SceNpMatching2SearchRoomResponse* search_resp);
|
||||
void GetRoomDataExternalListResponse_to_SceNpMatching2GetRoomDataExternalListResponse(const GetRoomDataExternalListResponse* resp, SceNpMatching2GetRoomDataExternalListResponse* get_resp);
|
||||
u16 RoomDataInternal_to_SceNpMatching2RoomDataInternal(const RoomDataInternal* resp, SceNpMatching2RoomDataInternal* room_resp, const SceNpId& npid);
|
||||
void RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(const RoomMemberDataInternal* member_data, const SceNpMatching2RoomDataInternal* room_info, SceNpMatching2RoomMemberDataInternal* sce_member_data);
|
||||
void RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(const RoomMemberUpdateInfo* resp, SceNpMatching2RoomMemberUpdateInfo* room_info);
|
||||
void RoomUpdateInfo_to_SceNpMatching2RoomUpdateInfo(const RoomUpdateInfo* update_info, SceNpMatching2RoomUpdateInfo* sce_update_info);
|
||||
void GetPingInfoResponse_to_SceNpMatching2SignalingGetPingInfoResponse(const GetPingInfoResponse* resp, SceNpMatching2SignalingGetPingInfoResponse* sce_resp);
|
||||
void RoomMessageInfo_to_SceNpMatching2RoomMessageInfo(const RoomMessageInfo* mi, SceNpMatching2RoomMessageInfo* sce_mi);
|
||||
void RoomDataInternalUpdateInfo_to_SceNpMatching2RoomDataInternalUpdateInfo(const RoomDataInternalUpdateInfo* update_info, SceNpMatching2RoomDataInternalUpdateInfo* sce_update_info, const SceNpId& npid);
|
||||
void RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo(const RoomMemberDataInternalUpdateInfo* update_info, SceNpMatching2RoomMemberDataInternalUpdateInfo* sce_update_info);
|
||||
bool is_netctl_init = false;
|
||||
bool is_NP_init = false;
|
||||
bool is_NP_Lookup_init = false;
|
||||
bool is_NP_Score_init = false;
|
||||
bool is_NP2_init = false;
|
||||
bool is_NP2_Match2_init = false;
|
||||
bool is_NP_Auth_init = false;
|
||||
|
||||
struct callback_info
|
||||
{
|
||||
SceNpMatching2ContextId ctx_id;
|
||||
vm::ptr<SceNpMatching2RequestCallback> cb;
|
||||
vm::ptr<void> cb_arg;
|
||||
// NP Handlers/Callbacks
|
||||
// Seems to be global
|
||||
vm::ptr<SceNpManagerCallback> manager_cb{}; // Connection status and tickets
|
||||
vm::ptr<void> manager_cb_arg{};
|
||||
|
||||
// Basic event handler;
|
||||
struct
|
||||
{
|
||||
SceNpCommunicationId context{};
|
||||
vm::ptr<SceNpBasicEventHandler> handler_func;
|
||||
vm::ptr<void> handler_arg;
|
||||
bool registered = false;
|
||||
bool context_sensitive = false;
|
||||
} basic_handler;
|
||||
|
||||
void queue_basic_event(basic_event to_queue);
|
||||
bool send_basic_event(s32 event, s32 retCode, u32 reqId);
|
||||
error_code get_basic_event(vm::ptr<s32> event, vm::ptr<SceNpUserInfo> from, vm::ptr<s32> data, vm::ptr<u32> size);
|
||||
std::optional<std::shared_ptr<std::pair<std::string, message_data>>> get_message(u64 id);
|
||||
|
||||
// Those should probably be under match2 ctx
|
||||
vm::ptr<SceNpMatching2RoomEventCallback> room_event_cb{}; // Room events
|
||||
u16 room_event_cb_ctx = 0;
|
||||
vm::ptr<void> room_event_cb_arg{};
|
||||
vm::ptr<SceNpMatching2RoomMessageCallback> room_msg_cb{};
|
||||
u16 room_msg_cb_ctx = 0;
|
||||
vm::ptr<void> room_msg_cb_arg{};
|
||||
|
||||
// Synchronous requests
|
||||
std::vector<SceNpMatching2ServerId> get_match2_server_list(SceNpMatching2ContextId);
|
||||
// Asynchronous requests
|
||||
u32 get_server_status(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id);
|
||||
u32 create_server_context(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id);
|
||||
u32 get_world_list(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id);
|
||||
u32 create_join_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2CreateJoinRoomRequest* req);
|
||||
u32 join_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2JoinRoomRequest* req);
|
||||
u32 leave_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2LeaveRoomRequest* req);
|
||||
u32 search_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SearchRoomRequest* req);
|
||||
u32 get_roomdata_external_list(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2GetRoomDataExternalListRequest* req);
|
||||
u32 set_roomdata_external(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomDataExternalRequest* req);
|
||||
u32 get_roomdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2GetRoomDataInternalRequest* req);
|
||||
u32 set_roomdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomDataInternalRequest* req);
|
||||
u32 set_roommemberdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomMemberDataInternalRequest* req);
|
||||
u32 get_ping_info(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SignalingGetPingInfoRequest* req);
|
||||
u32 send_room_message(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SendRoomMessageRequest* req);
|
||||
|
||||
u32 get_match2_event(SceNpMatching2EventKey event_key, u32 dest_addr, u32 size);
|
||||
|
||||
// Friend stuff
|
||||
u32 get_num_friends();
|
||||
u32 get_num_blocks();
|
||||
|
||||
// Misc stuff
|
||||
void req_ticket(u32 version, const SceNpId* npid, const char* service_id, const u8* cookie, u32 cookie_size, const char* entitlement_id, u32 consumed_count);
|
||||
const std::vector<u8>& get_ticket() const
|
||||
{
|
||||
return current_ticket;
|
||||
}
|
||||
u32 add_players_to_history(vm::cptr<SceNpId> npids, u32 count);
|
||||
|
||||
// For signaling
|
||||
void req_sign_infos(const std::string& npid, u32 conn_id);
|
||||
|
||||
// Mutex for NP status change
|
||||
shared_mutex mutex_status;
|
||||
|
||||
static constexpr std::string_view thread_name = "NP Handler Thread";
|
||||
|
||||
private:
|
||||
// Various generic helpers
|
||||
void discover_ip_address();
|
||||
bool discover_ether_address();
|
||||
bool error_and_disconnect(const std::string& error_msg);
|
||||
|
||||
// Notification handlers
|
||||
void notif_user_joined_room(std::vector<u8>& data);
|
||||
void notif_user_left_room(std::vector<u8>& data);
|
||||
void notif_room_destroyed(std::vector<u8>& data);
|
||||
void notif_updated_room_data_internal(std::vector<u8>& data);
|
||||
void notif_updated_room_member_data_internal(std::vector<u8>& data);
|
||||
void notif_p2p_connect(std::vector<u8>& data);
|
||||
void notif_room_message_received(std::vector<u8>& data);
|
||||
|
||||
// Reply handlers
|
||||
bool reply_get_world_list(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_create_join_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_join_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_leave_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_search_room(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_get_roomdata_external_list(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_set_roomdata_external(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_get_roomdata_internal(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_set_roomdata_internal(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_set_roommemberdata_internal(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_get_ping_info(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_send_room_message(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_req_sign_infos(u32 req_id, std::vector<u8>& reply_data);
|
||||
bool reply_req_ticket(u32 req_id, std::vector<u8>& reply_data);
|
||||
|
||||
// Helper functions(fb=>np2)
|
||||
void BinAttr_to_SceNpMatching2BinAttr(event_data& edata, const BinAttr* bin_attr, SceNpMatching2BinAttr* binattr_info);
|
||||
void BinAttrs_to_SceNpMatching2BinAttrs(event_data& edata, const flatbuffers::Vector<flatbuffers::Offset<BinAttr>>* fb_attr, SceNpMatching2BinAttr* binattr_info);
|
||||
void RoomMemberBinAttrInternal_to_SceNpMatching2RoomMemberBinAttrInternal(event_data& edata, const RoomMemberBinAttrInternal* fb_attr, SceNpMatching2RoomMemberBinAttrInternal* binattr_info);
|
||||
void RoomBinAttrInternal_to_SceNpMatching2RoomBinAttrInternal(event_data& edata, const BinAttrInternal* fb_attr, SceNpMatching2RoomBinAttrInternal* binattr_info);
|
||||
void RoomGroup_to_SceNpMatching2RoomGroup(const RoomGroup* fb_group, SceNpMatching2RoomGroup* sce_group);
|
||||
void RoomGroups_to_SceNpMatching2RoomGroups(const flatbuffers::Vector<flatbuffers::Offset<RoomGroup>>* fb_groups, SceNpMatching2RoomGroup* sce_groups);
|
||||
void UserInfo2_to_SceNpUserInfo2(event_data& edata, const UserInfo2* user, SceNpUserInfo2* user_info);
|
||||
void RoomDataExternal_to_SceNpMatching2RoomDataExternal(event_data& edata, const RoomDataExternal* room, SceNpMatching2RoomDataExternal* room_info);
|
||||
void SearchRoomResponse_to_SceNpMatching2SearchRoomResponse(event_data& edata, const SearchRoomResponse* resp, SceNpMatching2SearchRoomResponse* search_resp);
|
||||
void GetRoomDataExternalListResponse_to_SceNpMatching2GetRoomDataExternalListResponse(event_data& edata, const GetRoomDataExternalListResponse* resp, SceNpMatching2GetRoomDataExternalListResponse* get_resp);
|
||||
u16 RoomDataInternal_to_SceNpMatching2RoomDataInternal(event_data& edata, const RoomDataInternal* resp, SceNpMatching2RoomDataInternal* room_resp, const SceNpId& npid);
|
||||
void RoomMemberDataInternal_to_SceNpMatching2RoomMemberDataInternal(event_data& edata, const RoomMemberDataInternal* member_data, const SceNpMatching2RoomDataInternal* room_info, SceNpMatching2RoomMemberDataInternal* sce_member_data);
|
||||
void RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(event_data& edata, const RoomMemberUpdateInfo* resp, SceNpMatching2RoomMemberUpdateInfo* room_info);
|
||||
void RoomUpdateInfo_to_SceNpMatching2RoomUpdateInfo(const RoomUpdateInfo* update_info, SceNpMatching2RoomUpdateInfo* sce_update_info);
|
||||
void GetPingInfoResponse_to_SceNpMatching2SignalingGetPingInfoResponse(const GetPingInfoResponse* resp, SceNpMatching2SignalingGetPingInfoResponse* sce_resp);
|
||||
void RoomMessageInfo_to_SceNpMatching2RoomMessageInfo(event_data& edata, const RoomMessageInfo* mi, SceNpMatching2RoomMessageInfo* sce_mi);
|
||||
void RoomDataInternalUpdateInfo_to_SceNpMatching2RoomDataInternalUpdateInfo(event_data& edata, const RoomDataInternalUpdateInfo* update_info, SceNpMatching2RoomDataInternalUpdateInfo* sce_update_info, const SceNpId& npid);
|
||||
void RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo(event_data& edata, const RoomMemberDataInternalUpdateInfo* update_info, SceNpMatching2RoomMemberDataInternalUpdateInfo* sce_update_info);
|
||||
|
||||
struct callback_info
|
||||
{
|
||||
SceNpMatching2ContextId ctx_id;
|
||||
vm::ptr<SceNpMatching2RequestCallback> cb;
|
||||
vm::ptr<void> cb_arg;
|
||||
};
|
||||
u32 generate_callback_info(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam);
|
||||
callback_info take_pending_request(u32 req_id);
|
||||
|
||||
shared_mutex mutex_pending_requests;
|
||||
std::unordered_map<u32, callback_info> pending_requests;
|
||||
shared_mutex mutex_pending_sign_infos_requests;
|
||||
std::unordered_map<u32, u32> pending_sign_infos_requests;
|
||||
|
||||
shared_mutex mutex_queue_basic_events;
|
||||
std::queue<basic_event> queue_basic_events;
|
||||
|
||||
private:
|
||||
bool is_connected = false;
|
||||
bool is_psn_active = false;
|
||||
|
||||
std::vector<u8> current_ticket;
|
||||
|
||||
// IP & DNS info
|
||||
std::string hostname = "localhost";
|
||||
std::array<u8, 6> ether_address{};
|
||||
be_t<u32> local_ip_addr{};
|
||||
be_t<u32> public_ip_addr{};
|
||||
be_t<u32> dns_ip = 0x08080808;
|
||||
|
||||
// User infos
|
||||
SceNpId npid{};
|
||||
SceNpOnlineName online_name{};
|
||||
SceNpAvatarUrl avatar_url{};
|
||||
|
||||
// DNS related
|
||||
std::map<s32, std::queue<std::vector<u8>>> dns_spylist{};
|
||||
std::map<std::string, u32> switch_map{};
|
||||
|
||||
// Memory pool for sceNp/sceNp2
|
||||
memory_allocator np_memory;
|
||||
|
||||
// Requests(reqEventKey : data)
|
||||
shared_mutex mutex_match2_req_results;
|
||||
std::unordered_map<u32, event_data> match2_req_results;
|
||||
atomic_t<u16> match2_low_reqid_cnt = 1;
|
||||
atomic_t<u32> match2_event_cnt = 1;
|
||||
u32 get_req_id(u16 app_req)
|
||||
{
|
||||
return ((app_req << 16) | match2_low_reqid_cnt.fetch_add(1));
|
||||
}
|
||||
u32 get_event_key()
|
||||
{
|
||||
return match2_event_cnt.fetch_add(1);
|
||||
}
|
||||
event_data& allocate_req_result(u32 event_key, u32 max_size, u32 initial_size);
|
||||
|
||||
// RPCN
|
||||
shared_mutex mutex_rpcn;
|
||||
std::shared_ptr<rpcn::rpcn_client> rpcn;
|
||||
};
|
||||
u32 generate_callback_info(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam);
|
||||
callback_info take_pending_request(u32 req_id);
|
||||
|
||||
shared_mutex mutex_pending_requests;
|
||||
std::unordered_map<u32, callback_info> pending_requests;
|
||||
shared_mutex mutex_pending_sign_infos_requests;
|
||||
std::unordered_map<u32, u32> pending_sign_infos_requests;
|
||||
|
||||
shared_mutex mutex_queue_basic_events;
|
||||
std::queue<basic_event> queue_basic_events;
|
||||
|
||||
private:
|
||||
bool is_connected = false;
|
||||
bool is_psn_active = false;
|
||||
|
||||
std::vector<u8> current_ticket;
|
||||
|
||||
// IP & DNS info
|
||||
std::string hostname = "localhost";
|
||||
std::array<u8, 6> ether_address{};
|
||||
be_t<u32> local_ip_addr{};
|
||||
be_t<u32> public_ip_addr{};
|
||||
be_t<u32> dns_ip = 0x08080808;
|
||||
|
||||
// User infos
|
||||
SceNpId npid{};
|
||||
SceNpOnlineName online_name{};
|
||||
SceNpAvatarUrl avatar_url{};
|
||||
|
||||
// DNS related
|
||||
std::map<s32, std::queue<std::vector<u8>>> dns_spylist{};
|
||||
std::map<std::string, u32> switch_map{};
|
||||
|
||||
// Memory pool for sceNp/sceNp2
|
||||
vm::ptr<void> mpool{};
|
||||
u32 mpool_size = 0;
|
||||
u32 mpool_avail = 0;
|
||||
std::map<u32, u32> mpool_allocs{}; // offset/size
|
||||
vm::addr_t allocate(u32 size);
|
||||
|
||||
// Requests(reqEventKey : data)
|
||||
std::unordered_map<u32, std::vector<u8>> match2_req_results{};
|
||||
atomic_t<u16> match2_low_reqid_cnt = 1;
|
||||
atomic_t<u32> match2_event_cnt = 1;
|
||||
u32 get_req_id(u16 app_req)
|
||||
{
|
||||
return ((app_req << 16) | match2_low_reqid_cnt.fetch_add(1));
|
||||
}
|
||||
u32 get_event_key()
|
||||
{
|
||||
return match2_event_cnt.fetch_add(1);
|
||||
}
|
||||
shared_mutex mutex_req_results;
|
||||
u8* allocate_req_result(u32 event_key, usz size);
|
||||
|
||||
// RPCN
|
||||
shared_mutex mutex_rpcn;
|
||||
std::shared_ptr<rpcn::rpcn_client> rpcn;
|
||||
};
|
||||
} // namespace np
|
||||
|
46
rpcs3/Emu/NP/np_helpers.cpp
Normal file
46
rpcs3/Emu/NP/np_helpers.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include "stdafx.h"
|
||||
#include "util/types.hpp"
|
||||
#include "Utilities/StrUtil.h"
|
||||
#include "np_handler.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <WS2tcpip.h>
|
||||
#endif
|
||||
|
||||
namespace np
|
||||
{
|
||||
std::string ip_to_string(u32 ip_addr)
|
||||
{
|
||||
char ip_str[16];
|
||||
|
||||
inet_ntop(AF_INET, &ip_addr, ip_str, sizeof(ip_str));
|
||||
return std::string(ip_str);
|
||||
}
|
||||
|
||||
std::string ether_to_string(std::array<u8, 6>& ether)
|
||||
{
|
||||
return fmt::format("%02X:%02X:%02X:%02X:%02X:%02X", ether[0], ether[1], ether[2], ether[3], ether[4], ether[5]);
|
||||
}
|
||||
|
||||
void string_to_npid(const std::string& str, SceNpId* npid)
|
||||
{
|
||||
memset(npid, 0, sizeof(SceNpId));
|
||||
strcpy_trunc(npid->handle.data, str);
|
||||
// npid->reserved[0] = 1;
|
||||
}
|
||||
|
||||
void string_to_online_name(const std::string& str, SceNpOnlineName* online_name)
|
||||
{
|
||||
strcpy_trunc(online_name->data, str);
|
||||
}
|
||||
|
||||
void string_to_avatar_url(const std::string& str, SceNpAvatarUrl* avatar_url)
|
||||
{
|
||||
strcpy_trunc(avatar_url->data, str);
|
||||
}
|
||||
|
||||
void string_to_communication_id(const std::string& str, SceNpCommunicationId* comm_id)
|
||||
{
|
||||
strcpy_trunc(comm_id->data, str);
|
||||
}
|
||||
}
|
221
rpcs3/Emu/NP/np_notifications.cpp
Normal file
221
rpcs3/Emu/NP/np_notifications.cpp
Normal file
@ -0,0 +1,221 @@
|
||||
#include "stdafx.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Emu/Cell/Modules/cellSysutil.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "np_handler.h"
|
||||
#include "np_structs_extra.h"
|
||||
|
||||
LOG_CHANNEL(rpcn_log, "rpcn");
|
||||
|
||||
namespace np
|
||||
{
|
||||
void np_handler::notif_user_joined_room(std::vector<u8>& data)
|
||||
{
|
||||
vec_stream noti(data);
|
||||
u64 room_id = noti.get<u64>();
|
||||
auto update_info_raw = noti.get_rawdata();
|
||||
|
||||
if (noti.is_error())
|
||||
{
|
||||
rpcn_log.error("Received faulty UserJoinedRoom notification");
|
||||
return;
|
||||
}
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* update_info = flatbuffers::GetRoot<RoomMemberUpdateInfo>(update_info_raw.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberUpdateInfo, sizeof(SceNpMatching2RoomMemberUpdateInfo));
|
||||
auto* notif_data = reinterpret_cast<SceNpMatching2RoomMemberUpdateInfo*>(edata.data());
|
||||
RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(edata, update_info, notif_data);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
rpcn_log.notice("Received notification that user %s(%d) joined the room(%d)", notif_data->roomMemberDataInternal->userInfo.npId.handle.data, notif_data->roomMemberDataInternal->memberId, room_id);
|
||||
extra_nps::print_room_member_data_internal(notif_data->roomMemberDataInternal.get_ptr());
|
||||
|
||||
sysutil_register_cb([room_event_cb = this->room_event_cb, room_id, event_key, room_event_cb_ctx = this->room_event_cb_ctx, room_event_cb_arg = this->room_event_cb_arg, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_MemberJoined, event_key, 0, size, room_event_cb_arg);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
void np_handler::notif_user_left_room(std::vector<u8>& data)
|
||||
{
|
||||
vec_stream noti(data);
|
||||
u64 room_id = noti.get<u64>();
|
||||
auto update_info_raw = noti.get_rawdata();
|
||||
|
||||
if (noti.is_error())
|
||||
{
|
||||
rpcn_log.error("Received faulty UserLeftRoom notification");
|
||||
return;
|
||||
}
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* update_info = flatbuffers::GetRoot<RoomMemberUpdateInfo>(update_info_raw.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberUpdateInfo, sizeof(SceNpMatching2RoomMemberUpdateInfo));
|
||||
auto* notif_data = reinterpret_cast<SceNpMatching2RoomMemberUpdateInfo*>(edata.data());
|
||||
RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(edata, update_info, notif_data);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
rpcn_log.notice("Received notification that user %s(%d) left the room(%d)", notif_data->roomMemberDataInternal->userInfo.npId.handle.data, notif_data->roomMemberDataInternal->memberId, room_id);
|
||||
extra_nps::print_room_member_data_internal(notif_data->roomMemberDataInternal.get_ptr());
|
||||
|
||||
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_MemberLeft, event_key, 0, size, room_event_cb_arg);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
void np_handler::notif_room_destroyed(std::vector<u8>& data)
|
||||
{
|
||||
vec_stream noti(data);
|
||||
u64 room_id = noti.get<u64>();
|
||||
auto update_info_raw = noti.get_rawdata();
|
||||
|
||||
if (noti.is_error())
|
||||
{
|
||||
rpcn_log.error("Received faulty RoomDestroyed notification");
|
||||
return;
|
||||
}
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* update_info = flatbuffers::GetRoot<RoomUpdateInfo>(update_info_raw.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomUpdateInfo, sizeof(SceNpMatching2RoomUpdateInfo));
|
||||
auto* notif_data = reinterpret_cast<SceNpMatching2RoomUpdateInfo*>(edata.data());
|
||||
RoomUpdateInfo_to_SceNpMatching2RoomUpdateInfo(update_info, notif_data);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
rpcn_log.notice("Received notification that room(%d) was destroyed", room_id);
|
||||
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
sigh.disconnect_sig2_users(room_id);
|
||||
|
||||
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_RoomDestroyed, event_key, 0, size, room_event_cb_arg);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
void np_handler::notif_updated_room_data_internal(std::vector<u8>& data)
|
||||
{
|
||||
vec_stream noti(data);
|
||||
SceNpMatching2RoomId room_id = noti.get<u64>();
|
||||
auto update_info_raw = noti.get_rawdata();
|
||||
|
||||
if (noti.is_error())
|
||||
{
|
||||
rpcn_log.error("Received faulty UpdatedRoomDataInternal notification");
|
||||
return;
|
||||
}
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* update_info = flatbuffers::GetRoot<RoomDataInternalUpdateInfo>(update_info_raw.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomDataInternalUpdateInfo, sizeof(SceNpMatching2RoomDataInternalUpdateInfo));
|
||||
auto* notif_data = reinterpret_cast<SceNpMatching2RoomDataInternalUpdateInfo*>(edata.data());
|
||||
RoomDataInternalUpdateInfo_to_SceNpMatching2RoomDataInternalUpdateInfo(edata, update_info, notif_data, npid);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
extra_nps::print_room_data_internal(notif_data->newRoomDataInternal.get_ptr());
|
||||
|
||||
rpcn_log.notice("Received notification that room(%d)'s data was updated", room_id);
|
||||
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
sigh.disconnect_sig2_users(room_id);
|
||||
|
||||
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_UpdatedRoomDataInternal, event_key, 0, size, room_event_cb_arg);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
void np_handler::notif_updated_room_member_data_internal(std::vector<u8>& data)
|
||||
{
|
||||
vec_stream noti(data);
|
||||
SceNpMatching2RoomId room_id = noti.get<u64>();
|
||||
auto update_info_raw = noti.get_rawdata();
|
||||
|
||||
if (noti.is_error())
|
||||
{
|
||||
rpcn_log.error("Received faulty UpdatedRoomMemberDataInternal notification");
|
||||
return;
|
||||
}
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* update_info = flatbuffers::GetRoot<RoomMemberDataInternalUpdateInfo>(update_info_raw.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberDataInternalUpdateInfo, sizeof(SceNpMatching2RoomMemberDataInternalUpdateInfo));
|
||||
auto* notif_data = reinterpret_cast<SceNpMatching2RoomMemberDataInternalUpdateInfo*>(edata.data());
|
||||
RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo(edata, update_info, notif_data);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
rpcn_log.notice("Received notification that user's %s(%d) room (%d) data was updated", notif_data->newRoomMemberDataInternal->userInfo.npId.handle.data, notif_data->newRoomMemberDataInternal->memberId, room_id);
|
||||
extra_nps::print_room_member_data_internal(notif_data->newRoomMemberDataInternal.get_ptr());
|
||||
|
||||
sysutil_register_cb([room_event_cb = this->room_event_cb, room_event_cb_ctx = this->room_event_cb_ctx, room_id, event_key, room_event_cb_arg = this->room_event_cb_arg, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
room_event_cb(cb_ppu, room_event_cb_ctx, room_id, SCE_NP_MATCHING2_ROOM_EVENT_UpdatedRoomMemberDataInternal, event_key, 0, size, room_event_cb_arg);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
void np_handler::notif_room_message_received(std::vector<u8>& data)
|
||||
{
|
||||
vec_stream noti(data);
|
||||
u64 room_id = noti.get<u64>();
|
||||
u16 member_id = noti.get<u16>();
|
||||
auto message_info_raw = noti.get_rawdata();
|
||||
|
||||
if (noti.is_error())
|
||||
{
|
||||
rpcn_log.error("Received faulty RoomMessageReceived notification");
|
||||
return;
|
||||
}
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* message_info = flatbuffers::GetRoot<RoomMessageInfo>(message_info_raw.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMessageInfo, sizeof(SceNpMatching2RoomMessageInfo));
|
||||
auto* notif_data = reinterpret_cast<SceNpMatching2RoomMessageInfo*>(edata.data());
|
||||
RoomMessageInfo_to_SceNpMatching2RoomMessageInfo(edata, message_info, notif_data);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
rpcn_log.notice("Received notification of a room message from member(%d) in room(%d)", member_id, room_id);
|
||||
|
||||
if (room_msg_cb)
|
||||
{
|
||||
sysutil_register_cb([room_msg_cb = this->room_msg_cb, room_msg_cb_ctx = this->room_msg_cb_ctx, room_id, member_id, event_key, room_msg_cb_arg = this->room_msg_cb_arg, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
room_msg_cb(cb_ppu, room_msg_cb_ctx, room_id, member_id, SCE_NP_MATCHING2_ROOM_MSG_EVENT_Message, event_key, 0, size, room_msg_cb_arg);
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void np_handler::notif_p2p_connect(std::vector<u8>& data)
|
||||
{
|
||||
if (data.size() != 16)
|
||||
{
|
||||
rpcn_log.error("Notification data for SignalP2PConnect != 14");
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 room_id = reinterpret_cast<le_t<u64>&>(data[0]);
|
||||
const u16 member_id = reinterpret_cast<le_t<u16>&>(data[8]);
|
||||
const u16 port_p2p = reinterpret_cast<be_t<u16>&>(data[10]);
|
||||
const u32 addr_p2p = reinterpret_cast<le_t<u32>&>(data[12]);
|
||||
|
||||
rpcn_log.notice("Received notification to connect to member(%d) of room(%d): %s:%d", member_id, room_id, ip_to_string(addr_p2p), port_p2p);
|
||||
|
||||
// Attempt Signaling
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
sigh.set_sig2_infos(room_id, member_id, SCE_NP_SIGNALING_CONN_STATUS_PENDING, addr_p2p, port_p2p);
|
||||
sigh.start_sig2(room_id, member_id);
|
||||
}
|
||||
} // namespace np
|
625
rpcs3/Emu/NP/np_requests.cpp
Normal file
625
rpcs3/Emu/NP/np_requests.cpp
Normal file
@ -0,0 +1,625 @@
|
||||
#include "stdafx.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Emu/system_config.h"
|
||||
#include "Emu/Cell/Modules/cellSysutil.h"
|
||||
#include "Emu/Memory/vm_ptr.h"
|
||||
#include "Emu/IdManager.h"
|
||||
#include "np_handler.h"
|
||||
#include "np_contexts.h"
|
||||
#include "np_structs_extra.h"
|
||||
|
||||
LOG_CHANNEL(rpcn_log, "rpcn");
|
||||
|
||||
namespace np
|
||||
{
|
||||
std::vector<SceNpMatching2ServerId> np_handler::get_match2_server_list(SceNpMatching2ContextId ctx_id)
|
||||
{
|
||||
std::vector<SceNpMatching2ServerId> server_list{};
|
||||
|
||||
if (g_cfg.net.psn_status != np_psn_status::psn_rpcn)
|
||||
{
|
||||
return server_list;
|
||||
}
|
||||
|
||||
if (!rpcn->get_server_list(get_req_id(0), get_match2_context(ctx_id)->communicationId, server_list))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return server_list;
|
||||
}
|
||||
|
||||
u32 np_handler::get_server_status(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id)
|
||||
{
|
||||
// TODO: actually implement interaction with server for this?
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_GetServerInfo, sizeof(SceNpMatching2GetServerInfoResponse));
|
||||
SceNpMatching2GetServerInfoResponse* serv_info = reinterpret_cast<SceNpMatching2GetServerInfoResponse*>(edata.data());
|
||||
serv_info->server.serverId = server_id;
|
||||
serv_info->server.status = SCE_NP_MATCHING2_SERVER_STATUS_AVAILABLE;
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_GetServerInfo, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
u32 np_handler::create_server_context(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 /*server_id*/)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_CreateServerContext, event_key, 0, 0, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
u32 np_handler::get_world_list(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, u16 server_id)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->get_world_list(req_id, get_match2_context(ctx_id)->communicationId, server_id))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_get_world_list(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
|
||||
std::vector<u32> world_list;
|
||||
u32 num_worlds = reply.get<u32>();
|
||||
for (u32 i = 0; i < num_worlds; i++)
|
||||
{
|
||||
world_list.push_back(reply.get<u32>());
|
||||
}
|
||||
|
||||
if (reply.is_error())
|
||||
{
|
||||
world_list.clear();
|
||||
return error_and_disconnect("Malformed reply to GetWorldList command");
|
||||
}
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_GetWorldInfoList, sizeof(SceNpMatching2GetWorldInfoListResponse));
|
||||
auto* world_info = reinterpret_cast<SceNpMatching2GetWorldInfoListResponse*>(edata.data());
|
||||
world_info->worldNum = world_list.size();
|
||||
|
||||
if (!world_list.empty())
|
||||
{
|
||||
auto* worlds = edata.allocate<SceNpMatching2World>(sizeof(SceNpMatching2World) * world_list.size(), world_info->world);
|
||||
for (usz i = 0; i < world_list.size(); i++)
|
||||
{
|
||||
worlds[i].worldId = world_list[i];
|
||||
worlds[i].numOfLobby = 1; // TODO
|
||||
worlds[i].maxNumOfTotalLobbyMember = 10000;
|
||||
worlds[i].curNumOfTotalLobbyMember = 1;
|
||||
worlds[i].curNumOfRoom = 1;
|
||||
worlds[i].curNumOfTotalRoomMember = 1;
|
||||
}
|
||||
}
|
||||
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_GetWorldInfoList, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::create_join_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2CreateJoinRoomRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->createjoin_room(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_create_join_room(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
auto create_room_resp = reply.get_rawdata();
|
||||
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to CreateRoom command");
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* resp = flatbuffers::GetRoot<RoomDataInternal>(create_room_resp.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_CreateJoinRoom, sizeof(SceNpMatching2CreateJoinRoomResponse));
|
||||
auto* room_resp = reinterpret_cast<SceNpMatching2CreateJoinRoomResponse*>(edata.data());
|
||||
auto* room_info = edata.allocate<SceNpMatching2RoomDataInternal>(sizeof(SceNpMatching2RoomDataInternal), room_resp->roomDataInternal);
|
||||
RoomDataInternal_to_SceNpMatching2RoomDataInternal(edata, resp, room_info, npid);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
// Establish Matching2 self signaling info
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
sigh.set_self_sig2_info(room_info->roomId, 1);
|
||||
sigh.set_sig2_infos(room_info->roomId, 1, SCE_NP_SIGNALING_CONN_STATUS_ACTIVE, rpcn->get_addr_sig(), rpcn->get_port_sig(), true);
|
||||
// TODO? Should this send a message to Signaling CB? Is this even necessary?
|
||||
|
||||
extra_nps::print_create_room_resp(room_resp);
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_CreateJoinRoom, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::join_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2JoinRoomRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->join_room(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_join_room(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
|
||||
auto join_room_resp = reply.get_rawdata();
|
||||
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to JoinRoom command");
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto resp = flatbuffers::GetRoot<RoomDataInternal>(join_room_resp.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_JoinRoom, sizeof(SceNpMatching2JoinRoomResponse));
|
||||
auto* room_resp = reinterpret_cast<SceNpMatching2JoinRoomResponse*>(edata.data());
|
||||
auto* room_info = edata.allocate<SceNpMatching2RoomDataInternal>(sizeof(SceNpMatching2RoomDataInternal), room_resp->roomDataInternal);
|
||||
u16 member_id = RoomDataInternal_to_SceNpMatching2RoomDataInternal(edata, resp, room_info, npid);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
extra_nps::print_room_data_internal(room_resp->roomDataInternal.get_ptr());
|
||||
|
||||
// Establish Matching2 self signaling info
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
sigh.set_self_sig2_info(room_info->roomId, member_id);
|
||||
sigh.set_sig2_infos(room_info->roomId, member_id, SCE_NP_SIGNALING_CONN_STATUS_ACTIVE, rpcn->get_addr_sig(), rpcn->get_port_sig(), true);
|
||||
// TODO? Should this send a message to Signaling CB? Is this even necessary?
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_JoinRoom, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::leave_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2LeaveRoomRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->leave_room(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_leave_room(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
u64 room_id = reply.get<u64>();
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to LeaveRoom command");
|
||||
|
||||
u32 event_key = get_event_key(); // Unsure if necessary if there is no data
|
||||
|
||||
// Disconnect all users from that room
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
sigh.disconnect_sig2_users(room_id);
|
||||
|
||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_LeaveRoom, event_key, 0, 0, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::search_room(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SearchRoomRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->search_room(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_search_room(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
auto search_room_resp = reply.get_rawdata();
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to SearchRoom command");
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* resp = flatbuffers::GetRoot<SearchRoomResponse>(search_room_resp.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_SearchRoom, sizeof(SceNpMatching2SearchRoomResponse));
|
||||
auto* search_resp = reinterpret_cast<SceNpMatching2SearchRoomResponse*>(edata.data());
|
||||
SearchRoomResponse_to_SceNpMatching2SearchRoomResponse(edata, resp, search_resp);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SearchRoom, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::get_roomdata_external_list(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2GetRoomDataExternalListRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->get_roomdata_external_list(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_get_roomdata_external_list(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
auto get_room_ext_resp = reply.get_rawdata();
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to GetRoomDataExternalList command");
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* resp = flatbuffers::GetRoot<GetRoomDataExternalListResponse>(get_room_ext_resp.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_GetRoomDataExternalList, sizeof(SceNpMatching2GetRoomDataExternalListResponse));
|
||||
auto* sce_get_room_ext_resp = reinterpret_cast<SceNpMatching2GetRoomDataExternalListResponse*>(edata.data());
|
||||
GetRoomDataExternalListResponse_to_SceNpMatching2GetRoomDataExternalListResponse(edata, resp, sce_get_room_ext_resp);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SearchRoom, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::set_roomdata_external(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomDataExternalRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
extra_nps::print_set_roomdata_ext_req(req);
|
||||
|
||||
if (!rpcn->set_roomdata_external(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_set_roomdata_external(u32 req_id, std::vector<u8>& /*reply_data*/)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
u32 event_key = get_event_key(); // Unsure if necessary if there is no data
|
||||
|
||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SetRoomDataExternal, event_key, 0, 0, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::get_roomdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2GetRoomDataInternalRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->get_roomdata_internal(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_get_roomdata_internal(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
|
||||
auto internal_data = reply.get_rawdata();
|
||||
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to GetRoomDataInternal command");
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* resp = flatbuffers::GetRoot<RoomDataInternal>(internal_data.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_GetRoomDataInternal, sizeof(SceNpMatching2GetRoomDataInternalResponse));
|
||||
auto* room_resp = reinterpret_cast<SceNpMatching2GetRoomDataInternalResponse*>(edata.data());
|
||||
auto* room_info = edata.allocate<SceNpMatching2RoomDataInternal>(sizeof(SceNpMatching2RoomDataInternal), room_resp->roomDataInternal);
|
||||
RoomDataInternal_to_SceNpMatching2RoomDataInternal(edata, resp, room_info, npid);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
extra_nps::print_room_data_internal(room_resp->roomDataInternal.get_ptr());
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_GetRoomDataInternal, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::set_roomdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomDataInternalRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
extra_nps::print_set_roomdata_int_req(req);
|
||||
|
||||
if (!rpcn->set_roomdata_internal(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_set_roomdata_internal(u32 req_id, std::vector<u8>& /*reply_data*/)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
u32 event_key = get_event_key(); // Unsure if necessary if there is no data
|
||||
|
||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SetRoomDataInternal, event_key, 0, 0, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::set_roommemberdata_internal(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SetRoomMemberDataInternalRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->set_roommemberdata_internal(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_set_roommemberdata_internal(u32 req_id, std::vector<u8>& /*reply_data*/)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
u32 event_key = get_event_key(); // Unsure if necessary if there is no data
|
||||
|
||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SetRoomMemberDataInternal, event_key, 0, 0, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::get_ping_info(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SignalingGetPingInfoRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->ping_room_owner(req_id, get_match2_context(ctx_id)->communicationId, req->roomId))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_get_ping_info(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
|
||||
auto ping_resp = reply.get_rawdata();
|
||||
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to PingRoomOwner command");
|
||||
|
||||
u32 event_key = get_event_key();
|
||||
|
||||
auto* resp = flatbuffers::GetRoot<GetPingInfoResponse>(ping_resp.data());
|
||||
auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_SignalingGetPingInfo, sizeof(SceNpMatching2SignalingGetPingInfoResponse));
|
||||
auto* final_ping_resp = reinterpret_cast<SceNpMatching2SignalingGetPingInfoResponse*>(edata.data());
|
||||
GetPingInfoResponse_to_SceNpMatching2SignalingGetPingInfoResponse(resp, final_ping_resp);
|
||||
np_memory.shrink_allocation(edata.addr(), edata.size());
|
||||
|
||||
sysutil_register_cb([=, size = edata.size()](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SignalingGetPingInfo, event_key, 0, size, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 np_handler::send_room_message(SceNpMatching2ContextId ctx_id, vm::cptr<SceNpMatching2RequestOptParam> optParam, const SceNpMatching2SendRoomMessageRequest* req)
|
||||
{
|
||||
u32 req_id = generate_callback_info(ctx_id, optParam);
|
||||
|
||||
if (!rpcn->send_room_message(req_id, get_match2_context(ctx_id)->communicationId, req))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return req_id;
|
||||
}
|
||||
|
||||
bool np_handler::reply_send_room_message(u32 req_id, std::vector<u8>& /*reply_data*/)
|
||||
{
|
||||
const auto cb_info = take_pending_request(req_id);
|
||||
|
||||
sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32
|
||||
{
|
||||
cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_SendRoomMessage, 0, 0, 0, cb_info.cb_arg);
|
||||
return 0;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void np_handler::req_sign_infos(const std::string& npid, u32 conn_id)
|
||||
{
|
||||
u32 req_id = get_req_id(0x3333);
|
||||
{
|
||||
std::lock_guard lock(mutex_pending_sign_infos_requests);
|
||||
pending_sign_infos_requests[req_id] = conn_id;
|
||||
}
|
||||
|
||||
if (!rpcn->req_sign_infos(req_id, npid))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool np_handler::reply_req_sign_infos(u32 req_id, std::vector<u8>& reply_data)
|
||||
{
|
||||
u32 conn_id;
|
||||
{
|
||||
std::lock_guard lock(mutex_pending_sign_infos_requests);
|
||||
conn_id = pending_sign_infos_requests.at(req_id);
|
||||
pending_sign_infos_requests.erase(req_id);
|
||||
}
|
||||
|
||||
vec_stream reply(reply_data, 1);
|
||||
u32 addr = reply.get<u32>();
|
||||
u16 port = reply.get<u16>();
|
||||
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to RequestSignalingInfos command");
|
||||
|
||||
auto& sigh = g_fxo->get<named_thread<signaling_handler>>();
|
||||
sigh.start_sig(conn_id, addr, port);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void np_handler::req_ticket(u32 /*version*/, const SceNpId* /*npid*/, const char* service_id, const u8* /*cookie*/, u32 /*cookie_size*/, const char* /*entitlement_id*/, u32 /*consumed_count*/)
|
||||
{
|
||||
u32 req_id = get_req_id(0x3333);
|
||||
|
||||
std::string service_id_str(service_id);
|
||||
|
||||
if (!rpcn->req_ticket(req_id, service_id_str))
|
||||
{
|
||||
rpcn_log.error("Disconnecting from RPCN!");
|
||||
is_psn_active = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool np_handler::reply_req_ticket(u32 /*req_id*/, std::vector<u8>& reply_data)
|
||||
{
|
||||
vec_stream reply(reply_data, 1);
|
||||
auto ticket_raw = reply.get_rawdata();
|
||||
|
||||
if (reply.is_error())
|
||||
return error_and_disconnect("Malformed reply to RequestTicket command");
|
||||
|
||||
current_ticket = std::move(ticket_raw);
|
||||
auto ticket_size = static_cast<s32>(current_ticket.size());
|
||||
|
||||
if (manager_cb)
|
||||
{
|
||||
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 true;
|
||||
}
|
||||
|
||||
} // namespace np
|
@ -648,7 +648,7 @@ u32 signaling_handler::init_sig_infos(const SceNpId* npid)
|
||||
|
||||
// Request peer infos from RPCN
|
||||
std::string npid_str(reinterpret_cast<const char*>(npid->handle.data));
|
||||
auto& nph = g_fxo->get<named_thread<np_handler>>();
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
nph.req_sign_infos(npid_str, conn_id);
|
||||
}
|
||||
else
|
||||
|
@ -93,6 +93,9 @@
|
||||
<ClCompile Include="Emu\NP\fb_helpers.cpp" />
|
||||
<ClCompile Include="Emu\NP\np_contexts.cpp" />
|
||||
<ClCompile Include="Emu\NP\np_handler.cpp" />
|
||||
<ClCompile Include="Emu\NP\np_helpers.cpp" />
|
||||
<ClCompile Include="Emu\NP\np_notifications.cpp" />
|
||||
<ClCompile Include="Emu\NP\np_requests.cpp" />
|
||||
<ClCompile Include="Emu\NP\signaling_handler.cpp" />
|
||||
<ClCompile Include="Emu\NP\np_structs_extra.cpp" />
|
||||
<ClCompile Include="Emu\NP\rpcn_client.cpp" />
|
||||
@ -462,6 +465,8 @@
|
||||
<ClInclude Include="Emu\NP\generated\np2_structs_generated.h" />
|
||||
<ClInclude Include="Emu\NP\np_handler.h" />
|
||||
<ClInclude Include="Emu\NP\signaling_handler.h" />
|
||||
<ClInclude Include="Emu\NP\np_allocator.h" />
|
||||
<ClInclude Include="Emu\NP\np_event_data.h" />
|
||||
<ClInclude Include="Emu\NP\np_structs_extra.h" />
|
||||
<ClInclude Include="Emu\NP\rpcn_client.h" />
|
||||
<ClInclude Include="Emu\NP\rpcn_config.h" />
|
||||
|
@ -897,6 +897,15 @@
|
||||
<ClCompile Include="Emu\NP\np_handler.cpp">
|
||||
<Filter>Emu\NP</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\NP\np_helpers.cpp">
|
||||
<Filter>Emu\NP</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\NP\np_notifications.cpp">
|
||||
<Filter>Emu\NP</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\NP\np_requests.cpp">
|
||||
<Filter>Emu\NP</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Emu\NP\signaling_handler.cpp">
|
||||
<Filter>Emu\NP</Filter>
|
||||
</ClCompile>
|
||||
|
Loading…
Reference in New Issue
Block a user