From fca94497b10d3e192e704f0fa36962b3d70e1cf4 Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Tue, 9 Dec 2025 18:22:01 +0200 Subject: [PATCH] savedata path is not homedir / userid / savedata / gameid --- src/common/config.cpp | 74 ------------------- src/common/config.h | 2 - .../libraries/save_data/save_instance.cpp | 9 ++- src/core/libraries/save_data/savedata.cpp | 11 ++- src/main.cpp | 5 +- 5 files changed, 17 insertions(+), 84 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 089188b4c..f1fe62a1f 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -192,11 +192,6 @@ static ConfigEntry pipelineCacheArchive(false); static ConfigEntry isFpsColor(true); static ConfigEntry showFpsCounter(false); -// GUI -static std::vector settings_install_dirs = {}; -std::vector install_dirs_enabled = {}; -std::filesystem::path save_data_path = {}; - // Settings ConfigEntry m_language(1); // english @@ -264,13 +259,6 @@ void setTrophyKey(string key) { trophyKey = key; } -std::filesystem::path GetSaveDataPath() { - if (save_data_path.empty()) { - return Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "savedata"; - } - return save_data_path; -} - void setVolumeSlider(int volumeValue, bool is_game_specific) { volumeSlider.set(volumeValue, is_game_specific); } @@ -540,10 +528,6 @@ void setIsMotionControlsEnabled(bool use, bool is_game_specific) { isMotionControlsEnabled.set(use, is_game_specific); } -void setSaveDataPath(const std::filesystem::path& path) { - save_data_path = path; -} - u32 GetLanguage() { return m_language.get(); } @@ -697,32 +681,6 @@ void load(const std::filesystem::path& path, bool is_game_specific) { current_version = toml::find_or(debug, "ConfigVersion", current_version); } - if (data.contains("GUI")) { - const toml::value& gui = data.at("GUI"); - - const auto install_dir_array = - toml::find_or>(gui, "installDirs", {}); - - try { - install_dirs_enabled = toml::find>(gui, "installDirsEnabled"); - } catch (...) { - // If it does not exist, assume that all are enabled. - install_dirs_enabled.resize(install_dir_array.size(), true); - } - - if (install_dirs_enabled.size() < install_dir_array.size()) { - install_dirs_enabled.resize(install_dir_array.size(), true); - } - - settings_install_dirs.clear(); - for (size_t i = 0; i < install_dir_array.size(); i++) { - settings_install_dirs.push_back( - {std::filesystem::path{install_dir_array[i]}, install_dirs_enabled[i]}); - } - - save_data_path = toml::find_fs_path_or(gui, "saveDataPath", save_data_path); - } - if (data.contains("Settings")) { const toml::value& settings = data.at("Settings"); m_language.setFromToml(settings, "consoleLanguage", is_game_specific); @@ -834,39 +792,7 @@ void save(const std::filesystem::path& path, bool is_game_specific) { m_language.setTomlValue(data, "Settings", "consoleLanguage", is_game_specific); if (!is_game_specific) { - std::vector install_dirs; - std::vector install_dirs_enabled; - - // temporary structure for ordering - struct DirEntry { - string path_str; - bool enabled; - }; - - std::vector sorted_dirs; - for (const auto& dirInfo : settings_install_dirs) { - sorted_dirs.push_back( - {string{fmt::UTF(dirInfo.path.u8string()).data}, dirInfo.enabled}); - } - - // Sort directories alphabetically - std::sort(sorted_dirs.begin(), sorted_dirs.end(), [](const DirEntry& a, const DirEntry& b) { - return std::lexicographical_compare( - a.path_str.begin(), a.path_str.end(), b.path_str.begin(), b.path_str.end(), - [](char a_char, char b_char) { - return std::tolower(a_char) < std::tolower(b_char); - }); - }); - - for (const auto& entry : sorted_dirs) { - install_dirs.push_back(entry.path_str); - install_dirs_enabled.push_back(entry.enabled); - } - // Non game-specific entries - data["GUI"]["installDirs"] = install_dirs; - data["GUI"]["installDirsEnabled"] = install_dirs_enabled; - data["GUI"]["saveDataPath"] = string{fmt::UTF(save_data_path.u8string()).data}; data["Debug"]["ConfigVersion"] = config_version; data["Keys"]["TrophyKey"] = trophyKey; diff --git a/src/common/config.h b/src/common/config.h index db61c74b5..7780719ef 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -116,7 +116,6 @@ int getUsbDeviceBackend(); void setUsbDeviceBackend(int value, bool is_game_specific = false); // TODO -std::filesystem::path GetSaveDataPath(); std::string getUserName(int id); std::array const getUserNames(); bool GetUseUnifiedInputConfig(); @@ -125,7 +124,6 @@ bool GetOverrideControllerColor(); void SetOverrideControllerColor(bool enable); int* GetControllerCustomColor(); void SetControllerCustomColor(int r, int b, int g); -void setSaveDataPath(const std::filesystem::path& path); void setDefaultValues(bool is_game_specific = false); diff --git a/src/core/libraries/save_data/save_instance.cpp b/src/core/libraries/save_data/save_instance.cpp index 75a644fdb..25ea6493d 100644 --- a/src/core/libraries/save_data/save_instance.cpp +++ b/src/core/libraries/save_data/save_instance.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -9,6 +9,7 @@ #include "common/config.h" #include "common/path_util.h" #include "common/singleton.h" +#include "core/emulator_settings.h" #include "core/file_sys/fs.h" #include "save_backup.h" #include "save_instance.h" @@ -48,12 +49,14 @@ namespace Libraries::SaveData { fs::path SaveInstance::MakeTitleSavePath(OrbisUserServiceUserId user_id, std::string_view game_serial) { - return Config::GetSaveDataPath() / std::to_string(user_id) / game_serial; + return EmulatorSettings::GetInstance()->GetHomeDir() / std::to_string(user_id) / "savedata" / + game_serial; } fs::path SaveInstance::MakeDirSavePath(OrbisUserServiceUserId user_id, std::string_view game_serial, std::string_view dir_name) { - return Config::GetSaveDataPath() / std::to_string(user_id) / game_serial / dir_name; + return EmulatorSettings::GetInstance()->GetHomeDir() / std::to_string(user_id) / "savedata" / + game_serial / dir_name; } uint64_t SaveInstance::GetMaxBlockFromSFO(const PSF& psf) { diff --git a/src/core/libraries/save_data/savedata.cpp b/src/core/libraries/save_data/savedata.cpp index 7fba8ed21..fdf0b9d6a 100644 --- a/src/core/libraries/save_data/savedata.cpp +++ b/src/core/libraries/save_data/savedata.cpp @@ -1,9 +1,10 @@ -// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include #include #include +#include #include @@ -15,6 +16,7 @@ #include "common/logging/log.h" #include "common/path_util.h" #include "common/string_util.h" +#include "core/emulator_settings.h" #include "core/file_format/psf.h" #include "core/file_sys/fs.h" #include "core/libraries/error_codes.h" @@ -439,7 +441,8 @@ static Error saveDataMount(const OrbisSaveDataMount2* mount_info, LOG_INFO(Lib_SaveData, "called with invalid block size"); } - const auto root_save = Config::GetSaveDataPath(); + const auto root_save = EmulatorSettings::GetInstance()->GetHomeDir() / + std::to_string(mount_info->userId) / "savedata"; fs::create_directories(root_save); const auto available = fs::space(root_save).available; @@ -487,7 +490,9 @@ static Error Umount(const OrbisSaveDataMountPoint* mountPoint, bool call_backup return Error::PARAMETER; } LOG_DEBUG(Lib_SaveData, "Umount mountPoint:{}", mountPoint->data.to_view()); - const std::string_view mount_point_str{mountPoint->data}; + + std::string mount_point_str = mountPoint->data.to_string(); + for (auto& instance : g_mount_slots) { if (instance.has_value()) { const auto& slot_name = instance->GetMountPoint(); diff --git a/src/main.cpp b/src/main.cpp index 615e961f3..ea6dcfe8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) { bool waitForDebugger = false; std::optional waitPid; - +#if 0 // Map of argument strings to lambda functions std::unordered_map> arg_map = { {"-h", @@ -263,11 +263,12 @@ int main(int argc, char* argv[]) { if (waitPid.has_value()) { Core::Debugger::WaitForPid(waitPid.value()); } - +#endif // Run the emulator with the resolved eboot path Core::Emulator* emulator = Common::Singleton::Instance(); emulator->executableName = argv[0]; emulator->waitForDebuggerBeforeRun = waitForDebugger; + const char* const eboot_path = "D:/ps4/shadps4games/CUSA18992/eboot.bin"; emulator->Run(eboot_path, game_args, game_folder); return 0;