mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-22 10:21:39 +00:00
Make AchievementManager follow the same naming convention as PersistentStorageManager
This commit is contained in:
parent
3ad00fb5e3
commit
9b866168c4
4 changed files with 22 additions and 22 deletions
|
|
@ -65,16 +65,16 @@ static bool ProcessCorruptAchievementsMessage()
|
|||
if (!g_corruptAchievementsMessageOpen)
|
||||
return false;
|
||||
|
||||
auto message = AchievementManager::Status == EAchStatus::IOError
|
||||
auto message = AchievementManager::BinStatus == EAchStatus::IOError
|
||||
? Localise("Title_Message_AchievementDataIOError")
|
||||
: Localise("Title_Message_AchievementDataCorrupt");
|
||||
|
||||
if (MessageWindow::Open(message, &g_corruptAchievementsMessageResult) == MSG_CLOSED)
|
||||
{
|
||||
// Allow user to proceed if the achievement data couldn't be loaded.
|
||||
// Restarting may fix this error, so it isn't worth clearing the data for.
|
||||
if (AchievementManager::Status != EAchStatus::IOError)
|
||||
AchievementManager::Save(true);
|
||||
// Create a new save file if the file was successfully loaded and failed validation.
|
||||
// If the file couldn't be opened, restarting may fix this error, so it isn't worth clearing the data for.
|
||||
if (AchievementManager::BinStatus != EAchStatus::IOError)
|
||||
AchievementManager::SaveBinary(true);
|
||||
|
||||
g_corruptAchievementsMessageOpen = false;
|
||||
g_corruptAchievementsMessageOpen.notify_one();
|
||||
|
|
@ -136,10 +136,10 @@ void PressStartSaveLoadThreadMidAsmHook()
|
|||
g_faderBegun.wait(true);
|
||||
}
|
||||
|
||||
if (!AchievementManager::Load())
|
||||
LOGFN_ERROR("Failed to load achievement data... (status code {})", (int)AchievementManager::Status);
|
||||
if (!AchievementManager::LoadBinary())
|
||||
LOGFN_ERROR("Failed to load achievement data... (status code {})", (int)AchievementManager::BinStatus);
|
||||
|
||||
if (AchievementManager::Status != EAchStatus::Success)
|
||||
if (AchievementManager::BinStatus != EAchStatus::Success)
|
||||
{
|
||||
g_corruptAchievementsMessageOpen = true;
|
||||
g_corruptAchievementsMessageOpen.wait(true);
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ PPC_FUNC(sub_824E5170)
|
|||
|
||||
if (!isSavedExtraData)
|
||||
{
|
||||
AchievementManager::Save();
|
||||
AchievementManager::SaveBinary();
|
||||
PersistentStorageManager::SaveBinary();
|
||||
|
||||
isSavedExtraData = true;
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ void AchievementManager::Reset()
|
|||
Data = {};
|
||||
}
|
||||
|
||||
bool AchievementManager::Load()
|
||||
bool AchievementManager::LoadBinary()
|
||||
{
|
||||
AchievementManager::Reset();
|
||||
|
||||
Status = EAchStatus::Success;
|
||||
BinStatus = EAchStatus::Success;
|
||||
|
||||
auto dataPath = GetDataPath(true);
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ bool AchievementManager::Load()
|
|||
|
||||
if (fileSize != dataSize)
|
||||
{
|
||||
Status = EAchStatus::BadFileSize;
|
||||
BinStatus = EAchStatus::BadFileSize;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ bool AchievementManager::Load()
|
|||
|
||||
if (!file)
|
||||
{
|
||||
Status = EAchStatus::IOError;
|
||||
BinStatus = EAchStatus::IOError;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ bool AchievementManager::Load()
|
|||
|
||||
if (!data.VerifySignature())
|
||||
{
|
||||
Status = EAchStatus::BadSignature;
|
||||
BinStatus = EAchStatus::BadSignature;
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ bool AchievementManager::Load()
|
|||
|
||||
if (!data.VerifyVersion())
|
||||
{
|
||||
Status = EAchStatus::BadVersion;
|
||||
BinStatus = EAchStatus::BadVersion;
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ bool AchievementManager::Load()
|
|||
|
||||
if (!data.VerifyChecksum())
|
||||
{
|
||||
Status = EAchStatus::BadChecksum;
|
||||
BinStatus = EAchStatus::BadChecksum;
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -158,9 +158,9 @@ bool AchievementManager::Load()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool AchievementManager::Save(bool ignoreStatus)
|
||||
bool AchievementManager::SaveBinary(bool ignoreStatus)
|
||||
{
|
||||
if (!ignoreStatus && Status != EAchStatus::Success)
|
||||
if (!ignoreStatus && BinStatus != EAchStatus::Success)
|
||||
{
|
||||
LOGN_WARNING("Achievement data will not be saved in this session!");
|
||||
return false;
|
||||
|
|
@ -181,7 +181,7 @@ bool AchievementManager::Save(bool ignoreStatus)
|
|||
file.write((const char*)&Data, sizeof(AchievementData));
|
||||
file.close();
|
||||
|
||||
Status = EAchStatus::Success;
|
||||
BinStatus = EAchStatus::Success;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class AchievementManager
|
|||
{
|
||||
public:
|
||||
static inline AchievementData Data{};
|
||||
static inline EAchStatus Status{ EAchStatus::Unknown };
|
||||
static inline EAchStatus BinStatus{ EAchStatus::Unknown };
|
||||
|
||||
static std::filesystem::path GetDataPath(bool checkForMods)
|
||||
{
|
||||
|
|
@ -30,6 +30,6 @@ public:
|
|||
static void Unlock(uint16_t id);
|
||||
static void UnlockAll();
|
||||
static void Reset();
|
||||
static bool Load();
|
||||
static bool Save(bool ignoreStatus = false);
|
||||
static bool LoadBinary();
|
||||
static bool SaveBinary(bool ignoreStatus = false);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue