aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/CreatureAI.cpp
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-03-28 01:52:49 -0300
committerariel- <ariel-@users.noreply.github.com>2017-03-28 01:52:49 -0300
commit2f99fa09c9bacbad376d7a296c3311f94ec8a552 (patch)
treee3eebad6cda4b6a0338d5226331ae8942a6cd886 /src/server/game/AI/CreatureAI.cpp
parent97e54fe4582e59c268bd77020c59f467d0b20327 (diff)
Core/AI: AreaBoundary refactor
- Added an auxiliary function IsInBounds to base CreatureAI - Changed container to vector. Set had no sense because we're storing new pointers, they have different addresses even if the boundary is the same
Diffstat (limited to 'src/server/game/AI/CreatureAI.cpp')
-rw-r--r--src/server/game/AI/CreatureAI.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp
index fea83963924..b152773509b 100644
--- a/src/server/game/AI/CreatureAI.cpp
+++ b/src/server/game/AI/CreatureAI.cpp
@@ -358,13 +358,25 @@ bool CreatureAI::CheckBoundary(Position const* who) const
who = me;
if (_boundary)
- for (CreatureBoundary::const_iterator it = _boundary->begin(); it != _boundary->end(); ++it)
- if (!(*it)->IsWithinBoundary(who))
+ for (AreaBoundary const* areaBoundary : *_boundary)
+ if (!areaBoundary->IsWithinBoundary(who))
return false;
return true;
}
+bool CreatureAI::IsInBounds(CreatureBoundary const* boundary, Position const* pos)
+{
+ if (!boundary)
+ return true;
+
+ for (AreaBoundary const* areaBoundary : *boundary)
+ if (!areaBoundary->IsWithinBoundary(pos))
+ return false;
+
+ return true;
+}
+
bool CreatureAI::CheckInRoom()
{
if (CheckBoundary())