diff options
author | german77 <juangerman-13@hotmail.com> | 2024-01-13 21:19:44 +0100 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2024-01-13 21:28:29 +0100 |
commit | bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7 (patch) | |
tree | 0cba79e5f77d8940de057cf5eb439e5adf46c956 /src/core/hle/service | |
parent | Merge pull request #12653 from liamwhite/once-more (diff) | |
download | yuzu-bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7.tar yuzu-bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7.tar.gz yuzu-bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7.tar.bz2 yuzu-bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7.tar.lz yuzu-bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7.tar.xz yuzu-bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7.tar.zst yuzu-bee22540a1d8a7b3ebd9ff4c244bf257b5e9f8b7.zip |
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/acc/profile_manager.cpp | 19 | ||||
-rw-r--r-- | src/core/hle/service/acc/profile_manager.h | 1 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index 5542d6cbc..683f44e27 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp @@ -61,9 +61,7 @@ ProfileManager::ProfileManager() { OpenUser(*GetUser(current)); } -ProfileManager::~ProfileManager() { - WriteUserSaveFile(); -} +ProfileManager::~ProfileManager() = default; /// After a users creation it needs to be "registered" to the system. AddToProfiles handles the /// internal management of the users profiles @@ -113,6 +111,8 @@ Result ProfileManager::CreateNewUser(UUID uuid, const ProfileUsername& username) return ERROR_USER_ALREADY_EXISTS; } + is_save_needed = true; + return AddUser({ .user_uuid = uuid, .username = username, @@ -326,6 +326,9 @@ bool ProfileManager::RemoveUser(UUID uuid) { profiles[*index] = ProfileInfo{}; std::stable_partition(profiles.begin(), profiles.end(), [](const ProfileInfo& profile) { return profile.user_uuid.IsValid(); }); + + is_save_needed = true; + return true; } @@ -340,6 +343,8 @@ bool ProfileManager::SetProfileBase(UUID uuid, const ProfileBase& profile_new) { profile.username = profile_new.username; profile.creation_time = profile_new.timestamp; + is_save_needed = true; + return true; } @@ -348,6 +353,7 @@ bool ProfileManager::SetProfileBaseAndData(Common::UUID uuid, const ProfileBase& const auto index = GetUserIndex(uuid); if (index.has_value() && SetProfileBase(uuid, profile_new)) { profiles[*index].data = data_new; + is_save_needed = true; return true; } @@ -391,6 +397,10 @@ void ProfileManager::ParseUserSaveFile() { } void ProfileManager::WriteUserSaveFile() { + if (!is_save_needed) { + return; + } + ProfileDataRaw raw{}; for (std::size_t i = 0; i < MAX_USERS; ++i) { @@ -423,7 +433,10 @@ void ProfileManager::WriteUserSaveFile() { if (!save.IsOpen() || !save.SetSize(sizeof(ProfileDataRaw)) || !save.WriteObject(raw)) { LOG_WARNING(Service_ACC, "Failed to write save data to file... No changes to user data " "made in current session will be saved."); + return; } + + is_save_needed = false; } }; // namespace Service::Account diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 900e32200..e21863e64 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h @@ -103,6 +103,7 @@ private: std::optional<std::size_t> AddToProfiles(const ProfileInfo& profile); bool RemoveProfileAtIndex(std::size_t index); + bool is_save_needed{}; std::array<ProfileInfo, MAX_USERS> profiles{}; std::array<ProfileInfo, MAX_USERS> stored_opened_profiles{}; std::size_t user_count{}; |