From 170070baef64f97b843d4c778dbe861df884375a Mon Sep 17 00:00:00 2001 From: Nephrite Date: Mon, 26 Feb 2024 23:59:15 +0900 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Eduardo Quezada D'Ottone --- include/pokemon.h | 2 +- src/battle_util.c | 2 +- test/battle/move.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pokemon.h b/include/pokemon.h index 421c0ccd1f..3a9d533a5e 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -529,9 +529,9 @@ struct MoveInfo #define ADDITIONAL_EFFECTS(...) ((min(ARRAY_COUNT(EFFECTS_ARR( __VA_ARGS__ )), 15)) << 28) + (uintptr_t)(EFFECTS_ARR( __VA_ARGS__ )) // Retrieve a move's additional effects and the count thereof -#define GET_ADDITIONAL_EFFECTS_AND_COUNT(move, _count, _effects) u32 _count = GET_ADDITIONAL_EFFECTS_COUNT(move); const struct AdditionalEffect *_effects = GET_ADDITIONAL_EFFECTS(move) #define GET_ADDITIONAL_EFFECTS(move) (void *)(gMovesInfo[move].additionalEffects & 0x8FFFFFF) #define GET_ADDITIONAL_EFFECTS_COUNT(move) (gMovesInfo[move].additionalEffects >> 28) +#define GET_ADDITIONAL_EFFECTS_AND_COUNT(move, _count, _effects) u32 _count = GET_ADDITIONAL_EFFECTS_COUNT(move); const struct AdditionalEffect *_effects = GET_ADDITIONAL_EFFECTS(move) // Just a hack to make a move boosted by Sheer Force despite having no secondary effects affected #define SHEER_FORCE_HACK { .moveEffect = 0, .chance = 100, } diff --git a/src/battle_util.c b/src/battle_util.c index e1fc7a92f7..6e68187980 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -11084,7 +11084,7 @@ bool32 IsGen6ExpShareEnabled(void) /* Quick way of checking if a move has move effects with match a few comma-separated conditions. Each condition has to check a field of AdditionalEffect. */ -#define RETURN_HAS_MOVE_ADDITIONAL_EFFECT(condition1, ...) \ +#define RETURN_HAS_MOVE_ADDITIONAL_EFFECT(condition1, ...) \ u32 i; \ GET_ADDITIONAL_EFFECTS_AND_COUNT(move, count, effects); \ for (i = 0; i < count; i++) \ diff --git a/test/battle/move.c b/test/battle/move.c index 140b3b849a..936a821081 100644 --- a/test/battle/move.c +++ b/test/battle/move.c @@ -27,7 +27,7 @@ SINGLE_BATTLE_TEST("AdditionalEffect.chance controls the proportion of secondary PARAMETRIZE { move = MOVE_THUNDER_SHOCK; chance = 10; } PARAMETRIZE { move = MOVE_DISCHARGE; chance = 30; } PARAMETRIZE { move = MOVE_NUZZLE; chance = 100; } - ASSUME(MoveHasAdditionalEffectWithChance(move, MOVE_EFFECT_PARALYSIS, chance) == TRUE); + ASSUME(MoveHasAdditionalEffect(move, MOVE_EFFECT_PARALYSIS) == TRUE); PASSES_RANDOMLY(chance, 100, RNG_SECONDARY_EFFECT); GIVEN { PLAYER(SPECIES_WOBBUFFET);