mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-17 13:39:46 -04:00
Make a function(ToTempSummon()) which can convert Creature to TempSummon with a C++ cast(reinterpret_cast) and with a type check(isSummon()).
This function is like ToPlayer(), ToTotem(), etc. This commit is like ede831bdd6f0cff481acc33f269fa7f8c78befd4 / r7496: http://code.google.com/p/trinitycore/source/detail?r=ede831bdd6f0cff481acc33f269fa7f8c78befd4 As a result, this commit has the advantages and the "disadvantages" too, like r7496. Please try to be polite if this commit causes some crashes. --HG-- branch : trunk
This commit is contained in:
@@ -57,7 +57,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
|
||||
creature->AI()->AttackStart(target);
|
||||
else if(creature->isSummon())
|
||||
{
|
||||
if(Unit *summoner = ((TempSummon*)creature)->GetSummoner())
|
||||
if(Unit *summoner = creature->ToTempSummon()->GetSummoner())
|
||||
{
|
||||
Unit *target = summoner->getAttackerForHelper();
|
||||
if(!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty())
|
||||
|
||||
@@ -141,7 +141,7 @@ bool SpellClickInfo::IsFitToRequirements(Player const* player, Creature const *
|
||||
Unit const * summoner = NULL;
|
||||
// Check summoners for party
|
||||
if (clickNpc->isSummon())
|
||||
summoner = ((TempSummon*)clickNpc)->GetSummoner();
|
||||
summoner = clickNpc->ToTempSummon()->GetSummoner();
|
||||
if (!summoner)
|
||||
summoner = clickNpc;
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ void OutdoorPvPWG::OnCreatureCreate(Creature *creature, bool add)
|
||||
else
|
||||
return;
|
||||
|
||||
if (uint32 engLowguid = GUID_LOPART(((TempSummon*)creature)->GetSummonerGUID()))
|
||||
if (uint32 engLowguid = GUID_LOPART(creature->ToTempSummon()->GetSummonerGUID()))
|
||||
{
|
||||
if (OPvPCapturePointWG *workshop = GetWorkshopByEngGuid(engLowguid))
|
||||
{
|
||||
|
||||
@@ -5456,7 +5456,7 @@ void Spell::EffectScriptEffect(uint32 effIndex)
|
||||
case 52173: // Coyote Spirit Despawn
|
||||
case 60243: // Blood Parrot Despawn
|
||||
if (unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->ToCreature()->isSummon())
|
||||
((TempSummon*)unitTarget)->UnSummon();
|
||||
unitTarget->ToTempSummon()->UnSummon();
|
||||
return;
|
||||
// Sky Darkener Assault
|
||||
case 52124:
|
||||
@@ -5664,10 +5664,10 @@ void Spell::EffectScriptEffect(uint32 effIndex)
|
||||
if(chargesaura && chargesaura->GetCharges() > 1)
|
||||
{
|
||||
chargesaura->SetCharges(chargesaura->GetCharges() - 1);
|
||||
m_caster->CastSpell(unitTarget, spell_heal, true, NULL, NULL, ((TempSummon*)m_caster)->GetSummonerGUID());
|
||||
m_caster->CastSpell(unitTarget, spell_heal, true, NULL, NULL, m_caster->ToTempSummon()->GetSummonerGUID());
|
||||
}
|
||||
else
|
||||
((TempSummon*)m_caster)->UnSummon();
|
||||
m_caster->ToTempSummon()->UnSummon();
|
||||
return;
|
||||
}
|
||||
// Stoneclaw Totem
|
||||
|
||||
@@ -197,7 +197,7 @@ void TempSummon::InitStats(uint32 duration)
|
||||
{
|
||||
Creature *oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]);
|
||||
if(oldSummon && oldSummon->isSummon())
|
||||
((TempSummon*)oldSummon)->UnSummon();
|
||||
oldSummon->ToTempSummon()->UnSummon();
|
||||
}
|
||||
owner->m_SummonSlot[slot] = GetGUID();
|
||||
}
|
||||
|
||||
@@ -9335,7 +9335,7 @@ void Unit::RemoveAllMinionsByEntry(uint32 entry)
|
||||
++itr;
|
||||
if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
|
||||
&& unit->ToCreature()->isSummon()) // minion, actually
|
||||
((TempSummon*)unit)->UnSummon();
|
||||
unit->ToTempSummon()->UnSummon();
|
||||
// i think this is safe because i have never heard that a despawned minion will trigger a same minion
|
||||
}
|
||||
}
|
||||
@@ -9502,7 +9502,7 @@ void Unit::RemoveAllControlled()
|
||||
if (target->GetCharmerGUID() == GetGUID())
|
||||
target->RemoveCharmAuras();
|
||||
else if (target->GetOwnerGUID() == GetGUID() && target->isSummon())
|
||||
((TempSummon*)target)->UnSummon();
|
||||
target->ToTempSummon()->UnSummon();
|
||||
else
|
||||
sLog.outError("Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
|
||||
}
|
||||
@@ -9620,7 +9620,7 @@ void Unit::UnsummonAllTotems()
|
||||
|
||||
if (Creature *OldTotem = GetMap()->GetCreature(m_SummonSlot[i]))
|
||||
if (OldTotem->isSummon())
|
||||
((TempSummon*)OldTotem)->UnSummon();
|
||||
OldTotem->ToTempSummon()->UnSummon();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12138,7 +12138,7 @@ Unit* Creature::SelectVictim()
|
||||
target = getAttackerForHelper();
|
||||
if (!target && isSummon())
|
||||
{
|
||||
if (Unit * owner = ((TempSummon*)this)->GetOwner())
|
||||
if (Unit * owner = this->ToTempSummon()->GetOwner())
|
||||
{
|
||||
if (owner->isInCombat())
|
||||
target = owner->getAttackerForHelper();
|
||||
|
||||
@@ -1957,8 +1957,10 @@ class Unit : public WorldObject
|
||||
void OutDebugInfo() const;
|
||||
virtual bool isBeingLoaded() const { return false;}
|
||||
|
||||
Pet* ToPet(){ if(isPet()) return reinterpret_cast<Pet*>(this); else return NULL; }
|
||||
Pet* ToPet(){ if(isPet()) return reinterpret_cast<Pet*>(this); else return NULL; }
|
||||
Totem* ToTotem(){ if(isTotem()) return reinterpret_cast<Totem*>(this); else return NULL; }
|
||||
TempSummon* ToTempSummon() { if(isSummon()) return reinterpret_cast<TempSummon*>(this); else return NULL; }
|
||||
const TempSummon* ToTempSummon() const { if(isSummon()) return reinterpret_cast<const TempSummon*>(this); else return NULL; }
|
||||
|
||||
protected:
|
||||
explicit Unit ();
|
||||
|
||||
@@ -105,7 +105,7 @@ void Vehicle::Uninstall()
|
||||
for (SeatMap::iterator itr = m_Seats.begin(); itr != m_Seats.end(); ++itr)
|
||||
if(Unit *passenger = itr->second.passenger)
|
||||
if(passenger->HasUnitTypeMask(UNIT_MASK_ACCESSORY))
|
||||
((TempSummon*)passenger)->UnSummon();
|
||||
passenger->ToTempSummon()->UnSummon();
|
||||
RemoveAllPassengers();
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ struct boss_svalaAI : public ScriptedAI
|
||||
{
|
||||
m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE);
|
||||
m_creature->SetDisplayId(DATA_SVALA_DISPLAY_ID);
|
||||
((TempSummon*)pArthas)->UnSummon(); // TODO: should need a ToTempSummon()
|
||||
pArthas->ToTempSummon()->UnSummon();
|
||||
ArthasGUID = 0;
|
||||
Phase = FINISHED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user