Reset saveblock data between test runs (#8145)

Co-authored-by: Hedara <hedara90@gmail.com>
This commit is contained in:
hedara90 2025-11-05 21:45:39 +01:00 committed by GitHub
parent d1428d7966
commit c8159ba182
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -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;
}

View File

@ -1,4 +1,5 @@
#include <stdarg.h>
#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)