Curation round 4: popups, Seeds/Random, Game, KeyConfigs, offline NetplayManager, Console, TextureCache, render passes

Six agents took over PopupButtons/PopupQueue/AchievementOverlay, Seeds with the global Random (now seeded from the
clock as in the original), Game (g_game exists from Manager::Init on), KeyConfigs, an offline NetplayManager, Console's
output and printing, TextureCache, the color-mod and sprite shader passes, mod shaders and reload_resource_paths. An
integration pass moved callers to the new APIs (0 errors, 0 warnings with -Wall -Wextra). build/isaac loads the 34
installed mods and stops at ScoreSheet::ScoreSheet in Game's constructor; with the remaining stubs skipped under gdb the
intro cutscene plays through and the main menu's frame loop runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-11-20 01:32:19 -05:00
1 parent ddf913f304
commit fd8b965350
110 files changed
+6500 -40129

No files matched your search

+269
View File
@@ -0,0 +1,269 @@
#include "game.h"
#include "manager.h"
#include "menu_manager.h"
#include "log.h"
constexpr const char* STAGES_XML = "stages.xml";
constexpr const char* CURSES_XML = "curses.xml";
constexpr const char* MINIBOSSES_XML = "minibosses.xml";
constexpr const char* GIANTBOOK_XML = "giantbook.xml";
constexpr const char* BOSS_OVERLAYS_XML = "bossoverlays.xml";
constexpr const char* PIXELATION_SURFACE = "Pixelation Surface";
constexpr const char* BLOOM_SURFACE = "Bloom Surface";
constexpr const char* OLD_TV_SURFACE = "Old TV Surface";
constexpr const char* HALLUCINATION_SURFACE = "Hallucination Surface";
constexpr const char* HALLUCINATION_SNAPSHOT = "Hallucination Snapshot";
constexpr const char* COLORMOD_SURFACE = "Colormod Surface";
constexpr int FILTER_LINEAR = 1;
// The deathmatch type a new Game picks: the first one half the time, else one of the ten after it.
constexpr int DEATHMATCH_TYPE_FIRST = 1;
constexpr int DEATHMATCH_TYPE_RANDOM_FIRST = 2;
constexpr uint32_t DEATHMATCH_TYPE_RANDOM_COUNT = 10;
constexpr int BLOOM_DURATION_DEFAULT = 30;
constexpr int REVIVE_MACHINE_COINS = 10;
constexpr float DIZZY_CHANGE_SPEED_DEFAULT = 0.001f;
constexpr int ITEM_OVERLAY_ACTIVE = 2;
constexpr uint32_t CHALLENGE_BACKASSWARDS = 44;
constexpr int DIMENSION_DEATH_CERTIFICATE = 2;
constexpr int STAGE_ID_DEATH_CERTIFICATE = 35;
// 006f1020 Starts the floor with an empty room, picks the deathmatch type and creates the run's render surfaces and the
// loaded mods' shader targets. The co-op awards table it also fills is not modeled yet.
Game::Game()
{
fadeInColor = kcolor_make(1, 1, 1, 1);
fadeOutColor = kcolor_make(1, 1, 1, 1);
level_reset();
init_coop_awards(&onlinePlayerStats);
bool isRandomType = Random() & 1;
deathmatchManager.set_type(isRandomType ? Random() % DEATHMATCH_TYPE_RANDOM_COUNT + DEATHMATCH_TYPE_RANDOM_FIRST
: DEATHMATCH_TYPE_FIRST);
// ChallengeParam::Reset on dailyChallenge's params waits for DailyChallenge's takeover (classes.h has bytes).
create_render_surfaces();
g_manager->modManager.create_shader_render_targets();
}
Game::~Game()
{
reconstruction_missing("Game::~Game 006f3060");
}
// 006f4740 Resets the run, then loads the run's configs through the mods' redirection: stages, curses with the mods',
// minibosses, the giant book and boss overlays, then the run's UI, ambushes and preloads.
void Game::LoadConfigXmls()
{
Game& game = *g_game;
ModManager& mods = g_manager->modManager;
game.reset_run_state();
game.challenge = 0;
game.isRerun = false;
game.screenShakeOffset = {};
game.isPocketItemRewindSaved = false;
game.trapdoorLoopVolume = 0;
game.roomConfig.LoadStages(mods.TryRedirectPath(STAGES_XML));
game.roomConfig.LoadCurses(mods.TryRedirectPath(CURSES_XML), CURSES_REPLACE);
mods.LoadModCurses();
game.roomConfig.LoadMinibosses(mods.TryRedirectPath(MINIBOSSES_XML));
std::string giantBookPath = mods.TryRedirectPath(GIANTBOOK_XML);
load_giantbook_xml(&game.itemOverlay, (uint8_t*)giantBookPath.data());
load_bossoverlays_xml(mods.TryRedirectPath(BOSS_OVERLAYS_XML));
reconstruction_missing("Game::LoadConfigXmls 006f4740: game over and leaderboard sprites, emotes, completion "
"widget, pause, revive and minimap init, ambush.xml, preload.xml and its groups, procedural "
"item surfaces, par times, prompts, the giant book clicker and the co-op awards");
}
// 00420ba0 Reads bossoverlays.xml into the boss overlay's five entries.
// Its this is the overlay, which classes.h lost.
uint32_t Game::load_bossoverlays_xml(std::string_view)
{
reconstruction_missing("Game::load_bossoverlays_xml 00420ba0");
}
// 00834680 Reads ambush.xml into the boss rush waves (its this is Ambush's wave list, which classes.h lost).
void Game::LoadBossRushXml(std::string_view)
{
reconstruction_missing("Game::LoadBossRushXml 00834680");
}
// 006f43b0 Clears the run back to a fresh one: counters, fades, debug flags, the daily, score sheet and screen effects.
void Game::reset_run_state()
{
isRerun = false;
isDebug = false;
frameCount = 0;
timeCounter = 0;
screenShakeTimer = 0;
ResetState();
freezeFrames = 0;
fadeInColor = {};
fadeOutColor = {};
debugFlags = 0;
debugCurses = 0;
fadeOutTarget = 0;
restartHoldFrames = 0;
framesSinceRoomTransition = 0;
dailyChallenge._id = 0;
dailyChallenge._seed = 0;
dailyChallenge._specialDailyId = 0;
dailyChallenge._isPractice = false;
// ChallengeParam::Reset on dailyChallenge's params waits for DailyChallenge's takeover (classes.h has bytes).
ScoreSheet::Reset();
currentColorModifier = COLOR_MOD_NEUTRAL;
pixelationDuration = 0;
pixelationTimer = 0;
isStartingFromState = false;
isColorModifierLerped = false;
lightningIntensity = 0;
dizzyIntensity = 0;
dizzyTargetIntensity = 0;
dizzyIntensityChangeSpeed = DIZZY_CHANGE_SPEED_DEFAULT;
isRoomRespawned = false;
magicSkinUses = 0;
erasedEntities.clear();
isPocketItemRewindSaved = false;
}
// 006f4520 Clears what a run counts across floors: deals, visits, donations, effects, bosses met, the backwards path's
// saved rooms and the Glowing Hourglass states.
void Game::ResetState()
{
lastDevilRoomStage = 0;
treasureRoomsVisited = 0;
planetariumsVisited = 0;
stagesWithoutHeartsPicked = 0;
stagesWithoutDamage = 0;
devilRoomDeals = 0;
donationModGreed = 0;
donationModAngel = 0;
lastLevelWithoutHalfHp = 0;
isRoomSnapshotTaken = false;
shopVisits = 0;
bloomTimer = 0;
bloomDuration = BLOOM_DURATION_DEFAULT;
bloomStrength = 1;
hallucinationDuration = 0;
hallucinationTimer = 0;
framesSinceRoomTransition = 0;
gameStateFlags = 0;
ascentTimer = 0;
for (BackwardsStageDesc& backwards : backwardsStages)
{
backwards._isXL = false;
backwards._bossRoomsCount = 0;
backwards._treasureRoomsCount = 0;
}
deathCertificateExitTimer = 0;
darknessTimeout = 0;
darknessModifier = 0;
darknessStrength = 0;
stageNameNumeral = 1;
victoryLap = 0;
lastLevelWithDamage = 0;
encounteredBosses.clear();
isStoringGlowingHourglassState = false;
isRestoringGlowingHourglassState = false;
currentGlowingHourglassSlot = -1;
rewindsThisFloor = 0;
for (GlowingHourglassState& state : glowingHourglassStates) state._isUsable = false;
isPocketItemRewindSaved = false;
reviveMachineUses = 0;
reviveMachineCoinsLeft = REVIVE_MACHINE_COINS;
}
// 007384d0 Replaces the current room with a new one and clears the floor: no rooms, stage, curses or Greed waves.
void Game::level_reset()
{
room.reset();
room = std::make_unique<Room>();
startingRoomIdx = -1;
nbRooms = 0;
stage = 0;
stageType = 0;
curses = 0;
greedModeWave = 0;
greedWaveSeeds = {};
greedLastBeatenWave = 0;
greedLastPaidWave = 0;
}
// Creates a surface of the framebuffer's size with linear filtering, unless it exists.
static void surface_create(KAGE::Graphics::ImagePtr& surface, const char* name)
{
if (surface) return;
surface = KAGE::Graphics::manager.render_target_create({kcolor_make(0, 0, 0, 0), name, (int)DAT_00c79114,
g_framebufferWidth});
if (surface->minFilter != FILTER_LINEAR || surface->magFilter != FILTER_LINEAR)
surface->filter_set(FILTER_LINEAR, FILTER_LINEAR);
}
// 006f37e0 Creates the run's effect surfaces that do not exist yet: pixelation, bloom (when enabled), old TV,
// hallucination and its snapshot, and the color modifier's.
void Game::create_render_surfaces()
{
surface_create(pixelationSurface, PIXELATION_SURFACE);
if (g_manager->optionsConfig.render.isBloomEnabled) surface_create(bloomSurface, BLOOM_SURFACE);
surface_create(oldTvSurface, OLD_TV_SURFACE);
surface_create(hallucinationSurface, HALLUCINATION_SURFACE);
surface_create(hallucinationSnapshot, HALLUCINATION_SNAPSHOT);
surface_create(colormodSurface, COLORMOD_SURFACE);
}
void Game::Exit(bool)
{
reconstruction_missing("Game::Exit 006fa0c0");
}
void Game::Update()
{
reconstruction_missing("Game::Update 006fadc0");
}
void Game::Render()
{
reconstruction_missing("Game::Render 006fbc10");
}
// 006fd350 Whether the run's frame stands still: an open console or pause menu while offline, a freeze, the death or
// leaderboard screen, a stage or room transition, an item overlay playing, any state but the game, a prompt animating,
// or the online stats screen. The original's netplay player-list checks are is_online, as the game is offline.
bool Game::IsPaused()
{
bool isOffline = !g_manager->netplayManager.is_online();
if (console.state != CONSOLE_CLOSED && isOffline) return true;
return freezeFrames > 0 || gameOver._state != 0 || leaderboard._state != 0 || stageTransition._state != 0 ||
roomTransition._mode != 0 || itemOverlay._state == ITEM_OVERLAY_ACTIVE ||
(pauseScreen._state != 0 && isOffline) || g_manager->state != MANAGER_STATE_GAME ||
is_screen_transition_active(&genericPrompt) || onlineStatsScreen._isActive;
}
// 006f8120 Whether the run plays Greed mode.
bool Game::IsGreedMode()
{
return difficulty == DIFFICULTY_GREED || difficulty == DIFFICULTY_GREEDIER;
}
// 00738470 The stage id the floor's rooms come from: the current room's own stage in Backasswards, the Death
// Certificate floor in its dimension, else the floor's stage and type. It never used its argument.
int Game::GetStageID()
{
if (g_game->challenge == CHALLENGE_BACKASSWARDS)
reconstruction_missing("Game::GetStageID 00738470: Level::GetRoomStageType 0074f690 on Game's room list");
if (currentDimensionIdx == DIMENSION_DEATH_CERTIFICATE) return STAGE_ID_DEATH_CERTIFICATE;
return RoomConfig::GetStageID(stage, stageType, ROOM_MODE_CURRENT);
}