mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 04:32:35 +01:00
SceNpScore: improvements
This commit is contained in:
parent
18e30c7e44
commit
880a4e3ca6
@ -3962,7 +3962,7 @@ error_code sceNpScoreSetPlayerCharacterId(s32 ctxId, SceNpScorePcId pcId)
|
||||
|
||||
error_code sceNpScoreWaitAsync(s32 transId, vm::ptr<s32> result)
|
||||
{
|
||||
sceNp.todo("sceNpScoreWaitAsync(transId=%d, result=*0x%x)", transId, result);
|
||||
sceNp.warning("sceNpScoreWaitAsync(transId=%d, result=*0x%x)", transId, result);
|
||||
|
||||
auto& nph = g_fxo->get<named_thread<np::np_handler>>();
|
||||
|
||||
@ -3977,7 +3977,7 @@ error_code sceNpScoreWaitAsync(s32 transId, vm::ptr<s32> result)
|
||||
return SCE_NP_COMMUNITY_ERROR_INVALID_ID;
|
||||
}
|
||||
|
||||
trans->wait_for_completion();
|
||||
*result = trans->wait_for_completion();
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -4194,14 +4194,14 @@ error_code scenp_score_record_game_data(s32 transId, SceNpScoreBoardId boardId,
|
||||
|
||||
error_code sceNpScoreRecordGameData(s32 transId, SceNpScoreBoardId boardId, SceNpScoreValue score, u32 totalSize, u32 sendSize, vm::cptr<void> data, vm::ptr<void> 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);
|
||||
sceNp.warning("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, u32 totalSize, u32 sendSize, vm::cptr<void> data, s32 prio, vm::ptr<void> 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);
|
||||
sceNp.warning("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);
|
||||
}
|
||||
@ -4244,15 +4244,15 @@ error_code scenp_score_get_game_data(s32 transId, SceNpScoreBoardId boardId, vm:
|
||||
|
||||
error_code sceNpScoreGetGameData(s32 transId, SceNpScoreBoardId boardId, vm::cptr<SceNpId> npId, vm::ptr<u32> totalSize, u32 recvSize, vm::ptr<void> data, vm::ptr<void> 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);
|
||||
sceNp.warning("sceNpScoreGetGameData(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<SceNpId> npId, vm::ptr<u32> totalSize, u32 recvSize, vm::ptr<void> data, s32 prio, vm::ptr<void> 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);
|
||||
sceNp.warning("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);
|
||||
|
||||
return scenp_score_get_game_data(transId, boardId, npId, totalSize, recvSize, data, option, true);
|
||||
}
|
||||
|
@ -68,16 +68,18 @@ void score_transaction_ctx::abort_score_transaction()
|
||||
result = SCE_NP_COMMUNITY_ERROR_ABORTED;
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
void score_transaction_ctx::wait_for_completion()
|
||||
error_code score_transaction_ctx::wait_for_completion()
|
||||
{
|
||||
std::unique_lock lock(mutex);
|
||||
|
||||
if (result)
|
||||
{
|
||||
return;
|
||||
return *result;
|
||||
}
|
||||
|
||||
completion_cond.wait(lock);
|
||||
|
||||
return *result;
|
||||
}
|
||||
|
||||
bool score_transaction_ctx::set_result_and_wake(error_code err)
|
||||
|
@ -80,7 +80,7 @@ struct score_transaction_ctx
|
||||
~score_transaction_ctx();
|
||||
std::optional<s32> get_score_transaction_status();
|
||||
void abort_score_transaction();
|
||||
void wait_for_completion();
|
||||
error_code wait_for_completion();
|
||||
bool set_result_and_wake(error_code err);
|
||||
|
||||
static const u32 id_base = 0x1001;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
#include "Emu/Cell/lv2/sys_sync.h"
|
||||
#include "Emu/system_config.h"
|
||||
#include "Emu/Cell/Modules/cellSysutil.h"
|
||||
#include "Emu/Memory/vm_ptr.h"
|
||||
@ -774,7 +775,10 @@ namespace np
|
||||
return;
|
||||
}
|
||||
|
||||
return worker_function(std::move(lock));
|
||||
auto& cpu_thread = *get_current_cpu_thread();
|
||||
lv2_obj::sleep(cpu_thread);
|
||||
worker_function(std::move(lock));
|
||||
cpu_thread.check_state();
|
||||
}
|
||||
|
||||
void np_handler::get_board_infos(std::shared_ptr<score_transaction_ctx>& trans_ctx, SceNpScoreBoardId boardId, vm::ptr<SceNpScoreBoardInfo> boardInfo, bool async)
|
||||
@ -967,8 +971,16 @@ namespace np
|
||||
return;
|
||||
}
|
||||
|
||||
// If here the data has already been acquired and the client is just asking for part of it
|
||||
// Check if the transaction has actually completed, otherwise adjust tdata parameters
|
||||
if (!trans_ctx->result)
|
||||
{
|
||||
tdata->totalSize = totalSize;
|
||||
tdata->recvSize = recvSize;
|
||||
tdata->score_data = score_data;
|
||||
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<usz>(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);
|
||||
|
Loading…
Reference in New Issue
Block a user