summaryrefslogtreecommitdiff
path: root/mm/2s2h/DeveloperTools
diff options
context:
space:
mode:
authorArchez <Archez@users.noreply.github.com>2025-04-15 10:19:43 -0400
committerGitHub <noreply@github.com>2025-04-15 10:19:43 -0400
commitd725437d51aa5a0c9cbb1dd1af3fc5bc26df7b3f (patch)
treec6e3b682d9199368e5ed7b6283fc45ea7ec69887 /mm/2s2h/DeveloperTools
parent3f2f4ac71d9c3146ed6773a3b07b4aedcb384210 (diff)
Clear flags on boot to warp (#1116)
* Clear flags on boot to warp * fix grotto debug warp
Diffstat (limited to 'mm/2s2h/DeveloperTools')
-rw-r--r--mm/2s2h/DeveloperTools/BetterMapSelect.c22
-rw-r--r--mm/2s2h/DeveloperTools/WarpPoint.cpp15
2 files changed, 28 insertions, 9 deletions
diff --git a/mm/2s2h/DeveloperTools/BetterMapSelect.c b/mm/2s2h/DeveloperTools/BetterMapSelect.c
index 5afee676a..1023a4e6d 100644
--- a/mm/2s2h/DeveloperTools/BetterMapSelect.c
+++ b/mm/2s2h/DeveloperTools/BetterMapSelect.c
@@ -185,18 +185,22 @@ void BetterMapSelect_LoadGame(MapSelectState* mapSelectState, u32 entrance, s32
if (spawn >= 0 && spawn < ARRAY_COUNT(sBetterMapSelectGrottoInfo)) {
grotto = sBetterMapSelectGrottoInfo[spawn];
}
- } else if (entrance == ENTRANCE(GROTTOS, 4)) {
- if (spawn >= 0 && spawn < ARRAY_COUNT(sBetterMapSelectChestGrottoInfo)) {
- grotto = sBetterMapSelectChestGrottoInfo[spawn];
- }
- } else if (entrance == ENTRANCE(GROTTOS, 10)) {
- if (spawn >= 0 && spawn < ARRAY_COUNT(sBetterMapSelectCowGrottoInfo)) {
- grotto = sBetterMapSelectCowGrottoInfo[spawn];
+ } else {
+ // Chest/cow grotto selection uses a special list and changes the meaning of the `spawn` value,
+ // so we need to set entrance back to the value one
+ gSaveContext.save.entrance = entrance;
+
+ if (entrance == ENTRANCE(GROTTOS, 4)) { // Chests
+ if (spawn >= 0 && spawn < ARRAY_COUNT(sBetterMapSelectChestGrottoInfo)) {
+ grotto = sBetterMapSelectChestGrottoInfo[spawn];
+ }
+ } else if (entrance == ENTRANCE(GROTTOS, 10)) { // Cows
+ if (spawn >= 0 && spawn < ARRAY_COUNT(sBetterMapSelectCowGrottoInfo)) {
+ grotto = sBetterMapSelectCowGrottoInfo[spawn];
+ }
}
}
- gSaveContext.save.entrance = entrance;
-
// Set player void out location
gSaveContext.respawn[RESPAWN_MODE_DOWN].data = grotto.downRespawn.data;
gSaveContext.respawn[RESPAWN_MODE_DOWN].roomIndex = grotto.downRespawn.roomIndex;
diff --git a/mm/2s2h/DeveloperTools/WarpPoint.cpp b/mm/2s2h/DeveloperTools/WarpPoint.cpp
index dacfc38b3..31b175893 100644
--- a/mm/2s2h/DeveloperTools/WarpPoint.cpp
+++ b/mm/2s2h/DeveloperTools/WarpPoint.cpp
@@ -46,6 +46,21 @@ void Warp() {
gSaveContext.save.cutsceneIndex = 0;
gSaveContext.save.playerForm = PLAYER_FORM_HUMAN;
gSaveContext.save.linkAge = 0;
+
+ // Need to unset flag values that are outside of `.save`
+ // Normally would happened in the MapSelect_LoadGame, but is skipped because of the dummy file num below
+ // This is mostly copied from Sram_OpenSave.
+ for (size_t i = 0; i < ARRAY_COUNT(gSaveContext.eventInf); i++) {
+ gSaveContext.eventInf[i] = 0;
+ }
+ for (int i = 0; i < ARRAY_COUNT(gSaveContext.cycleSceneFlags); i++) {
+ gSaveContext.cycleSceneFlags[i].chest = gSaveContext.save.saveInfo.permanentSceneFlags[i].chest;
+ gSaveContext.cycleSceneFlags[i].switch0 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch0;
+ gSaveContext.cycleSceneFlags[i].switch1 = gSaveContext.save.saveInfo.permanentSceneFlags[i].switch1;
+ gSaveContext.cycleSceneFlags[i].clearedRoom = gSaveContext.save.saveInfo.permanentSceneFlags[i].clearedRoom;
+ gSaveContext.cycleSceneFlags[i].collectible = gSaveContext.save.saveInfo.permanentSceneFlags[i].collectible;
+ }
+
// Using dummy file num to bypass debug save setup in map select and manually execute save init/load hooks after
gSaveContext.fileNum = 0xFE;
MapSelect_LoadGame((MapSelectState*)gGameState, entrance, 0);