Skip to content

Commit 40ba5e0

Browse files
authored
Merge pull request #108 from JCog/isBattle-fix
rename isBattle to context and fix associated logic
2 parents 9e1785b + bb50b53 commit 40ba5e0

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

src/commands.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bool fpWarp(enum Areas area, u16 map, u16 entrance) {
8787
pm_gGameStatus.entryID = entrance;
8888

8989
PRINTF("***** WARP TRIGGERED *****\n");
90-
if (pm_gGameStatus.isBattle || pm_gPopupState == 1) {
90+
if (pm_gGameStatus.context != CONTEXT_WORLD || pm_gPopupState == 1) {
9191
// prevent crashes from warping when in battle menus or with partner/item menu open
9292
pm_clear_windows();
9393
}

src/enums.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,4 +987,10 @@ enum PlayerStatusAnimFlags {
987987
PA_FLAG_80000000 = 0x80000000,
988988
};
989989

990+
enum GameContext {
991+
CONTEXT_WORLD = 0,
992+
CONTEXT_BATTLE = 1,
993+
CONTEXT_PAUSE = 2,
994+
};
995+
990996
#endif

src/fp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void fpUpdateCheats(void) {
320320
pm_gPlayerData.curHP = 1;
321321
}
322322
if (CHEAT_ACTIVE(CHEAT_AUTO_MASH)) {
323-
if (pm_gGameStatus.isBattle == 1) {
323+
if (pm_gGameStatus.context == CONTEXT_BATTLE) {
324324
pm_gActionCommandStatus.barFillLevel = 10000;
325325
}
326326
}
@@ -558,7 +558,8 @@ void fpDraw(void) {
558558
trainerDrawPinned(settings->trainerX, settings->trainerY, font, cellWidth, cellHeight, 0xC0C0C0, menuAlpha);
559559
}
560560

561-
if (fp.spinTrainerMoving || (settings->trainerSpinBarEnabled && !fp.menuActive && pm_gGameStatus.isBattle == 0)) {
561+
if (fp.spinTrainerMoving ||
562+
(settings->trainerSpinBarEnabled && !fp.menuActive && pm_gGameStatus.context == CONTEXT_WORLD)) {
562563
trainerDrawSpinBar(settings->trainerSpinX, settings->trainerSpinY, font, 0xC0C0C0, menuAlpha);
563564
}
564565

src/fp/practice/trainer.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static s32 spinVisualPositionProc(struct MenuItem *item, enum MenuCallbackReason
208208
}
209209

210210
static void spinDraw(s32 x, s32 y, struct GfxFont *font, s32 chWidth, s32 chHeight, u32 color, u8 alpha) {
211-
if (pm_gGameStatus.isBattle != 0) {
211+
if (pm_gGameStatus.context != CONTEXT_WORLD) {
212212
return;
213213
}
214214

@@ -508,7 +508,7 @@ static void aceOotInstrProc(struct MenuItem *item, void *data) {
508508
}
509509

510510
static void updateBowserBlockTrainer(void) {
511-
if (pm_gGameStatus.isBattle) {
511+
if (pm_gGameStatus.context == CONTEXT_BATTLE) {
512512
pm_Actor *enemy0 = pm_gBattleStatus.enemyActors[0];
513513
if (enemy0) {
514514
bool isBowser = FALSE;
@@ -640,8 +640,8 @@ static void updateLzsTrainer(void) {
640640
}
641641

642642
static void updateSpinTrainer(void) {
643-
if (!(pm_gGameStatus.isBattle != 1 &&
644-
(settings->trainerSpinBarEnabled || settings->pinnedTrainer == TRAINER_SPIN))) {
643+
if (pm_gGameStatus.context == CONTEXT_BATTLE ||
644+
!(settings->trainerSpinBarEnabled || settings->pinnedTrainer == TRAINER_SPIN)) {
645645
return;
646646
}
647647

@@ -737,7 +737,7 @@ static void blockCheckSuccessOrEarly(void) {
737737
}
738738

739739
static void updateBlockTrainer(void) {
740-
if (settings->trainerAcEnabled && pm_gGameStatus.isBattle) {
740+
if (settings->trainerAcEnabled && pm_gGameStatus.context == CONTEXT_BATTLE) {
741741
// blocks
742742
switch (pm_gBattleStatus.blockResult) {
743743
case BLOCK_EARLY:
@@ -828,7 +828,8 @@ static void updateQuickJumpTrainer(void) {
828828
static bool waitForNextTurn;
829829
static u8 frameWindow;
830830

831-
if (settings->trainerQuickJumpsEnabled && pm_gGameStatus.isBattle && pm_gBattleStatus.playerActor) {
831+
if (settings->trainerQuickJumpsEnabled && pm_gGameStatus.context == CONTEXT_BATTLE &&
832+
pm_gBattleStatus.playerActor) {
832833
if (pm_gBattleStatus.playerActor->partsTable->curAnimation == 0x10004) {
833834
waitForNextTurn = FALSE;
834835
jumpFrame = -1;

src/fp/warps/bosses.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ static void bossWarpProc(struct MenuItem *item, void *data) {
137137
battle = (u8)((s32)data & 0xFF);
138138
pm_clear_windows();
139139
pm_clear_printers();
140-
// isBattle is also true when paused, so checking game mode
141-
if (pm_gGameStatus.isBattle && pm_CurGameMode != 10 && pm_CurGameMode != 11) {
140+
// context is also true when paused, so checking game mode
141+
if (pm_gGameStatus.context != CONTEXT_WORLD && pm_CurGameMode != 10 && pm_CurGameMode != 11) {
142142
// end battle cleanly so next fight can start fresh
143143
pm_gBattleState = 32; // BATTLE_STATE_END_BATTLE
144144
pm_gBattleSubState = 2; // BTL_SUBSTATE_END_BATTLE_EXEC_STAGE_SCRIPT
@@ -150,7 +150,7 @@ static void bossWarpProc(struct MenuItem *item, void *data) {
150150
}
151151

152152
void bossesUpdateWarps() {
153-
if (leavingBattle && !pm_gGameStatus.isBattle) {
153+
if (leavingBattle && pm_gGameStatus.context == CONTEXT_WORLD) {
154154
leavingBattle = FALSE;
155155
bossWarp();
156156
} else if (warpCountdown == 30) {

src/pm64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ typedef struct pm_GameStatus {
119119
/* 0x06A */ s8 demoStickX;
120120
/* 0x06B */ s8 demoStickY;
121121
/* 0x06C */ s32 mainScriptID;
122-
/* 0x070 */ s8 isBattle;
122+
/* 0x070 */ s8 context;
123123
/* 0x071 */ s8 demoState; /* (0 = not demo, 1 = map demo, 2 = demo map changing) */
124124
/* 0x072 */ s8 nextDemoScene; /* which part of the demo to play next */
125125
/* 0x073 */ u8 controllerPlugged; /*needs to be 1 otherwise "no controller" */

0 commit comments

Comments
 (0)