Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool fpWarp(enum Areas area, u16 map, u16 entrance) {
pm_gGameStatus.entryID = entrance;

PRINTF("***** WARP TRIGGERED *****\n");
if (pm_gGameStatus.isBattle || pm_gPopupState == 1) {
if (pm_gGameStatus.context != CONTEXT_WORLD || pm_gPopupState == 1) {
// prevent crashes from warping when in battle menus or with partner/item menu open
pm_clear_windows();
}
Expand Down
6 changes: 6 additions & 0 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -987,4 +987,10 @@ enum PlayerStatusAnimFlags {
PA_FLAG_80000000 = 0x80000000,
};

enum GameContext {
CONTEXT_WORLD = 0,
CONTEXT_BATTLE = 1,
CONTEXT_PAUSE = 2,
};

#endif
5 changes: 3 additions & 2 deletions src/fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void fpUpdateCheats(void) {
pm_gPlayerData.curHP = 1;
}
if (CHEAT_ACTIVE(CHEAT_AUTO_MASH)) {
if (pm_gGameStatus.isBattle == 1) {
if (pm_gGameStatus.context == CONTEXT_BATTLE) {
pm_gActionCommandStatus.barFillLevel = 10000;
}
}
Expand Down Expand Up @@ -558,7 +558,8 @@ void fpDraw(void) {
trainerDrawPinned(settings->trainerX, settings->trainerY, font, cellWidth, cellHeight, 0xC0C0C0, menuAlpha);
}

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

Expand Down
13 changes: 7 additions & 6 deletions src/fp/practice/trainer.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static s32 spinVisualPositionProc(struct MenuItem *item, enum MenuCallbackReason
}

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

Expand Down Expand Up @@ -508,7 +508,7 @@ static void aceOotInstrProc(struct MenuItem *item, void *data) {
}

static void updateBowserBlockTrainer(void) {
if (pm_gGameStatus.isBattle) {
if (pm_gGameStatus.context == CONTEXT_BATTLE) {
pm_Actor *enemy0 = pm_gBattleStatus.enemyActors[0];
if (enemy0) {
bool isBowser = FALSE;
Expand Down Expand Up @@ -640,8 +640,8 @@ static void updateLzsTrainer(void) {
}

static void updateSpinTrainer(void) {
if (!(pm_gGameStatus.isBattle != 1 &&
(settings->trainerSpinBarEnabled || settings->pinnedTrainer == TRAINER_SPIN))) {
if (pm_gGameStatus.context == CONTEXT_BATTLE ||
!(settings->trainerSpinBarEnabled || settings->pinnedTrainer == TRAINER_SPIN)) {
return;
}

Expand Down Expand Up @@ -737,7 +737,7 @@ static void blockCheckSuccessOrEarly(void) {
}

static void updateBlockTrainer(void) {
if (settings->trainerAcEnabled && pm_gGameStatus.isBattle) {
if (settings->trainerAcEnabled && pm_gGameStatus.context == CONTEXT_BATTLE) {
// blocks
switch (pm_gBattleStatus.blockResult) {
case BLOCK_EARLY:
Expand Down Expand Up @@ -828,7 +828,8 @@ static void updateQuickJumpTrainer(void) {
static bool waitForNextTurn;
static u8 frameWindow;

if (settings->trainerQuickJumpsEnabled && pm_gGameStatus.isBattle && pm_gBattleStatus.playerActor) {
if (settings->trainerQuickJumpsEnabled && pm_gGameStatus.context == CONTEXT_BATTLE &&
pm_gBattleStatus.playerActor) {
if (pm_gBattleStatus.playerActor->partsTable->curAnimation == 0x10004) {
waitForNextTurn = FALSE;
jumpFrame = -1;
Expand Down
6 changes: 3 additions & 3 deletions src/fp/warps/bosses.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ static void bossWarpProc(struct MenuItem *item, void *data) {
battle = (u8)((s32)data & 0xFF);
pm_clear_windows();
pm_clear_printers();
// isBattle is also true when paused, so checking game mode
if (pm_gGameStatus.isBattle && pm_CurGameMode != 10 && pm_CurGameMode != 11) {
// context is also true when paused, so checking game mode
if (pm_gGameStatus.context != CONTEXT_WORLD && pm_CurGameMode != 10 && pm_CurGameMode != 11) {
// end battle cleanly so next fight can start fresh
pm_gBattleState = 32; // BATTLE_STATE_END_BATTLE
pm_gBattleSubState = 2; // BTL_SUBSTATE_END_BATTLE_EXEC_STAGE_SCRIPT
Expand All @@ -150,7 +150,7 @@ static void bossWarpProc(struct MenuItem *item, void *data) {
}

void bossesUpdateWarps() {
if (leavingBattle && !pm_gGameStatus.isBattle) {
if (leavingBattle && pm_gGameStatus.context == CONTEXT_WORLD) {
leavingBattle = FALSE;
bossWarp();
} else if (warpCountdown == 30) {
Expand Down
2 changes: 1 addition & 1 deletion src/pm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ typedef struct pm_GameStatus {
/* 0x06A */ s8 demoStickX;
/* 0x06B */ s8 demoStickY;
/* 0x06C */ s32 mainScriptID;
/* 0x070 */ s8 isBattle;
/* 0x070 */ s8 context;
/* 0x071 */ s8 demoState; /* (0 = not demo, 1 = map demo, 2 = demo map changing) */
/* 0x072 */ s8 nextDemoScene; /* which part of the demo to play next */
/* 0x073 */ u8 controllerPlugged; /*needs to be 1 otherwise "no controller" */
Expand Down