From 08ec873ef27da02404c35c9ae911779043edaf9a Mon Sep 17 00:00:00 2001 From: CallmeEchoo Date: Tue, 25 Apr 2023 20:35:36 +0200 Subject: [PATCH] update MoveWithPP macro to use struct --- test/test_battle.h | 10 ++++++---- test/test_runner_battle.c | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/test/test_battle.h b/test/test_battle.h index 0f413a2e4..f2d8bab78 100644 --- a/test/test_battle.h +++ b/test/test_battle.h @@ -713,8 +713,10 @@ void Randomly(u32 sourceLine, u32 passes, u32 trials, struct RandomlyContext); /* Given */ -#define MOVE_ARGS(...) {__VA_ARGS__} -#define PP_ARGS(...) {__VA_ARGS__} +struct moveWithPP { + u16 moveId; + u8 pp; +}; #define GIVEN for (; gBattleTestRunnerState->runGiven; gBattleTestRunnerState->runGiven = FALSE) @@ -736,7 +738,7 @@ void Randomly(u32 sourceLine, u32 passes, u32 trials, struct RandomlyContext); #define Speed(speed) Speed_(__LINE__, speed) #define Item(item) Item_(__LINE__, item) #define Moves(move1, ...) Moves_(__LINE__, (const u16 [MAX_MON_MOVES]) { move1, __VA_ARGS__ }) -#define MovesWithPP(moves, pp) MovesWithPP_(__LINE__, (const u16 [MAX_MON_MOVES]) MOVE_ARGS moves, (const u8 [MAX_MON_MOVES]) PP_ARGS pp) +#define MovesWithPP(movewithpp1, ...) MovesWithPP_(__LINE__, (struct moveWithPP[MAX_MON_MOVES]) {movewithpp1, __VA_ARGS__}) #define Friendship(friendship) Friendship_(__LINE__, friendship) #define Status1(status1) Status1_(__LINE__, status1) @@ -757,7 +759,7 @@ void SpDefense_(u32 sourceLine, u32 spDefense); void Speed_(u32 sourceLine, u32 speed); void Item_(u32 sourceLine, u32 item); void Moves_(u32 sourceLine, const u16 moves[MAX_MON_MOVES]); -void MovesWithPP_(u32 sourceLine, const u16 moves[MAX_MON_MOVES], const u8 pp[MAX_MON_MOVES]); +void MovesWithPP_(u32 sourceLine, struct moveWithPP moveWithPP[MAX_MON_MOVES]); void Friendship_(u32 sourceLine, u32 friendship); void Status1_(u32 sourceLine, u32 status1); diff --git a/test/test_runner_battle.c b/test/test_runner_battle.c index 33fcd5a0f..75e459e49 100644 --- a/test/test_runner_battle.c +++ b/test/test_runner_battle.c @@ -1161,17 +1161,17 @@ void Moves_(u32 sourceLine, const u16 moves[MAX_MON_MOVES]) DATA.explicitMoves[DATA.currentSide] |= 1 << DATA.currentPartyIndex; } -void MovesWithPP_(u32 sourceLine, const u16 moves[MAX_MON_MOVES], const u8 pp[MAX_MON_MOVES]) +void MovesWithPP_(u32 sourceLine, struct moveWithPP moveWithPP[MAX_MON_MOVES]) { s32 i; INVALID_IF(!DATA.currentMon, "Moves outside of PLAYER/OPPONENT"); for (i = 0; i < MAX_MON_MOVES; i++) { - if (moves[i] == MOVE_NONE) + if (moveWithPP[i].moveId == MOVE_NONE) break; - INVALID_IF(moves[i] >= MOVES_COUNT, "Illegal move: %d", moves[i]); - SetMonData(DATA.currentMon, MON_DATA_MOVE1 + i, &moves[i]); - SetMonData(DATA.currentMon, MON_DATA_PP1 + i, &pp[i]); + INVALID_IF(moveWithPP[i].moveId >= MOVES_COUNT, "Illegal move: %d", &moveWithPP[i].moveId); + SetMonData(DATA.currentMon, MON_DATA_MOVE1 + i, &moveWithPP[i].moveId); + SetMonData(DATA.currentMon, MON_DATA_PP1 + i, &moveWithPP[i].pp); } DATA.explicitMoves[DATA.currentSide] |= 1 << DATA.currentPartyIndex; }