diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-03-28 01:52:49 -0300 |
|---|---|---|
| committer | ariel- <ariel-@users.noreply.github.com> | 2017-03-28 01:52:49 -0300 |
| commit | 2f99fa09c9bacbad376d7a296c3311f94ec8a552 (patch) | |
| tree | e3eebad6cda4b6a0338d5226331ae8942a6cd886 /src/server/game/AI | |
| parent | 97e54fe4582e59c268bd77020c59f467d0b20327 (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')
| -rw-r--r-- | src/server/game/AI/CreatureAI.cpp | 16 | ||||
| -rw-r--r-- | src/server/game/AI/CreatureAI.h | 4 |
2 files changed, 17 insertions, 3 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()) diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index 1d776a38075..5a8158f1a69 100644 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -65,7 +65,7 @@ enum SCEquip EQUIP_UNEQUIP = 0 }; -typedef std::set<AreaBoundary const*> CreatureBoundary; +typedef std::vector<AreaBoundary const*> CreatureBoundary; class TC_GAME_API CreatureAI : public UnitAI { protected: @@ -81,6 +81,8 @@ class TC_GAME_API CreatureAI : public UnitAI Creature* DoSummonFlyer(uint32 entry, WorldObject* obj, float flightZ, float radius = 5.0f, uint32 despawnTime = 30000, TempSummonType summonType = TEMPSUMMON_CORPSE_TIMED_DESPAWN); bool CheckBoundary(Position const* who = nullptr) const; + static bool IsInBounds(CreatureBoundary const* boundary, Position const* who); + void SetBoundary(CreatureBoundary const* boundary) { _boundary = boundary; me->DoImmediateBoundaryCheck(); } public: enum EvadeReason |
