From 149c08ba785154ac6849ff105cd0eafbaee171d5 Mon Sep 17 00:00:00 2001 From: Inviuz Date: Wed, 22 Mar 2017 11:09:10 +0100 Subject: [PATCH] implement getSizeKB functions bugfix in sys_net. id 0 is acceptable socket id --- rpcs3/Emu/Cell/Modules/cellGame.cpp | 40 +++++++++++++++++++++++---- rpcs3/Emu/Cell/Modules/cellGcmSys.cpp | 4 +-- rpcs3/Emu/Cell/Modules/sys_net.cpp | 2 +- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 9edbde7e62..1ce74cfff3 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -181,9 +181,16 @@ s32 cellHddGameCheck2() s32 cellHddGameGetSizeKB(vm::ptr size) { - cellGame.todo("cellHddGameGetSizeKB(size=*0x%x)", size); + cellGame.warning("cellHddGameGetSizeKB(size=*0x%x)", size); + + const std::string& local_dir = vfs::get("/dev_hdd0/game/" + Emu.GetTitleID()); + if (!fs::is_dir(local_dir)) + { + return CELL_HDDGAME_ERROR_FAILURE; + } + + *size = (u32)fs::get_dir_size(local_dir); - *size = 0; return CELL_OK; } @@ -200,10 +207,18 @@ s32 cellHddGameExitBroken() s32 cellGameDataGetSizeKB(vm::ptr size) { - cellGame.todo("cellGameDataGetSizeKB(size=*0x%x)", size); + cellGame.warning("cellGameDataGetSizeKB(size=*0x%x)", size); + + const std::string& local_dir = vfs::get("/dev_hdd0/game/" + Emu.GetTitleID()); + if (!fs::is_dir(local_dir)) + { + return CELL_GAMEDATA_ERROR_FAILURE; + } + + *size = (u32)fs::get_dir_size(local_dir); - *size = 0; return CELL_OK; + } s32 cellGameDataSetSystemVer() @@ -701,9 +716,22 @@ error_code cellGameSetParamString(s32 id, vm::cptr buf) s32 cellGameGetSizeKB(vm::ptr size) { - cellGame.todo("cellGameGetSizeKB(size=*0x%x)", size); + cellGame.warning("cellGameGetSizeKB(size=*0x%x)", size); + const auto prm = fxm::get(); + + if (!prm) + { + return CELL_GAME_ERROR_FAILURE; + } + + const std::string& local_dir = prm->is_temporary? vfs::get("/dev_hdd1/game/"s + prm->dir) : vfs::get("/dev_hdd0/game/"s + prm->dir); //should we check the temporary folder? + if (!fs::is_dir(local_dir)) + { + return CELL_GAME_ERROR_FAILURE; + } + + *size = (u32)fs::get_dir_size(local_dir); - *size = 0; return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp index 1acb353418..488b831aaa 100644 --- a/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGcmSys.cpp @@ -808,9 +808,9 @@ s32 cellGcmSetQueueHandler() return CELL_OK; } -s32 cellGcmSetSecondVHandler() +s32 cellGcmSetSecondVHandler(vm::ptr handler) { - UNIMPLEMENTED_FUNC(cellGcmSys); + cellGcmSys.todo("cellGcmSetSecondVHandler(handler=0x%x)", handler); return CELL_OK; } diff --git a/rpcs3/Emu/Cell/Modules/sys_net.cpp b/rpcs3/Emu/Cell/Modules/sys_net.cpp index 1607b7e280..93ad21d57e 100644 --- a/rpcs3/Emu/Cell/Modules/sys_net.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_net.cpp @@ -444,7 +444,7 @@ namespace sys_net memcpy(&_addr, addr.get_ptr(), sizeof(::sockaddr)); _addr.sa_family = addr->sa_family; - if (s <= 0) { + if (s < 0) { libnet.error("recvfrom(): invalid socket %d", s); return SYS_NET_EBADF; }