From 423a2ed614d778163318a400135d74a34322ec34 Mon Sep 17 00:00:00 2001 From: Cesar Canassa Date: Mon, 4 Jul 2022 19:08:20 +0200 Subject: [PATCH] :recycle: Refactor MonsterRangedAttack to receive a Monster reference (#4891) --- Source/monster.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 51fe052bb..84f8c0834 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1428,11 +1428,8 @@ bool MonsterAttack(int monsterId) return false; } -bool MonsterRangedAttack(int monsterId) +bool MonsterRangedAttack(Monster &monster) { - assert(monsterId >= 0 && monsterId < MaxMonsters); - auto &monster = Monsters[monsterId]; - if (monster.AnimInfo.currentFrame == monster.data().mAFNum - 1) { const auto &missileType = static_cast(monster._mVar1); if (missileType != MIS_NULL) { @@ -1446,7 +1443,7 @@ bool MonsterRangedAttack(int monsterId) monster._mdir, missileType, TARGET_PLAYERS, - monsterId, + monster.getId(), monster._mVar2, 0); } @@ -4262,7 +4259,7 @@ void ProcessMonsters() raflag = MonsterFadeout(monster); break; case MonsterMode::RangedAttack: - raflag = MonsterRangedAttack(monsterId); + raflag = MonsterRangedAttack(monster); break; case MonsterMode::SpecialStand: raflag = MonsterSpecialStand(monster);