From 66cf864ee06e11dad4ed3a03233e5aa71a43ea47 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Mon, 13 Jul 2015 22:06:16 +0300 Subject: [PATCH] Fix saving and some more logging Fixes Shin Hayarigami (BLJS10279). --- rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp | 45 +++++++++++++++++---- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 18 +-------- rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp | 24 ++++++++--- rpcs3/Loader/TRP.cpp | 2 +- 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp index 9556a2da4d..8b6d66b328 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.cpp @@ -57,6 +57,7 @@ never_inline s32 savedata_op( if (!lock) { + cellSysutil.Error("savedata_op(): failed to lock the mutex."); return CELL_SAVEDATA_ERROR_BUSY; } @@ -191,6 +192,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcList returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -302,6 +304,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcFixed returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -343,10 +346,39 @@ never_inline s32 savedata_op( PSFLoader psf; + // Create save directory if necessary + if (save_entry.isNew) + { + if (!Emu.GetVFS().ExistsDir(dir_path) && !Emu.GetVFS().CreateDir(dir_path)) + { + // Let's ignore this error for now + } + else + { + std::string rSfo_path = "/dev_hdd0/game/" + save_entry.dirName.substr(0, 9) + "/PS3_GAME/PARAM.SFO"; // The real SFO path + if (!Emu.GetVFS().ExistsFile(rSfo_path)) + { + rSfo_path = "/dev_hdd0/game/" + save_entry.dirName.substr(0, 9) + "/PARAM.SFO"; + } + + vfsFile rSfo(rSfo_path); + PSFLoader rPsf(rSfo); + psf.Clear(); + psf.SetInteger("ATTRIBUTE", rPsf.GetInteger("ATTRIBUTE")); + psf.SetString("TITLE", rPsf.GetString("TITLE")); + psf.SetString("SUB_TITLE", rPsf.GetString("SUB_TITLE")); + psf.SetString("DETAIL", rPsf.GetString("DETAIL")); + psf.SetString("SAVEDATA_LIST_PARAM", rPsf.GetString("SAVEDATA_LIST_PARAM")); + } + } + // Load PARAM.SFO { - vfsFile f(sfo_path); - psf.Load(f); + if (!save_entry.isNew) + { + vfsFile f(sfo_path); + psf.Load(f); + } } // Get save stats @@ -436,6 +468,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcStat returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -485,12 +518,6 @@ never_inline s32 savedata_op( } } - // Create save directory if necessary - if (save_entry.isNew && !Emu.GetVFS().CreateDir(dir_path)) - { - // Let's ignore this error for now - } - // Enter the loop where the save files are read/created/deleted vm::stackvar fileGet(CPU); vm::stackvar fileSet(CPU); @@ -504,6 +531,7 @@ never_inline s32 savedata_op( if (result->result < 0) { + cellSysutil.Error("savedata_op(): funcFile returned result < 0."); return CELL_SAVEDATA_ERROR_CBRESULT; } @@ -605,6 +633,7 @@ never_inline s32 savedata_op( // Write PARAM.SFO if (psf) { + cellSysutil.Error("psf: true"); vfsFile f(sfo_path, vfsWriteNew); psf.Save(f); } diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index a02614fc34..d96cb33601 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -191,14 +191,7 @@ s32 sceNpDrmGetTimelimit(vm::ptr path, vm::ptr time_remain) s32 sceNpDrmProcessExitSpawn(vm::cptr path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags) { - sceNp.Warning("sceNpDrmProcessExitSpawn()"); - sceNp.Warning("path: %s", path.get_ptr()); - sceNp.Warning("argv: 0x%x", argv_addr); - sceNp.Warning("envp: 0x%x", envp_addr); - sceNp.Warning("data: 0x%x", data_addr); - sceNp.Warning("data_size: 0x%x", data_size); - sceNp.Warning("prio: %d", prio); - sceNp.Warning("flags: %d", flags); + sceNp.Warning("sceNpDrmProcessExitSpawn() -> sys_game_process_exitspawn"); sys_game_process_exitspawn(path, argv_addr, envp_addr, data_addr, data_size, prio, flags); @@ -207,14 +200,7 @@ s32 sceNpDrmProcessExitSpawn(vm::cptr path, u32 argv_addr, u32 envp_addr, s32 sceNpDrmProcessExitSpawn2(vm::cptr path, u32 argv_addr, u32 envp_addr, u32 data_addr, u32 data_size, u32 prio, u64 flags) { - sceNp.Warning("sceNpDrmProcessExitSpawn2()"); - sceNp.Warning("path: %s", path.get_ptr()); - sceNp.Warning("argv: 0x%x", argv_addr); - sceNp.Warning("envp: 0x%x", envp_addr); - sceNp.Warning("data: 0x%x", data_addr); - sceNp.Warning("data_size: 0x%x", data_size); - sceNp.Warning("prio: %d", prio); - sceNp.Warning("flags: %d", flags); + sceNp.Warning("sceNpDrmProcessExitSpawn2() -> sys_game_process_exitspawn2"); sys_game_process_exitspawn2(path, argv_addr, envp_addr, data_addr, data_size, prio, flags); diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index be1a709d89..8366138ff3 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -157,6 +157,7 @@ s32 sceNpTrophyRegisterContext(PPUThread& CPU, u32 context, u32 handle, vm::ptr< if (!ctxt) { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT"); return SCE_NP_TROPHY_ERROR_UNKNOWN_CONTEXT; } @@ -164,43 +165,56 @@ s32 sceNpTrophyRegisterContext(PPUThread& CPU, u32 context, u32 handle, vm::ptr< if (!hndl) { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE"); return SCE_NP_TROPHY_ERROR_UNKNOWN_HANDLE; } TRPLoader trp(*ctxt->trp_stream); if (!trp.LoadHeader()) + { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE"); return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; + } // Rename or discard certain entries based on the files found const size_t kTargetBufferLength = 31; - char target[kTargetBufferLength+1]; + char target[kTargetBufferLength + 1]; target[kTargetBufferLength] = 0; strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", Ini.SysLanguage.GetValue())); - if (trp.ContainsEntry(target)) { + if (trp.ContainsEntry(target)) + { trp.RemoveEntry("TROPCONF.SFM"); trp.RemoveEntry("TROP.SFM"); trp.RenameEntry(target, "TROPCONF.SFM"); } - else if (trp.ContainsEntry("TROP.SFM")) { + else if (trp.ContainsEntry("TROP.SFM")) + { trp.RemoveEntry("TROPCONF.SFM"); trp.RenameEntry("TROP.SFM", "TROPCONF.SFM"); } - else if (!trp.ContainsEntry("TROPCONF.SFM")) { + else if (!trp.ContainsEntry("TROPCONF.SFM")) + { return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; } // Discard unnecessary TROP_XX.SFM files - for (s32 i=0; i<=18; i++) { + for (s32 i = 0; i <= 18; i++) + { strcpy_trunc(target, fmt::Format("TROP_%02d.SFM", i)); if (i != Ini.SysLanguage.GetValue()) + { trp.RemoveEntry(target); + } } // TODO: Get the path of the current user std::string trophyPath = "/dev_hdd0/home/00000001/trophy/" + ctxt->trp_name; if (!trp.Install(trophyPath)) + { + sceNpTrophy.Error("sceNpTrophyRegisterContext(): SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE"); return SCE_NP_TROPHY_ERROR_ILLEGAL_UPDATE; + } TROPUSRLoader* tropusr = new TROPUSRLoader(); std::string trophyUsrPath = trophyPath + "/TROPUSR.DAT"; diff --git a/rpcs3/Loader/TRP.cpp b/rpcs3/Loader/TRP.cpp index 4ced4804d6..77b0763061 100644 --- a/rpcs3/Loader/TRP.cpp +++ b/rpcs3/Loader/TRP.cpp @@ -16,7 +16,7 @@ TRPLoader::~TRPLoader() bool TRPLoader::Install(std::string dest, bool show) { - if(!trp_f.IsOpened()) + if (!trp_f.IsOpened()) return false; if (!dest.empty() && dest.back() != '/')