Skip to content

Commit

Permalink
Fix flag debug screen corrupting subsequent message boxes (#3317)
Browse files Browse the repository at this point in the history
  • Loading branch information
DizzyEggg authored Sep 21, 2023
1 parent 5b498e9 commit 8bf8c9e
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,17 @@ enum { // Battle 1 AI FLags
DEBUG_BATTLE_1_MENU_ITEM_CONTINUE,
};
enum { // Battle 2 Terrain
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_0,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_1,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_2,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_3,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_4,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_5,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_6,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_7,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_8,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_0,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_1,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_2,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_3,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_4,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_5,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_6,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_7,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_8,
DEBUG_BATTLE_2_MENU_ITEM_TERRAIN_9,
};
};
enum { // Give
DEBUG_GIVE_MENU_ITEM_ITEM_X,
DEBUG_GIVE_MENU_ITEM_ALLTMS,
Expand Down Expand Up @@ -1109,7 +1109,7 @@ static void Debug_InitDebugBattleData(void)
sDebugBattleData->submenu = 0;
sDebugBattleData->battleType = 0xFF;
sDebugBattleData->battleTerrain = 0xFF;

for (i = 0; i < AI_FLAG_COUNT; i++)
sDebugBattleData->aiFlags[i] = FALSE;
}
Expand Down Expand Up @@ -1145,7 +1145,7 @@ static void Debug_RefreshListMenu(u8 taskId)
// Copy item names for all entries but the last (which is Cancel)
for(i = 0; i < totalItems; i++)
{

if (sDebugMenuListData->listId == 1 && sDebugBattleData->submenu > 1)
{
u16 species;
Expand Down Expand Up @@ -1179,7 +1179,7 @@ static void Debug_RefreshListMenu(u8 taskId)
flagResult == 0xFF;
name = sDebugMenu_Items_Battle_1[i].name;
}

if (flagResult == 0xFF)
{
StringCopy(&sDebugMenuListData->itemNames[i][0], name);
Expand Down Expand Up @@ -1315,10 +1315,6 @@ static void DebugTask_HandleMenuInput_FlagsVars(u8 taskId)
{
PlaySE(SE_SELECT);
Debug_DestroyMenu(taskId);

ClearStdWindowAndFrame(gTasks[taskId].data[2], TRUE);
RemoveWindow(gTasks[taskId].data[2]);

Debug_ReShowMainMenu();
}
}
Expand Down Expand Up @@ -1356,7 +1352,7 @@ static void DebugTask_HandleMenuInput_Battle(u8 taskId)
ListMenuGetCurrentItemArrayId(listTaskId, &idx);

if (gMain.newKeys & A_BUTTON)
{
{
PlaySE(SE_SELECT);

switch (sDebugBattleData->submenu)
Expand Down Expand Up @@ -1389,7 +1385,7 @@ static void DebugTask_HandleMenuInput_Battle(u8 taskId)
sDebugBattleData->aiFlags[idx] = !sDebugBattleData->aiFlags[idx];
Debug_RedrawListMenu(taskId);
}

break;
case 2: // Terrain
sDebugBattleData->submenu++;
Expand All @@ -1413,7 +1409,7 @@ static void DebugTask_HandleMenuInput_Battle(u8 taskId)
Debug_ReShowMainMenu();
break;
case 2: // Skip AI Flag selection if wild battle
if (sDebugBattleData->battleType == DEBUG_BATTLE_0_MENU_ITEM_WILD
if (sDebugBattleData->battleType == DEBUG_BATTLE_0_MENU_ITEM_WILD
|| sDebugBattleData->battleType == DEBUG_BATTLE_0_MENU_ITEM_WILD_DOUBLE)
{
sDebugBattleData->submenu = 0;
Expand Down Expand Up @@ -1450,7 +1446,7 @@ static void Debug_InitializeBattle(u8 taskId)
gBattleTypeFlags = (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TRAINER | BATTLE_TYPE_INGAME_PARTNER);
break;
}

// Set terrain
gBattleTerrain = sDebugBattleData->battleTerrain;

Expand Down Expand Up @@ -2401,7 +2397,7 @@ static void DebugAction_FlagsVars_ToggleFlyFlags(u8 taskId)
else
{
PlaySE(SE_PC_LOGIN);

FlagSet(FLAG_VISITED_LITTLEROOT_TOWN);
FlagSet(FLAG_VISITED_OLDALE_TOWN);
FlagSet(FLAG_VISITED_DEWFORD_TOWN);
Expand Down

0 comments on commit 8bf8c9e

Please sign in to comment.