Repository navigation
Port: keep dungeon monster slots below the sub-game slots - #119
Closed
carrdylan52 wants to merge 1 commit into
Closed
carrdylan52 wants to merge 1 commit into
carrdylan52 wants to merge 1 commit into
Conversation
Merging PR TheMoonPeople#59 raised MONSTER_ACTIVE_MAX to 60 in the header mirror, so the active monsters became scene characters 24 to 83. Scene characters 64 to 103 (SUBGAME_CHARA_BASE, SUBGAME_CHARA_NUM) belong to the sub-games, and InitDungeonMain calls InitSubGame after binding the monsters, which clears them. The floor script's LoadDungeonMapFile then runs CMonsterMan::Initialize, which reads every one of the 60 slots back and calls Initialize on monster 40's now-empty slot: a null dereference on every dungeon entry, with game.more_monsters on or off, since the loop runs to MONSTER_ACTIVE_MAX either way. MONSTER_ACTIVE_MAX is now 40, so the slots end at scene character 63. A floor's placement list holds at most 32 monsters, so the setting still raises the opening count as far as before. A static assert in port/src/monster.cpp holds the range below SUBGAME_CHARA_BASE; a unit test runs InitSubGame over a full 128-slot scene and a header fixup test checks the mirrored constants.
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the PR #59 merge (029e28e), entering any dungeon floor crashes, and so does New Game, because the opening is a dungeon scene. It happens with
game.more_monsterson or off. 3c8c146 is fine; 029e28e and current master crash.Cause.
header_fixups.pyraisesMONSTER_ACTIVE_MAXto 60, so the active monsters occupy scene characters 24 to 83. Characters 64 to 103 are the sub-game slots (SUBGAME_CHARA_BASE).InitDungeonMaincallsInitSubGameafter binding the monsters, and that clears them, so monsters 40 to 59 are wiped. The floor script'sLoadDungeonMapFilethen runsCMonsterMan::Initialize, which always loops over allMONSTER_ACTIVE_MAXslots, reads slot 64 back as null, and faults atmonster.cpp:778.Fix.
MONSTER_ACTIVE_MAXis now 40, so the slots end at character 63.MONSTER_LOCATE_MAX), so the setting still opens a floor with as many monsters as before. It does lower the room for later spawns from 60 to 40.port/src/monster.cppkeeps the range belowSUBGAME_CHARA_BASE.Tests.
MonsterSlots.SurviveTheSubGameClearruns the realInitSubGameover a full 128-slot scene.--jump dungeon:0:1anddungeon:1:1withtools/input/jump-dungeon-floor1.inputreach frame 2300 with more_monsters off and on, and--jump openingplays.