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