From ceefc8c3d706a10ea43312b6836102d30e9cad03 Mon Sep 17 00:00:00 2001 From: Spp- Date: Fri, 8 Jul 2011 11:12:19 +0200 Subject: Core/Misc: Replace dynamic_cast with proper ToXXX --- src/server/game/Scripting/MapScripts.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/server/game/Scripting/MapScripts.cpp') diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index 6ee95125fce..088e5eb1e75 100755 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -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(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(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(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(source); - uTarget = dynamic_cast(target); + uSource = source ? source->ToUnit() : NULL; + uTarget = target ? target->ToUnit() : NULL; break; case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source - uSource = dynamic_cast(source); + uSource = source ? source->ToUnit() : NULL; uTarget = uSource; break; case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target - uSource = dynamic_cast(target); + uSource = target ? target->ToUnit() : NULL; uTarget = uSource; break; case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source - uSource = dynamic_cast(target); - uTarget = dynamic_cast(source); + uSource = target ? target->ToUnit() : NULL; + uTarget = source ? source->ToUnit() : NULL; break; case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry - uSource = dynamic_cast(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; } -- cgit v1.2.3