From 32a4c2242baae000978cd3eca7a3dee13f6d7759 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 12 Sep 2019 20:51:18 +0200 Subject: [PATCH] sceNp: fixups --- rpcs3/Emu/Cell/Modules/sceNp.cpp | 34 ++++- rpcs3/Emu/Cell/Modules/sceNp.h | 8 ++ rpcs3/Emu/Cell/Modules/sceNp2.cpp | 192 ++++++++++++---------------- rpcs3/Emu/Cell/Modules/sceNp2.h | 12 +- rpcs3/Emu/Cell/Modules/sceNpSns.cpp | 98 ++++++++++++-- 5 files changed, 213 insertions(+), 131 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 4e47640b07..d73e263f28 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -392,7 +392,7 @@ error_code sceNpInit(u32 poolsize, vm::ptr poolptr) { return SCE_NP_ERROR_INVALID_ARGUMENT; } - else if (poolsize < 128 * 1024) + else if (poolsize < SCE_NP_MIN_POOLSIZE) { return SCE_NP_ERROR_INSUFFICIENT_BUFFER; } @@ -1746,7 +1746,16 @@ error_code sceNpLookupInit() const auto lookup_manager = g_fxo->get(); - // TODO: check if this might throw SCE_NP_COMMUNITY_ERROR_ALREADY_INITIALIZED + if (lookup_manager->is_initialized) + { + return SCE_NP_COMMUNITY_ERROR_ALREADY_INITIALIZED; + } + + if (!g_fxo->get()->is_initialized) + { + return SCE_NP_ERROR_NOT_INITIALIZED; + } + lookup_manager->is_initialized = true; return CELL_OK; @@ -1758,7 +1767,16 @@ error_code sceNpLookupTerm() const auto lookup_manager = g_fxo->get(); - // TODO: check if this might throw SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED + if (!lookup_manager->is_initialized) + { + return SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED; + } + + if (!g_fxo->get()->is_initialized) + { + return SCE_NP_ERROR_NOT_INITIALIZED; + } + lookup_manager->is_initialized = false; return CELL_OK; @@ -2900,6 +2918,11 @@ error_code sceNpScoreInit() return SCE_NP_COMMUNITY_ERROR_ALREADY_INITIALIZED; } + if (!g_fxo->get()->is_initialized) + { + return SCE_NP_ERROR_NOT_INITIALIZED; + } + score_manager->is_initialized = true; return CELL_OK; @@ -2916,6 +2939,11 @@ error_code sceNpScoreTerm() return SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED; } + if (!g_fxo->get()->is_initialized) + { + return SCE_NP_ERROR_NOT_INITIALIZED; + } + score_manager->is_initialized = false; return CELL_OK; diff --git a/rpcs3/Emu/Cell/Modules/sceNp.h b/rpcs3/Emu/Cell/Modules/sceNp.h index 41e4972bbe..c9122b5ed9 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.h +++ b/rpcs3/Emu/Cell/Modules/sceNp.h @@ -6,6 +6,9 @@ #include +error_code sceNpInit(u32 poolsize, vm::ptr poolptr); +error_code sceNpTerm(); + using in_addr_t = u32; using in_port_t = u16; using sa_family_t = u8; @@ -490,6 +493,11 @@ enum #define SCE_NP_CUSTOM_MENU_INDEX_ZERO(p) ( for (u32 i = 0; i < (SCE_NP_CUSTOM_MENU_INDEX_SETSIZE >> SCE_NP_CUSTOM_MENU_INDEX_BITS_SHIFT); i++) p->index_bits[i] = 0; ) #define SCE_NP_CUSTOM_MENU_INDEX_SET_ALL(p) ( for (u32 i = 0; i < (SCE_NP_CUSTOM_MENU_INDEX_SETSIZE >> SCE_NP_CUSTOM_MENU_INDEX_BITS_SHIFT); i++) p->index_bits[i] = SCE_NP_CUSTOM_MENU_INDEX_BITS_ALL; ) +enum +{ + SCE_NP_MIN_POOLSIZE = 128 * 1024 +}; + enum { SCE_NP_DRM_OPEN_FLAG = 2 diff --git a/rpcs3/Emu/Cell/Modules/sceNp2.cpp b/rpcs3/Emu/Cell/Modules/sceNp2.cpp index dc8bd08033..8625553780 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp2.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp2.cpp @@ -173,6 +173,10 @@ void fmt_class_string::format(std::string& out, u64 arg) }); } +error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr param); +error_code sceNpMatching2Term(ppu_thread& ppu); +error_code sceNpMatching2Term2(); + error_code sceNp2Init(u64 poolsize, vm::ptr poolptr) { sceNp2.warning("sceNp2Init(poolsize=0x%x, poolptr=*0x%x)", poolsize, poolptr); @@ -184,14 +188,11 @@ error_code sceNp2Init(u64 poolsize, vm::ptr poolptr) return SCE_NP_ERROR_ALREADY_INITIALIZED; } - if (poolsize == 0 || !poolptr) - { - return SCE_NP_ERROR_INVALID_ARGUMENT; - } + auto result = sceNpInit(poolsize, poolptr); - if (poolsize < SCE_NP_MIN_POOLSIZE) + if (result != CELL_OK) { - return SCE_NP_ERROR_INSUFFICIENT_BUFFER; + return result; } manager->is_initialized = true; @@ -202,22 +203,7 @@ error_code sceNp2Init(u64 poolsize, vm::ptr poolptr) error_code sceNpMatching2Init(u32 stackSize, s32 priority) { sceNp2.todo("sceNpMatching2Init(stackSize=0x%x, priority=%d)", stackSize, priority); - - if (!g_fxo->get()->is_initialized) - { - return SCE_NP_ERROR_NOT_INITIALIZED; - } - - const auto matching_manager = g_fxo->get(); - - if (matching_manager->is_initialized) - { - return SCE_NP_MATCHING2_ERROR_ALREADY_INITIALIZED; - } - - matching_manager->is_initialized = true; - - return CELL_OK; + return sceNpMatching2Init2(stackSize, priority, vm::null); // > SDK 2.4.0 } error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr param) @@ -229,7 +215,7 @@ error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptrget(); + const auto matching_2_manager = g_fxo->get(); if (matching_2_manager->is_initialized) { @@ -246,7 +232,7 @@ error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptris_initialized = false; return CELL_OK; @@ -265,22 +256,7 @@ error_code sceNp2Term() error_code sceNpMatching2Term(ppu_thread& ppu) { sceNp2.warning("sceNpMatching2Term()"); - - if (!g_fxo->get()->is_initialized) - { - return SCE_NP_ERROR_NOT_INITIALIZED; - } - - const auto matching_manager = g_fxo->get(); - - if (!matching_manager->is_initialized) - { - return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; - } - - matching_manager->is_initialized = false; - - return CELL_OK; + return sceNpMatching2Term2(); // > SDK 2.4.0 } error_code sceNpMatching2Term2() @@ -292,13 +268,15 @@ error_code sceNpMatching2Term2() return SCE_NP_ERROR_NOT_INITIALIZED; } - const auto matching_2_manager = g_fxo->get(); + const auto matching_2_manager = g_fxo->get(); if (!matching_2_manager->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } + // TODO: for all contexts: sceNpMatching2DestroyContext + matching_2_manager->is_initialized = false; return CELL_OK; @@ -308,7 +286,7 @@ error_code sceNpMatching2DestroyContext(SceNpMatching2ContextId ctxId) { sceNp2.todo("sceNpMatching2DestroyContext(ctxId=%d)", ctxId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -320,7 +298,7 @@ error_code sceNpMatching2LeaveLobby(SceNpMatching2ContextId ctxId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -337,7 +315,7 @@ error_code sceNpMatching2RegisterLobbyMessageCallback(SceNpMatching2ContextId ct { sceNp2.todo("sceNpMatching2RegisterLobbyMessageCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -349,7 +327,7 @@ error_code sceNpMatching2GetWorldInfoList(SceNpMatching2ContextId ctxId, vm::cpt { sceNp2.todo("sceNpMatching2GetWorldInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -366,7 +344,7 @@ error_code sceNpMatching2RegisterLobbyEventCallback(SceNpMatching2ContextId ctxI { sceNp2.todo("sceNpMatching2RegisterLobbyEventCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -378,7 +356,7 @@ error_code sceNpMatching2GetLobbyMemberDataInternalList(SceNpMatching2ContextId { sceNp2.todo("sceNpMatching2GetLobbyMemberDataInternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -395,7 +373,7 @@ error_code sceNpMatching2SearchRoom(SceNpMatching2ContextId ctxId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -412,7 +390,7 @@ error_code sceNpMatching2SignalingGetConnectionStatus(SceNpMatching2ContextId ct { sceNp2.todo("sceNpMatching2SignalingGetConnectionStatus(ctxId=%d, roomId=%d, memberId=%d, connStatus=*0x%x, peerAddr=*0x%x, peerPort=*0x%x)", ctxId, roomId, memberId, connStatus, peerAddr, peerPort); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -424,7 +402,7 @@ error_code sceNpMatching2SetUserInfo(SceNpMatching2ContextId ctxId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -441,7 +419,7 @@ error_code sceNpMatching2GetClanLobbyId(SceNpMatching2ContextId ctxId, SceNpClan { sceNp2.todo("sceNpMatching2GetClanLobbyId(ctxId=%d, clanId=%d, lobbyId=*0x%x)", ctxId, clanId, lobbyId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -453,7 +431,7 @@ error_code sceNpMatching2GetLobbyMemberDataInternal(SceNpMatching2ContextId ctxI { sceNp2.todo("sceNpMatching2GetLobbyMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -470,7 +448,7 @@ error_code sceNpMatching2ContextStart(SceNpMatching2ContextId ctxId) { sceNp2.todo("sceNpMatching2ContextStart(ctxId=%d)", ctxId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -482,7 +460,7 @@ error_code sceNpMatching2CreateServerContext(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2CreateServerContext(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -499,7 +477,7 @@ error_code sceNpMatching2GetMemoryInfo(vm::ptr memInfo { sceNp2.todo("sceNpMatching2GetMemoryInfo(memInfo=*0x%x)", memInfo); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -511,7 +489,7 @@ error_code sceNpMatching2LeaveRoom(SceNpMatching2ContextId ctxId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -528,7 +506,7 @@ error_code sceNpMatching2SetRoomDataExternal(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2SetRoomDataExternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -545,7 +523,7 @@ error_code sceNpMatching2SignalingGetConnectionInfo(SceNpMatching2ContextId ctxI { sceNp2.todo("sceNpMatching2SignalingGetConnectionInfo(ctxId=%d, roomId=%d, memberId=%d, code=%d, connInfo=*0x%x)", ctxId, roomId, memberId, code, connInfo); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -557,7 +535,7 @@ error_code sceNpMatching2SendRoomMessage(SceNpMatching2ContextId ctxId, vm::cptr { sceNp2.todo("sceNpMatching2SendRoomMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -574,7 +552,7 @@ error_code sceNpMatching2JoinLobby(SceNpMatching2ContextId ctxId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -591,7 +569,7 @@ error_code sceNpMatching2GetRoomMemberDataExternalList(SceNpMatching2ContextId c { sceNp2.todo("sceNpMatching2GetRoomMemberDataExternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -608,7 +586,7 @@ error_code sceNpMatching2AbortRequest(SceNpMatching2ContextId ctxId, SceNpMatchi { sceNp2.todo("sceNpMatching2AbortRequest(ctxId=%d, reqId=%d)", ctxId, reqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -620,7 +598,7 @@ error_code sceNpMatching2GetServerInfo(SceNpMatching2ContextId ctxId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -637,7 +615,7 @@ error_code sceNpMatching2GetEventData(SceNpMatching2ContextId ctxId, SceNpMatchi { sceNp2.todo("sceNpMatching2GetEventData(ctxId=%d, eventKey=%d, buf=*0x%x, bufLen=%d)", ctxId, eventKey, buf, bufLen); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -654,7 +632,7 @@ error_code sceNpMatching2GetRoomSlotInfoLocal(SceNpMatching2ContextId ctxId, con { sceNp2.todo("sceNpMatching2GetRoomSlotInfoLocal(ctxId=%d, roomId=%d, roomSlotInfo=*0x%x)", ctxId, roomId, roomSlotInfo); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -666,7 +644,7 @@ error_code sceNpMatching2SendLobbyChatMessage(SceNpMatching2ContextId ctxId, vm: { sceNp2.todo("sceNpMatching2SendLobbyChatMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -683,7 +661,7 @@ error_code sceNpMatching2AbortContextStart(SceNpMatching2ContextId ctxId) { sceNp2.todo("sceNpMatching2AbortContextStart(ctxId=%d)", ctxId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -695,7 +673,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); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -707,7 +685,7 @@ error_code sceNpMatching2JoinRoom(SceNpMatching2ContextId ctxId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -726,7 +704,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); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -738,7 +716,7 @@ error_code sceNpMatching2GetCbQueueInfo(SceNpMatching2ContextId ctxId, vm::ptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -750,7 +728,7 @@ error_code sceNpMatching2KickoutRoomMember(SceNpMatching2ContextId ctxId, vm::cp { sceNp2.todo("sceNpMatching2KickoutRoomMember(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -767,7 +745,7 @@ error_code sceNpMatching2ContextStartAsync(SceNpMatching2ContextId ctxId, u32 ti { sceNp2.todo("sceNpMatching2ContextStartAsync(ctxId=%d, timeout=%d)", ctxId, timeout); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -779,7 +757,7 @@ error_code sceNpMatching2SetSignalingOptParam(SceNpMatching2ContextId ctxId, vm: { sceNp2.todo("sceNpMatching2SetSignalingOptParam(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -796,7 +774,7 @@ error_code sceNpMatching2RegisterContextCallback(SceNpMatching2ContextId ctxId, { sceNp2.todo("sceNpMatching2RegisterContextCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -808,7 +786,7 @@ error_code sceNpMatching2SendRoomChatMessage(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2SendRoomChatMessage(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -825,7 +803,7 @@ error_code sceNpMatching2SetRoomDataInternal(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2SetRoomDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -842,7 +820,7 @@ error_code sceNpMatching2GetRoomDataInternal(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2GetRoomDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -859,7 +837,7 @@ error_code sceNpMatching2SignalingGetPingInfo(SceNpMatching2ContextId ctxId, vm: { sceNp2.todo("sceNpMatching2SignalingGetPingInfo(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -876,7 +854,7 @@ error_code sceNpMatching2GetServerIdListLocal(SceNpMatching2ContextId ctxId, vm: { sceNp2.todo("sceNpMatching2GetServerIdListLocal(ctxId=%d, serverId=*0x%x, serverIdNum=%d)", ctxId, serverId, serverIdNum); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -906,7 +884,7 @@ error_code sceNpMatching2GrantRoomOwner(SceNpMatching2ContextId ctxId, vm::cptr< { sceNp2.todo("sceNpMatching2GrantRoomOwner(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -923,7 +901,7 @@ error_code sceNpMatching2CreateContext(vm::cptr npId, vm::cptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -940,7 +918,7 @@ error_code sceNpMatching2GetSignalingOptParamLocal(SceNpMatching2ContextId ctxId { sceNp2.todo("sceNpMatching2GetSignalingOptParamLocal(ctxId=%d, roomId=%d, signalingOptParam=*0x%x)", ctxId, roomId, signalingOptParam); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -952,7 +930,7 @@ error_code sceNpMatching2RegisterSignalingCallback(SceNpMatching2ContextId ctxId { sceNp2.todo("sceNpMatching2RegisterSignalingCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -964,7 +942,7 @@ error_code sceNpMatching2ClearEventData(SceNpMatching2ContextId ctxId, SceNpMatc { sceNp2.todo("sceNpMatching2ClearEventData(ctxId=%d, eventKey=%d)", ctxId, eventKey); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -976,7 +954,7 @@ error_code sceNpMatching2GetUserInfoList(SceNpMatching2ContextId ctxId, vm::cptr { sceNp2.todo("sceNpMatching2GetUserInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -993,7 +971,7 @@ error_code sceNpMatching2GetRoomMemberDataInternal(SceNpMatching2ContextId ctxId { sceNp2.todo("sceNpMatching2GetRoomMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1010,7 +988,7 @@ error_code sceNpMatching2SetRoomMemberDataInternal(SceNpMatching2ContextId ctxId { sceNp2.todo("sceNpMatching2SetRoomMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1027,7 +1005,7 @@ error_code sceNpMatching2JoinProhibitiveRoom(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2JoinProhibitiveRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1044,7 +1022,7 @@ error_code sceNpMatching2SignalingSetCtxOpt(SceNpMatching2ContextId ctxId, s32 o { sceNp2.todo("sceNpMatching2SignalingSetCtxOpt(ctxId=%d, optname=%d, optval=%d)", ctxId, optname, optval); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1056,7 +1034,7 @@ error_code sceNpMatching2DeleteServerContext(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2DeleteServerContext(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1073,7 +1051,7 @@ error_code sceNpMatching2SetDefaultRequestOptParam(SceNpMatching2ContextId ctxId { sceNp2.todo("sceNpMatching2SetDefaultRequestOptParam(ctxId=%d, optParam=*0x%x)", ctxId, optParam); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1090,7 +1068,7 @@ error_code sceNpMatching2RegisterRoomEventCallback(SceNpMatching2ContextId ctxId { sceNp2.todo("sceNpMatching2RegisterRoomEventCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1102,7 +1080,7 @@ error_code sceNpMatching2GetRoomPasswordLocal(SceNpMatching2ContextId ctxId, Sce { sceNp2.todo("sceNpMatching2GetRoomPasswordLocal(ctxId=%d, roomId=%d, withPassword=*0x%x, roomPassword=*0x%x)", ctxId, roomId, withPassword, roomPassword); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1114,7 +1092,7 @@ error_code sceNpMatching2GetRoomDataExternalList(SceNpMatching2ContextId ctxId, { sceNp2.todo("sceNpMatching2GetRoomDataExternalList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1131,7 +1109,7 @@ error_code sceNpMatching2CreateJoinRoom(SceNpMatching2ContextId ctxId, vm::cptr< { sceNp2.todo("sceNpMatching2CreateJoinRoom(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1148,7 +1126,7 @@ error_code sceNpMatching2SignalingGetCtxOpt(SceNpMatching2ContextId ctxId, s32 o { sceNp2.todo("sceNpMatching2SignalingGetCtxOpt(ctxId=%d, optname=%d, optval=*0x%x)", ctxId, optname, optval); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1160,7 +1138,7 @@ error_code sceNpMatching2GetLobbyInfoList(SceNpMatching2ContextId ctxId, vm::cpt { sceNp2.todo("sceNpMatching2GetLobbyInfoList(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1177,7 +1155,7 @@ error_code sceNpMatching2GetLobbyMemberIdListLocal(SceNpMatching2ContextId ctxId { sceNp2.todo("sceNpMatching2GetLobbyMemberIdListLocal(ctxId=%d, lobbyId=%d, memberId=*0x%x, memberIdNum=%d, me=*0x%x)", ctxId, lobbyId, memberId, memberIdNum, me); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1189,7 +1167,7 @@ error_code sceNpMatching2SendLobbyInvitation(SceNpMatching2ContextId ctxId, vm:: { sceNp2.todo("sceNpMatching2SendLobbyInvitation(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1206,7 +1184,7 @@ error_code sceNpMatching2ContextStop(SceNpMatching2ContextId ctxId) { sceNp2.todo("sceNpMatching2ContextStop(ctxId=%d)", ctxId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1218,7 +1196,7 @@ error_code sceNpMatching2SetLobbyMemberDataInternal(SceNpMatching2ContextId ctxI { sceNp2.todo("sceNpMatching2SetLobbyMemberDataInternal(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1235,7 +1213,7 @@ error_code sceNpMatching2RegisterRoomMessageCallback(SceNpMatching2ContextId ctx { sceNp2.todo("sceNpMatching2RegisterRoomMessageCallback(ctxId=%d, cbFunc=*0x%x, cbFuncArg=*0x%x)", ctxId, cbFunc, cbFuncArg); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1247,7 +1225,7 @@ error_code sceNpMatching2SignalingCancelPeerNetInfo(SceNpMatching2ContextId ctxI { sceNp2.todo("sceNpMatching2SignalingCancelPeerNetInfo(ctxId=%d, reqId=%d)", ctxId, reqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1259,7 +1237,7 @@ error_code sceNpMatching2SignalingGetLocalNetInfo(vm::ptrget()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1277,7 +1255,7 @@ error_code sceNpMatching2SignalingGetPeerNetInfo(SceNpMatching2ContextId ctxId, { sceNp2.todo("sceNpMatching2SignalingGetPeerNetInfo(ctxId=%d, roomId=%d, roomMemberId=%d, reqId=*0x%x)", ctxId, roomId, roomMemberId, reqId); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } @@ -1294,7 +1272,7 @@ error_code sceNpMatching2SignalingGetPeerNetInfoResult(SceNpMatching2ContextId c { sceNp2.todo("sceNpMatching2SignalingGetPeerNetInfoResult(ctxId=%d, reqId=%d, netinfo=*0x%x)", ctxId, reqId, netinfo); - if (!g_fxo->get()->is_initialized) + if (!g_fxo->get()->is_initialized) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } diff --git a/rpcs3/Emu/Cell/Modules/sceNp2.h b/rpcs3/Emu/Cell/Modules/sceNp2.h index b19e18b09e..5daed324a6 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp2.h +++ b/rpcs3/Emu/Cell/Modules/sceNp2.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "sceNp.h" @@ -465,11 +465,6 @@ enum SCE_NP_MATCHING2_CONTEXT_EVENT_Stop = 0x6f03, }; -enum -{ - SCE_NP_MIN_POOLSIZE = 128 * 1024 -}; - typedef u16 SceNpMatching2ServerId; typedef u32 SceNpMatching2WorldId; typedef u16 SceNpMatching2WorldNumber; @@ -1597,11 +1592,6 @@ struct sce_np_2_matching_manager std::atomic is_initialized = false; }; -struct sce_np_2_matching_2_manager -{ - std::atomic is_initialized = false; -}; - struct sce_np_oauth_2_manager { std::atomic is_initialized = false; diff --git a/rpcs3/Emu/Cell/Modules/sceNpSns.cpp b/rpcs3/Emu/Cell/Modules/sceNpSns.cpp index 31979e6c24..3124d0733c 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpSns.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpSns.cpp @@ -91,13 +91,14 @@ error_code sceNpSnsFbCreateHandle(vm::ptr handle) return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; } - //if (count > SCE_NP_SNS_FB_HANDLE_SLOT_MAX) - //{ - // return SCE_NP_SNS_FB_ERROR_EXCEEDS_MAX; - //} - + // TODO: is handle set here or after the next check ? *handle = idm::make(); + if (*handle == SCE_NP_SNS_FB_INVALID_HANDLE) // id_count > SCE_NP_SNS_FB_HANDLE_SLOT_MAX + { + return SCE_NP_SNS_FB_ERROR_EXCEEDS_MAX; + } + return CELL_OK; } @@ -157,12 +158,19 @@ error_code sceNpSnsFbGetAccessToken(u32 handle, vm::cptrfb_app_id) + { + return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; + } + if (!g_fxo->get()->is_initialized) { return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED; } - if (handle == SCE_NP_SNS_FB_INVALID_HANDLE || handle > SCE_NP_SNS_FB_HANDLE_SLOT_MAX || !param || !result || !param->fb_app_id) + // TODO: test the following checks + + if (handle == SCE_NP_SNS_FB_INVALID_HANDLE || handle > SCE_NP_SNS_FB_HANDLE_SLOT_MAX) { return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; } @@ -184,27 +192,90 @@ error_code sceNpSnsFbGetAccessToken(u32 handle, vm::cptr SCE_NP_SNS_FB_HANDLE_SLOT_MAX) + { + return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; + } + + const auto sfh = idm::get(handle); + + if (!sfh) + { + return SCE_NP_SNS_FB_ERROR_UNKNOWN_HANDLE; + } + + //if (canceled) + //{ + // return CELL_ECANCELED; + //} + + //if (aborted) + //{ + // return SCE_NP_SNS_FB_ERROR_ABORTED; + //} + return CELL_OK; } -s32 sceNpSnsFbCheckThrottle() +s32 sceNpSnsFbCheckThrottle(vm::ptr r3) { UNIMPLEMENTED_FUNC(sceNpSns); + + if (!r3) + { + return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; + } + + if (!g_fxo->get()->is_initialized) + { + return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED; + } + return CELL_OK; } s32 sceNpSnsFbCheckConfig() { UNIMPLEMENTED_FUNC(sceNpSns); + + if (!g_fxo->get()->is_initialized) + { + return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED; + } + return CELL_OK; } -s32 sceNpSnsFbLoadThrottle() +s32 sceNpSnsFbLoadThrottle(u32 handle) { UNIMPLEMENTED_FUNC(sceNpSns); + + if (handle == SCE_NP_SNS_FB_INVALID_HANDLE || handle > SCE_NP_SNS_FB_HANDLE_SLOT_MAX) + { + return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; + } + + const auto sfh = idm::get(handle); + + if (!sfh) + { + return SCE_NP_SNS_FB_ERROR_UNKNOWN_HANDLE; + } + + //if (canceled) + //{ + // return CELL_ECANCELED; + //} + + //if (aborted) + //{ + // return SCE_NP_SNS_FB_ERROR_ABORTED; + //} + return CELL_OK; } @@ -212,12 +283,19 @@ error_code sceNpSnsFbGetLongAccessToken(u32 handle, vm::cptrfb_app_id) + { + return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; + } + if (!g_fxo->get()->is_initialized) { return SCE_NP_SNS_FB_ERROR_NOT_INITIALIZED; } - if (handle == SCE_NP_SNS_FB_INVALID_HANDLE || handle > SCE_NP_SNS_FB_HANDLE_SLOT_MAX || !param || !result || !param->fb_app_id) + // TODO: test the following checks + + if (handle == SCE_NP_SNS_FB_INVALID_HANDLE || handle > SCE_NP_SNS_FB_HANDLE_SLOT_MAX) { return SCE_NP_SNS_ERROR_INVALID_ARGUMENT; }