mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 13:48:40 +00:00
savedata path is not homedir / userid / savedata / gameid
This commit is contained in:
@@ -192,11 +192,6 @@ static ConfigEntry<bool> pipelineCacheArchive(false);
|
||||
static ConfigEntry<bool> isFpsColor(true);
|
||||
static ConfigEntry<bool> showFpsCounter(false);
|
||||
|
||||
// GUI
|
||||
static std::vector<GameInstallDir> settings_install_dirs = {};
|
||||
std::vector<bool> install_dirs_enabled = {};
|
||||
std::filesystem::path save_data_path = {};
|
||||
|
||||
// Settings
|
||||
ConfigEntry<u32> 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<std::string>(debug, "ConfigVersion", current_version);
|
||||
}
|
||||
|
||||
if (data.contains("GUI")) {
|
||||
const toml::value& gui = data.at("GUI");
|
||||
|
||||
const auto install_dir_array =
|
||||
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
|
||||
|
||||
try {
|
||||
install_dirs_enabled = toml::find<std::vector<bool>>(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<std::string> install_dirs;
|
||||
std::vector<bool> install_dirs_enabled;
|
||||
|
||||
// temporary structure for ordering
|
||||
struct DirEntry {
|
||||
string path_str;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
std::vector<DirEntry> 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;
|
||||
|
||||
|
||||
@@ -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<std::string, 4> 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);
|
||||
|
||||
|
||||
@@ -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 <iostream>
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 <span>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -43,7 +43,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
bool waitForDebugger = false;
|
||||
std::optional<int> waitPid;
|
||||
|
||||
#if 0
|
||||
// Map of argument strings to lambda functions
|
||||
std::unordered_map<std::string, std::function<void(int&)>> 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<Core::Emulator>::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;
|
||||
|
||||
Reference in New Issue
Block a user