diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index a07f9d407..03f0b7543 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -37,7 +37,7 @@ AggressorAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) +AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK) { } @@ -73,7 +73,7 @@ void AggressorAI::EnterEvadeMode() if (!m_creature->isAlive()) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow()); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->DeleteThreatList(); return; @@ -114,7 +114,7 @@ void AggressorAI::EnterEvadeMode() } m_creature->DeleteThreatList(); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->SetLootRecipient(NULL); } @@ -126,7 +126,7 @@ AggressorAI::UpdateAI(const uint32 /*diff*/) if(!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; - i_victimGuid = m_creature->getVictim()->GetGUID(); + i_victimGuid = m_creature->getVictim()->GetObjectGuid(); DoMeleeAttackIfReady(); } @@ -146,7 +146,7 @@ AggressorAI::AttackStart(Unit *u) if(m_creature->Attack(u,true)) { - i_victimGuid = u->GetGUID(); + i_victimGuid = u->GetObjectGuid(); m_creature->AddThreat(u); m_creature->SetInCombatWith(u); diff --git a/src/game/AggressorAI.h b/src/game/AggressorAI.h index 2277b64ec..9f0b00d3c 100644 --- a/src/game/AggressorAI.h +++ b/src/game/AggressorAI.h @@ -21,6 +21,7 @@ #include "CreatureAI.h" #include "Timer.h" +#include "ObjectGuid.h" class Creature; @@ -45,8 +46,9 @@ class MANGOS_DLL_DECL AggressorAI : public CreatureAI static int Permissible(const Creature *); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; AggressorState i_state; TimeTracker i_tracker; }; + #endif diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 8be95b7ab..fd0829ca4 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -73,7 +73,7 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry *pSpell, return CAST_FAIL_OTHER; } -CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, uint64 uiOriginalCasterGUID) +CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, ObjectGuid uiOriginalCasterGUID) { Unit* pCaster = m_creature; diff --git a/src/game/CreatureAI.h b/src/game/CreatureAI.h index 401b6e038..10ea75c21 100644 --- a/src/game/CreatureAI.h +++ b/src/game/CreatureAI.h @@ -24,6 +24,7 @@ #include "Policies/Singleton.h" #include "Dynamic/ObjectRegistry.h" #include "Dynamic/FactoryHolder.h" +#include "ObjectGuid.h" class WorldObject; class GameObject; @@ -156,7 +157,7 @@ class MANGOS_DLL_SPEC CreatureAI ///== Helper functions ============================= bool DoMeleeAttackIfReady(); - CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, uint64 uiOriginalCasterGUID = 0); + CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, ObjectGuid uiOriginalCasterGUID = ObjectGuid()); ///== Fields ======================================= diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 64940e08e..c4287f3ce 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -189,9 +189,9 @@ FleeingMovementGenerator::_setMoveData(T &owner) { float cur_dist_xyz = owner.GetDistance(i_caster_x, i_caster_y, i_caster_z); - if(i_to_distance_from_caster > 0.0f) + if (i_to_distance_from_caster > 0.0f) { - if((i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz < i_to_distance_from_caster) || + if ((i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz < i_to_distance_from_caster) || // if we reach lower distance (i_last_distance_from_caster > i_to_distance_from_caster && cur_dist_xyz > i_last_distance_from_caster) || // if we can't be close @@ -217,12 +217,10 @@ FleeingMovementGenerator::_setMoveData(T &owner) float cur_dist; float angle_to_caster; - Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID); - - if(fright) + if (Unit* fright = owner.GetMap()->GetUnit(i_frightGuid)) { cur_dist = fright->GetDistance(&owner); - if(cur_dist < cur_dist_xyz) + if (cur_dist < cur_dist_xyz) { i_caster_x = fright->GetPositionX(); i_caster_y = fright->GetPositionY(); @@ -286,7 +284,7 @@ FleeingMovementGenerator::Initialize(T &owner) _Init(owner); - if(Unit * fright = ObjectAccessor::GetUnit(owner, i_frightGUID)) + if (Unit * fright = owner.GetMap()->GetUnit(i_frightGuid)) { i_caster_x = fright->GetPositionX(); i_caster_y = fright->GetPositionY(); diff --git a/src/game/FleeingMovementGenerator.h b/src/game/FleeingMovementGenerator.h index f3b2b2654..7803197cf 100644 --- a/src/game/FleeingMovementGenerator.h +++ b/src/game/FleeingMovementGenerator.h @@ -22,13 +22,14 @@ #include "MovementGenerator.h" #include "DestinationHolder.h" #include "Traveller.h" +#include "ObjectGuid.h" template class MANGOS_DLL_SPEC FleeingMovementGenerator : public MovementGeneratorMedium< T, FleeingMovementGenerator > { public: - FleeingMovementGenerator(uint64 fright) : i_frightGUID(fright), i_nextCheckTime(0) {} + FleeingMovementGenerator(ObjectGuid fright) : i_frightGuid(fright), i_nextCheckTime(0) {} void Initialize(T &); void Finalize(T &); @@ -54,7 +55,7 @@ class MANGOS_DLL_SPEC FleeingMovementGenerator float i_last_distance_from_caster; float i_to_distance_from_caster; float i_cur_angle; - uint64 i_frightGUID; + ObjectGuid i_frightGuid; TimeTracker i_nextCheckTime; DestinationHolder< Traveller > i_destinationHolder; @@ -64,7 +65,7 @@ class MANGOS_DLL_SPEC TimedFleeingMovementGenerator : public FleeingMovementGenerator { public: - TimedFleeingMovementGenerator(uint64 fright, uint32 time) : + TimedFleeingMovementGenerator(ObjectGuid fright, uint32 time) : FleeingMovementGenerator(fright), i_totalFleeTime(time) {} diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index b01c3241d..dea2b6927 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -345,13 +345,13 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str()); if (m_owner->GetTypeId() == TYPEID_PLAYER) - Mutate(new FleeingMovementGenerator(enemy->GetGUID())); + Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); else { if (time) - Mutate(new TimedFleeingMovementGenerator(enemy->GetGUID(), time)); + Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); else - Mutate(new FleeingMovementGenerator(enemy->GetGUID())); + Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); } } diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index ae9b2eaad..5692eaf0b 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -252,7 +252,7 @@ void PetAI::UpdateAI(const uint32 diff) bool spellUsed = false; for (AllySet::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar) { - Unit* Target = ObjectAccessor::GetUnit(*m_creature,*tar); + Unit* Target = m_creature->GetMap()->GetUnit(*tar); //only buff targets that are in combat, unless the spell can only be cast while out of combat if (!Target) diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index f530f9556..0a32c864e 100644 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -48,7 +48,7 @@ ReactorAI::AttackStart(Unit *p) if(m_creature->Attack(p,true)) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId()); - i_victimGuid = p->GetGUID(); + i_victimGuid = p->GetObjectGuid(); m_creature->AddThreat(p); m_creature->SetInCombatWith(p); @@ -71,7 +71,7 @@ ReactorAI::UpdateAI(const uint32 /*time_diff*/) if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; - i_victimGuid = m_creature->getVictim()->GetGUID(); + i_victimGuid = m_creature->getVictim()->GetObjectGuid(); DoMeleeAttackIfReady(); } @@ -84,7 +84,7 @@ ReactorAI::EnterEvadeMode() DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Creature stopped attacking, he is dead [guid=%u]", m_creature->GetGUIDLow()); m_creature->GetMotionMaster()->MovementExpired(); m_creature->GetMotionMaster()->MoveIdle(); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->DeleteThreatList(); return; @@ -111,7 +111,7 @@ ReactorAI::EnterEvadeMode() m_creature->RemoveAllAuras(); m_creature->DeleteThreatList(); - i_victimGuid = 0; + i_victimGuid.Clear(); m_creature->CombatStop(true); m_creature->SetLootRecipient(NULL); diff --git a/src/game/ReactorAI.h b/src/game/ReactorAI.h index e0579f821..3da990f5e 100644 --- a/src/game/ReactorAI.h +++ b/src/game/ReactorAI.h @@ -20,6 +20,7 @@ #define MANGOS_REACTORAI_H #include "CreatureAI.h" +#include "ObjectGuid.h" class Unit; @@ -27,7 +28,7 @@ class MANGOS_DLL_DECL ReactorAI : public CreatureAI { public: - explicit ReactorAI(Creature *c) : CreatureAI(c), i_victimGuid(0) {} + explicit ReactorAI(Creature *c) : CreatureAI(c) {} void MoveInLineOfSight(Unit *); void AttackStart(Unit *); @@ -38,6 +39,6 @@ class MANGOS_DLL_DECL ReactorAI : public CreatureAI static int Permissible(const Creature *); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; }; #endif diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 1b9a81eab..d3467e2a1 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -35,7 +35,7 @@ TotemAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -TotemAI::TotemAI(Creature *c) : CreatureAI(c), i_victimGuid(0) +TotemAI::TotemAI(Creature *c) : CreatureAI(c) { } @@ -70,7 +70,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) // SPELLMOD_RANGE not applied in this place just because nonexistent range mods for attacking totems // pointer to appropriate target if found any - Unit* victim = i_victimGuid ? m_creature->GetMap()->GetUnit(i_victimGuid) : NULL; + Unit* victim = m_creature->GetMap()->GetUnit(i_victimGuid); // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end) if( !victim || @@ -88,14 +88,14 @@ TotemAI::UpdateAI(const uint32 /*diff*/) if (victim) { // remember - i_victimGuid = victim->GetGUID(); + i_victimGuid = victim->GetObjectGuid(); // attack m_creature->SetInFront(victim); // client change orientation by self m_creature->CastSpell(victim, getTotem().GetSpell(), false); } else - i_victimGuid = 0; + i_victimGuid.Clear(); } bool diff --git a/src/game/TotemAI.h b/src/game/TotemAI.h index 43dd34bf8..fc983793d 100644 --- a/src/game/TotemAI.h +++ b/src/game/TotemAI.h @@ -20,6 +20,7 @@ #define MANGOS_TOTEMAI_H #include "CreatureAI.h" +#include "ObjectGuid.h" #include "Timer.h" class Creature; @@ -42,6 +43,6 @@ class MANGOS_DLL_DECL TotemAI : public CreatureAI Totem& getTotem(); private: - uint64 i_victimGuid; + ObjectGuid i_victimGuid; }; #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 367d18d2e..a8ce501ce 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11459" + #define REVISION_NR "11460" #endif // __REVISION_NR_H__