From f4fd4b1644455f1cacdc08d0a9d3dcd5c5250646 Mon Sep 17 00:00:00 2001 From: Cesar Canassa Date: Wed, 20 Jul 2022 12:31:15 +0200 Subject: [PATCH] :recycle: Remove monsterId from AiPlanWalk (#5073) --- Source/monster.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/monster.cpp b/Source/monster.cpp index 6a7ce9df7..3725812a4 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -1865,16 +1865,13 @@ bool IsTileAccessible(const Monster &monster, Point position) return IsTileSafe(monster, position); } -bool AiPlanWalk(int monsterId) +bool AiPlanWalk(Monster &monster) { int8_t path[MaxPathLength]; /** Maps from walking path step to facing direction. */ const Direction plr2monst[9] = { Direction::South, Direction::NorthEast, Direction::NorthWest, Direction::SouthEast, Direction::SouthWest, Direction::North, Direction::East, Direction::South, Direction::West }; - assert(static_cast(monsterId) < MaxMonsters); - auto &monster = Monsters[monsterId]; - if (FindPath([&monster](Point position) { return IsTileAccessible(monster, position); }, monster.position.tile, monster.enemyPosition, path) == 0) { return false; } @@ -1941,7 +1938,7 @@ bool AiPlanPath(int monsterId) monster.pathCount++; if (monster.pathCount < 5) return false; - if (AiPlanWalk(monsterId)) + if (AiPlanWalk(monster)) return true; }