aboutsummaryrefslogtreecommitdiff
path: root/src/game/CreatureEventAI.cpp
diff options
context:
space:
mode:
authorraczman <none@none>2010-03-07 15:20:19 +0100
committerraczman <none@none>2010-03-07 15:20:19 +0100
commit91b8ee104eac7446f9b8cbea7ed9dce641740c8e (patch)
tree2866b76745089d8066dad65b63e5aff07e92f4f6 /src/game/CreatureEventAI.cpp
parentaeebe57dc08d8b2d90972f50f00c4a28dd3947ba (diff)
Added new type-safe cast functions.
This, when properly used, should get rid of most memory corruption issues, currently, casting types C-style with no checks leads to some abstract crashing. Functionality is same as with dynamic_cast<>, but with no RTTI check - so when casting into invalid type you will receive NULL, and most probably crash. At the same time, i took the liberty to convert most Player* casts to ToPlayer(). Still needs crapload of casts being moved to new facility. --HG-- branch : trunk
Diffstat (limited to 'src/game/CreatureEventAI.cpp')
-rw-r--r--src/game/CreatureEventAI.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp
index debcdfb8056..a962c8195eb 100644
--- a/src/game/CreatureEventAI.cpp
+++ b/src/game/CreatureEventAI.cpp
@@ -534,12 +534,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
case ACTION_T_QUEST_EVENT:
if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker))
if (target->GetTypeId() == TYPEID_PLAYER)
- ((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId);
+ target->ToPlayer()->AreaExploredOrEventHappens(action.quest_event.questId);
break;
case ACTION_T_CAST_EVENT:
if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker))
if (target->GetTypeId() == TYPEID_PLAYER)
- ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetGUID(), action.cast_event.spellId);
+ target->ToPlayer()->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetGUID(), action.cast_event.spellId);
break;
case ACTION_T_SET_UNIT_FIELD:
{
@@ -622,7 +622,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
{
if (Unit* Temp = Unit::GetUnit(*m_creature,pActionInvoker->GetGUID()))
if (Temp->GetTypeId() == TYPEID_PLAYER)
- ((Player*)Temp)->GroupEventHappens(action.quest_event_all.questId,m_creature);
+ Temp->ToPlayer()->GroupEventHappens(action.quest_event_all.questId,m_creature);
}
break;
case ACTION_T_CAST_EVENT_ALL:
@@ -631,7 +631,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
for (std::list<HostilReference*>::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->GetGUID(), action.cast_event_all.spellId);
+ Temp->ToPlayer()->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetGUID(), action.cast_event_all.spellId);
break;
}
case ACTION_T_REMOVEAURASFROMSPELL: