Curation round 3: Lua engine, Manager, sound, menus, cutscenes, rooms, item pools, saves; boots past LuaEngine::Init
Seven agents took over LuaEngine (the mod API registration deferred), the rest of Manager (LoadConfigs, fonts, render surfaces, Update/Render), MusicManager/SFXManager, MenuManager with the title/save/game menus, Cutscene/NightmareScene/ Backdrop, RoomConfig (src/rooms ported and retired) with ItemPool, and PersistentGameData (the original binary save format) with InfoDisplay. An integration pass moved call sites to the new APIs, declared the taken-over free functions, fixed two data.cpp crashes (an empty children array, null attribute strings), and made the generator keep a header's own name where a prototype names another address. Clean build (0 warnings with -Wall -Wextra). build/isaac runs the game's Lua scripts (without the mod API yet) and stops at reload_resource_paths. 901 functions taken over, boot path 204/615. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a7061306fa
commit
ddf913f304
137 files changed
+12684
-50687
No files matched your search
@@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
constexpr int ACHIEVEMENT_COUNT = 642;
|
||||
constexpr int BOSS_COUNT = 104;
|
||||
constexpr int CHALLENGE_COUNT = 46;
|
||||
constexpr int COLLECTIBLE_SEEN_COUNT = 733;
|
||||
constexpr int CUTSCENE_COUNTER_COUNT = 27;
|
||||
constexpr int EVENT_COUNTER_COUNT = 523;
|
||||
constexpr int LEVEL_COUNTER_COUNT = 14;
|
||||
constexpr int MINIBOSS_COUNT = 7;
|
||||
constexpr int SPECIAL_SEED_COUNT = 80;
|
||||
|
||||
// How a Checksum folds bytes in: 4-byte words added to the state rotated right by 1, or CRC-32.
|
||||
enum ChecksumMode
|
||||
{
|
||||
CHECKSUM_ROTATE_ADD,
|
||||
CHECKSUM_CRC32
|
||||
};
|
||||
|
||||
// The running checksum KAGE closes its save files with. Saves use CRC-32 started from SEED.
|
||||
struct Checksum
|
||||
{
|
||||
static constexpr uint32_t SEED = 0xfedcba76;
|
||||
|
||||
ChecksumMode mode = CHECKSUM_CRC32;
|
||||
uint32_t state = SEED;
|
||||
uint32_t word = 0;
|
||||
uint8_t wordSize = 0;
|
||||
|
||||
void Update(std::span<const uint8_t> data);
|
||||
uint32_t value_get();
|
||||
};
|
||||
|
||||
// Whether Clear also restarts the count of saves written.
|
||||
enum ClearMode
|
||||
{
|
||||
CLEAR_KEEP_SAVE_COUNT,
|
||||
CLEAR_ALL
|
||||
};
|
||||
|
||||
struct SaveImport;
|
||||
|
||||
// The bestiary's counts per entity, keyed by type << 20 | variant << 8.
|
||||
// Construction and destruction (00926020, 00926120) are the defaults.
|
||||
struct PersistentGameData_Bestiary
|
||||
{
|
||||
std::map<int, int> deaths;
|
||||
std::map<int, int> encounters;
|
||||
std::map<int, int> hits;
|
||||
std::map<int, int> kills;
|
||||
};
|
||||
|
||||
// A save slot's progress (persistentgamedata1-3.dat): achievements, event counters, the collection, bosses, challenges,
|
||||
// cutscenes seen and the bestiary, kept in the original binary format so a Windows save loads as it is.
|
||||
// Unlocking re-checks the unlocks that depend on others. Read-only mode freezes it during runs that cannot unlock.
|
||||
// Copies, assignment and destruction (00925f80, 009261a0, 00929010) are the defaults.
|
||||
// Steam Cloud (00926cf0, 00928ee0, 0092bd20, 0092bf00, 0092c0e0) is dropped, since Steam is offline.
|
||||
class PersistentGameData
|
||||
{
|
||||
public:
|
||||
std::string filePath;
|
||||
PersistentGameData_Bestiary bestiary;
|
||||
std::array<bool, ACHIEVEMENT_COUNT> achievements{};
|
||||
std::array<bool, BOSS_COUNT> bosses{};
|
||||
std::array<bool, CHALLENGE_COUNT> challenges{};
|
||||
std::array<bool, COLLECTIBLE_SEEN_COUNT> itemsCollection{};
|
||||
std::array<bool, MINIBOSS_COUNT> miniBosses{};
|
||||
std::array<bool, SPECIAL_SEED_COUNT> specialSeeds{};
|
||||
std::array<int, CUTSCENE_COUNTER_COUNT> cutsceneCounters{};
|
||||
std::array<int, EVENT_COUNTER_COUNT> eventCounters{};
|
||||
std::array<int, LEVEL_COUNTER_COUNT> levelCounters{};
|
||||
int characterMenuShown = 0;
|
||||
int lastDifficulty = 0;
|
||||
uint32_t gameStateChecksum = 0;
|
||||
uint32_t saveCount = 0;
|
||||
bool isChangesMade = false;
|
||||
bool isFileLoaded = true;
|
||||
bool isReadOnly = false;
|
||||
bool isSteamAchievementsEnabled = true;
|
||||
|
||||
static void copy_shared_progress(PersistentGameData& destination, PersistentGameData& source);
|
||||
void Clear(ClearMode mode);
|
||||
bool Load(std::string_view path);
|
||||
void Save();
|
||||
void write_file(std::string_view path);
|
||||
void BackupSaveFile();
|
||||
std::string get_save_file_name();
|
||||
void SetReadOnly(bool isEnabled);
|
||||
|
||||
bool TryUnlock(int achievementID);
|
||||
bool Unlocked(int achievementID);
|
||||
void UnlockSteamAchievement(int achievementID);
|
||||
void IncreaseEventCounter(int eventCounter, int num);
|
||||
void AddToCollection(int collectibleID);
|
||||
void AddChallenge(int challengeID);
|
||||
void set_run_mask(uint64_t mask);
|
||||
|
||||
bool AddBestiaryKill(int type, int variant);
|
||||
bool TryAddBestiaryEncounter(int type, int variant);
|
||||
int GetBestiaryDeathCount(int type, int variant);
|
||||
int GetBestiaryEncounterCount(int type, int variant);
|
||||
int GetBestiaryKillCount(int type, int variant);
|
||||
|
||||
private:
|
||||
bool read(std::span<const uint8_t> file);
|
||||
std::vector<uint8_t> write();
|
||||
bool stream_load(std::span<const uint8_t> file);
|
||||
void backfill_cutscene_counters();
|
||||
void check_counter_unlocks();
|
||||
void check_challenge_unlocks();
|
||||
void check_collection_unlocks();
|
||||
void check_collection_set_unlocks();
|
||||
bool TryImportLocalSave(std::string_view path, const SaveImport& import);
|
||||
};
|
||||
Reference in new issue
Block a user