summaryrefslogtreecommitdiff
path: root/mm/2s2h/DeveloperTools/BetterMapSelect.c
diff options
context:
space:
mode:
authorArchez <Archez@users.noreply.github.com>2025-05-16 12:25:21 -0400
committerGitHub <noreply@github.com>2025-05-16 11:25:21 -0500
commitbde6fcfc15c0a7f737d48f2b6cee9bcc54ed49aa (patch)
treef5b526a056c8165aa3590050c8c746fe27ac9922 /mm/2s2h/DeveloperTools/BetterMapSelect.c
parent8b7675a1c90e1fda27a0eb9814140b96d718b8fb (diff)
[Better Warp] Wrap entrance value for supported count on each scene (#1126)
* [Better Warp] Wrap entrance value for supported count on each scene * don't be too fancy with macro magic, and rearrange entrance check
Diffstat (limited to 'mm/2s2h/DeveloperTools/BetterMapSelect.c')
-rw-r--r--mm/2s2h/DeveloperTools/BetterMapSelect.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/mm/2s2h/DeveloperTools/BetterMapSelect.c b/mm/2s2h/DeveloperTools/BetterMapSelect.c
index 1023a4e6d..0c3412dc0 100644
--- a/mm/2s2h/DeveloperTools/BetterMapSelect.c
+++ b/mm/2s2h/DeveloperTools/BetterMapSelect.c
@@ -46,6 +46,7 @@ static BetterMapSelectInfoEntry sBetterMapSelectInfo[102] = {
#define STAGE_CURRENT_TIME 0x9000
extern SceneSelectEntry sScenes[143];
+extern SceneEntranceTableEntry sSceneEntranceTable[ENTR_SCENE_MAX];
static bool sIsBetterMapSelectEnabled = false;
@@ -273,18 +274,34 @@ void BetterMapSelect_Update(MapSelectState* mapSelectState) {
BetterMapSelect_Init(mapSelectState);
}
- static s32 sScene = -1;
- Input* controller1 = CONTROLLER1(&mapSelectState->state);
-
- if (sScene == -1) {
- sScene = CVarGetInteger("gDeveloperTools.BetterMapSelect.CurrentScene", 0);
+ if (!sIsBetterMapSelectEnabled) {
+ return;
}
- mapSelectState->opt = CLAMP_MIN(mapSelectState->opt, 0);
+ static s32 sPrevScene = -1;
+ Input* controller1 = CONTROLLER1(&mapSelectState->state);
+
+ // Clamp and wrap around the spawn value based on the supported entrances for that scene
+ if (mapSelectState->currentScene < ARRAY_COUNT(sBetterMapSelectInfo)) {
+ // Scenes from scene_table.h can be checked directly against `sSceneEntranceTable`
+ s32 entrSceneId = sBetterScenes[mapSelectState->currentScene].entrance >> 9;
+ SceneEntranceTableEntry entry = sSceneEntranceTable[entrSceneId];
- // Reset entrance value when scene changes
- if (sScene != mapSelectState->currentScene) {
- sScene = mapSelectState->currentScene;
+ if (mapSelectState->opt >= entry.tableCount) {
+ mapSelectState->opt = 0;
+ } else if (mapSelectState->opt < 0) {
+ mapSelectState->opt = entry.tableCount - 1;
+ }
+ } else if (mapSelectState->currentScene == 102 || mapSelectState->currentScene == 103) {
+ // Cheset/Cow special entries
+ s32 count = mapSelectState->currentScene == 102 ? ARRAY_COUNT(sBetterMapSelectChestGrottoInfo)
+ : ARRAY_COUNT(sBetterMapSelectCowGrottoInfo);
+ if (mapSelectState->opt >= count) {
+ mapSelectState->opt = 0;
+ } else if (mapSelectState->opt < 0) {
+ mapSelectState->opt = count - 1;
+ }
+ } else { // File Select/Title Screen
mapSelectState->opt = 0;
}