diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index ee176603d5..48ce271ebf 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -1299,7 +1299,7 @@ error_code sceNpBasicGetFriendListEntryCount(vm::ptr count) error_code sceNpBasicGetFriendListEntry(u32 index, vm::ptr npid) { - sceNp.todo("sceNpBasicGetFriendListEntry(index=%d, npid=*0x%x)", index, npid); + sceNp.warning("sceNpBasicGetFriendListEntry(index=%d, npid=*0x%x)", index, npid); auto& nph = g_fxo->get>(); @@ -4146,7 +4146,7 @@ error_code sceNpScoreRecordScoreAsync(s32 transId, SceNpScoreBoardId boardId, Sc return scenp_score_record_score(transId, boardId, score, scoreComment, gameInfo, tmpRank, option, true); } -error_code scenp_score_record_game_data(s32 transId, SceNpScoreBoardId /* boardId */, SceNpScoreValue /* score */, u64 /* totalSize */, u64 /* sendSize */, vm::cptr data, vm::ptr option, bool /* async */) +error_code scenp_score_record_game_data(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, vm::cptr data, vm::ptr /* option */, bool async) { auto& nph = g_fxo->get>(); @@ -4155,19 +4155,14 @@ error_code scenp_score_record_game_data(s32 transId, SceNpScoreBoardId /* boardI return SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED; } - if (nph.get_psn_status() != SCE_NP_MANAGER_STATUS_ONLINE) - { - return SCE_NP_COMMUNITY_ERROR_INVALID_ONLINE_ID; - } - if (!data) { return SCE_NP_COMMUNITY_ERROR_INSUFFICIENT_ARGUMENT; } - if (option) // option check at least until fw 4.71 + if (!transId) { - return SCE_NP_COMMUNITY_ERROR_INVALID_ARGUMENT; + return SCE_NP_COMMUNITY_ERROR_INVALID_ID; } auto trans_ctx = idm::get(transId); @@ -4177,24 +4172,41 @@ error_code scenp_score_record_game_data(s32 transId, SceNpScoreBoardId /* boardI return SCE_NP_COMMUNITY_ERROR_INVALID_ID; } - return CELL_OK; + if (!nph.is_NP_init) + { + return SCE_NP_ERROR_NOT_INITIALIZED; + } + + if (nph.get_psn_status() != SCE_NP_MANAGER_STATUS_ONLINE) + { + return SCE_NP_COMMUNITY_ERROR_INVALID_ONLINE_ID; + } + + nph.record_score_data(trans_ctx, boardId, score, totalSize, sendSize, static_cast(data.get_ptr()), async); + + if (async) + { + return CELL_OK; + } + + return *trans_ctx->result; } -error_code sceNpScoreRecordGameData(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u64 totalSize, u64 sendSize, vm::cptr data, vm::ptr option) +error_code sceNpScoreRecordGameData(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, vm::cptr data, vm::ptr option) { sceNp.todo("sceNpScoreRecordGameData(transId=%d, boardId=%d, score=%d, totalSize=%d, sendSize=%d, data=*0x%x, option=*0x%x)", transId, boardId, score, totalSize, sendSize, data, option); return scenp_score_record_game_data(transId, boardId, score, totalSize, sendSize, data, option, false); } -error_code sceNpScoreRecordGameDataAsync(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u64 totalSize, u64 sendSize, vm::cptr data, s32 prio, vm::ptr option) +error_code sceNpScoreRecordGameDataAsync(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, vm::cptr data, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreRecordGameDataAsync(transId=%d, boardId=%d, score=%d, totalSize=%d, sendSize=%d, data=*0x%x, prio=%d, option=*0x%x)", transId, boardId, score, totalSize, sendSize, data, prio, option); return scenp_score_record_game_data(transId, boardId, score, totalSize, sendSize, data, option, true); } -error_code scenp_score_get_game_data(s32 /* transId */, SceNpScoreBoardId /* boardId */, vm::cptr npId, vm::ptr totalSize, u64 /* recvSize */, vm::ptr data, vm::ptr option, bool /* async */) +error_code scenp_score_get_game_data(s32 transId, SceNpScoreBoardId boardId, vm::cptr npId, vm::ptr totalSize, u32 recvSize, vm::ptr data, vm::ptr /* option */, bool async) { auto& nph = g_fxo->get>(); @@ -4203,14 +4215,16 @@ error_code scenp_score_get_game_data(s32 /* transId */, SceNpScoreBoardId /* boa return SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED; } - if (!npId || !totalSize || !data) + if (!npId || !data) { return SCE_NP_COMMUNITY_ERROR_INSUFFICIENT_ARGUMENT; } - if (option) // option check at least until fw 4.71 + auto trans_ctx = idm::get(transId); + + if (!trans_ctx) { - return SCE_NP_COMMUNITY_ERROR_INVALID_ARGUMENT; + return SCE_NP_COMMUNITY_ERROR_INVALID_ID; } if (nph.get_psn_status() != SCE_NP_MANAGER_STATUS_ONLINE) @@ -4218,17 +4232,24 @@ error_code scenp_score_get_game_data(s32 /* transId */, SceNpScoreBoardId /* boa return SCE_NP_COMMUNITY_ERROR_INVALID_ONLINE_ID; } - return CELL_OK; + nph.get_score_data(trans_ctx, boardId, *npId, totalSize, recvSize, data, async); + + if (async) + { + return CELL_OK; + } + + return *trans_ctx->result; } -error_code sceNpScoreGetGameData(s32 transId, SceNpScoreBoardId boardId, vm::cptr npId, vm::ptr totalSize, u64 recvSize, vm::ptr data, vm::ptr option) +error_code sceNpScoreGetGameData(s32 transId, SceNpScoreBoardId boardId, vm::cptr npId, vm::ptr totalSize, u32 recvSize, vm::ptr data, vm::ptr option) { sceNp.todo("sceNpScoreGetGameDataAsync(transId=%d, boardId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, option=*0x%x)", transId, boardId, npId, totalSize, recvSize, data, option); return scenp_score_get_game_data(transId, boardId, npId, totalSize, recvSize, data, option, false); } -error_code sceNpScoreGetGameDataAsync(s32 transId, SceNpScoreBoardId boardId, vm::cptr npId, vm::ptr totalSize, u64 recvSize, vm::ptr data, s32 prio, vm::ptr option) +error_code sceNpScoreGetGameDataAsync(s32 transId, SceNpScoreBoardId boardId, vm::cptr npId, vm::ptr totalSize, u32 recvSize, vm::ptr data, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreGetGameDataAsync(transId=%d, boardId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, prio=%d, option=*0x%x)", transId, boardId, npId, totalSize, recvSize, data, prio, option); @@ -4237,8 +4258,8 @@ error_code sceNpScoreGetGameDataAsync(s32 transId, SceNpScoreBoardId boardId, vm } template -error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardId, T npIdArray, u64 npIdArraySize, vm::ptr rankArray, u64 rankArraySize, - vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardId, T npIdArray, u32 npIdArraySize, vm::ptr rankArray, u32 rankArraySize, + vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr /* option */, bool async) { auto& nph = g_fxo->get>(); @@ -4284,7 +4305,8 @@ error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardI return SCE_NP_COMMUNITY_ERROR_INVALID_ALIGNMENT; } - if (rankArraySize != (arrayNum * sizeof(SceNpScorePlayerRankData))) + // Function can actually accept SceNpScoreRankData though it is undocumented + if (rankArraySize != (arrayNum * sizeof(SceNpScorePlayerRankData)) && rankArraySize != (arrayNum * sizeof(SceNpScoreRankData))) { return SCE_NP_COMMUNITY_ERROR_INVALID_ALIGNMENT; } @@ -4302,7 +4324,7 @@ error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardI return SCE_NP_COMMUNITY_ERROR_INVALID_ALIGNMENT; } - for (u64 index = 0; index < arrayNum; index++) + for (u32 index = 0; index < arrayNum; index++) { npid_vec.push_back(std::make_pair(npIdArray[index], 0)); } @@ -4314,7 +4336,7 @@ error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardI return SCE_NP_COMMUNITY_ERROR_INVALID_ALIGNMENT; } - for (u64 index = 0; index < arrayNum; index++) + for (u32 index = 0; index < arrayNum; index++) { npid_vec.push_back(std::make_pair(npIdArray[index].npId, npIdArray[index].pcId)); } @@ -4330,8 +4352,8 @@ error_code scenp_score_get_ranking_by_npid(s32 transId, SceNpScoreBoardId boardI return *trans_ctx->result; } -error_code sceNpScoreGetRankingByNpId(s32 transId, SceNpScoreBoardId boardId, vm::cptr npIdArray, u64 npIdArraySize, vm::ptr rankArray, u64 rankArraySize, - vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetRankingByNpId(s32 transId, SceNpScoreBoardId boardId, vm::cptr npIdArray, u32 npIdArraySize, vm::ptr rankArray, u32 rankArraySize, + vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.warning("sceNpScoreGetRankingByNpId(transId=%d, boardId=%d, npIdArray=*0x%x, npIdArraySize=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, " @@ -4342,8 +4364,8 @@ error_code sceNpScoreGetRankingByNpId(s32 transId, SceNpScoreBoardId boardId, vm infoArraySize, arrayNum, lastSortDate, totalRecord, option, false); } -error_code sceNpScoreGetRankingByNpIdAsync(s32 transId, SceNpScoreBoardId boardId, vm::cptr npIdArray, u64 npIdArraySize, vm::ptr rankArray, u64 rankArraySize, - vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetRankingByNpIdAsync(s32 transId, SceNpScoreBoardId boardId, vm::cptr npIdArray, u32 npIdArraySize, vm::ptr rankArray, u32 rankArraySize, + vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.warning("sceNpScoreGetRankingByNpIdAsync(transId=%d, boardId=%d, npIdArray=*0x%x, npIdArraySize=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, " @@ -4354,8 +4376,8 @@ error_code sceNpScoreGetRankingByNpIdAsync(s32 transId, SceNpScoreBoardId boardI infoArraySize, arrayNum, lastSortDate, totalRecord, option, true); } -error_code scenp_score_get_ranking_by_range(s32 transId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u64 rankArraySize, - vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code scenp_score_get_ranking_by_range(s32 transId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u32 rankArraySize, + vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option, bool async) { auto& nph = g_fxo->get>(); @@ -4433,8 +4455,8 @@ error_code scenp_score_get_ranking_by_range(s32 transId, SceNpScoreBoardId board return *trans_ctx->result; } -error_code sceNpScoreGetRankingByRange(s32 transId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u64 rankArraySize, - vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetRankingByRange(s32 transId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u32 rankArraySize, + vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.warning("sceNpScoreGetRankingByRange(transId=%d, boardId=%d, startSerialRank=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, infoArraySize=%d, " @@ -4445,8 +4467,8 @@ error_code sceNpScoreGetRankingByRange(s32 transId, SceNpScoreBoardId boardId, S arrayNum, lastSortDate, totalRecord, option, false); } -error_code sceNpScoreGetRankingByRangeAsync(s32 transId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u64 rankArraySize, - vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetRankingByRangeAsync(s32 transId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u32 rankArraySize, + vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.warning("sceNpScoreGetRankingByRangeAsync(transId=%d, boardId=%d, startSerialRank=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, " @@ -4457,8 +4479,8 @@ error_code sceNpScoreGetRankingByRangeAsync(s32 transId, SceNpScoreBoardId board arrayNum, lastSortDate, totalRecord, option, true); } -error_code scenp_score_get_friends_ranking(s32 transId, SceNpScoreBoardId boardId, s32 includeSelf, vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, - u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option, +error_code scenp_score_get_friends_ranking(s32 transId, SceNpScoreBoardId boardId, s32 includeSelf, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, + u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option, bool async) { auto& nph = g_fxo->get>(); @@ -4514,8 +4536,8 @@ error_code scenp_score_get_friends_ranking(s32 transId, SceNpScoreBoardId boardI return *trans_ctx->result; } -error_code sceNpScoreGetFriendsRanking(s32 transId, SceNpScoreBoardId boardId, s32 includeSelf, vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, - u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) +error_code sceNpScoreGetFriendsRanking(s32 transId, SceNpScoreBoardId boardId, s32 includeSelf, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, + u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.warning("sceNpScoreGetFriendsRanking(transId=%d, boardId=%d, includeSelf=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, infoArraySize=%d, " "arrayNum=%d, lastSortDate=*0x%x, totalRecord=*0x%x, option=*0x%x)", @@ -4525,8 +4547,8 @@ error_code sceNpScoreGetFriendsRanking(s32 transId, SceNpScoreBoardId boardId, s arrayNum, lastSortDate, totalRecord, option, false); } -error_code sceNpScoreGetFriendsRankingAsync(s32 transId, SceNpScoreBoardId boardId, s32 includeSelf, vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, - u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, +error_code sceNpScoreGetFriendsRankingAsync(s32 transId, SceNpScoreBoardId boardId, s32 includeSelf, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, + u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.warning("sceNpScoreGetFriendsRankingAsync(transId=%d, boardId=%d, includeSelf=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, infoArraySize=%d, " @@ -4537,10 +4559,8 @@ error_code sceNpScoreGetFriendsRankingAsync(s32 transId, SceNpScoreBoardId board arrayNum, lastSortDate, totalRecord, option, true); } -error_code sceNpScoreCensorComment(s32 transId, vm::cptr comment, vm::ptr option) +error_code scenp_score_censor_comment(s32 transId, vm::cptr comment, vm::ptr option, bool async) { - sceNp.todo("sceNpScoreCensorComment(transId=%d, comment=%s, option=*0x%x)", transId, comment, option); - auto& nph = g_fxo->get>(); if (!nph.is_NP_Score_init) @@ -4564,32 +4584,36 @@ error_code sceNpScoreCensorComment(s32 transId, vm::cptr comment, vm::ptr< return SCE_NP_COMMUNITY_ERROR_INVALID_ONLINE_ID; } - return CELL_OK; + auto trans_ctx = idm::get(transId); + + if (!trans_ctx) + { + return SCE_NP_COMMUNITY_ERROR_INVALID_ID; + } + + // TODO: actual implementation of this + trans_ctx->result = CELL_OK; + + if (async) + { + return CELL_OK; + } + + return *trans_ctx->result; +} + +error_code sceNpScoreCensorComment(s32 transId, vm::cptr comment, vm::ptr option) +{ + sceNp.todo("sceNpScoreCensorComment(transId=%d, comment=%s, option=*0x%x)", transId, comment, option); + + return scenp_score_censor_comment(transId, comment, option, false); } error_code sceNpScoreCensorCommentAsync(s32 transId, vm::cptr comment, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreCensorCommentAsync(transId=%d, comment=%s, prio=%d, option=*0x%x)", transId, comment, prio, option); - auto& nph = g_fxo->get>(); - - if (!nph.is_NP_Score_init) - { - return SCE_NP_COMMUNITY_ERROR_NOT_INITIALIZED; - } - - if (!comment) - { - return SCE_NP_COMMUNITY_ERROR_INSUFFICIENT_ARGUMENT; - } - - if (strlen(comment.get_ptr()) > SCE_NP_SCORE_CENSOR_COMMENT_MAXLEN || option) // option check at least until fw 4.71 - { - // TODO: is SCE_NP_SCORE_CENSOR_COMMENT_MAXLEN + 1 allowed ? - return SCE_NP_COMMUNITY_ERROR_INVALID_ARGUMENT; - } - - return CELL_OK; + return scenp_score_censor_comment(transId, comment, option, true); } error_code sceNpScoreSanitizeComment(s32 transId, vm::cptr comment, vm::ptr sanitizedComment, vm::ptr option) @@ -4651,8 +4675,8 @@ error_code sceNpScoreSanitizeCommentAsync(s32 transId, vm::cptr comment, v return CELL_OK; } -error_code sceNpScoreGetRankingByNpIdPcId(s32 transId, SceNpScoreBoardId boardId, vm::cptr idArray, u64 idArraySize, vm::ptr rankArray, u64 rankArraySize, - vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetRankingByNpIdPcId(s32 transId, SceNpScoreBoardId boardId, vm::cptr idArray, u32 idArraySize, vm::ptr rankArray, u32 rankArraySize, + vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.warning("sceNpScoreGetRankingByNpIdPcId(transId=%d, boardId=%d, idArray=*0x%x, idArraySize=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, " @@ -4663,8 +4687,8 @@ error_code sceNpScoreGetRankingByNpIdPcId(s32 transId, SceNpScoreBoardId boardId infoArraySize, arrayNum, lastSortDate, totalRecord, option, false); } -error_code sceNpScoreGetRankingByNpIdPcIdAsync(s32 transId, SceNpScoreBoardId boardId, vm::cptr idArray, u64 idArraySize, vm::ptr rankArray, - u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetRankingByNpIdPcIdAsync(s32 transId, SceNpScoreBoardId boardId, vm::cptr idArray, u32 idArraySize, vm::ptr rankArray, + u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.warning("sceNpScoreGetRankingByNpIdPcIdAsync(transId=%d, boardId=%d, idArray=*0x%x, idArraySize=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, infoArray=*0x%x, " @@ -4697,9 +4721,9 @@ error_code sceNpScoreAbortTransaction(s32 transId) return CELL_OK; } -error_code sceNpScoreGetClansMembersRankingByNpId(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u64 idArraySize, vm::ptr rankArray, - u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, vm::ptr descriptArray, - u64 descriptArraySize, u64 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) +error_code sceNpScoreGetClansMembersRankingByNpId(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u32 idArraySize, vm::ptr rankArray, + u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, vm::ptr descriptArray, + u32 descriptArraySize, u32 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.todo("sceNpScoreGetClansMembersRankingByNpId(transId=%d, clanId=%d, boardId=%d, idArray=*0x%x, idArraySize=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, " "infoArray=*0x%x, infoArraySize=%d, descriptArray=*0x%x, descriptArraySize=%d, arrayNum=%d, clanInfo=*0x%x, lastSortDate=*0x%x, totalRecord=*0x%x, option=*0x%x)", @@ -4736,9 +4760,9 @@ error_code sceNpScoreGetClansMembersRankingByNpId(s32 transId, SceNpClanId clanI return CELL_OK; } -error_code sceNpScoreGetClansMembersRankingByNpIdAsync(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u64 idArraySize, - vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, - vm::ptr descriptArray, u64 descriptArraySize, u64 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, +error_code sceNpScoreGetClansMembersRankingByNpIdAsync(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u32 idArraySize, + vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, + vm::ptr descriptArray, u32 descriptArraySize, u32 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreGetClansMembersRankingByNpIdAsync(transId=%d, clanId=%d, boardId=%d, idArray=*0x%x, idArraySize=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, " @@ -4766,9 +4790,9 @@ error_code sceNpScoreGetClansMembersRankingByNpIdAsync(s32 transId, SceNpClanId return CELL_OK; } -error_code sceNpScoreGetClansMembersRankingByNpIdPcId(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u64 idArraySize, - vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, - vm::ptr descriptArray, u64 descriptArraySize, u64 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, +error_code sceNpScoreGetClansMembersRankingByNpIdPcId(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u32 idArraySize, + vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, + vm::ptr descriptArray, u32 descriptArraySize, u32 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.todo("sceNpScoreGetClansMembersRankingByNpIdPcId(transId=%d, clanId=%d, boardId=%d, idArray=*0x%x, idArraySize=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, " @@ -4806,9 +4830,9 @@ error_code sceNpScoreGetClansMembersRankingByNpIdPcId(s32 transId, SceNpClanId c return CELL_OK; } -error_code sceNpScoreGetClansMembersRankingByNpIdPcIdAsync(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u64 idArraySize, - vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, - vm::ptr descriptArray, u64 descriptArraySize, u64 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, +error_code sceNpScoreGetClansMembersRankingByNpIdPcIdAsync(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, vm::cptr idArray, u32 idArraySize, + vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, + vm::ptr descriptArray, u32 descriptArraySize, u32 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.todo( @@ -4837,8 +4861,8 @@ error_code sceNpScoreGetClansMembersRankingByNpIdPcIdAsync(s32 transId, SceNpCla return CELL_OK; } -error_code sceNpScoreGetClansRankingByRange(s32 transId, SceNpScoreClansBoardId clanBoardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u64 rankArraySize, - vm::ptr reserved1, u64 reservedSize1, vm::ptr reserved2, u64 reservedSize2, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, +error_code sceNpScoreGetClansRankingByRange(s32 transId, SceNpScoreClansBoardId clanBoardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u32 rankArraySize, + vm::ptr reserved1, u32 reservedSize1, vm::ptr reserved2, u32 reservedSize2, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.todo("sceNpScoreGetClansRankingByRange(transId=%d, clanBoardId=%d, startSerialRank=%d, rankArray=*0x%x, rankArraySize=%d, reserved1=*0x%x, reservedSize1=%d, reserved2=*0x%x, reservedSize2=%d, " @@ -4875,8 +4899,8 @@ error_code sceNpScoreGetClansRankingByRange(s32 transId, SceNpScoreClansBoardId return CELL_OK; } -error_code sceNpScoreGetClansRankingByRangeAsync(s32 transId, SceNpScoreClansBoardId clanBoardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u64 rankArraySize, - vm::ptr reserved1, u64 reservedSize1, vm::ptr reserved2, u64 reservedSize2, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, +error_code sceNpScoreGetClansRankingByRangeAsync(s32 transId, SceNpScoreClansBoardId clanBoardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u32 rankArraySize, + vm::ptr reserved1, u32 reservedSize1, vm::ptr reserved2, u32 reservedSize2, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreGetClansRankingByRangeAsync(transId=%d, clanBoardId=%d, startSerialRank=%d, rankArray=*0x%x, rankArraySize=%d, reserved1=*0x%x, reservedSize1=%d, reserved2=*0x%x, " @@ -4904,7 +4928,7 @@ error_code sceNpScoreGetClansRankingByRangeAsync(s32 transId, SceNpScoreClansBoa } error_code sceNpScoreGetClanMemberGameData( - s32 transId, SceNpScoreBoardId boardId, SceNpClanId clanId, vm::cptr npId, vm::ptr totalSize, u64 recvSize, vm::ptr data, vm::ptr option) + s32 transId, SceNpScoreBoardId boardId, SceNpClanId clanId, vm::cptr npId, vm::ptr totalSize, u32 recvSize, vm::ptr data, vm::ptr option) { sceNp.todo("sceNpScoreGetClanMemberGameData(transId=%d, boardId=%d, clanId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, option=*0x%x)", transId, boardId, clanId, npId, totalSize, recvSize, data, option); @@ -4935,7 +4959,7 @@ error_code sceNpScoreGetClanMemberGameData( } error_code sceNpScoreGetClanMemberGameDataAsync( - s32 transId, SceNpScoreBoardId boardId, SceNpClanId clanId, vm::cptr npId, vm::ptr totalSize, u64 recvSize, vm::ptr data, s32 prio, vm::ptr option) + s32 transId, SceNpScoreBoardId boardId, SceNpClanId clanId, vm::cptr npId, vm::ptr totalSize, u32 recvSize, vm::ptr data, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreGetClanMemberGameDataAsync(transId=%d, boardId=%d, clanId=%d, npId=*0x%x, totalSize=*0x%x, recvSize=%d, data=*0x%x, prio=%d, option=*0x%x)", transId, boardId, clanId, npId, totalSize, recvSize, data, prio, option); @@ -4955,8 +4979,8 @@ error_code sceNpScoreGetClanMemberGameDataAsync( return CELL_OK; } -error_code sceNpScoreGetClansRankingByClanId(s32 transId, SceNpScoreClansBoardId clanBoardId, vm::cptr clanIdArray, u64 clanIdArraySize, vm::ptr rankArray, - u64 rankArraySize, vm::ptr reserved1, u64 reservedSize1, vm::ptr reserved2, u64 reservedSize2, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetClansRankingByClanId(s32 transId, SceNpScoreClansBoardId clanBoardId, vm::cptr clanIdArray, u32 clanIdArraySize, vm::ptr rankArray, + u32 rankArraySize, vm::ptr reserved1, u32 reservedSize1, vm::ptr reserved2, u32 reservedSize2, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.todo("sceNpScoreGetClansRankingByClanId(transId=%d, clanBoardId=%d, clanIdArray=*0x%x, clanIdArraySize=%d, rankArray=*0x%x, rankArraySize=%d, reserved1=*0x%x, reservedSize1=%d, " @@ -4993,8 +5017,8 @@ error_code sceNpScoreGetClansRankingByClanId(s32 transId, SceNpScoreClansBoardId return CELL_OK; } -error_code sceNpScoreGetClansRankingByClanIdAsync(s32 transId, SceNpScoreClansBoardId clanBoardId, vm::cptr clanIdArray, u64 clanIdArraySize, vm::ptr rankArray, - u64 rankArraySize, vm::ptr reserved1, u64 reservedSize1, vm::ptr reserved2, u64 reservedSize2, u64 arrayNum, vm::ptr lastSortDate, +error_code sceNpScoreGetClansRankingByClanIdAsync(s32 transId, SceNpScoreClansBoardId clanBoardId, vm::cptr clanIdArray, u32 clanIdArraySize, vm::ptr rankArray, + u32 rankArraySize, vm::ptr reserved1, u32 reservedSize1, vm::ptr reserved2, u32 reservedSize2, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreGetClansRankingByRangeAsync(transId=%d, clanBoardId=%d, clanIdArray=*0x%x, clanIdArraySize=%d, rankArray=*0x%x, rankArraySize=%d, reserved1=*0x%x, reservedSize1=%d, " @@ -5022,8 +5046,8 @@ error_code sceNpScoreGetClansRankingByClanIdAsync(s32 transId, SceNpScoreClansBo } error_code sceNpScoreGetClansMembersRankingByRange(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, - u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, vm::ptr descriptArray, - u64 descriptArraySize, u64 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) + u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, vm::ptr descriptArray, + u32 descriptArraySize, u32 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, vm::ptr option) { sceNp.todo("sceNpScoreGetClansMembersRankingByRange(transId=%d, clanId=%d, boardId=%d, startSerialRank=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, " "infoArray=*0x%x, infoArraySize=%d, descriptArray=*0x%x, descriptArraySize=%d, arrayNum=%d, clanInfo=*0x%x, lastSortDate=*0x%x, totalRecord=*0x%x, option=*0x%x)", @@ -5061,8 +5085,8 @@ error_code sceNpScoreGetClansMembersRankingByRange(s32 transId, SceNpClanId clan } error_code sceNpScoreGetClansMembersRankingByRangeAsync(s32 transId, SceNpClanId clanId, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, - u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, vm::ptr descriptArray, - u64 descriptArraySize, u64 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) + u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, vm::ptr descriptArray, + u32 descriptArraySize, u32 arrayNum, vm::ptr clanInfo, vm::ptr lastSortDate, vm::ptr totalRecord, s32 prio, vm::ptr option) { sceNp.todo("sceNpScoreGetClansMembersRankingByRangeAsync(transId=%d, clanId=%d, boardId=%d, startSerialRank=%d, rankArray=*0x%x, rankArraySize=%d, commentArray=*0x%x, commentArraySize=%d, " "infoArray=*0x%x, infoArraySize=%d, descriptArray=*0x%x, descriptArraySize=%d, arrayNum=%d, clanInfo=*0x%x, lastSortDate=*0x%x, totalRecord=*0x%x, prio=%d, option=*0x%x)", diff --git a/rpcs3/Emu/Cell/Modules/sceNp.h b/rpcs3/Emu/Cell/Modules/sceNp.h index 0b29442e77..48d3fc177b 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.h +++ b/rpcs3/Emu/Cell/Modules/sceNp.h @@ -1157,9 +1157,9 @@ struct SceNpScoreRankData be_t serialRank; be_t rank; be_t highestRank; - be_t scoreValue; be_t hasGameData; u8 pad0[4]; + be_t scoreValue; CellRtcTick recordDate; }; diff --git a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp b/rpcs3/Emu/Cell/Modules/sceNpTus.cpp index a1b9dc193b..8a494502c8 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTus.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTus.cpp @@ -1224,7 +1224,7 @@ error_code sceNpTusDeleteMultiSlotVariableVUserAsync(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, u64 totalSize, u64 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) +error_code sceNpTusSetData(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, u32 totalSize, u32 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) { sceNpTus.todo("sceNpTusSetData(transId=%d, targetNpId=*0x%x, slotId=%d, totalSize=%d, sendSize=%d, data=*0x%x, info=*0x%x, infoStructSize=%d, option=*0x%x)", transId, targetNpId, slotId, totalSize, sendSize, data, info, infoStructSize, option); @@ -1255,7 +1255,7 @@ error_code sceNpTusSetData(s32 transId, vm::cptr targetNpId, SceNpTusSl return not_an_error(data_size); } -error_code sceNpTusSetDataVUser(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, u64 totalSize, u64 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) +error_code sceNpTusSetDataVUser(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, u32 totalSize, u32 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) { sceNpTus.todo("sceNpTusSetDataAsync(transId=%d, targetVirtualUserId=*0x%x, slotId=%d, totalSize=%d, sendSize=%d, data=*0x%x, info=*0x%x, infoStructSize=%d, option=*0x%x)", transId, targetVirtualUserId, slotId, totalSize, sendSize, data, info, infoStructSize, option); @@ -1286,7 +1286,7 @@ error_code sceNpTusSetDataVUser(s32 transId, vm::cptr tar return not_an_error(data_size); } -error_code sceNpTusSetDataAsync(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, u64 totalSize, u64 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) +error_code sceNpTusSetDataAsync(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, u32 totalSize, u32 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) { sceNpTus.todo("sceNpTusSetDataAsync(transId=%d, targetNpId=*0x%x, slotId=%d, totalSize=%d, sendSize=%d, data=*0x%x, info=*0x%x, infoStructSize=%d, option=*0x%x)", transId, targetNpId, slotId, totalSize, sendSize, data, info, infoStructSize, option); @@ -1316,7 +1316,7 @@ error_code sceNpTusSetDataAsync(s32 transId, vm::cptr targetNpId, SceNp return CELL_OK; } -error_code sceNpTusSetDataVUserAsync(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, u64 totalSize, u64 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) +error_code sceNpTusSetDataVUserAsync(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, u32 totalSize, u32 sendSize, vm::cptr data, vm::cptr info, u64 infoStructSize, vm::ptr option) { sceNpTus.todo("sceNpTusSetDataAsync(transId=%d, targetVirtualUserId=*0x%x, slotId=%d, totalSize=%d, sendSize=%d, data=*0x%x, info=*0x%x, infoStructSize=%d, option=*0x%x)", transId, targetVirtualUserId, slotId, totalSize, sendSize, data, info, infoStructSize, option); @@ -1346,7 +1346,7 @@ error_code sceNpTusSetDataVUserAsync(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, vm::ptr dataStatus, u64 dataStatusSize, vm::ptr data, u64 recvSize, vm::ptr option) +error_code sceNpTusGetData(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, vm::ptr dataStatus, u32 dataStatusSize, vm::ptr data, u32 recvSize, vm::ptr option) { sceNpTus.todo("sceNpTusGetData(transId=%d, targetNpId=*0x%x, slotId=%d, dataStatus=*0x%x, dataStatusSize=%d, data=*0x%x, recvSize=%d, option=*0x%x)", transId, targetNpId, slotId, dataStatus, dataStatusSize, data, recvSize, option); @@ -1377,7 +1377,7 @@ error_code sceNpTusGetData(s32 transId, vm::cptr targetNpId, SceNpTusSl return not_an_error(data_size); } -error_code sceNpTusGetDataVUser(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, vm::ptr dataStatus, u64 dataStatusSize, vm::ptr data, u64 recvSize, vm::ptr option) +error_code sceNpTusGetDataVUser(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, vm::ptr dataStatus, u32 dataStatusSize, vm::ptr data, u32 recvSize, vm::ptr option) { sceNpTus.todo("sceNpTusGetDataVUser(transId=%d, targetVirtualUserId=*0x%x, slotId=%d, dataStatus=*0x%x, dataStatusSize=%d, data=*0x%x, recvSize=%d, option=*0x%x)", transId, targetVirtualUserId, slotId, dataStatus, dataStatusSize, data, recvSize, option); @@ -1408,7 +1408,7 @@ error_code sceNpTusGetDataVUser(s32 transId, vm::cptr tar return not_an_error(data_size); } -error_code sceNpTusGetDataAsync(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, vm::ptr dataStatus, u64 dataStatusSize, vm::ptr data, u64 recvSize, vm::ptr option) +error_code sceNpTusGetDataAsync(s32 transId, vm::cptr targetNpId, SceNpTusSlotId slotId, vm::ptr dataStatus, u32 dataStatusSize, vm::ptr data, u32 recvSize, vm::ptr option) { sceNpTus.todo("sceNpTusGetDataAsync(transId=%d, targetNpId=*0x%x, slotId=%d, dataStatus=*0x%x, dataStatusSize=%d, data=*0x%x, recvSize=%d, option=*0x%x)", transId, targetNpId, slotId, dataStatus, dataStatusSize, data, recvSize, option); @@ -1443,7 +1443,7 @@ error_code sceNpTusGetDataAsync(s32 transId, vm::cptr targetNpId, SceNp return CELL_OK; } -error_code sceNpTusGetDataVUserAsync(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, vm::ptr dataStatus, u64 dataStatusSize, vm::ptr data, u64 recvSize, vm::ptr option) +error_code sceNpTusGetDataVUserAsync(s32 transId, vm::cptr targetVirtualUserId, SceNpTusSlotId slotId, vm::ptr dataStatus, u32 dataStatusSize, vm::ptr data, u32 recvSize, vm::ptr option) { sceNpTus.todo("sceNpTusGetDataVUser(transId=%d, targetVirtualUserId=*0x%x, slotId=%d, dataStatus=*0x%x, dataStatusSize=%d, data=*0x%x, recvSize=%d, option=*0x%x)", transId, targetVirtualUserId, slotId, dataStatus, dataStatusSize, data, recvSize, option); @@ -1968,7 +1968,7 @@ error_code sceNpTusDeleteMultiSlotDataVUserAsync(s32 transId, vm::cptr dataStatus, u64 dataStatusSize, vm::ptr data, u64 recvSize, vm::ptr option) +error_code sceNpTssGetData(s32 transId, SceNpTssSlotId slotId, vm::ptr dataStatus, u32 dataStatusSize, vm::ptr data, u32 recvSize, vm::ptr option) { sceNpTus.todo("sceNpTssGetData(transId=%d, slotId=%d, dataStatus=*0x%x, dataStatusSize=%d, data=*0x%x, recvSize=%d, option=*0x%x)", transId, slotId, dataStatus, dataStatusSize, data, recvSize, option); @@ -1993,7 +1993,7 @@ error_code sceNpTssGetData(s32 transId, SceNpTssSlotId slotId, vm::ptr dataStatus, u64 dataStatusSize, vm::ptr data, u64 recvSize, vm::ptr option) +error_code sceNpTssGetDataAsync(s32 transId, SceNpTssSlotId slotId, vm::ptr dataStatus, u32 dataStatusSize, vm::ptr data, u32 recvSize, vm::ptr option) { sceNpTus.todo("sceNpTssGetDataAsync(transId=%d, slotId=%d, dataStatus=*0x%x, dataStatusSize=%d, data=*0x%x, recvSize=%d, option=*0x%x)", transId, slotId, dataStatus, dataStatusSize, data, recvSize, option); diff --git a/rpcs3/Emu/NP/generated/np2_structs.fbs b/rpcs3/Emu/NP/generated/np2_structs.fbs index 2fc73926a7..62550fbb0b 100644 --- a/rpcs3/Emu/NP/generated/np2_structs.fbs +++ b/rpcs3/Emu/NP/generated/np2_structs.fbs @@ -336,3 +336,15 @@ table GetScoreResponse { lastSortDate:uint64; totalRecord:uint32; } + +table RecordScoreGameDataRequest { + boardId:uint32; + pcId:int32; + score:int64; +} + +table GetScoreGameDataRequest { + boardId:uint32; + npId:string; + pcId:int32; +} diff --git a/rpcs3/Emu/NP/generated/np2_structs_generated.h b/rpcs3/Emu/NP/generated/np2_structs_generated.h index b08e9cb07b..3759926f49 100644 --- a/rpcs3/Emu/NP/generated/np2_structs_generated.h +++ b/rpcs3/Emu/NP/generated/np2_structs_generated.h @@ -145,6 +145,12 @@ struct ScoreInfoBuilder; struct GetScoreResponse; struct GetScoreResponseBuilder; +struct RecordScoreGameDataRequest; +struct RecordScoreGameDataRequestBuilder; + +struct GetScoreGameDataRequest; +struct GetScoreGameDataRequestBuilder; + struct BinAttr FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { typedef BinAttrBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { @@ -4271,4 +4277,140 @@ inline flatbuffers::Offset CreateGetScoreResponseDirect( totalRecord); } +struct RecordScoreGameDataRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef RecordScoreGameDataRequestBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_BOARDID = 4, + VT_PCID = 6, + VT_SCORE = 8 + }; + uint32_t boardId() const { + return GetField(VT_BOARDID, 0); + } + int32_t pcId() const { + return GetField(VT_PCID, 0); + } + int64_t score() const { + return GetField(VT_SCORE, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_BOARDID, 4) && + VerifyField(verifier, VT_PCID, 4) && + VerifyField(verifier, VT_SCORE, 8) && + verifier.EndTable(); + } +}; + +struct RecordScoreGameDataRequestBuilder { + typedef RecordScoreGameDataRequest Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_boardId(uint32_t boardId) { + fbb_.AddElement(RecordScoreGameDataRequest::VT_BOARDID, boardId, 0); + } + void add_pcId(int32_t pcId) { + fbb_.AddElement(RecordScoreGameDataRequest::VT_PCID, pcId, 0); + } + void add_score(int64_t score) { + fbb_.AddElement(RecordScoreGameDataRequest::VT_SCORE, score, 0); + } + explicit RecordScoreGameDataRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateRecordScoreGameDataRequest( + flatbuffers::FlatBufferBuilder &_fbb, + uint32_t boardId = 0, + int32_t pcId = 0, + int64_t score = 0) { + RecordScoreGameDataRequestBuilder builder_(_fbb); + builder_.add_score(score); + builder_.add_pcId(pcId); + builder_.add_boardId(boardId); + return builder_.Finish(); +} + +struct GetScoreGameDataRequest FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef GetScoreGameDataRequestBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_BOARDID = 4, + VT_NPID = 6, + VT_PCID = 8 + }; + uint32_t boardId() const { + return GetField(VT_BOARDID, 0); + } + const flatbuffers::String *npId() const { + return GetPointer(VT_NPID); + } + int32_t pcId() const { + return GetField(VT_PCID, 0); + } + bool Verify(flatbuffers::Verifier &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_BOARDID, 4) && + VerifyOffset(verifier, VT_NPID) && + verifier.VerifyString(npId()) && + VerifyField(verifier, VT_PCID, 4) && + verifier.EndTable(); + } +}; + +struct GetScoreGameDataRequestBuilder { + typedef GetScoreGameDataRequest Table; + flatbuffers::FlatBufferBuilder &fbb_; + flatbuffers::uoffset_t start_; + void add_boardId(uint32_t boardId) { + fbb_.AddElement(GetScoreGameDataRequest::VT_BOARDID, boardId, 0); + } + void add_npId(flatbuffers::Offset npId) { + fbb_.AddOffset(GetScoreGameDataRequest::VT_NPID, npId); + } + void add_pcId(int32_t pcId) { + fbb_.AddElement(GetScoreGameDataRequest::VT_PCID, pcId, 0); + } + explicit GetScoreGameDataRequestBuilder(flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = flatbuffers::Offset(end); + return o; + } +}; + +inline flatbuffers::Offset CreateGetScoreGameDataRequest( + flatbuffers::FlatBufferBuilder &_fbb, + uint32_t boardId = 0, + flatbuffers::Offset npId = 0, + int32_t pcId = 0) { + GetScoreGameDataRequestBuilder builder_(_fbb); + builder_.add_pcId(pcId); + builder_.add_npId(npId); + builder_.add_boardId(boardId); + return builder_.Finish(); +} + +inline flatbuffers::Offset CreateGetScoreGameDataRequestDirect( + flatbuffers::FlatBufferBuilder &_fbb, + uint32_t boardId = 0, + const char *npId = nullptr, + int32_t pcId = 0) { + auto npId__ = npId ? _fbb.CreateString(npId) : 0; + return CreateGetScoreGameDataRequest( + _fbb, + boardId, + npId__, + pcId); +} + #endif // FLATBUFFERS_GENERATED_NP2STRUCTS_H_ diff --git a/rpcs3/Emu/NP/np_contexts.cpp b/rpcs3/Emu/NP/np_contexts.cpp index 36dcfe95d6..58d1dff8a2 100644 --- a/rpcs3/Emu/NP/np_contexts.cpp +++ b/rpcs3/Emu/NP/np_contexts.cpp @@ -80,6 +80,13 @@ void score_transaction_ctx::wait_for_completion() completion_cond.wait(lock); } +bool score_transaction_ctx::set_result_and_wake(error_code err) +{ + result = err; + wake_cond.notify_one(); + return true; +} + match2_ctx::match2_ctx(vm::cptr communicationId, vm::cptr passphrase) { ensure(!communicationId->data[9] && strlen(communicationId->data) == 9); diff --git a/rpcs3/Emu/NP/np_contexts.h b/rpcs3/Emu/NP/np_contexts.h index 7db54e4548..42a39b7a1f 100644 --- a/rpcs3/Emu/NP/np_contexts.h +++ b/rpcs3/Emu/NP/np_contexts.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "Utilities/mutex.h" @@ -32,6 +33,47 @@ struct score_ctx s32 create_score_context(vm::cptr communicationId, vm::cptr passphrase); bool destroy_score_context(s32 ctx_id); +struct tdata_invalid +{ +}; + +struct tdata_get_board_infos +{ + vm::ptr boardInfo; +}; + +struct tdata_record_score +{ + vm::ptr tmpRank; +}; + +struct tdata_record_score_data +{ + u32 game_data_size = 0; + std::vector game_data; +}; + +struct tdata_get_score_data +{ + vm::ptr totalSize; + u32 recvSize = 0; + vm::ptr score_data; + u32 game_data_size = 0; + std::vector game_data; +}; + +struct tdata_get_score_generic +{ + vm::ptr rankArray; + u32 rankArraySize = 0; + vm::ptr commentArray; + vm::ptr infoArray; + u32 infoArraySize = 0; + u32 arrayNum = 0; + vm::ptr lastSortDate; + vm::ptr totalRecord; +}; + struct score_transaction_ctx { score_transaction_ctx(const std::shared_ptr& score); @@ -39,6 +81,7 @@ struct score_transaction_ctx std::optional get_score_transaction_status(); void abort_score_transaction(); void wait_for_completion(); + bool set_result_and_wake(error_code err); static const u32 id_base = 0x1001; static const u32 id_step = 1; @@ -49,8 +92,7 @@ struct score_transaction_ctx std::condition_variable_any wake_cond, completion_cond; std::optional result; - std::vector data; - std::vector game_data; + std::variant tdata; u64 timeout = 60'000'000; // 60 seconds; diff --git a/rpcs3/Emu/NP/np_handler.cpp b/rpcs3/Emu/NP/np_handler.cpp index 0b64950edc..88c5c2c21f 100644 --- a/rpcs3/Emu/NP/np_handler.cpp +++ b/rpcs3/Emu/NP/np_handler.cpp @@ -800,6 +800,9 @@ namespace np const u32 req_id = reply.first; std::vector& data = reply.second.second; + // Every reply should at least contain a return value/error code + ensure(data.size() >= 1); + switch (command) { case rpcn::CommandType::GetWorldList: reply_get_world_list(req_id, data); break; @@ -818,7 +821,7 @@ namespace np case rpcn::CommandType::RequestTicket: reply_req_ticket(req_id, data); break; case rpcn::CommandType::GetBoardInfos: reply_get_board_infos(req_id, data); break; case rpcn::CommandType::RecordScore: reply_record_score(req_id, data); break; - case rpcn::CommandType::StoreScoreData: reply_store_score_data(req_id, data); break; + case rpcn::CommandType::RecordScoreData: reply_record_score_data(req_id, data); break; case rpcn::CommandType::GetScoreData: reply_get_score_data(req_id, data); break; case rpcn::CommandType::GetScoreRange: reply_get_score_range(req_id, data); break; case rpcn::CommandType::GetScoreFriends: reply_get_score_friends(req_id, data); break; diff --git a/rpcs3/Emu/NP/np_handler.h b/rpcs3/Emu/NP/np_handler.h index d176225058..8616a08aff 100644 --- a/rpcs3/Emu/NP/np_handler.h +++ b/rpcs3/Emu/NP/np_handler.h @@ -155,11 +155,13 @@ namespace np // Score requests void score_async_handler(std::unique_lock lock, const std::shared_ptr& trans_ctx, u32 req_id, bool async); - void get_board_infos(std::shared_ptr& trans_ctx, SceNpScoreBoardId board_id, vm::ptr board_info, bool async); - void record_score(std::shared_ptr& trans_ctx, SceNpScoreBoardId board_id, SceNpScoreValue score, vm::cptr comment, const u8* data, u32 data_size, vm::ptr tmp_rank, bool async); - void get_score_range(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async); - void get_score_npid(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, const std::vector>& npid_vec, vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async); - void get_score_friend(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, bool include_self, vm::ptr rankArray, u64 rankArraySize, vm::ptr commentArray, u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async); + void get_board_infos(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, vm::ptr boardInfo, bool async); + void record_score(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreValue score, vm::cptr scoreComment, const u8* data, u32 data_size, vm::ptr tmpRank, bool async); + void record_score_data(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, const u8* score_data, bool async); + void get_score_data(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, const SceNpId& npId, vm::ptr totalSize, u32 recvSize, vm::ptr score_data, bool async); + void get_score_range(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async); + void get_score_npid(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, const std::vector>& npid_vec, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async); + void get_score_friend(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, bool include_self, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async); // Local functions std::pair> local_get_room_slots(SceNpMatching2RoomId room_id); @@ -232,7 +234,7 @@ namespace np bool reply_req_ticket(u32 req_id, std::vector& reply_data); bool reply_get_board_infos(u32 req_id, std::vector& reply_data); bool reply_record_score(u32 req_id, std::vector& reply_data); - bool reply_store_score_data(u32 req_id, std::vector& reply_data); + bool reply_record_score_data(u32 req_id, std::vector& reply_data); bool reply_get_score_data(u32 req_id, std::vector& reply_data); bool reply_get_score_range(u32 req_id, std::vector& reply_data); bool reply_get_score_friends(u32 req_id, std::vector& reply_data); diff --git a/rpcs3/Emu/NP/np_notifications.cpp b/rpcs3/Emu/NP/np_notifications.cpp index 8833781d52..37ef91daa7 100644 --- a/rpcs3/Emu/NP/np_notifications.cpp +++ b/rpcs3/Emu/NP/np_notifications.cpp @@ -13,8 +13,8 @@ namespace np void np_handler::notif_user_joined_room(std::vector& data) { vec_stream noti(data); - u64 room_id = noti.get(); - auto update_info_raw = noti.get_rawdata(); + u64 room_id = noti.get(); + auto* update_info = noti.get_flatbuffer(); if (noti.is_error()) { @@ -24,9 +24,8 @@ namespace np u32 event_key = get_event_key(); - auto* update_info = flatbuffers::GetRoot(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(edata.data()); + auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberUpdateInfo, sizeof(SceNpMatching2RoomMemberUpdateInfo)); + auto* notif_data = reinterpret_cast(edata.data()); RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(edata, update_info, notif_data); np_memory.shrink_allocation(edata.addr(), edata.size()); @@ -45,8 +44,8 @@ namespace np void np_handler::notif_user_left_room(std::vector& data) { vec_stream noti(data); - u64 room_id = noti.get(); - auto update_info_raw = noti.get_rawdata(); + u64 room_id = noti.get(); + auto* update_info = noti.get_flatbuffer(); if (noti.is_error()) { @@ -56,9 +55,8 @@ namespace np u32 event_key = get_event_key(); - auto* update_info = flatbuffers::GetRoot(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(edata.data()); + auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberUpdateInfo, sizeof(SceNpMatching2RoomMemberUpdateInfo)); + auto* notif_data = reinterpret_cast(edata.data()); RoomMemberUpdateInfo_to_SceNpMatching2RoomMemberUpdateInfo(edata, update_info, notif_data); np_memory.shrink_allocation(edata.addr(), edata.size()); @@ -77,8 +75,8 @@ namespace np void np_handler::notif_room_destroyed(std::vector& data) { vec_stream noti(data); - u64 room_id = noti.get(); - auto update_info_raw = noti.get_rawdata(); + u64 room_id = noti.get(); + auto* update_info = noti.get_flatbuffer(); if (noti.is_error()) { @@ -88,9 +86,8 @@ namespace np u32 event_key = get_event_key(); - auto* update_info = flatbuffers::GetRoot(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(edata.data()); + auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomUpdateInfo, sizeof(SceNpMatching2RoomUpdateInfo)); + auto* notif_data = reinterpret_cast(edata.data()); RoomUpdateInfo_to_SceNpMatching2RoomUpdateInfo(update_info, notif_data); np_memory.shrink_allocation(edata.addr(), edata.size()); @@ -110,7 +107,7 @@ namespace np { vec_stream noti(data); SceNpMatching2RoomId room_id = noti.get(); - auto update_info_raw = noti.get_rawdata(); + auto* update_info = noti.get_flatbuffer(); if (noti.is_error()) { @@ -120,9 +117,8 @@ namespace np u32 event_key = get_event_key(); - auto* update_info = flatbuffers::GetRoot(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(edata.data()); + auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomDataInternalUpdateInfo, sizeof(SceNpMatching2RoomDataInternalUpdateInfo)); + auto* notif_data = reinterpret_cast(edata.data()); RoomDataInternalUpdateInfo_to_SceNpMatching2RoomDataInternalUpdateInfo(edata, update_info, notif_data, npid); np_memory.shrink_allocation(edata.addr(), edata.size()); @@ -143,7 +139,7 @@ namespace np { vec_stream noti(data); SceNpMatching2RoomId room_id = noti.get(); - auto update_info_raw = noti.get_rawdata(); + auto* update_info = noti.get_flatbuffer(); if (noti.is_error()) { @@ -153,9 +149,8 @@ namespace np u32 event_key = get_event_key(); - auto* update_info = flatbuffers::GetRoot(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(edata.data()); + auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMemberDataInternalUpdateInfo, sizeof(SceNpMatching2RoomMemberDataInternalUpdateInfo)); + auto* notif_data = reinterpret_cast(edata.data()); RoomMemberDataInternalUpdateInfo_to_SceNpMatching2RoomMemberDataInternalUpdateInfo(edata, update_info, notif_data); np_memory.shrink_allocation(edata.addr(), edata.size()); @@ -174,9 +169,9 @@ namespace np void np_handler::notif_room_message_received(std::vector& data) { vec_stream noti(data); - u64 room_id = noti.get(); - u16 member_id = noti.get(); - auto message_info_raw = noti.get_rawdata(); + u64 room_id = noti.get(); + u16 member_id = noti.get(); + auto* message_info = noti.get_flatbuffer(); if (noti.is_error()) { @@ -186,9 +181,8 @@ namespace np u32 event_key = get_event_key(); - auto* message_info = flatbuffers::GetRoot(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(edata.data()); + auto& edata = allocate_req_result(event_key, SCE_NP_MATCHING2_EVENT_DATA_MAX_SIZE_RoomMessageInfo, sizeof(SceNpMatching2RoomMessageInfo)); + auto* notif_data = reinterpret_cast(edata.data()); RoomMessageInfo_to_SceNpMatching2RoomMessageInfo(edata, message_info, notif_data); np_memory.shrink_allocation(edata.addr(), edata.size()); diff --git a/rpcs3/Emu/NP/np_requests.cpp b/rpcs3/Emu/NP/np_requests.cpp index ffcebbe644..32aced5f75 100644 --- a/rpcs3/Emu/NP/np_requests.cpp +++ b/rpcs3/Emu/NP/np_requests.cpp @@ -183,14 +183,13 @@ namespace np const auto cb_info = take_pending_request(req_id); vec_stream reply(reply_data, 1); - auto create_room_resp = reply.get_rawdata(); + auto* resp = reply.get_flatbuffer(); if (reply.is_error()) return error_and_disconnect("Malformed reply to CreateRoom command"); u32 event_key = get_event_key(); - auto* resp = flatbuffers::GetRoot(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(edata.data()); auto* room_info = edata.allocate(sizeof(SceNpMatching2RoomDataInternal), room_resp->roomDataInternal); @@ -237,18 +236,44 @@ namespace np bool np_handler::reply_join_room(u32 req_id, std::vector& reply_data) { + s32 error_code = 0; + + if (rpcn::is_error(static_cast(reply_data[0]))) + { + switch (reply_data[0]) + { + case rpcn::ErrorType::RoomMissing: error_code = SCE_NP_MATCHING2_SERVER_ERROR_NO_SUCH_ROOM; break; + case rpcn::ErrorType::RoomAlreadyJoined: error_code = SCE_NP_MATCHING2_SERVER_ERROR_ALREADY_JOINED; break; + case rpcn::ErrorType::RoomFull: error_code = SCE_NP_MATCHING2_SERVER_ERROR_ROOM_FULL; break; + default: return false; + } + } + const auto cb_info = take_pending_request(req_id); + if (error_code != 0) + { + if (cb_info.cb) + { + sysutil_register_cb([=](ppu_thread& cb_ppu) -> s32 + { + cb_info.cb(cb_ppu, cb_info.ctx_id, req_id, SCE_NP_MATCHING2_REQUEST_EVENT_JoinRoom, 0, error_code, 0, cb_info.cb_arg); + return 0; + }); + } + + return true; + } + vec_stream reply(reply_data, 1); - auto join_room_resp = reply.get_rawdata(); + auto* resp = reply.get_flatbuffer(); if (reply.is_error()) return error_and_disconnect("Malformed reply to JoinRoom command"); u32 event_key = get_event_key(); - auto resp = flatbuffers::GetRoot(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(edata.data()); auto* room_info = edata.allocate(sizeof(SceNpMatching2RoomDataInternal), room_resp->roomDataInternal); @@ -337,13 +362,13 @@ namespace np const auto cb_info = take_pending_request(req_id); vec_stream reply(reply_data, 1); - auto search_room_resp = reply.get_rawdata(); + auto* resp = reply.get_flatbuffer(); + if (reply.is_error()) return error_and_disconnect("Malformed reply to SearchRoom command"); u32 event_key = get_event_key(); - auto* resp = flatbuffers::GetRoot(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(edata.data()); SearchRoomResponse_to_SceNpMatching2SearchRoomResponse(edata, resp, search_resp); @@ -383,13 +408,13 @@ namespace np const auto cb_info = take_pending_request(req_id); vec_stream reply(reply_data, 1); - auto get_room_ext_resp = reply.get_rawdata(); + auto* resp = reply.get_flatbuffer(); + if (reply.is_error()) return error_and_disconnect("Malformed reply to GetRoomDataExternalList command"); u32 event_key = get_event_key(); - auto* resp = flatbuffers::GetRoot(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(edata.data()); GetRoomDataExternalListResponse_to_SceNpMatching2GetRoomDataExternalListResponse(edata, resp, sce_get_room_ext_resp); @@ -461,14 +486,13 @@ namespace np vec_stream reply(reply_data, 1); - auto internal_data = reply.get_rawdata(); + auto* resp = reply.get_flatbuffer(); if (reply.is_error()) return error_and_disconnect("Malformed reply to GetRoomDataInternal command"); u32 event_key = get_event_key(); - auto* resp = flatbuffers::GetRoot(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(edata.data()); auto* room_info = edata.allocate(sizeof(SceNpMatching2RoomDataInternal), room_resp->roomDataInternal); @@ -578,14 +602,13 @@ namespace np vec_stream reply(reply_data, 1); - auto ping_resp = reply.get_rawdata(); + auto* resp = reply.get_flatbuffer(); if (reply.is_error()) return error_and_disconnect("Malformed reply to PingRoomOwner command"); u32 event_key = get_event_key(); - auto* resp = flatbuffers::GetRoot(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(edata.data()); GetPingInfoResponse_to_SceNpMatching2SignalingGetPingInfoResponse(resp, final_ping_resp); @@ -645,8 +668,6 @@ namespace np rpcn_log.error("Disconnecting from RPCN!"); is_psn_active = false; } - - return; } bool np_handler::reply_req_sign_infos(u32 req_id, std::vector& reply_data) @@ -756,26 +777,25 @@ namespace np return worker_function(std::move(lock)); } - void np_handler::get_board_infos(std::shared_ptr& trans_ctx, SceNpScoreBoardId board_id, vm::ptr board_info, bool async) + void np_handler::get_board_infos(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, vm::ptr boardInfo, bool async) { std::unique_lock lock(trans_ctx->mutex); - u32 req_id = get_req_id(0x3334); - std::string comm_id(static_cast(trans_ctx->communicationId.data)); + u32 req_id = get_req_id(0x3334); + trans_ctx->tdata = tdata_get_board_infos{.boardInfo = boardInfo}; + rpcn->get_board_infos(req_id, trans_ctx->communicationId, boardId); - trans_ctx->data.clear(); - trans_ctx->data.push_back(board_info.addr()); - rpcn->get_board_infos(req_id, trans_ctx->communicationId, board_id); - - return score_async_handler(std::move(lock), trans_ctx, req_id, async); + score_async_handler(std::move(lock), trans_ctx, req_id, async); } bool np_handler::reply_get_board_infos(u32 req_id, std::vector& reply_data) { vec_stream reply(reply_data, 1); - auto raw_board_info = reply.get_rawdata(); - auto* resp = flatbuffers::GetRoot(raw_board_info.data()); + auto* resp = reply.get_flatbuffer(); + + if (reply.is_error()) + return error_and_disconnect("Malformed reply to GetBoardInfos command"); SceNpScoreBoardInfo board_info; @@ -794,30 +814,34 @@ namespace np auto trans = ::at32(score_transactions, req_id); std::lock_guard lock(trans->mutex); - ensure(trans->data.size() == 1); - vm::ptr boardinfo_ptr = vm::cast(trans->data[0]); - memcpy(reinterpret_cast(boardinfo_ptr.get_ptr()), &board_info, sizeof(SceNpScoreBoardInfo)); + + const auto* tdata = std::get_if(&trans->tdata); + ensure(tdata); + + memcpy(reinterpret_cast(tdata->boardInfo.get_ptr()), &board_info, sizeof(SceNpScoreBoardInfo)); trans->result = CELL_OK; trans->wake_cond.notify_one(); return true; } - void np_handler::record_score(std::shared_ptr& trans_ctx, SceNpScoreBoardId board_id, SceNpScoreValue score, vm::cptr comment, const u8* data, u32 data_size, vm::ptr tmp_rank, bool async) + void np_handler::record_score(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreValue score, vm::cptr scoreComment, const u8* data, u32 data_size, vm::ptr tmpRank, bool async) { std::unique_lock lock(trans_ctx->mutex); u32 req_id = get_req_id(0x3334); - std::optional str_comment = comment ? std::optional(std::string(reinterpret_cast(comment->data))) : std::nullopt; - std::optional> vec_data = data ? std::optional(std::vector(data, data + data_size)) : std::nullopt; - trans_ctx->data.clear(); - if (tmp_rank) + std::optional str_comment = scoreComment ? std::optional(std::string(reinterpret_cast(scoreComment->data))) : std::nullopt; + std::optional> vec_data; + + if (data) { - trans_ctx->data.push_back(tmp_rank.addr()); + vec_data = std::vector(data, data + data_size); } - rpcn->record_score(req_id, trans_ctx->communicationId, board_id, trans_ctx->pcId, score, str_comment, vec_data); + trans_ctx->tdata = tdata_record_score{.tmpRank = tmpRank}; - return score_async_handler(std::move(lock), trans_ctx, req_id, async); + rpcn->record_score(req_id, trans_ctx->communicationId, boardId, trans_ctx->pcId, score, str_comment, vec_data); + + score_async_handler(std::move(lock), trans_ctx, req_id, async); } bool np_handler::reply_record_score(u32 req_id, std::vector& reply_data) @@ -855,11 +879,12 @@ namespace np return false; } - ensure(trans->data.size() == 1 || trans->data.size() == 0); - if (!trans->data.empty()) + const auto* tdata = std::get_if(&trans->tdata); + ensure(tdata); + + if (tdata->tmpRank) { - vm::ptr tmprank_ptr = vm::cast(trans->data[0]); - *tmprank_ptr = tmp_rank; + *tdata->tmpRank = tmp_rank; } trans->result = CELL_OK; @@ -867,34 +892,156 @@ namespace np return true; } - bool np_handler::reply_store_score_data(u32 /* req_id */, std::vector& /* reply_data */) + void np_handler::record_score_data(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, const u8* score_data, bool async) { - return true; - } - bool np_handler::reply_get_score_data(u32 /* req_id */, std::vector& /* reply_data */) - { - return true; + std::unique_lock lock(trans_ctx->mutex); + + auto* tdata = std::get_if(&trans_ctx->tdata); + if (!tdata) + { + trans_ctx->tdata = tdata_record_score_data{.game_data_size = totalSize}; + tdata = std::get_if(&trans_ctx->tdata); + tdata->game_data.reserve(totalSize); + } + + std::copy(score_data, score_data + sendSize, std::back_inserter(tdata->game_data)); + + if (tdata->game_data.size() == tdata->game_data_size) + { + trans_ctx->result = std::nullopt; + u32 req_id = get_req_id(0x3334); + rpcn->record_score_data(req_id, trans_ctx->communicationId, trans_ctx->pcId, boardId, score, tdata->game_data); + score_async_handler(std::move(lock), trans_ctx, req_id, async); + } + else + { + trans_ctx->result = CELL_OK; + } } - void np_handler::get_score_range(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, [[maybe_unused]] u64 rankArraySize, vm::ptr commentArray, [[maybe_unused]] u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async) + bool np_handler::reply_record_score_data(u32 req_id, std::vector& reply_data) + { + std::lock_guard lock_trans(mutex_score_transactions); + if (!score_transactions.count(req_id)) + { + rpcn_log.error("Couldn't find transaction(%d) in trans_id!", req_id); + return false; + } + + auto trans = ::at32(score_transactions, req_id); + std::lock_guard lock(trans->mutex); + + auto set_result_and_wake = [&](error_code err) -> bool + { + trans->result = err; + trans->wake_cond.notify_one(); + return true; + }; + + if (rpcn::is_error(static_cast(reply_data[0]))) + { + switch (reply_data[0]) + { + case rpcn::ErrorType::NotFound: return trans->set_result_and_wake(SCE_NP_COMMUNITY_SERVER_ERROR_RANKING_STORE_NOT_FOUND); + case rpcn::ErrorType::ScoreInvalid: return trans->set_result_and_wake(SCE_NP_COMMUNITY_SERVER_ERROR_INVALID_SCORE); + case rpcn::ErrorType::ScoreHasData: return trans->set_result_and_wake(SCE_NP_COMMUNITY_SERVER_ERROR_GAME_DATA_ALREADY_EXISTS); + default: return false; + } + } + + return set_result_and_wake(CELL_OK); + } + + void np_handler::get_score_data(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, const SceNpId& npId, vm::ptr totalSize, u32 recvSize, vm::ptr score_data, bool async) + { + std::unique_lock lock(trans_ctx->mutex); + + auto* tdata = std::get_if(&trans_ctx->tdata); + if (!tdata) + { + trans_ctx->tdata = tdata_get_score_data{.totalSize = totalSize, .recvSize = recvSize, .score_data = score_data}; + + u32 req_id = get_req_id(0x3334); + rpcn->get_score_data(req_id, trans_ctx->communicationId, trans_ctx->pcId, boardId, npId); + score_async_handler(std::move(lock), trans_ctx, req_id, async); + return; + } + + // If here the data has already been acquired and the client is just asking for part of it + + usz to_copy = std::min(tdata->game_data.size(), static_cast(recvSize)); + std::memcpy(score_data.get_ptr(), tdata->game_data.data(), to_copy); + tdata->game_data.erase(tdata->game_data.begin(), tdata->game_data.begin() + to_copy); + *totalSize = tdata->game_data_size; + trans_ctx->result = not_an_error(to_copy); + } + + bool np_handler::reply_get_score_data(u32 req_id, std::vector& reply_data) + { + std::lock_guard lock_trans(mutex_score_transactions); + if (!score_transactions.count(req_id)) + { + rpcn_log.error("Couldn't find transaction(%d) in trans_id!", req_id); + return false; + } + + auto trans = ::at32(score_transactions, req_id); + std::lock_guard lock(trans->mutex); + + if (rpcn::is_error(static_cast(reply_data[0]))) + { + switch (reply_data[0]) + { + case rpcn::ErrorType::NotFound: return trans->set_result_and_wake(SCE_NP_COMMUNITY_SERVER_ERROR_RANKING_GAME_DATA_MASTER_NOT_FOUND); + default: return false; + } + } + + vec_stream reply(reply_data, 1); + + auto* tdata = std::get_if(&trans->tdata); + ensure(tdata); + + tdata->game_data = reply.get_rawdata(); + + if (reply.is_error()) + { + rpcn_log.error("Error parsing response in reply_get_score_data"); + return false; + } + + tdata->game_data_size = tdata->game_data.size(); + + usz to_copy = std::min(tdata->game_data.size(), static_cast(tdata->recvSize)); + std::memcpy(tdata->score_data.get_ptr(), tdata->game_data.data(), to_copy); + tdata->game_data.erase(tdata->game_data.begin(), tdata->game_data.begin() + to_copy); + *tdata->totalSize = tdata->game_data_size; + + return trans->set_result_and_wake(not_an_error(to_copy)); + } + + void np_handler::get_score_range(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, SceNpScoreRankNumber startSerialRank, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, [[maybe_unused]] u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async) { std::unique_lock lock(trans_ctx->mutex); u32 req_id = get_req_id(0x3334); - trans_ctx->data.clear(); - trans_ctx->data.push_back(static_cast(arrayNum)); - trans_ctx->data.push_back(rankArray.addr()); - trans_ctx->data.push_back(commentArray.addr()); - trans_ctx->data.push_back(infoArray.addr()); - trans_ctx->data.push_back(static_cast((arrayNum * sizeof(SceNpScoreGameInfo)) == infoArraySize)); - trans_ctx->data.push_back(lastSortDate.addr()); - trans_ctx->data.push_back(totalRecord.addr()); + + trans_ctx->tdata = tdata_get_score_generic{ + .rankArray = rankArray, + .rankArraySize = rankArraySize, + .commentArray = commentArray, + .infoArray = infoArray, + .infoArraySize = infoArraySize, + .arrayNum = arrayNum, + .lastSortDate = lastSortDate, + .totalRecord = totalRecord, + }; bool with_comments = !!commentArray; bool with_gameinfo = !!infoArray; rpcn->get_score_range(req_id, trans_ctx->communicationId, boardId, startSerialRank, arrayNum, with_comments, with_gameinfo); - return score_async_handler(std::move(lock), trans_ctx, req_id, async); + score_async_handler(std::move(lock), trans_ctx, req_id, async); } bool np_handler::handle_GetScoreResponse(u32 req_id, std::vector& reply_data) @@ -915,66 +1062,80 @@ namespace np } vec_stream reply(reply_data, 1); - auto raw_getscore_response = reply.get_rawdata(); - auto* resp = flatbuffers::GetRoot(raw_getscore_response.data()); - flatbuffers::Verifier verifier(raw_getscore_response.data(), raw_getscore_response.size()); + auto* resp = reply.get_flatbuffer(); - if (reply.is_error() || !resp->Verify(verifier)) + if (reply.is_error()) { - rpcn_log.error("Error parsing response in reply_record_score"); + rpcn_log.error("Error parsing response in handle_GetScoreResponse"); return false; } - ensure(trans_ctx->data.size() == 7); - u32 arrayNum = trans_ctx->data[0]; - vm::ptr rankArray = vm::cast(trans_ctx->data[1]); - vm::ptr commentArray = vm::cast(trans_ctx->data[2]); - vm::ptr infoArray = vm::cast(trans_ctx->data[3]); - bool info_array_is_SceNpScoreGameInfo = trans_ctx->data[4]; - vm::ptr lastSortDate = vm::cast(trans_ctx->data[5]); - vm::ptr totalRecord = vm::cast(trans_ctx->data[6]); + const auto* tdata = std::get_if(&trans_ctx->tdata); + ensure(tdata); + ensure(resp->rankArray() && resp->rankArray()->size() <= tdata->arrayNum); - ensure(resp->rankArray() && resp->rankArray()->size() <= arrayNum); - - memset(rankArray.get_ptr(), 0, sizeof(SceNpScoreRankData) * arrayNum); + memset(tdata->rankArray.get_ptr(), 0, tdata->rankArraySize); auto* fb_rankarray = resp->rankArray(); + u32 target_index = 0; + + vm::ptr rankArray = vm::static_ptr_cast(tdata->rankArray); + vm::ptr rankPlayerArray = vm::static_ptr_cast(tdata->rankArray); + for (flatbuffers::uoffset_t i = 0; i < fb_rankarray->size(); i++) { const auto* fb_rankdata = fb_rankarray->Get(i); ensure(fb_rankdata->npId() && fb_rankdata->onlineName()); - string_to_npid(fb_rankdata->npId()->string_view(), &rankArray[i].npId); - string_to_online_name(fb_rankdata->onlineName()->string_view(), &rankArray[i].onlineName); - rankArray[i].pcId = fb_rankdata->pcId(); - rankArray[i].serialRank = fb_rankdata->rank(); - rankArray[i].rank = fb_rankdata->rank(); - rankArray[i].highestRank = fb_rankdata->rank(); - rankArray[i].scoreValue = fb_rankdata->score(); - rankArray[i].hasGameData = fb_rankdata->hasGameData(); - rankArray[i].recordDate.tick = fb_rankdata->recordDate(); + + if (fb_rankdata->recordDate() == 0) + continue; + + SceNpScoreRankData* cur_rank; + if (tdata->rankArraySize == (tdata->arrayNum * sizeof(SceNpScoreRankData))) + { + cur_rank = &rankArray[i]; + } + else + { + rankPlayerArray[i].hasData = 1; + cur_rank = &rankPlayerArray[i].rankData; + } + + string_to_npid(fb_rankdata->npId()->string_view(), &cur_rank->npId); + string_to_online_name(fb_rankdata->onlineName()->string_view(), &cur_rank->onlineName); + + cur_rank->pcId = fb_rankdata->pcId(); + cur_rank->serialRank = fb_rankdata->rank(); + cur_rank->rank = fb_rankdata->rank(); + cur_rank->highestRank = fb_rankdata->rank(); + cur_rank->scoreValue = fb_rankdata->score(); + cur_rank->hasGameData = fb_rankdata->hasGameData(); + cur_rank->recordDate.tick = fb_rankdata->recordDate(); + + target_index++; } - if (commentArray) + if (tdata->commentArray) { - ensure(resp->commentArray() && resp->commentArray()->size() <= arrayNum); - memset(commentArray.get_ptr(), 0, sizeof(SceNpScoreComment) * arrayNum); + ensure(resp->commentArray() && resp->commentArray()->size() <= tdata->arrayNum); + memset(tdata->commentArray.get_ptr(), 0, sizeof(SceNpScoreComment) * tdata->arrayNum); auto* fb_commentarray = resp->commentArray(); for (flatbuffers::uoffset_t i = 0; i < fb_commentarray->size(); i++) { const auto* fb_comment = fb_commentarray->Get(i); - strcpy_trunc(commentArray[i].data, fb_comment->string_view()); + strcpy_trunc(tdata->commentArray[i].data, fb_comment->string_view()); } } - if (infoArray) + if (tdata->infoArray) { - ensure(resp->infoArray() && resp->infoArray()->size() <= arrayNum); + ensure(resp->infoArray() && resp->infoArray()->size() <= tdata->arrayNum); auto* fb_infoarray = resp->infoArray(); - if (info_array_is_SceNpScoreGameInfo) + if ((tdata->arrayNum * sizeof(SceNpScoreGameInfo)) == tdata->infoArraySize) { - vm::ptr ptr_gameinfo = vm::static_ptr_cast(infoArray); - memset(ptr_gameinfo.get_ptr(), 0, sizeof(SceNpScoreGameInfo) * arrayNum); + vm::ptr ptr_gameinfo = vm::static_ptr_cast(tdata->infoArray); + memset(ptr_gameinfo.get_ptr(), 0, sizeof(SceNpScoreGameInfo) * tdata->arrayNum); for (flatbuffers::uoffset_t i = 0; i < fb_infoarray->size(); i++) { const auto* fb_info = fb_infoarray->Get(i); @@ -984,8 +1145,8 @@ namespace np } else { - vm::ptr ptr_vargameinfo = vm::static_ptr_cast(infoArray); - memset(ptr_vargameinfo.get_ptr(), 0, sizeof(SceNpScoreVariableSizeGameInfo) * arrayNum); + vm::ptr ptr_vargameinfo = vm::static_ptr_cast(tdata->infoArray); + memset(ptr_vargameinfo.get_ptr(), 0, sizeof(SceNpScoreVariableSizeGameInfo) * tdata->arrayNum); for (flatbuffers::uoffset_t i = 0; i < fb_infoarray->size(); i++) { const auto* fb_info = fb_infoarray->Get(i); @@ -996,8 +1157,8 @@ namespace np } } - lastSortDate->tick = resp->lastSortDate(); - *totalRecord = resp->totalRecord(); + tdata->lastSortDate->tick = resp->lastSortDate(); + *tdata->totalRecord = resp->totalRecord(); if (fb_rankarray->size()) trans_ctx->result = not_an_error(fb_rankarray->size()); @@ -1012,50 +1173,54 @@ namespace np return handle_GetScoreResponse(req_id, reply_data); } - void np_handler::get_score_friend(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, bool include_self, vm::ptr rankArray, [[maybe_unused]] u64 rankArraySize, vm::ptr commentArray, [[maybe_unused]] u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async) + void np_handler::get_score_friend(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, bool include_self, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, [[maybe_unused]] u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async) { std::unique_lock lock(trans_ctx->mutex); - u32 req_id = get_req_id(0x3334); - trans_ctx->data.clear(); - trans_ctx->data.push_back(static_cast(arrayNum)); - trans_ctx->data.push_back(rankArray.addr()); - trans_ctx->data.push_back(commentArray.addr()); - trans_ctx->data.push_back(infoArray.addr()); - trans_ctx->data.push_back(static_cast((arrayNum * sizeof(SceNpScoreGameInfo)) == infoArraySize)); - trans_ctx->data.push_back(lastSortDate.addr()); - trans_ctx->data.push_back(totalRecord.addr()); + u32 req_id = get_req_id(0x3334); + trans_ctx->tdata = tdata_get_score_generic{ + .rankArray = rankArray, + .rankArraySize = rankArraySize, + .commentArray = commentArray, + .infoArray = infoArray, + .infoArraySize = infoArraySize, + .arrayNum = arrayNum, + .lastSortDate = lastSortDate, + .totalRecord = totalRecord, + }; bool with_comments = !!commentArray; bool with_gameinfo = !!infoArray; rpcn->get_score_friend(req_id, trans_ctx->communicationId, boardId, include_self, with_comments, with_gameinfo, arrayNum); - return score_async_handler(std::move(lock), trans_ctx, req_id, async); + score_async_handler(std::move(lock), trans_ctx, req_id, async); } bool np_handler::reply_get_score_friends(u32 req_id, std::vector& reply_data) { return handle_GetScoreResponse(req_id, reply_data); } - void np_handler::get_score_npid(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, const std::vector>& npid_vec, vm::ptr rankArray, [[maybe_unused]] u64 rankArraySize, vm::ptr commentArray, [[maybe_unused]] u64 commentArraySize, vm::ptr infoArray, u64 infoArraySize, u64 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async) + void np_handler::get_score_npid(std::shared_ptr& trans_ctx, SceNpScoreBoardId boardId, const std::vector>& npid_vec, vm::ptr rankArray, u32 rankArraySize, vm::ptr commentArray, [[maybe_unused]] u32 commentArraySize, vm::ptr infoArray, u32 infoArraySize, u32 arrayNum, vm::ptr lastSortDate, vm::ptr totalRecord, bool async) { std::unique_lock lock(trans_ctx->mutex); - u32 req_id = get_req_id(0x3334); - trans_ctx->data.clear(); - trans_ctx->data.push_back(static_cast(arrayNum)); - trans_ctx->data.push_back(rankArray.addr()); - trans_ctx->data.push_back(commentArray.addr()); - trans_ctx->data.push_back(infoArray.addr()); - trans_ctx->data.push_back(static_cast((arrayNum * sizeof(SceNpScoreGameInfo)) == infoArraySize)); - trans_ctx->data.push_back(lastSortDate.addr()); - trans_ctx->data.push_back(totalRecord.addr()); + u32 req_id = get_req_id(0x3334); + trans_ctx->tdata = tdata_get_score_generic{ + .rankArray = rankArray, + .rankArraySize = rankArraySize, + .commentArray = commentArray, + .infoArray = infoArray, + .infoArraySize = infoArraySize, + .arrayNum = arrayNum, + .lastSortDate = lastSortDate, + .totalRecord = totalRecord, + }; bool with_comments = !!commentArray; bool with_gameinfo = !!infoArray; rpcn->get_score_npid(req_id, trans_ctx->communicationId, boardId, npid_vec, with_comments, with_gameinfo); - return score_async_handler(std::move(lock), trans_ctx, req_id, async); + score_async_handler(std::move(lock), trans_ctx, req_id, async); } bool np_handler::reply_get_score_npid(u32 req_id, std::vector& reply_data) { diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index 41a65eb379..c9c90521c0 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -71,7 +71,7 @@ namespace rpcn return get_localized_string(rpcn_state_to_localized_string_id(state)); } - constexpr u32 RPCN_PROTOCOL_VERSION = 16; + constexpr u32 RPCN_PROTOCOL_VERSION = 17; constexpr usz RPCN_HEADER_SIZE = 15; constexpr usz COMMUNICATION_ID_SIZE = 9; @@ -99,7 +99,9 @@ namespace rpcn case CreationExistingUsername: rpcn_log.error("Error creating an account: existing username!"); break; case CreationBannedEmailProvider: rpcn_log.error("Error creating an account: banned email provider!"); break; case CreationExistingEmail: rpcn_log.error("Error creating an account: an account with that email already exist!"); break; - case AlreadyJoined: rpcn_log.error("User has already joined!"); break; + case RoomMissing: rpcn_log.error("User tried to join a non-existent room!"); break; + case RoomAlreadyJoined: rpcn_log.error("User has already joined!"); break; + case RoomFull: rpcn_log.error("User tried to join a full room!"); break; case Unauthorized: rpcn_log.error("User attempted an unauthorized operation!"); break; case DbFail: rpcn_log.error("A db query failed on the server!"); break; case EmailFail: rpcn_log.error("An email action failed on the server!"); break; @@ -107,6 +109,8 @@ namespace rpcn case Blocked: rpcn_log.error("You're blocked!"); break; case AlreadyFriend: rpcn_log.error("You're already friends!"); break; case ScoreNotBest: rpcn_log.error("Attempted to register a score that is not better!"); break; + case ScoreInvalid: rpcn_log.error("Score for player was found but wasn't what was expected!"); break; + case ScoreHasData: rpcn_log.error("Score already has game data associated with it!"); break; case Unsupported: rpcn_log.error("An unsupported operation was attempted!"); break; default: rpcn_log.fatal("Unhandled ErrorType reached the switch?"); break; } @@ -1193,8 +1197,6 @@ namespace rpcn bool rpcn_client::createjoin_room(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2CreateJoinRoomRequest* req) { - std::vector data; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset>> final_binattrinternal_vec; @@ -1306,7 +1308,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1317,8 +1319,6 @@ namespace rpcn bool rpcn_client::join_room(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2JoinRoomRequest* req) { - std::vector data; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset> final_roompassword; @@ -1345,7 +1345,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1356,15 +1356,13 @@ namespace rpcn bool rpcn_client::leave_room(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2LeaveRoomRequest* req) { - std::vector data; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset final_optdata = CreatePresenceOptionData(builder, builder.CreateVector(req->optData.data, 16), req->optData.length); auto req_finished = CreateLeaveRoomRequest(builder, req->roomId, final_optdata); builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1375,8 +1373,6 @@ namespace rpcn bool rpcn_client::search_room(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2SearchRoomRequest* req) { - std::vector data; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset>> final_intfilter_vec; if (req->intFilterNum) @@ -1433,7 +1429,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); + std::vector data(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1444,8 +1440,6 @@ namespace rpcn bool rpcn_client::get_roomdata_external_list(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2GetRoomDataExternalListRequest* req) { - std::vector data; - flatbuffers::FlatBufferBuilder builder(1024); std::vector roomIds; for (u32 i = 0; i < req->roomIdNum; i++) @@ -1463,7 +1457,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); + std::vector data(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1474,8 +1468,6 @@ namespace rpcn bool rpcn_client::set_roomdata_external(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2SetRoomDataExternalRequest* req) { - std::vector data; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset>> final_searchintattrexternal_vec; if (req->roomSearchableIntAttrExternalNum) @@ -1515,7 +1507,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); + std::vector data(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1526,8 +1518,6 @@ namespace rpcn bool rpcn_client::get_roomdata_internal(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2GetRoomDataInternalRequest* req) { - std::vector data, reply_data; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset> final_attr_ids_vec; @@ -1546,7 +1536,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); + std::vector data(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1557,8 +1547,6 @@ namespace rpcn bool rpcn_client::set_roomdata_internal(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2SetRoomDataInternalRequest* req) { - std::vector data; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset>> final_binattrinternal_vec; if (req->roomBinAttrInternalNum) @@ -1603,7 +1591,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); + std::vector data(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1614,8 +1602,6 @@ namespace rpcn bool rpcn_client::set_roommemberdata_internal(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2SetRoomMemberDataInternalRequest* req) { - std::vector data{}; - flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::Offset>> final_binattrinternal_vec; if (req->roomMemberBinAttrInternalNum) @@ -1634,7 +1620,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); + std::vector data(COMMUNICATION_ID_SIZE + bufsize + sizeof(u32)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1645,9 +1631,7 @@ namespace rpcn bool rpcn_client::ping_room_owner(u32 req_id, const SceNpCommunicationId& communication_id, u64 room_id) { - std::vector data; - - data.resize(COMMUNICATION_ID_SIZE + sizeof(u64)); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u64)); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); *utils::bless>(&data[COMMUNICATION_ID_SIZE]) = room_id; @@ -1657,7 +1641,6 @@ namespace rpcn bool rpcn_client::send_room_message(u32 req_id, const SceNpCommunicationId& communication_id, const SceNpMatching2SendRoomMessageRequest* req) { - std::vector data; flatbuffers::FlatBufferBuilder builder(1024); std::vector dst; @@ -1687,7 +1670,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1719,7 +1702,6 @@ namespace rpcn bool rpcn_client::sendmessage(const message_data& msg_data, const std::set& npids) { - std::vector data; flatbuffers::FlatBufferBuilder builder(1024); flatbuffers::FlatBufferBuilder nested_builder(1024); @@ -1742,7 +1724,7 @@ namespace rpcn builder.Finish(fb_sendmessage); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(bufsize + sizeof(u32)); + std::vector data(bufsize + sizeof(u32)); reinterpret_cast&>(data[0]) = static_cast(bufsize); memcpy(data.data() + sizeof(u32), buf, bufsize); @@ -1763,7 +1745,6 @@ namespace rpcn bool rpcn_client::record_score(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, SceNpScorePcId char_id, SceNpScoreValue score, const std::optional comment, const std::optional> score_data) { - std::vector data; flatbuffers::FlatBufferBuilder builder(1024); auto req_finished = CreateRecordScoreRequestDirect(builder, board_id, char_id, score, comment ? (*comment).c_str() : nullptr, score_data ? &*score_data : nullptr); @@ -1771,7 +1752,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1782,14 +1763,13 @@ namespace rpcn bool rpcn_client::get_score_range(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, u32 start_rank, u32 num_rank, bool with_comment, bool with_gameinfo) { - std::vector data; flatbuffers::FlatBufferBuilder builder(1024); auto req_finished = CreateGetScoreRangeRequest(builder, board_id, start_rank, num_rank, with_comment, with_gameinfo); builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1800,7 +1780,6 @@ namespace rpcn bool rpcn_client::get_score_npid(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, const std::vector>& npids, bool with_comment, bool with_gameinfo) { - std::vector data; flatbuffers::FlatBufferBuilder builder(1024); std::vector> davec; @@ -1815,7 +1794,7 @@ namespace rpcn builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1826,14 +1805,13 @@ namespace rpcn bool rpcn_client::get_score_friend(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, bool include_self, bool with_comment, bool with_gameinfo, u32 max_entries) { - std::vector data; flatbuffers::FlatBufferBuilder builder(1024); auto req_finished = CreateGetScoreFriendsRequest(builder, board_id, include_self, max_entries, with_comment, with_gameinfo); builder.Finish(req_finished); u8* buf = builder.GetBufferPointer(); usz bufsize = builder.GetSize(); - data.resize(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); @@ -1842,6 +1820,42 @@ namespace rpcn return forge_send(CommandType::GetScoreFriends, req_id, data); } + bool rpcn_client::record_score_data(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScorePcId pc_id, SceNpScoreBoardId board_id, s64 score, const std::vector& score_data) + { + flatbuffers::FlatBufferBuilder builder(1024); + auto req_finished = CreateRecordScoreGameDataRequest(builder, board_id, pc_id, score); + builder.Finish(req_finished); + + u8* buf = builder.GetBufferPointer(); + usz bufsize = builder.GetSize(); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize + sizeof(u32) + score_data.size()); + + memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); + reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); + memcpy(data.data() + COMMUNICATION_ID_SIZE + sizeof(u32), buf, bufsize); + reinterpret_cast&>(data[COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize]) = static_cast(score_data.size()); + memcpy(data.data() + COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize + sizeof(u32), score_data.data(), score_data.size()); + + return forge_send(CommandType::RecordScoreData, req_id, data); + } + + bool rpcn_client::get_score_data(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScorePcId pc_id, SceNpScoreBoardId board_id, const SceNpId& npid) + { + flatbuffers::FlatBufferBuilder builder(1024); + auto req_finished = CreateGetScoreGameDataRequest(builder, board_id, builder.CreateString(reinterpret_cast(npid.handle.data)), pc_id); + builder.Finish(req_finished); + + u8* buf = builder.GetBufferPointer(); + usz bufsize = builder.GetSize(); + std::vector data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize); + + memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); + reinterpret_cast&>(data[COMMUNICATION_ID_SIZE]) = static_cast(bufsize); + memcpy(data.data() + COMMUNICATION_ID_SIZE + sizeof(u32), buf, bufsize); + + return forge_send(CommandType::GetScoreData, req_id, data); + } + std::vector rpcn_client::forge_request(u16 command, u64 packet_id, const std::vector& data) const { u32 packet_size = data.size() + RPCN_HEADER_SIZE; @@ -2029,15 +2043,13 @@ namespace rpcn // Unserialize the message vec_stream sdata(data); std::string sender = sdata.get_string(false); - auto raw_msg_data = sdata.get_rawdata(); + auto* fb_mdata = sdata.get_flatbuffer(); if (sdata.is_error()) { return; } - auto fb_mdata = flatbuffers::GetRoot(raw_msg_data.data()); - if (!fb_mdata->communicationId() || fb_mdata->communicationId()->size() == 0 || fb_mdata->communicationId()->size() > 9 || !fb_mdata->subject() || !fb_mdata->body() || !fb_mdata->data()) { diff --git a/rpcs3/Emu/NP/rpcn_client.h b/rpcs3/Emu/NP/rpcn_client.h index 6de34ad0a9..de73b6d35e 100644 --- a/rpcs3/Emu/NP/rpcn_client.h +++ b/rpcs3/Emu/NP/rpcn_client.h @@ -85,6 +85,33 @@ public: return ret; } + template + const T* get_flatbuffer() + { + auto rawdata_vec = get_rawdata(); + + if (error) + return nullptr; + + if (vec.empty()) + { + error = true; + return nullptr; + } + + const T* ret = flatbuffers::GetRoot(rawdata_vec.data()); + flatbuffers::Verifier verifier(rawdata_vec.data(), rawdata_vec.size()); + + if (!ret->Verify(verifier)) + { + error = true; + return nullptr; + } + + aligned_bufs.push_back(std::move(rawdata_vec)); + + return ret; + } // Setters @@ -106,6 +133,7 @@ public: protected: std::vector& vec; + std::vector> aligned_bufs; usz i = 0; bool error = false; }; @@ -142,7 +170,7 @@ namespace rpcn SendMessage, GetBoardInfos, RecordScore, - StoreScoreData, + RecordScoreData, GetScoreData, GetScoreRange, GetScoreFriends, @@ -203,10 +231,12 @@ namespace rpcn LoginInvalidPassword, // Invalid password LoginInvalidToken, // Invalid token CreationError, // An error happened related to account creation - CreationExistingUsername, // Specific + CreationExistingUsername, // Specific to Account Creation: username exists already CreationBannedEmailProvider, // Specific to Account Creation: the email provider is banned CreationExistingEmail, // Specific to Account Creation: that email is already registered to an account - AlreadyJoined, // User tried to join a room he's already part of + RoomMissing, // User tried to join a non existing room + RoomAlreadyJoined, // User tried to join a room he's already part of + RoomFull, // User tried to join a full room Unauthorized, // User attempted an unauthorized operation DbFail, // Generic failure on db side EmailFail, // Generic failure related to email @@ -214,6 +244,8 @@ namespace rpcn Blocked, // The operation can't complete because you've been blocked AlreadyFriend, // Can't add friend because already friend ScoreNotBest, // A better score is already registered for that user/character_id + ScoreInvalid, // Score for player was found but wasn't what was expected + ScoreHasData, // Score already has data Unsupported, __error_last }; @@ -368,6 +400,8 @@ namespace rpcn bool get_score_range(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, u32 start_rank, u32 num_rank, bool with_comment, bool with_gameinfo); bool get_score_npid(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, const std::vector>& npids, bool with_comment, bool with_gameinfo); bool get_score_friend(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScoreBoardId board_id, bool include_self, bool with_comment, bool with_gameinfo, u32 max_entries); + bool record_score_data(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScorePcId pc_id, SceNpScoreBoardId board_id, s64 score, const std::vector& score_data); + bool get_score_data(u32 req_id, const SceNpCommunicationId& communication_id, SceNpScorePcId pc_id, SceNpScoreBoardId board_id, const SceNpId& npid); const std::string& get_online_name() const { diff --git a/rpcs3/Emu/NP/signaling_handler.cpp b/rpcs3/Emu/NP/signaling_handler.cpp index ded085e1dd..c033c2af59 100644 --- a/rpcs3/Emu/NP/signaling_handler.cpp +++ b/rpcs3/Emu/NP/signaling_handler.cpp @@ -259,14 +259,14 @@ void signaling_handler::process_incoming_messages() } sent_packet.command = signal_ping; - sent_packet.timestamp = now.time_since_epoch().count(); + sent_packet.timestamp_sender = now.time_since_epoch().count(); send_signaling_packet(sent_packet, si->addr, si->port); queue_signaling_packet(sent_packet, si, now + REPEAT_PING_DELAY); }; - const auto update_rtt = [&]() + const auto update_rtt = [&](u64 rtt_timestamp) { - u32 rtt = now.time_since_epoch().count() - sp->timestamp; + u32 rtt = now.time_since_epoch().count() - rtt_timestamp; si->last_rtts[(si->rtt_counters % 6)] = rtt; si->rtt_counters++; @@ -286,10 +286,10 @@ void signaling_handler::process_incoming_messages() reply = true; schedule_repeat = false; sent_packet.command = signal_pong; - sent_packet.timestamp = sp->timestamp; + sent_packet.timestamp_sender = sp->timestamp_sender; break; case signal_pong: - update_rtt(); + update_rtt(sp->timestamp_sender); reply = false; schedule_repeat = false; reschedule_packet(si, signal_ping, now + 10s); @@ -298,15 +298,17 @@ void signaling_handler::process_incoming_messages() reply = true; schedule_repeat = true; sent_packet.command = signal_connect_ack; - sent_packet.timestamp = sp->timestamp; + sent_packet.timestamp_sender = sp->timestamp_sender; + sent_packet.timestamp_receiver = now.time_since_epoch().count(); // connection is established break; case signal_connect_ack: - update_rtt(); + update_rtt(sp->timestamp_sender); reply = true; schedule_repeat = false; setup_ping(); sent_packet.command = signal_confirm; + sent_packet.timestamp_receiver = now.time_since_epoch().count(); retire_packet(si, signal_connect); // connection is active update_si_addr(si, op_addr, op_port); @@ -314,6 +316,7 @@ void signaling_handler::process_incoming_messages() update_si_status(si, SCE_NP_SIGNALING_CONN_STATUS_ACTIVE); break; case signal_confirm: + update_rtt(sp->timestamp_receiver); reply = false; schedule_repeat = false; setup_ping(); @@ -382,7 +385,10 @@ void signaling_handler::operator()() { case signal_connect: case signal_ping: - it->second.packet.timestamp = now.time_since_epoch().count(); + it->second.packet.timestamp_sender = now.time_since_epoch().count(); + break; + case signal_connect_ack: + it->second.packet.timestamp_receiver = now.time_since_epoch().count(); break; default: break; @@ -597,7 +603,7 @@ void signaling_handler::start_sig_nl(u32 conn_id, u32 addr, u16 port) { auto& sent_packet = sig1_packet; sent_packet.command = signal_connect; - sent_packet.timestamp = steady_clock::now().time_since_epoch().count(); + sent_packet.timestamp_sender = steady_clock::now().time_since_epoch().count(); ensure(sig1_peers.contains(conn_id)); std::shared_ptr si = ::at32(sig1_peers, conn_id); @@ -632,7 +638,7 @@ void signaling_handler::start_sig2(u64 room_id, u16 member_id) auto& sent_packet = sig2_packet; sent_packet.command = signal_connect; - sent_packet.timestamp = steady_clock::now().time_since_epoch().count(); + sent_packet.timestamp_sender = steady_clock::now().time_since_epoch().count(); ensure(sig2_peers.contains(room_id)); const auto& sp = ::at32(sig2_peers, room_id); diff --git a/rpcs3/Emu/NP/signaling_handler.h b/rpcs3/Emu/NP/signaling_handler.h index 7b5aa04997..0525a58a8b 100644 --- a/rpcs3/Emu/NP/signaling_handler.h +++ b/rpcs3/Emu/NP/signaling_handler.h @@ -100,7 +100,8 @@ private: { be_t signature = SIGNALING_SIGNATURE; le_t version; - le_t timestamp; + le_t timestamp_sender; + le_t timestamp_receiver; le_t command; le_t sent_addr; le_t sent_port;