Use ToTempSummon() in a case instead of a C style cast.

Use correct Unit::GetCreature() instead of Unit::GetUnit() with casting the object to Creature pointer.
Remove some usless casts.
Fix a possible crash in pyrewood_ambushAI.

TODO: Remove ugly cast macros(like CAST_PLR(), CAST_CRE()) from scripts and use the correct ToX() functions(like ToPlayer(), ToCreature()).

--HG--
branch : trunk
This commit is contained in:
Anubisss
2010-04-01 19:09:56 +02:00
parent 9f544d2f93
commit f78b766705
10 changed files with 16 additions and 15 deletions
@@ -254,6 +254,7 @@ struct pyrewood_ambushAI : public ScriptedAI
if (PlayerGUID) if (PlayerGUID)
{ {
pPlayer = Unit::GetPlayer(PlayerGUID); pPlayer = Unit::GetPlayer(PlayerGUID);
if (pPlayer)
pTarget = RAND((Unit*)m_creature, (Unit*)pPlayer); pTarget = RAND((Unit*)m_creature, (Unit*)pPlayer);
} else } else
pTarget = m_creature; pTarget = m_creature;
+1 -1
View File
@@ -672,7 +672,7 @@ struct npc_nesingwary_trapperAI : public ScriptedAI
if (go_caribou && go_caribou->GetTypeId() == TYPEID_GAMEOBJECT) if (go_caribou && go_caribou->GetTypeId() == TYPEID_GAMEOBJECT)
go_caribou->SetLootState(GO_JUST_DEACTIVATED); go_caribou->SetLootState(GO_JUST_DEACTIVATED);
if (TempSummon *summon = (TempSummon*)m_creature) if (TempSummon *summon = m_creature->ToTempSummon())
if (summon->isSummon()) if (summon->isSummon())
if (Unit *pTemp = summon->GetSummoner()) if (Unit *pTemp = summon->GetSummoner())
if (pTemp->GetTypeId() == TYPEID_PLAYER) if (pTemp->GetTypeId() == TYPEID_PLAYER)
@@ -1073,8 +1073,8 @@ struct mob_acolyte_of_shadronAI : public ScriptedAI
{ {
Unit *pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 0, 999, true); Unit *pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 0, 999, true);
Creature* pShadron = NULL; Creature* pShadron = NULL;
Creature* pSartharion = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_SARTHARION))); Creature* pSartharion = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_SARTHARION));
if (Creature* pShadron = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_SHADRON)))) if (Creature* pShadron = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_SHADRON)))
//if not solo figth, buff main boss, else place debuff on mini-boss. both spells TARGET_SCRIPT //if not solo figth, buff main boss, else place debuff on mini-boss. both spells TARGET_SCRIPT
if (pInstance->GetData(TYPE_SARTHARION_EVENT) == IN_PROGRESS) if (pInstance->GetData(TYPE_SARTHARION_EVENT) == IN_PROGRESS)
pSartharion->CastSpell(m_creature, SPELL_GIFT_OF_TWILIGTH_SAR, true); pSartharion->CastSpell(m_creature, SPELL_GIFT_OF_TWILIGTH_SAR, true);
@@ -1116,14 +1116,14 @@ struct mob_acolyte_of_shadronAI : public ScriptedAI
if (pInstance->GetData(TYPE_SARTHARION_EVENT) == IN_PROGRESS) if (pInstance->GetData(TYPE_SARTHARION_EVENT) == IN_PROGRESS)
{ {
//not solo fight, so main boss has deduff //not solo fight, so main boss has deduff
Creature* pDebuffTarget = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_SARTHARION))); Creature* pDebuffTarget = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_SARTHARION));
if (pDebuffTarget && pDebuffTarget->isAlive() && pDebuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SAR)) if (pDebuffTarget && pDebuffTarget->isAlive() && pDebuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SAR))
pDebuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SAR); pDebuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SAR);
} }
else else
{ {
//event not in progress, then solo fight and must remove debuff mini-boss //event not in progress, then solo fight and must remove debuff mini-boss
Creature* pDebuffTarget = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_SHADRON))); Creature* pDebuffTarget = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_SHADRON));
if (pDebuffTarget && pDebuffTarget->isAlive() && pDebuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA)) if (pDebuffTarget && pDebuffTarget->isAlive() && pDebuffTarget->HasAura(SPELL_GIFT_OF_TWILIGTH_SHA))
pDebuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SHA); pDebuffTarget->RemoveAurasDueToSpell(SPELL_GIFT_OF_TWILIGTH_SHA);
} }
@@ -1171,7 +1171,7 @@ struct mob_acolyte_of_vesperonAI : public ScriptedAI
// remove twilight torment on Vesperon // remove twilight torment on Vesperon
if (pInstance) if (pInstance)
{ {
Creature* pVesperon = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_VESPERON))); Creature* pVesperon = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_VESPERON));
if (pVesperon && pVesperon->isAlive() && pVesperon->HasAura(SPELL_TWILIGHT_TORMENT_VESP)) if (pVesperon && pVesperon->isAlive() && pVesperon->HasAura(SPELL_TWILIGHT_TORMENT_VESP))
pVesperon->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP); pVesperon->RemoveAurasDueToSpell(SPELL_TWILIGHT_TORMENT_VESP);
@@ -333,7 +333,7 @@ struct mob_collapsing_starAI : public ScriptedAI
{ {
mob_collapsing_starAI(Creature *pCreature) : ScriptedAI(pCreature) mob_collapsing_starAI(Creature *pCreature) : ScriptedAI(pCreature)
{ {
pInstance = (ScriptedInstance*)pCreature->GetInstanceData(); pInstance = pCreature->GetInstanceData();
} }
ScriptedInstance* pInstance; ScriptedInstance* pInstance;
@@ -23,7 +23,7 @@ The teleporter appears to be active and stable.
bool GoHello_ulduar_teleporter( Player *pPlayer, GameObject *pGO ) bool GoHello_ulduar_teleporter( Player *pPlayer, GameObject *pGO )
{ {
ScriptedInstance *pInstance = (ScriptedInstance *) pGO->GetInstanceData(); ScriptedInstance *pInstance = pGO->GetInstanceData();
if(!pInstance) return true; if(!pInstance) return true;
pPlayer->ADD_GOSSIP_ITEM(0, "Teleport to the Expedition Base Camp", GOSSIP_SENDER_MAIN, BASE_CAMP); pPlayer->ADD_GOSSIP_ITEM(0, "Teleport to the Expedition Base Camp", GOSSIP_SENDER_MAIN, BASE_CAMP);
@@ -723,7 +723,7 @@ struct mob_palehoof_orbAI : public ScriptedAI
{ {
pNext->RemoveAurasDueToSpell(SPELL_FREEZE); pNext->RemoveAurasDueToSpell(SPELL_FREEZE);
pNext->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_ATTACKABLE_1|UNIT_FLAG_OOC_NOT_ATTACKABLE); pNext->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE|UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_ATTACKABLE_1|UNIT_FLAG_OOC_NOT_ATTACKABLE);
((Unit*)pNext)->SetStandState(UNIT_STAND_STATE_STAND); pNext->SetStandState(UNIT_STAND_STATE_STAND);
pNext->SetInCombatWithZone(); pNext->SetInCombatWithZone();
pNext->Attack(pNext->SelectNearestTarget(100),true); pNext->Attack(pNext->SelectNearestTarget(100),true);
@@ -344,7 +344,7 @@ struct boss_ymironAI : public ScriptedAI
void DespawnBoatGhosts(uint64& m_uiCreatureGUID) void DespawnBoatGhosts(uint64& m_uiCreatureGUID)
{ {
if (m_uiCreatureGUID) if (m_uiCreatureGUID)
if (Creature* pTemp = (Creature*)Unit::GetUnit(*m_creature, m_uiCreatureGUID)) if (Creature* pTemp = Unit::GetCreature(*m_creature, m_uiCreatureGUID))
pTemp->DisappearAndDie(); pTemp->DisappearAndDie();
m_uiCreatureGUID = 0; m_uiCreatureGUID = 0;
@@ -349,7 +349,7 @@ struct mob_ichor_globuleAI : public ScriptedAI
{ {
if (pInstance) if (pInstance)
{ {
if (Creature* pIchoron = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ICHORON)))) if (Creature* pIchoron = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_ICHORON)))
{ {
if (m_creature->IsWithinDist(pIchoron, 2.0f , false)) if (m_creature->IsWithinDist(pIchoron, 2.0f , false))
{ {
@@ -367,7 +367,7 @@ struct mob_ichor_globuleAI : public ScriptedAI
void JustDied(Unit* pKiller) void JustDied(Unit* pKiller)
{ {
DoCast(m_creature, SPELL_SPLASH); DoCast(m_creature, SPELL_SPLASH);
if (Creature* pIchoron = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_ICHORON)))) if (Creature* pIchoron = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_ICHORON)))
if (pIchoron->AI()) if (pIchoron->AI())
pIchoron->AI()->DoAction(ACTION_WATER_ELEMENT_KILLED); pIchoron->AI()->DoAction(ACTION_WATER_ELEMENT_KILLED);
} }
@@ -252,7 +252,7 @@ struct mob_ethereal_sphereAI : public ScriptedAI
{ {
if (pInstance) if (pInstance)
{ {
if (Creature* pXevozz = ((Creature*)Unit::GetUnit((*m_creature), pInstance->GetData64(DATA_XEVOZZ)))) if (Creature* pXevozz = Unit::GetCreature(*m_creature, pInstance->GetData64(DATA_XEVOZZ)))
{ {
float fDistance = m_creature->GetDistance2d(pXevozz); float fDistance = m_creature->GetDistance2d(pXevozz);
if (fDistance <= 3) if (fDistance <= 3)
+1 -1
View File
@@ -277,7 +277,7 @@ struct npc_gurgthockAI : public ScriptedAI
for(std::list<uint64>::iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr) for(std::list<uint64>::iterator itr = SummonList.begin(); itr != SummonList.end(); ++itr)
{ {
if (Creature* pTemp = (Creature*)Unit::GetUnit(*m_creature, *itr)) if (Creature* pTemp = Unit::GetCreature(*m_creature, *itr))
if (pTemp) if (pTemp)
pTemp->RemoveFromWorld(); pTemp->RemoveFromWorld();
} }