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