diff --git a/rpcs3/Emu/Cell/Modules/sceNp2.cpp b/rpcs3/Emu/Cell/Modules/sceNp2.cpp index 38db62ee20..0788ca6d82 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp2.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp2.cpp @@ -179,14 +179,14 @@ error_code sceNpMatching2Init2(u32 stackSize, s32 priority, vm::ptr& nph, SceNpMatching2ContextId ctxId, vm::cptr reqParam, vm::ptr assignedReqId) +error_code generic_match2_error_check(const named_thread& nph, SceNpMatching2ContextId ctxId, vm::cptr reqParam) { if (!nph.is_NP2_Match2_init) { return SCE_NP_MATCHING2_ERROR_NOT_INITIALIZED; } - if (!reqParam || !assignedReqId) + if (!reqParam) { return SCE_NP_MATCHING2_ERROR_INVALID_ARGUMENT; } @@ -341,7 +341,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -369,7 +369,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -379,7 +379,12 @@ error_code sceNpMatching2GetWorldInfoList( return SCE_NP_MATCHING2_ERROR_INVALID_SERVER_ID; } - *assignedReqId = nph.get_world_list(ctxId, optParam, reqParam->serverId); + const u32 request_id = nph.get_world_list(ctxId, optParam, reqParam->serverId); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -404,7 +409,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -418,12 +423,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.search_room(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.search_room(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -497,7 +507,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -525,7 +535,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -566,7 +576,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -576,7 +586,12 @@ error_code sceNpMatching2CreateServerContext( return SCE_NP_MATCHING2_ERROR_INVALID_SERVER_ID; } - *assignedReqId = nph.create_server_context(ctxId, optParam, reqParam->serverId); + const u32 request_id = nph.create_server_context(ctxId, optParam, reqParam->serverId); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -601,12 +616,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.leave_room(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.leave_room(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -617,12 +637,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.set_roomdata_external(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.set_roomdata_external(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -713,12 +738,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.send_room_message(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.send_room_message(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -729,7 +759,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -743,7 +773,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -784,12 +814,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.get_server_status(ctxId, optParam, reqParam->serverId); + const u32 request_id = nph.get_server_status(ctxId, optParam, reqParam->serverId); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -862,7 +897,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -938,12 +973,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.join_room(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.join_room(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1014,7 +1054,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1060,7 +1100,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1100,7 +1140,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1114,12 +1154,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.set_roomdata_internal(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.set_roomdata_internal(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1130,12 +1175,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.get_roomdata_internal(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.get_roomdata_internal(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1146,12 +1196,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.get_ping_info(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.get_ping_info(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1211,7 +1266,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1297,7 +1352,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1311,7 +1366,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1325,12 +1380,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.set_roommemberdata_internal(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.set_roommemberdata_internal(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1341,13 +1401,18 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } // TODO: add blocked users - *assignedReqId = nph.join_room(ctxId, optParam, &reqParam->joinParam); + const u32 request_id = nph.join_room(ctxId, optParam, &reqParam->joinParam); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1372,7 +1437,7 @@ error_code sceNpMatching2DeleteServerContext( sceNp2.warning("sceNpMatching2DeleteServerContext(ctxId=%d, reqParam=*0x%x, optParam=*0x%x, assignedReqId=*0x%x)", ctxId, reqParam, optParam, assignedReqId); auto& nph = g_fxo->get>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1382,7 +1447,12 @@ error_code sceNpMatching2DeleteServerContext( return SCE_NP_MATCHING2_ERROR_INVALID_SERVER_ID; } - *assignedReqId = nph.delete_server_context(ctxId, optParam, reqParam->serverId); + const u32 request_id = nph.delete_server_context(ctxId, optParam, reqParam->serverId); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1485,12 +1555,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.get_roomdata_external_list(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.get_roomdata_external_list(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1501,12 +1576,17 @@ 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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } - *assignedReqId = nph.create_join_room(ctxId, optParam, reqParam.get_ptr()); + const u32 request_id = nph.create_join_room(ctxId, optParam, reqParam.get_ptr()); + + if (assignedReqId) + { + *assignedReqId = request_id; + } return CELL_OK; } @@ -1531,7 +1611,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1560,7 +1640,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; } @@ -1604,7 +1684,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>(); - if (auto res = generic_match2_error_check(nph, ctxId, reqParam, assignedReqId); res != CELL_OK) + if (auto res = generic_match2_error_check(nph, ctxId, reqParam); res != CELL_OK) { return res; }