diff options
author | thenecromancer <none@none> | 2010-03-11 20:51:31 +0100 |
---|---|---|
committer | thenecromancer <none@none> | 2010-03-11 20:51:31 +0100 |
commit | e1542df90ccde91e2f7fded2d5378d77b1f9ea84 (patch) | |
tree | a2d4cfaa4ede97263b30ce11c8ff1450361de846 /src | |
parent | 02a9cd6a43a18f2350801bd9473c2346b36b0575 (diff) |
Convert some C style casts to new functions
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Level1.cpp | 2 | ||||
-rw-r--r-- | src/game/Map.cpp | 18 | ||||
-rw-r--r-- | src/game/Pet.cpp | 2 | ||||
-rw-r--r-- | src/game/Player.cpp | 8 | ||||
-rw-r--r-- | src/game/Spell.cpp | 6 | ||||
-rw-r--r-- | src/game/SpellAuraEffects.cpp | 14 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 16 | ||||
-rw-r--r-- | src/game/SpellHandler.cpp | 2 | ||||
-rw-r--r-- | src/game/Unit.cpp | 41 | ||||
-rw-r--r-- | src/scripts/kalimdor/durotar.cpp | 2 |
10 files changed, 51 insertions, 60 deletions
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 9aa1d3eca2a..360810801a1 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -2110,7 +2110,7 @@ bool ChatHandler::HandleModifyBitCommand(const char* args) } // check online security - if (unit->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player *)unit, 0)) + if (unit->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity(unit->ToPlayer(), 0)) return false; char* pField = strtok((char*)args, " "); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 2c2552c530c..1b54b9d430e 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -3026,7 +3026,7 @@ void Map::ScriptsProcess() switch(step.script->datalong) { case 0: // Say - ((Creature *)source)->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); + source->ToCreature()->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); break; case 1: // Whisper if(!unit_target) @@ -3034,17 +3034,17 @@ void Map::ScriptsProcess() sLog.outError("SCRIPT_COMMAND_TALK attempt to whisper (%u) NULL, skipping.",step.script->datalong); break; } - ((Creature *)source)->Whisper(step.script->dataint,unit_target); + source->ToCreature()->Whisper(step.script->dataint,unit_target); break; case 2: // Yell - ((Creature *)source)->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); + source->ToCreature()->Yell(step.script->dataint, LANG_UNIVERSAL, unit_target); break; case 3: // Emote text - ((Creature *)source)->TextEmote(step.script->dataint, unit_target); + source->ToCreature()->TextEmote(step.script->dataint, unit_target); break; case 4: // Boss Emote text - ((Creature *)source)->MonsterTextEmote(step.script->dataint, unit_target, true); - break; + source->ToCreature()->MonsterTextEmote(step.script->dataint, unit_target, true); + break; default: break; // must be already checked at load } @@ -3064,7 +3064,7 @@ void Map::ScriptsProcess() break; } - ((Creature *)source)->HandleEmoteCommand(step.script->datalong); + source->ToCreature()->HandleEmoteCommand(step.script->datalong); break; case SCRIPT_COMMAND_FIELD_SET: if(!source) @@ -3694,8 +3694,8 @@ void Map::ScriptsProcess() break; } - ((Creature *)source)->SetOrientation(step.script->o); - ((Creature *)source)->SendMovementFlagUpdate(); + source->ToCreature()->SetOrientation(step.script->o); + source->ToCreature()->SendMovementFlagUpdate(); break; } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 7d3d93c9e79..05b9f177d39 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1572,7 +1572,7 @@ bool Pet::resetTalents(bool no_cost) if (!pet_family || pet_family->petTalentType < 0) return false; - Player *player = (Player *)owner; + Player *player = owner->ToPlayer(); uint8 level = getLevel(); uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 0426fac4066..69475ff46ac 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -6404,7 +6404,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt if( uVictim->GetTypeId() == TYPEID_PLAYER ) { - Player *pVictim = (Player *)uVictim; + Player *pVictim = uVictim->ToPlayer(); if( GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm() ) return false; @@ -6459,9 +6459,7 @@ bool Player::RewardHonor(Unit *uVictim, uint32 groupsize, float honor, bool pvpt } else { - Creature *cVictim = (Creature *)uVictim; - - if (!cVictim->isRacialLeader()) + if (!uVictim->ToCreature()->isRacialLeader()) return false; honor = 100; // ??? need more info @@ -19921,7 +19919,7 @@ bool Player::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool if(isGameMaster()) { if(u->GetTypeId() == TYPEID_PLAYER) - return ((Player *)u)->GetSession()->GetSecurity() <= GetSession()->GetSecurity(); + return u->ToPlayer()->GetSession()->GetSecurity() <= GetSession()->GetSecurity(); else return true; } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 7f2b0a76017..85c9c17e07c 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1182,7 +1182,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) caster->ProcDamageAndSpell(unitTarget, procAttacker, procVictim, procEx, damageInfo.damage, m_attackType, m_spellInfo, m_triggeredByAuraSpell); if(caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->Attributes & SPELL_ATTR_STOP_ATTACK_TARGET) == 0 && (m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED)) - ((Player *)caster)->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx); + caster->ToPlayer()->CastItemCombatSpell(unitTarget, m_attackType, procVictim, procEx); } caster->DealSpellDamage(&damageInfo, true); @@ -1730,7 +1730,7 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargets TargetType) if ((*itr)->GetEntry() == i_spellST->second.targetEntry && (*itr)->IsWithinDistInMap(m_caster, range)) { goScriptTarget = NULL; - creatureScriptTarget = ((Creature *)*itr); + creatureScriptTarget = (*itr)->ToCreature(); range = m_caster->GetDistance(creatureScriptTarget); } break; @@ -4506,7 +4506,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_targets.m_targetMask == TARGET_FLAG_SELF && m_spellInfo->EffectImplicitTargetA[1] == TARGET_UNIT_TARGET_ENEMY) { - if (target = m_caster->GetUnit(*m_caster, ((Player *)m_caster)->GetSelection())) + if (target = m_caster->GetUnit(*m_caster, m_caster->ToPlayer()->GetSelection())) m_targets.setUnitTarget(target); else return SPELL_FAILED_BAD_TARGETS; diff --git a/src/game/SpellAuraEffects.cpp b/src/game/SpellAuraEffects.cpp index 5ea6a776ea3..18377b86541 100644 --- a/src/game/SpellAuraEffects.cpp +++ b/src/game/SpellAuraEffects.cpp @@ -2385,20 +2385,20 @@ void AuraEffect::HandleShapeshiftBoosts(Unit * target, bool apply) const if (spellId) { if(target->GetTypeId() == TYPEID_PLAYER) - ((Player *)target)->RemoveSpellCooldown(spellId); + target->ToPlayer()->RemoveSpellCooldown(spellId); target->CastSpell(target, spellId, true, NULL, this ); } if (spellId2) { if(target->GetTypeId() == TYPEID_PLAYER) - ((Player *)target)->RemoveSpellCooldown(spellId2); + target->ToPlayer()->RemoveSpellCooldown(spellId2); target->CastSpell(target, spellId2, true, NULL, this); } if(target->GetTypeId() == TYPEID_PLAYER) { - const PlayerSpellMap& sp_list = ((Player *)target)->GetSpellMap(); + const PlayerSpellMap& sp_list = target->ToPlayer()->GetSpellMap(); for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { if(itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) continue; @@ -2886,7 +2886,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const * aurApp, uint8 m // Stance mastery + Tactical mastery (both passive, and last have aura only in defense stance, but need apply at any stance switch) if(target->GetTypeId() == TYPEID_PLAYER) { - PlayerSpellMap const& sp_list = ((Player *)target)->GetSpellMap(); + PlayerSpellMap const& sp_list = target->ToPlayer()->GetSpellMap(); for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { if(itr->second->state == PLAYERSPELL_REMOVED || itr->second->disabled) continue; @@ -5834,7 +5834,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo { // Play part 1 if(apply) - target->PlayDirectSound(14970, (Player *)target); + target->PlayDirectSound(14970, target->ToPlayer()); // continue in 58205 else target->CastSpell(target, 58205, true); @@ -5846,10 +5846,10 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo { // Play part 2 if(apply) - target->PlayDirectSound(14971, (Player *)target); + target->PlayDirectSound(14971, target->ToPlayer()); // Play part 3 else - target->PlayDirectSound(14972, (Player *)target); + target->PlayDirectSound(14972, target->ToPlayer()); } break; } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index e7df7ce656b..3253cd36f86 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -510,7 +510,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) // Shadow Bite else if (m_spellInfo->SpellFamilyFlags[1] & 0x400000) { - if (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature *)m_caster)->isPet()) + if (m_caster->GetTypeId() == TYPEID_UNIT && m_caster->ToCreature()->isPet()) { // Get DoTs on target by owner (5% increase by dot) damage += 5 * unitTarget->GetDoTsByCaster(m_caster->GetOwnerGUID()) / 100; @@ -1473,7 +1473,7 @@ void Spell::EffectDummy(uint32 i) return; // immediately finishes the cooldown on Frost spells - const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap(); + const SpellCooldowns& cm = m_caster->ToPlayer()->GetSpellCooldownMap(); for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); @@ -1751,7 +1751,7 @@ void Spell::EffectDummy(uint32 i) return; //immediately finishes the cooldown on certain Rogue abilities - const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap(); + const SpellCooldowns& cm = m_caster->ToPlayer()->GetSpellCooldownMap(); for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); @@ -4829,8 +4829,8 @@ void Spell::EffectSummonObjectWild(uint32 i) if(pGameObj->GetGoType() == GAMEOBJECT_TYPE_FLAGDROP && m_caster->GetTypeId() == TYPEID_PLAYER) { - Player *pl = (Player*)m_caster; - BattleGround* bg = ((Player *)m_caster)->GetBattleGround(); + Player *pl = m_caster->ToPlayer(); + BattleGround* bg = pl->GetBattleGround(); switch(pGameObj->GetMapId()) { @@ -5807,7 +5807,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) // Demonic Empowerment case 47193: { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || !((Creature *)unitTarget)->isPet()) + if(!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || !unitTarget->ToCreature()->isPet()) return; CreatureInfo const * ci = objmgr.GetCreatureTemplate(unitTarget->GetEntry()); switch (ci->family) @@ -6152,7 +6152,7 @@ void Spell::EffectSanctuary(uint32 /*i*/) && m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags[0] & SPELLFAMILYFLAG_ROGUE_VANISH)) { - ((Player *)m_caster)->RemoveAurasByType(SPELL_AURA_MOD_ROOT); + m_caster->ToPlayer()->RemoveAurasByType(SPELL_AURA_MOD_ROOT); // Overkill if(m_caster->ToPlayer()->HasSpell(58426)) m_caster->CastSpell(m_caster, 58427, true); @@ -7580,7 +7580,7 @@ void Spell::EffectPlayerNotification(uint32 /*eff_idx*/) { case 58730: // Restricted Flight Area case 58600: // Restricted Flight Area - ((Player *)unitTarget)->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE); + unitTarget->ToPlayer()->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE); break; } } diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 231d0c4e0b4..43f68e14794 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -582,7 +582,7 @@ void WorldSession::HandleMirrrorImageDataRequest( WorldPacket & recv_data ) data << (uint32)creator->GetDisplayId(); if (creator->GetTypeId() == TYPEID_PLAYER) { - Player * pCreator = (Player *)creator; + Player * pCreator = creator->ToPlayer(); data << (uint8)pCreator->getRace(); data << (uint8)pCreator->getGender(); data << (uint8)pCreator->getClass(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 15f1276ac41..a3f7c616154 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -241,7 +241,7 @@ void Unit::Update(uint32 p_time) SendThreatListUpdate(); // update combat timer only for players and pets (only pets with PetAI) - if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || (((Creature *)this)->isPet() && IsControlledByPlayer()))) + if (isInCombat() && (GetTypeId() == TYPEID_PLAYER || (ToCreature()->isPet() && IsControlledByPlayer()))) { // Check UNIT_STAT_MELEE_ATTACKING or UNIT_STAT_CHASE (without UNIT_STAT_FOLLOW in this case) so pets can reach far away // targets without stopping half way there and running off. @@ -578,13 +578,6 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) uint32 originalDamage = damage; - //Script Event damage Deal - //if (GetTypeId() == TYPEID_UNIT && ((Creature *)this)->AI()) - // ((Creature *)this)->AI()->DamageDeal(pVictim, damage); - //Script Event damage taken - //if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled) - // ((Creature *)pVictim)->AI()->DamageTaken(this, damage); - if (absorb && originalDamage > damage) absorb += (originalDamage - damage); } @@ -1553,7 +1546,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) } if (GetTypeId() == TYPEID_PLAYER) - ((Player *)this)->CastItemCombatSpell(pVictim, damageInfo->attackType, damageInfo->procVictim, damageInfo->procEx); + ToPlayer()->CastItemCombatSpell(pVictim, damageInfo->attackType, damageInfo->procVictim, damageInfo->procEx); // Do effect if any damage done to target if (damageInfo->damage) @@ -1649,7 +1642,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt // item dependent spell - check curent weapons for (int i = 0; i < MAX_ATTACK; ++i) { - Item *weapon = ((Player *)this)->GetWeaponForAttack(WeaponAttackType(i)); + Item *weapon = ToPlayer()->GetWeaponForAttack(WeaponAttackType(i)); if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) { @@ -5518,14 +5511,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45479; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { // triggered at positive/self casts also, current attack target used then if(IsFriendlyTo(target)) @@ -5533,7 +5526,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger target = getVictim(); if(!target) { - uint64 selected_guid = ((Player *)this)->GetSelection(); + uint64 selected_guid = ToPlayer()->GetSelection(); target = ObjectAccessor::GetUnit(*this,selected_guid); if(!target) return false; @@ -5556,14 +5549,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45480; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { triggered_spell_id = 45428; break; @@ -5579,14 +5572,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45432; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { target = this; triggered_spell_id = 45431; @@ -5603,14 +5596,14 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger return false; // Get Aldor reputation rank - if (((Player *)this)->GetReputationRank(932) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(932) == REP_EXALTED) { target = this; triggered_spell_id = 45478; break; } // Get Scryers reputation rank - if (((Player *)this)->GetReputationRank(934) == REP_EXALTED) + if (ToPlayer()->GetReputationRank(934) == REP_EXALTED) { triggered_spell_id = 45430; break; @@ -6288,7 +6281,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger int32 basepoints1 = triggerAmount * 2; // Improved Leader of the Pack // Check cooldown of heal spell cooldown - if (GetTypeId() == TYPEID_PLAYER && !((Player *)this)->HasSpellCooldown(34299)) + if (GetTypeId() == TYPEID_PLAYER && !ToPlayer()->HasSpellCooldown(34299)) CastCustomSpell(this,60889,&basepoints1,0,0,true,0,triggeredByAura); break; } @@ -11301,7 +11294,7 @@ void Unit::Mount(uint32 mount, uint32 VehicleId) Pet* pet = this->ToPlayer()->GetPet(); if (pet) { - BattleGround *bg = ((Player *)this)->GetBattleGround(); + BattleGround *bg = ToPlayer()->GetBattleGround(); // don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface if (bg && bg->isArena()) pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); @@ -11541,7 +11534,7 @@ bool Unit::isAttackableByAOE() const UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_OOC_NOT_ATTACKABLE)) return false; - if (GetTypeId() == TYPEID_PLAYER && ((Player *)this)->isGameMaster()) + if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->isGameMaster()) return false; return !hasUnitState(UNIT_STAT_UNATTACKABLE); @@ -14828,7 +14821,7 @@ void Unit::SetStunned(bool apply) // don't remove UNIT_FLAG_STUNNED for pet when owner is mounted (disabled pet's interface) Unit *pOwner = GetOwner(); - if (!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !((Player *)pOwner)->IsMounted())) + if (!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !pOwner->ToPlayer()->IsMounted())) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); if (!hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect @@ -14855,7 +14848,7 @@ void Unit::SetRooted(bool apply) SendMessageToSet(&data,true); if (GetTypeId() != TYPEID_PLAYER) - ((Creature *)this)->StopMoving(); + ToCreature()->StopMoving(); } else { diff --git a/src/scripts/kalimdor/durotar.cpp b/src/scripts/kalimdor/durotar.cpp index 6d61ecbfd9a..d10e24f6a26 100644 --- a/src/scripts/kalimdor/durotar.cpp +++ b/src/scripts/kalimdor/durotar.cpp @@ -62,7 +62,7 @@ struct npc_lazy_peonAI : public ScriptedAI if (spell->Id == SPELL_AWAKEN_PEON && caster->GetTypeId() == TYPEID_PLAYER && CAST_PLR(caster)->GetQuestStatus(QUEST_LAZY_PEONS) == QUEST_STATUS_INCOMPLETE) { - ((Player *)caster)->KilledMonsterCredit(m_creature->GetEntry(),m_creature->GetGUID()); + caster->ToPlayer()->KilledMonsterCredit(m_creature->GetEntry(),m_creature->GetGUID()); DoScriptText(SAY_SPELL_HIT, m_creature, caster); m_creature->RemoveAllAuras(); if(GameObject* Lumberpile = m_creature->FindNearestGameObject(GO_LUMBERPILE, 20)) |