aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/CreatureAI.cpp2
-rw-r--r--src/game/ObjectMgr.cpp2
-rw-r--r--src/game/OutdoorPvPWG.cpp2
-rw-r--r--src/game/SpellEffects.cpp6
-rw-r--r--src/game/TemporarySummon.cpp2
-rw-r--r--src/game/Unit.cpp8
-rw-r--r--src/game/Unit.h4
-rw-r--r--src/game/Vehicle.cpp2
-rw-r--r--src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp2
9 files changed, 16 insertions, 14 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp
index 106ac67d03f..503c7ce033d 100644
--- a/src/game/CreatureAI.cpp
+++ b/src/game/CreatureAI.cpp
@@ -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())
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 84a8254bbe8..c449267e5f5 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -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;
diff --git a/src/game/OutdoorPvPWG.cpp b/src/game/OutdoorPvPWG.cpp
index 018bcaa556d..a5047e3a5ff 100644
--- a/src/game/OutdoorPvPWG.cpp
+++ b/src/game/OutdoorPvPWG.cpp
@@ -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))
{
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 36f8387d91a..f63b36e8736 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -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
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp
index e708aadfd77..c60e0119821 100644
--- a/src/game/TemporarySummon.cpp
+++ b/src/game/TemporarySummon.cpp
@@ -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();
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index fabc476e8ff..afcf7e1a44f 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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();
diff --git a/src/game/Unit.h b/src/game/Unit.h
index d98c9730049..88db4527727 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -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 ();
diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index 6fcea316787..bd81199a375 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -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();
}
diff --git a/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp b/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp
index 1dfa43d171a..99e3fee4069 100644
--- a/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp
+++ b/src/scripts/northrend/utgarde_keep/utgarde_pinnacle/boss_svala.cpp
@@ -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;
}