From c8159ba18210d68e92483cd5202f88f491abc5f0 Mon Sep 17 00:00:00 2001 From: hedara90 <90hedara@gmail.com> Date: Wed, 5 Nov 2025 21:45:39 +0100 Subject: [PATCH] Reset saveblock data between test runs (#8145) Co-authored-by: Hedara --- src/battle_main.c | 5 ++++- test/test_runner.c | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index ad5ccac4ba..cd76bc827b 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3002,7 +3002,10 @@ static void ClearSetBScriptingStruct(void) memset(&gBattleScripting, 0, sizeof(gBattleScripting)); gBattleScripting.windowsType = temp; - gBattleScripting.battleStyle = gSaveBlock2Ptr->optionsBattleStyle; + if (TESTING) + gBattleScripting.battleStyle = OPTIONS_BATTLE_STYLE_SET; + else + gBattleScripting.battleStyle = gSaveBlock2Ptr->optionsBattleStyle; gBattleScripting.expOnCatch = (B_EXP_CATCH >= GEN_6); gBattleScripting.specialTrainerBattleType = specialBattleType; } diff --git a/test/test_runner.c b/test/test_runner.c index 450283ab58..ac4b20cd2c 100644 --- a/test/test_runner.c +++ b/test/test_runner.c @@ -1,4 +1,5 @@ #include +#include "fake_rtc.h" #include "global.h" #include "gpu_regs.h" #include "load_save.h" @@ -184,6 +185,13 @@ void TestRunner_CheckMemory(void) } } +static void ClearSaveBlocks(void) +{ + ClearSav1(); + ClearSav2(); + ClearSav3(); +} + void CB2_TestRunner(void) { top: @@ -201,17 +209,13 @@ top: gTestRunnerState.filterMode = DetectFilterMode(gTestRunnerArgv); MoveSaveBlocks_ResetHeap(); - ClearSav1(); - ClearSav2(); - ClearSav3(); gIntrTable[7] = Intr_Timer2; - gSaveBlock2Ptr->optionsBattleStyle = OPTIONS_BATTLE_STYLE_SET; - // The current test restarted the ROM (e.g. by jumping to NULL). if (gPersistentTestRunnerState.address != 0) { + ClearSaveBlocks(); gTestRunnerState.test = __start_tests; while ((uintptr_t)gTestRunnerState.test != gPersistentTestRunnerState.address) { @@ -255,6 +259,7 @@ top: break; case STATE_ASSIGN_TEST: + ClearSaveBlocks(); while (1) { if (gTestRunnerState.test == __stop_tests)