From 67323994fc0be86196f6279e0ef9932040885f6c Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Sat, 22 Oct 2022 15:45:46 +0200 Subject: [PATCH] Implement sceNpScoreSanitizeComment --- rpcs3/Emu/Cell/Modules/sceNp.cpp | 54 +++++++++++++++---------------- rpcs3/Emu/Cell/Modules/sceNp2.cpp | 2 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 1d6ec5ae3d..c3e3c3afb9 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -4616,9 +4616,12 @@ error_code sceNpScoreCensorCommentAsync(s32 transId, vm::cptr comment, s32 return scenp_score_censor_comment(transId, comment, option, true); } -error_code sceNpScoreSanitizeComment(s32 transId, vm::cptr comment, vm::ptr sanitizedComment, vm::ptr option) +error_code scenp_score_sanitize_comment(s32 transId, vm::cptr comment, vm::ptr sanitizedComment, vm::ptr /* option */, bool async) { - sceNp.warning("sceNpScoreSanitizeComment(transId=%d, comment=%s, sanitizedComment=*0x%x, option=*0x%x)", transId, comment, sanitizedComment, option); + if (!sanitizedComment) + { + return SCE_NP_COMMUNITY_ERROR_INSUFFICIENT_ARGUMENT; + } auto& nph = g_fxo->get>(); @@ -4634,45 +4637,42 @@ error_code sceNpScoreSanitizeComment(s32 transId, vm::cptr comment, vm::pt const auto comment_len = strlen(comment.get_ptr()); - if (comment_len > SCE_NP_SCORE_CENSOR_COMMENT_MAXLEN || option) // option check at least until fw 4.71 + if (comment_len > SCE_NP_SCORE_CENSOR_COMMENT_MAXLEN) { return SCE_NP_COMMUNITY_ERROR_INVALID_ARGUMENT; } - if (nph.get_psn_status() != SCE_NP_MANAGER_STATUS_ONLINE) + auto trans_ctx = idm::get(transId); + + if (!trans_ctx) { - return SCE_NP_COMMUNITY_ERROR_INVALID_ONLINE_ID; + return SCE_NP_COMMUNITY_ERROR_INVALID_ID; } - // TODO: send to server and get sanitized version back + // TODO: actual implementation of this memcpy(sanitizedComment.get_ptr(), comment.get_ptr(), comment_len + 1); + trans_ctx->result = CELL_OK; - return CELL_OK; + if (async) + { + return CELL_OK; + } + + return *trans_ctx->result; +} + +error_code sceNpScoreSanitizeComment(s32 transId, vm::cptr comment, vm::ptr sanitizedComment, vm::ptr option) +{ + sceNp.warning("sceNpScoreSanitizeComment(transId=%d, comment=%s, sanitizedComment=*0x%x, option=*0x%x)", transId, comment, sanitizedComment, option); + + return scenp_score_sanitize_comment(transId, comment, sanitizedComment, option, false); } error_code sceNpScoreSanitizeCommentAsync(s32 transId, vm::cptr comment, vm::ptr sanitizedComment, s32 prio, vm::ptr option) { - sceNp.todo("sceNpScoreSanitizeCommentAsync(transId=%d, comment=%s, sanitizedComment=*0x%x, prio=%d, option=*0x%x)", transId, comment, sanitizedComment, prio, option); + sceNp.warning("sceNpScoreSanitizeCommentAsync(transId=%d, comment=%s, sanitizedComment=*0x%x, prio=%d, option=*0x%x)", transId, comment, sanitizedComment, 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_sanitize_comment(transId, comment, sanitizedComment, option, true); } error_code sceNpScoreGetRankingByNpIdPcId(s32 transId, SceNpScoreBoardId boardId, vm::cptr idArray, u32 idArraySize, vm::ptr rankArray, u32 rankArraySize, diff --git a/rpcs3/Emu/Cell/Modules/sceNp2.cpp b/rpcs3/Emu/Cell/Modules/sceNp2.cpp index 3a33c4b8de..c18d722d32 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp2.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp2.cpp @@ -237,7 +237,7 @@ error_code sceNpMatching2Init(u32 stackSize, s32 priority) error_code sceNpMatching2Init2(u64 stackSize, s32 priority, vm::ptr param) { - sceNp2.todo("sceNpMatching2Init2(stackSize=0x%x, priority=%d, param=*0x%x)", stackSize, priority, param); + sceNp2.warning("sceNpMatching2Init2(stackSize=0x%x, priority=%d, param=*0x%x)", stackSize, priority, param); auto& nph = g_fxo->get>();