Files
UnleashedRecomp-hedge-dev/UnleashedRecomp/user/achievement_data.h
Skyth (Asilkan) a397a90551 Mod loader implementation. (#66)
* Initial mod loader implementation.

* Allow iterating in mod directories.

* Initial append archive implementation.

* Avoid calling function wrappers when loading append ARs.

For some reason they cause issues. Should investigate later.

* UMM merge archive support.

* Load merge archives without archive lists.

* Less thread locals.

I shouldn't worry about string allocations this much when the game itself spams them...

* Check for read-only UMM archives.

TODO: Skip merging as it's currently just doing duplicate loads.

* Skip loading merge archives if they are read-only.

* Merge only archives.

* Implement decompression.

* Fix append ARLs not loading.

* Initial save file redirection implementation.

* Slightly refactor resolved path usage.

* Implement save file redirection fallback.

* Set a default save file path if none is provided.

* Check for enabled option & replace backward slashes with forward ones in mod save file paths.

* Convert back slashes to forward ones when iterating directories.

* Make CSB limit dynamic.

* Cache append/merge archive lookups.

* Close stream after reading compressed ARL.

* Fix UMM/HMM ARL file path inconsistency.
2024-12-31 20:20:07 +03:00

64 lines
1.4 KiB
C++

#pragma once
#include <user/paths.h>
#define ACH_SIGNATURE { 'A', 'C', 'H', ' ' }
#define ACH_VERSION { 1, 0, 0 }
#define ACH_RECORDS 50
class AchievementData
{
public:
#pragma pack(push, 1)
struct Record
{
uint16_t ID;
time_t Timestamp;
uint16_t Reserved[3];
};
#pragma pack(pop)
struct Version
{
uint8_t Major;
uint8_t Minor;
uint8_t Revision;
uint8_t Reserved;
bool operator==(const Version& other) const
{
return Major == other.Major &&
Minor == other.Minor &&
Revision == other.Revision;
}
};
class Data
{
public:
char Signature[4];
Version Version{};
uint32_t Checksum;
uint32_t Reserved;
Record Records[ACH_RECORDS];
};
static inline Data Data{ ACH_SIGNATURE, ACH_VERSION };
static std::filesystem::path GetDataPath(bool checkForMods)
{
return GetSavePath(checkForMods) / "ACH-DATA";
}
static time_t GetTimestamp(uint16_t id);
static int GetTotalRecords();
static bool IsUnlocked(uint16_t id);
static void Unlock(uint16_t id);
static uint32_t CalculateChecksum();
static bool VerifySignature();
static bool VerifyVersion();
static bool VerifyChecksum();
static void Load();
static void Save();
};