mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[10385] Remove Unit::GetUnit and update it callers.
This commit is contained in:
parent
dcc9dc25ae
commit
77ae9a63b8
7 changed files with 40 additions and 50 deletions
|
|
@ -84,12 +84,12 @@ VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extend
|
|||
|
||||
bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
if(Unit* victim = Unit::GetUnit(m_owner, m_victim))
|
||||
if (Unit* victim = m_owner.GetMap()->GetUnit(m_victimGuid))
|
||||
{
|
||||
while (!m_assistants.empty())
|
||||
while (!m_assistantGuids.empty())
|
||||
{
|
||||
Creature* assistant = (Creature*)Unit::GetUnit(m_owner, *m_assistants.begin());
|
||||
m_assistants.pop_front();
|
||||
Creature* assistant = m_owner.GetMap()->GetAnyTypeCreature(*m_assistantGuids.rbegin());
|
||||
m_assistantGuids.pop_back();
|
||||
|
||||
if (assistant && assistant->CanAssistTo(&m_owner, victim))
|
||||
{
|
||||
|
|
@ -102,6 +102,14 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
|||
return true;
|
||||
}
|
||||
|
||||
AssistDelayEvent::AssistDelayEvent( ObjectGuid victim, Unit& owner, std::list<Creature*> const& assistants ) : BasicEvent(), m_victimGuid(victim), m_owner(owner)
|
||||
{
|
||||
// Pushing guids because in delay can happen some creature gets despawned => invalid pointer
|
||||
m_assistantGuids.reserve(assistants.size());
|
||||
for (std::list<Creature*>::const_iterator itr = assistants.begin(); itr != assistants.end(); ++itr)
|
||||
m_assistantGuids.push_back((*itr)->GetObjectGuid());
|
||||
}
|
||||
|
||||
bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
m_owner.ForcedDespawn();
|
||||
|
|
@ -1663,13 +1671,7 @@ void Creature::CallAssistance()
|
|||
|
||||
if (!assistList.empty())
|
||||
{
|
||||
AssistDelayEvent *e = new AssistDelayEvent(getVictim()->GetGUID(), *this);
|
||||
while (!assistList.empty())
|
||||
{
|
||||
// Pushing guids because in delay can happen some creature gets despawned => invalid pointer
|
||||
e->AddAssistant((*assistList.begin())->GetGUID());
|
||||
assistList.pop_front();
|
||||
}
|
||||
AssistDelayEvent *e = new AssistDelayEvent(getVictim()->GetObjectGuid(), *this, assistList);
|
||||
m_Events.AddEvent(e, m_Events.CalculateTime(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)));
|
||||
}
|
||||
}
|
||||
|
|
@ -1945,17 +1947,17 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position) c
|
|||
case ATTACKING_TARGET_RANDOM:
|
||||
{
|
||||
advance(i, position + (rand() % (threatlist.size() - position)));
|
||||
return Unit::GetUnit(*this, (*i)->getUnitGuid());
|
||||
return GetMap()->GetUnit((*i)->getUnitGuid());
|
||||
}
|
||||
case ATTACKING_TARGET_TOPAGGRO:
|
||||
{
|
||||
advance(i, position);
|
||||
return Unit::GetUnit(*this, (*i)->getUnitGuid());
|
||||
return GetMap()->GetUnit((*i)->getUnitGuid());
|
||||
}
|
||||
case ATTACKING_TARGET_BOTTOMAGGRO:
|
||||
{
|
||||
advance(r, position);
|
||||
return Unit::GetUnit(*this, (*r)->getUnitGuid());
|
||||
return GetMap()->GetUnit((*r)->getUnitGuid());
|
||||
}
|
||||
// TODO: implement these
|
||||
//case ATTACKING_TARGET_RANDOM_PLAYER:
|
||||
|
|
|
|||
|
|
@ -703,16 +703,15 @@ class MANGOS_DLL_SPEC Creature : public Unit
|
|||
class AssistDelayEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
AssistDelayEvent(const uint64& victim, Unit& owner) : BasicEvent(), m_victim(victim), m_owner(owner) { }
|
||||
AssistDelayEvent(ObjectGuid victim, Unit& owner, std::list<Creature*> const& assistants);
|
||||
|
||||
bool Execute(uint64 e_time, uint32 p_time);
|
||||
void AddAssistant(const uint64& guid) { m_assistants.push_back(guid); }
|
||||
private:
|
||||
AssistDelayEvent();
|
||||
|
||||
uint64 m_victim;
|
||||
std::list<uint64> m_assistants;
|
||||
Unit& m_owner;
|
||||
ObjectGuid m_victimGuid;
|
||||
std::vector<ObjectGuid> m_assistantGuids;
|
||||
Unit& m_owner;
|
||||
};
|
||||
|
||||
class ForcedDespawnDelayEvent : public BasicEvent
|
||||
|
|
|
|||
|
|
@ -551,7 +551,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
{
|
||||
ThreatList const& threatList = m_creature->getThreatManager().getThreatList();
|
||||
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
|
||||
if(Unit* Temp = Unit::GetUnit(*m_creature,(*i)->getUnitGuid()))
|
||||
if(Unit* Temp = m_creature->GetMap()->GetUnit((*i)->getUnitGuid()))
|
||||
m_creature->getThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent);
|
||||
break;
|
||||
}
|
||||
|
|
@ -652,19 +652,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
|||
break;
|
||||
case ACTION_T_QUEST_EVENT_ALL:
|
||||
if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (Unit* Temp = Unit::GetUnit(*m_creature,pActionInvoker->GetGUID()))
|
||||
if (Temp->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)Temp)->GroupEventHappens(action.quest_event_all.questId,m_creature);
|
||||
}
|
||||
((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId,m_creature);
|
||||
break;
|
||||
case ACTION_T_CAST_EVENT_ALL:
|
||||
{
|
||||
ThreatList const& threatList = m_creature->getThreatManager().getThreatList();
|
||||
for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i)
|
||||
if (Unit* Temp = Unit::GetUnit(*m_creature,(*i)->getUnitGuid()))
|
||||
if (Temp->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)Temp)->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId);
|
||||
if (Player* temp = m_creature->GetMap()->GetPlayer((*i)->getUnitGuid()))
|
||||
temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId);
|
||||
break;
|
||||
}
|
||||
case ACTION_T_REMOVEAURASFROMSPELL:
|
||||
|
|
|
|||
|
|
@ -4336,8 +4336,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
}
|
||||
else if (m_caster == target)
|
||||
{
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER) // Target - is player caster
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->IsInWorld())
|
||||
{
|
||||
// Additional check for some spells
|
||||
// If 0 spell effect empty - client not send target data (need use selection)
|
||||
|
|
@ -4345,7 +4344,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
if (m_targets.m_targetMask == TARGET_FLAG_SELF &&
|
||||
m_spellInfo->EffectImplicitTargetA[EFFECT_INDEX_1] == TARGET_CHAIN_DAMAGE)
|
||||
{
|
||||
if (target = m_caster->GetUnit(*m_caster, ((Player *)m_caster)->GetSelection()))
|
||||
if (target = m_caster->GetMap()->GetUnit(((Player *)m_caster)->GetSelection()))
|
||||
m_targets.setUnitTarget(target);
|
||||
else
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
|
|
|||
|
|
@ -8643,11 +8643,6 @@ void Unit::ApplyDiminishingAura( DiminishingGroup group, bool apply )
|
|||
}
|
||||
}
|
||||
|
||||
Unit* Unit::GetUnit(WorldObject const& object, uint64 guid)
|
||||
{
|
||||
return ObjectAccessor::GetUnit(object,guid);
|
||||
}
|
||||
|
||||
bool Unit::isVisibleForInState( Player const* u, WorldObject const* viewPoint, bool inVisibleList ) const
|
||||
{
|
||||
return isVisibleForOrDetect(u, viewPoint, false, inVisibleList, false);
|
||||
|
|
@ -9664,7 +9659,7 @@ void Unit::SetFeared(bool apply, uint64 const& casterGUID, uint32 spellID, uint3
|
|||
{
|
||||
if( apply )
|
||||
{
|
||||
if(HasAuraType(SPELL_AURA_PREVENTS_FLEEING))
|
||||
if (HasAuraType(SPELL_AURA_PREVENTS_FLEEING))
|
||||
return;
|
||||
|
||||
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING);
|
||||
|
|
@ -9672,7 +9667,7 @@ void Unit::SetFeared(bool apply, uint64 const& casterGUID, uint32 spellID, uint3
|
|||
GetMotionMaster()->MovementExpired(false);
|
||||
CastStop(GetGUID() == casterGUID ? spellID : 0);
|
||||
|
||||
Unit* caster = ObjectAccessor::GetUnit(*this,casterGUID);
|
||||
Unit* caster = IsInWorld() ? GetMap()->GetUnit(casterGUID) : NULL;
|
||||
|
||||
GetMotionMaster()->MoveFleeing(caster, time); // caster==NULL processed in MoveFleeing
|
||||
}
|
||||
|
|
@ -9682,18 +9677,19 @@ void Unit::SetFeared(bool apply, uint64 const& casterGUID, uint32 spellID, uint3
|
|||
|
||||
GetMotionMaster()->MovementExpired(false);
|
||||
|
||||
if( GetTypeId() != TYPEID_PLAYER && isAlive() )
|
||||
if (GetTypeId() != TYPEID_PLAYER && isAlive())
|
||||
{
|
||||
Creature* c = ((Creature*)this);
|
||||
// restore appropriate movement generator
|
||||
if(getVictim())
|
||||
if (getVictim())
|
||||
GetMotionMaster()->MoveChase(getVictim());
|
||||
else
|
||||
GetMotionMaster()->Initialize();
|
||||
|
||||
// attack caster if can
|
||||
Unit* caster = Unit::GetUnit(*this, casterGUID);
|
||||
if(caster && ((Creature*)this)->AI())
|
||||
((Creature*)this)->AI()->AttackedBy(caster);
|
||||
if (Unit* caster = IsInWorld() ? GetMap()->GetUnit(casterGUID) : NULL)
|
||||
if (c->AI())
|
||||
c->AI()->AttackedBy(caster);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1848,7 +1848,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
|
||||
void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); }
|
||||
void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ }
|
||||
static Unit* GetUnit(WorldObject const& object, uint64 guid);
|
||||
|
||||
MotionMaster* GetMotionMaster() { return &i_motionMaster; }
|
||||
|
||||
|
|
@ -1973,13 +1972,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
template<typename Func>
|
||||
void Unit::CallForAllControlledUnits(Func const& func, bool withTotems, bool withGuardians, bool withCharms)
|
||||
{
|
||||
if(Pet* pet = GetPet())
|
||||
if (Pet* pet = GetPet())
|
||||
func(pet);
|
||||
|
||||
if (withGuardians)
|
||||
{
|
||||
for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr)
|
||||
if(Unit* guardian = Unit::GetUnit(*this,*itr))
|
||||
if (Pet* guardian = GetMap()->GetPet(*itr))
|
||||
func(guardian);
|
||||
}
|
||||
|
||||
|
|
@ -1991,7 +1990,7 @@ void Unit::CallForAllControlledUnits(Func const& func, bool withTotems, bool wit
|
|||
}
|
||||
|
||||
if (withCharms)
|
||||
if(Unit* charm = GetCharm())
|
||||
if (Unit* charm = GetCharm())
|
||||
func(charm);
|
||||
}
|
||||
|
||||
|
|
@ -2006,7 +2005,7 @@ bool Unit::CheckAllControlledUnits(Func const& func, bool withTotems, bool withG
|
|||
if (withGuardians)
|
||||
{
|
||||
for(GuardianPetList::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr)
|
||||
if (Unit const* guardian = Unit::GetUnit(*this,*itr))
|
||||
if (Pet const* guardian = GetMap()->GetPet(*itr))
|
||||
if (func(guardian))
|
||||
return true;
|
||||
|
||||
|
|
@ -2021,7 +2020,7 @@ bool Unit::CheckAllControlledUnits(Func const& func, bool withTotems, bool withG
|
|||
}
|
||||
|
||||
if (withCharms)
|
||||
if(Unit const* charm = GetCharm())
|
||||
if (Unit const* charm = GetCharm())
|
||||
if (func(charm))
|
||||
return true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10384"
|
||||
#define REVISION_NR "10385"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue