mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
Core/Misc: Replace dynamic_cast<XXX*> with proper ToXXX
This commit is contained in:
@@ -812,12 +812,12 @@ void Group::GroupLoot(Loot *loot, WorldObject* pLootedObject)
|
||||
|
||||
RollId.push_back(r);
|
||||
|
||||
if (Creature* creature = dynamic_cast<Creature *>(pLootedObject))
|
||||
if (Creature* creature = pLootedObject->ToCreature())
|
||||
{
|
||||
creature->m_groupLootTimer = 60000;
|
||||
creature->lootingGroupLowGUID = GetLowGUID();
|
||||
}
|
||||
else if (GameObject* go = dynamic_cast<GameObject *>(pLootedObject))
|
||||
else if (GameObject* go = pLootedObject->ToGameObject())
|
||||
{
|
||||
go->m_groupLootTimer = 60000;
|
||||
go->lootingGroupLowGUID = GetLowGUID();
|
||||
@@ -903,7 +903,7 @@ void Group::NeedBeforeGreed(Loot *loot, WorldObject* pLootedObject)
|
||||
|
||||
RollId.push_back(r);
|
||||
|
||||
if (Creature* creature = dynamic_cast<Creature *>(pLootedObject))
|
||||
if (Creature* creature = pLootedObject->ToCreature())
|
||||
{
|
||||
creature->m_groupLootTimer = 60000;
|
||||
creature->lootingGroupLowGUID = GetLowGUID();
|
||||
|
||||
@@ -163,7 +163,7 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUIDLow());
|
||||
else
|
||||
{
|
||||
pUnit = dynamic_cast<Unit*>(obj);
|
||||
pUnit = obj->ToUnit();
|
||||
if (!pUnit)
|
||||
sLog->outError("%s %s object could not be casted to unit.",
|
||||
scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
|
||||
@@ -257,7 +257,7 @@ inline void Map::_ScriptProcessDoor(Object* source, Object* target, const Script
|
||||
|
||||
if (target && target->isType(TYPEMASK_GAMEOBJECT))
|
||||
{
|
||||
GameObject* goTarget = dynamic_cast<GameObject*>(target);
|
||||
GameObject* goTarget = target->ToGameObject();
|
||||
if (goTarget && goTarget->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
|
||||
goTarget->UseDoorOrButton(nTimeToToggle);
|
||||
}
|
||||
@@ -678,7 +678,7 @@ void Map::ScriptsProcess()
|
||||
break;
|
||||
}
|
||||
|
||||
if (GameObject *pGO = dynamic_cast<GameObject*>(target))
|
||||
if (GameObject *pGO = target->ToGameObject())
|
||||
pGO->Use(pSource);
|
||||
}
|
||||
break;
|
||||
@@ -707,24 +707,24 @@ void Map::ScriptsProcess()
|
||||
switch (step.script->CastSpell.Flags)
|
||||
{
|
||||
case SF_CASTSPELL_SOURCE_TO_TARGET: // source -> target
|
||||
uSource = dynamic_cast<Unit*>(source);
|
||||
uTarget = dynamic_cast<Unit*>(target);
|
||||
uSource = source ? source->ToUnit() : NULL;
|
||||
uTarget = target ? target->ToUnit() : NULL;
|
||||
break;
|
||||
case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source
|
||||
uSource = dynamic_cast<Unit*>(source);
|
||||
uSource = source ? source->ToUnit() : NULL;
|
||||
uTarget = uSource;
|
||||
break;
|
||||
case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target
|
||||
uSource = dynamic_cast<Unit*>(target);
|
||||
uSource = target ? target->ToUnit() : NULL;
|
||||
uTarget = uSource;
|
||||
break;
|
||||
case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source
|
||||
uSource = dynamic_cast<Unit*>(target);
|
||||
uTarget = dynamic_cast<Unit*>(source);
|
||||
uSource = target ? target->ToUnit() : NULL;
|
||||
uTarget = source ? source->ToUnit() : NULL;
|
||||
break;
|
||||
case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry
|
||||
uSource = dynamic_cast<Unit*>(source);
|
||||
uTarget = GetClosestCreatureWithEntry(uSource, abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius);
|
||||
uSource = source ? source->ToUnit() : NULL;
|
||||
uTarget = uSource ? GetClosestCreatureWithEntry(uSource, abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -4480,18 +4480,16 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
|
||||
}
|
||||
// Plant Warmaul Ogre Banner
|
||||
case 32307:
|
||||
{
|
||||
Player* p_caster = dynamic_cast<Player*>(m_caster);
|
||||
if (!p_caster)
|
||||
break;
|
||||
p_caster->RewardPlayerAndGroupAtEvent(18388, unitTarget);
|
||||
Creature* cTarget = dynamic_cast<Creature*>(unitTarget);
|
||||
if (!cTarget)
|
||||
break;
|
||||
cTarget->setDeathState(CORPSE);
|
||||
cTarget->RemoveCorpse();
|
||||
if (Player* caster = m_caster->ToPlayer()))
|
||||
{
|
||||
caster->RewardPlayerAndGroupAtEvent(18388, unitTarget);
|
||||
if (Creature* target = unitTarget->ToCreature())
|
||||
{
|
||||
target->setDeathState(CORPSE);
|
||||
target->RemoveCorpse();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 48025: // Headless Horseman's Mount
|
||||
{
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
@@ -5076,8 +5074,10 @@ void Spell::EffectScriptEffect(SpellEffIndex effIndex)
|
||||
{
|
||||
if (Vehicle* seat = m_caster->GetVehicleKit())
|
||||
{
|
||||
if (Creature* oldContainer = dynamic_cast<Creature*>(seat->GetPassenger(1)))
|
||||
oldContainer->DisappearAndDie();
|
||||
if (Unit* passenger = seat->GetPassenger(1))
|
||||
if (Creature* oldContainer = passenger->ToCreature())
|
||||
oldContainer->DisappearAndDie();
|
||||
|
||||
// TODO: a hack, range = 11, should after some time cast, otherwise too far
|
||||
m_caster->CastSpell(seat->GetBase(), 62496, true);
|
||||
unitTarget->EnterVehicle(m_caster, 1);
|
||||
|
||||
Reference in New Issue
Block a user