diff options
Diffstat (limited to 'src')
33 files changed, 991 insertions, 1025 deletions
diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index dafdbf811bb..e790304fb33 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -20,7 +20,7 @@ struct TSpellSummary void SummonList::DoZoneInCombat(uint32 entry) { - for (iterator i = begin(); i != end(); ) + for (iterator i = begin(); i != end();) { Creature *summon = Unit::GetCreature(*m_creature, *i); ++i; @@ -32,7 +32,7 @@ void SummonList::DoZoneInCombat(uint32 entry) void SummonList::DoAction(uint32 entry, uint32 info) { - for (iterator i = begin(); i != end(); ) + for (iterator i = begin(); i != end();) { Creature *summon = Unit::GetCreature(*m_creature, *i); ++i; @@ -44,7 +44,7 @@ void SummonList::DoAction(uint32 entry, uint32 info) void SummonList::DespawnEntry(uint32 entry) { - for (iterator i = begin(); i != end(); ) + for (iterator i = begin(); i != end();) { Creature *summon = Unit::GetCreature(*m_creature, *i); if(!summon) diff --git a/src/bindings/scripts/scripts/world/item_scripts.cpp b/src/bindings/scripts/scripts/world/item_scripts.cpp index 2464d64422e..0c3b470ce1d 100644 --- a/src/bindings/scripts/scripts/world/item_scripts.cpp +++ b/src/bindings/scripts/scripts/world/item_scripts.cpp @@ -150,7 +150,7 @@ bool ItemUse_item_flying_machine(Player* pPlayer, Item* pItem, SpellCastTargets bool ItemUse_item_gor_dreks_ointment(Player* pPlayer, Item* pItem, SpellCastTargets const& targets) { - if (targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId()==TYPEID_UNIT && + if (targets.getUnitTarget() && targets.getUnitTarget()->GetTypeId() == TYPEID_UNIT && targets.getUnitTarget()->GetEntry() == 20748 && !targets.getUnitTarget()->HasAura(32578)) return false; diff --git a/src/framework/Utilities/EventProcessor.cpp b/src/framework/Utilities/EventProcessor.cpp index d3b8bd20d67..852f84bc4e2 100644 --- a/src/framework/Utilities/EventProcessor.cpp +++ b/src/framework/Utilities/EventProcessor.cpp @@ -66,7 +66,7 @@ void EventProcessor::KillAllEvents(bool force) m_aborting = true; // first, abort all existing events - for (EventList::iterator i = m_events.begin(); i != m_events.end(); ) + for (EventList::iterator i = m_events.begin(); i != m_events.end();) { EventList::iterator i_old = i; ++i; diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 97b8aa0c928..e79290b5168 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -428,16 +428,14 @@ void BattleGround::Update(uint32 diff) plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION); // remove auras with duration lower than 30s Unit::AuraMap & aurMap = plr->GetAuras(); - for (Unit::AuraMap::iterator iter = aurMap.begin(); iter != aurMap.end(); ) + for (Unit::AuraMap::iterator iter = aurMap.begin(); iter != aurMap.end();) { if (!iter->second->IsPermanent() && iter->second->GetAuraDuration()<=30*IN_MILISECONDS && iter->second->IsPositive() && (!(iter->second->GetSpellProto()->Attributes & SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY)) && (!iter->second->IsAuraType(SPELL_AURA_MOD_INVISIBILITY))) - { plr->RemoveAura(iter); - } else ++iter; } diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 49d24fd2809..b697b8bbc9b 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -1132,9 +1132,9 @@ BattleGroundMgr::~BattleGroundMgr() void BattleGroundMgr::DeleteAllBattleGrounds() { - for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++) + for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i) { - for (BattleGroundSet::iterator itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end(); ) + for (BattleGroundSet::iterator itr = m_BattleGrounds[i].begin(); itr != m_BattleGrounds[i].end();) { BattleGround * bg = itr->second; m_BattleGrounds[i].erase(itr++); @@ -1157,7 +1157,7 @@ void BattleGroundMgr::DeleteAllBattleGrounds() void BattleGroundMgr::Update(uint32 diff) { BattleGroundSet::iterator itr, next; - for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++) + for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i) { itr = m_BattleGrounds[i].begin(); // skip updating battleground template @@ -1530,7 +1530,7 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI // the following works, because std::set is default ordered with "<" // the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable uint32 lastId = 0; - for (std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][queue_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][queue_id].end(); ) + for (std::set<uint32>::iterator itr = m_ClientBattleGroundIds[bgTypeId][queue_id].begin(); itr != m_ClientBattleGroundIds[bgTypeId][queue_id].end();) { if( (++lastId) != *itr) //if there is a gap between the ids, we will break.. break; diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 93e1e8a85bb..c8538a53afe 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -837,7 +837,7 @@ bool ChatHandler::hasStringAbbr(const char* name, const char* part) if (!*part) return false; - for (; ; ) + for (;;) { if (!*part) return true; diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index 77661def698..44eba0e8ccd 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -675,7 +675,7 @@ void WorldSession::HandleTextEmoteOpcode( WorldPacket & recv_data ) GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, text_emote, 0, unit); //Send scripted event call - if (unit && unit->GetTypeId()==TYPEID_UNIT && ((Creature*)unit)->AI()) + if (unit && unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->AI()) ((Creature*)unit)->AI()->ReceiveEmote(GetPlayer(),text_emote); } diff --git a/src/game/Formulas.h b/src/game/Formulas.h index 41e75905df2..0f98a9873ce 100644 --- a/src/game/Formulas.h +++ b/src/game/Formulas.h @@ -112,7 +112,7 @@ namespace Trinity inline uint32 Gain(Player *pl, Unit *u) { - if (u->GetTypeId()==TYPEID_UNIT && ( + if (u->GetTypeId() == TYPEID_UNIT && ( ((Creature*)u)->isTotem() || ((Creature*)u)->isPet() || (((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) )) return 0; diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 42c4960f90c..424be2121d2 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -792,7 +792,7 @@ namespace Trinity if(!u->isAlive()) return false; - if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isTotem()) + if(u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isTotem()) return false; return i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u); @@ -910,7 +910,7 @@ namespace Trinity // Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems if (!u->isTargetableForAttack()) return false; - if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isTotem()) + if(u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isTotem()) return false; if(( i_targetForPlayer ? !i_funit->IsFriendlyTo(u) : i_funit->IsHostileTo(u) )&& i_obj->IsWithinDistInMap(u, i_range)) diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index b15b57eff29..fd73119f0d3 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -151,7 +151,7 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target) if(!target->isAlive() || target->isInFlight() ) return; - if(target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->isTotem()) + if(target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->isTotem()) return; if (!i_dynobject.IsWithinDistInMap(target, i_dynobject.GetRadius())) @@ -162,7 +162,7 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target) return; // Evade target - if( target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->IsInEvadeMode() ) + if( target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->IsInEvadeMode() ) return; //Check player targets and remove if in GM mode or GM invisibility (for not self casting case) diff --git a/src/game/Group.cpp b/src/game/Group.cpp index c7a18d638f0..56a2539a798 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -1164,7 +1164,7 @@ void Group::_setLeader(const uint64 &guid) { for (uint8 i = 0; i < TOTAL_DIFFICULTIES; ++i) { - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ) + for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end();) { if(itr->second.perm) { @@ -1487,7 +1487,7 @@ void Group::ResetInstances(uint8 method, Player* SendMsgTo) // we assume that when the difficulty changes, all instances that can be reset will be uint8 dif = GetDifficulty(); - for (BoundInstancesMap::iterator itr = m_boundInstances[dif].begin(); itr != m_boundInstances[dif].end(); ) + for (BoundInstancesMap::iterator itr = m_boundInstances[dif].begin(); itr != m_boundInstances[dif].end();) { InstanceSave *p = itr->second.save; const MapEntry *entry = sMapStore.LookupEntry(itr->first); diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index c53a51fb40d..a39dff1183d 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -1720,7 +1720,7 @@ Item* Guild::StoreItem(uint8 tabId, GuildItemPosCountVec const& dest, Item* pIte Item* lastItem = pItem; - for (GuildItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ) + for (GuildItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end();) { uint8 slot = itr->Slot; uint32 count = itr->Count; diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index 667cd289c77..8c1aab1b60b 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -627,7 +627,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe } // remove all binds to instances of the given map - for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end(); ) + for (InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end();) { if(itr->second->GetMapId() == mapid) _ResetSave(itr); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 235086cda71..9b61f03e3f2 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -6457,7 +6457,7 @@ bool ChatHandler::HandleMovegensCommand(const char* /*args*/) break; } case HOME_MOTION_TYPE: - if(unit->GetTypeId()==TYPEID_UNIT) + if(unit->GetTypeId() == TYPEID_UNIT) { float x,y,z; mg->GetDestination(x,y,z); @@ -6838,7 +6838,7 @@ bool ChatHandler::HandleInstanceUnbindCommand(const char *args) for (uint8 i = 0; i < TOTAL_DIFFICULTIES; ++i) { Player::BoundInstancesMap &binds = player->GetBoundInstances(i); - for (Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end(); ) + for (Player::BoundInstancesMap::iterator itr = binds.begin(); itr != binds.end();) { if(itr->first != player->GetMapId()) { diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 0093066bd1f..d45cdab6f0c 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -768,7 +768,7 @@ void Map::Update(const uint32 &t_diff) // non-player active objects if (!m_activeNonPlayers.empty()) { - for (m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end(); ) + for (m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end();) { // skip not in world WorldObject* obj = *m_activeNonPlayersIter; @@ -1220,7 +1220,7 @@ void Map::UnloadAll() // clear all delayed moves, useless anyway do this moves before map unload. i_creaturesToMove.clear(); - for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end(); ) + for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end();) { NGridType &grid(*i->getSource()); ++i; @@ -2268,7 +2268,7 @@ void Map::DelayedUpdate(const uint32 t_diff) // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended if (!IsBattleGroundOrArena()) { - for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end(); ) + for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end();) { NGridType *grid = i->getSource(); GridInfo *info = i->getSource()->getGridInfoRef(); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 0a571d67dc0..bfca0c91861 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1783,7 +1783,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy { // Remove Demonic Sacrifice auras (known pet) Unit::AuraEffectList const& auraClassScripts = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr!=auraClassScripts.end(); ) + for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr!=auraClassScripts.end();) { if((*itr)->GetMiscValue()==2228) { @@ -1864,7 +1864,7 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy { // Remove Demonic Sacrifice auras (known pet) Unit::AuraEffectList const& auraClassScripts = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); - for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr!=auraClassScripts.end(); ) + for (Unit::AuraEffectList::const_iterator itr = auraClassScripts.begin(); itr!=auraClassScripts.end();) { if((*itr)->GetMiscValue()==2228) { @@ -1903,7 +1903,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float return NULL; } go->SetRespawnTime(respawnTime); - if(GetTypeId() == TYPEID_PLAYER || GetTypeId()==TYPEID_UNIT) //not sure how to handle this + if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) //not sure how to handle this ((Unit*)this)->AddGameObject(go); else go->SetSpawnedByDefault(false); @@ -1920,7 +1920,7 @@ Creature* WorldObject::SummonTrigger(float x, float y, float z, float ang, uint3 return NULL; //summon->SetName(GetName()); - if(GetTypeId() == TYPEID_PLAYER || GetTypeId()==TYPEID_UNIT) + if(GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) { summon->setFaction(((Unit*)this)->getFaction()); summon->SetLevel(((Unit*)this)->getLevel()); diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp index 9a8d89d1120..df95eccbb3b 100644 --- a/src/game/ObjectGridLoader.cpp +++ b/src/game/ObjectGridLoader.cpp @@ -54,7 +54,7 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m) // creature in unloading grid can have respawn point in another grid // if it will be unloaded then it will not respawn in original grid until unload/load original grid // move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn. - for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ) + for (CreatureMapType::iterator iter = m.begin(); iter != m.end();) { Creature * c = iter->getSource(); ++iter; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 4ac56042275..830df309021 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -3399,7 +3399,7 @@ void ObjectMgr::LoadGroups() // clean groups // TODO: maybe delete from the DB before loading in this case - for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ) + for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end();) { if((*itr)->GetMembersCount() < 2) { @@ -7372,7 +7372,7 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi } // cleanup affected map part for reloading case - for (TrinityStringLocaleMap::iterator itr = mTrinityStringLocaleMap.begin(); itr != mTrinityStringLocaleMap.end(); ) + for (TrinityStringLocaleMap::iterator itr = mTrinityStringLocaleMap.begin(); itr != mTrinityStringLocaleMap.end();) { if (itr->first >= start_value && itr->first < end_value) mTrinityStringLocaleMap.erase(itr++); diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp index de9eb1f0cb5..5b10fda7549 100644 --- a/src/game/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP.cpp @@ -275,7 +275,7 @@ bool OPvPCapturePoint::Update(uint32 diff) for (uint32 team = 0; team < 2; ++team) { - for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end(); ) + for (PlayerSet::iterator itr = m_activePlayers[team].begin(); itr != m_activePlayers[team].end();) { Player *player = *itr; ++itr; diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index f0f04031967..446625bda2b 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -1093,7 +1093,7 @@ void Pet::_SaveSpellCooldowns() time_t curTime = time(NULL); // remove oudated and save active - for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end(); ) + for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();) { if (itr->second <= curTime) m_CreatureSpellCooldowns.erase(itr++); @@ -1575,7 +1575,7 @@ bool Pet::resetTalents(bool no_cost) for (uint8 j = 0; j < MAX_TALENT_RANK; ++j) { - for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ) + for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end();) { if (itr->second.state == PETSPELL_REMOVED) { @@ -1865,7 +1865,7 @@ void Pet::CastPetAuras(bool current) if (!IsPermanentPetFor((Player*)owner)) return; - for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); ) + for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();) { PetAura const* pa = *itr; ++itr; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 8feeb0faaf2..cd9a2adc480 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3608,7 +3608,7 @@ void Player::RemoveSpellCategoryCooldown(uint32 cat, bool update /* = false */) return; const SpellCategorySet& ct_set = ct->second; - for (SpellCooldowns::const_iterator i = m_spellCooldowns.begin(); i != m_spellCooldowns.end(); ) + for (SpellCooldowns::const_iterator i = m_spellCooldowns.begin(); i != m_spellCooldowns.end();) { if (ct_set.find(i->first) != ct_set.end()) RemoveSpellCooldown((i++)->first, update); @@ -3695,7 +3695,7 @@ void Player::_SaveSpellCooldowns() time_t infTime = curTime + infinityCooldownDelayCheck; // remove outdated and save active - for (SpellCooldowns::iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ) + for (SpellCooldowns::iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end();) { if(itr->second.end <= curTime) m_spellCooldowns.erase(itr++); @@ -6806,7 +6806,7 @@ void Player::DuelComplete(DuelCompleteType type) /* remove auras */ AuraMap &itsAuras = duel->opponent->GetAuras(); - for (AuraMap::iterator i = itsAuras.begin(); i != itsAuras.end(); ) + for (AuraMap::iterator i = itsAuras.begin(); i != itsAuras.end();) { if (!i->second->IsPositive() && i->second->GetCasterGUID() == GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) duel->opponent->RemoveAura(i); @@ -6815,7 +6815,7 @@ void Player::DuelComplete(DuelCompleteType type) } AuraMap &myAuras = GetAuras(); - for (AuraMap::iterator i = myAuras.begin(); i != myAuras.end(); ) + for (AuraMap::iterator i = myAuras.begin(); i != myAuras.end();) { if (!i->second->IsPositive() && i->second->GetCasterGUID() == duel->opponent->GetGUID() && i->second->GetAuraApplyTime() >= duel->startTime) RemoveAura(i); @@ -10799,7 +10799,7 @@ Item* Player::StoreItem( ItemPosCountVec const& dest, Item* pItem, bool update ) Item* lastItem = pItem; uint32 entry = pItem->GetEntry(); - for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ) + for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end();) { uint16 pos = itr->pos; uint32 count = itr->count; @@ -12099,7 +12099,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) sLog.outDebug("Player::UpdateItemDuration(%u,%u)", time, realtimeonly); - for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ) + for (ItemDurationList::const_iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end();) { Item* item = *itr; ++itr; // current element can be erased in UpdateDuration @@ -12148,7 +12148,7 @@ void Player::AddEnchantmentDurations(Item *item) void Player::RemoveEnchantmentDurations(Item *item) { - for (EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ) + for (EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end();) { if (itr->item == item) { @@ -16470,7 +16470,7 @@ void Player::SaveGoldToDB() void Player::_SaveActions() { - for (ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end(); ) + for (ActionButtonList::iterator itr = m_actionButtons.begin(); itr != m_actionButtons.end();) { switch (itr->second.uState) { @@ -16635,7 +16635,7 @@ void Player::_SaveMail() } //deallocate deleted mails... - for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end(); ) + for (PlayerMails::iterator itr = m_mail.begin(); itr != m_mail.end();) { if ((*itr)->state == MAIL_STATE_DELETED) { @@ -16693,7 +16693,7 @@ void Player::_SaveDailyQuestStatus() void Player::_SaveSpells() { - for (PlayerSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end(); ) + for (PlayerSpellMap::iterator itr = m_spells.begin(), next = m_spells.begin(); itr != m_spells.end();) { if (itr->second->state == PLAYERSPELL_REMOVED || itr->second->state == PLAYERSPELL_CHANGED) CharacterDatabase.PExecute("DELETE FROM character_spell WHERE guid = '%u' and spell = '%u'", GetGUIDLow(), itr->first); @@ -16939,7 +16939,7 @@ void Player::ResetInstances(uint8 method) // we assume that when the difficulty changes, all instances that can be reset will be uint8 dif = GetDifficulty(); - for (BoundInstancesMap::iterator itr = m_boundInstances[dif].begin(); itr != m_boundInstances[dif].end(); ) + for (BoundInstancesMap::iterator itr = m_boundInstances[dif].begin(); itr != m_boundInstances[dif].end();) { InstanceSave *p = itr->second.save; const MapEntry *entry = sMapStore.LookupEntry(itr->first); @@ -17557,7 +17557,7 @@ void Player::RemoveSpellMods(Spell * spell) std::set <Aura *> checkedSpells; AuraEffectList const & auraList = GetAurasByType(SPELL_AURA_ABILITY_IGNORE_AURASTATE); - for (AuraEffectList::const_iterator itr = auraList.begin(); itr != auraList.end(); ) + for (AuraEffectList::const_iterator itr = auraList.begin(); itr != auraList.end();) { AuraEffect * aur = *itr; ++itr; @@ -17586,7 +17586,7 @@ void Player::RemoveSpellMods(Spell * spell) for (uint8 i=0; i<MAX_SPELLMOD; ++i) { - for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end(); ) + for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();) { SpellModifier *mod = *itr; ++itr; @@ -20046,7 +20046,7 @@ bool Player::CanNoReagentCast(SpellEntry const* spellInfo) const void Player::RemoveItemDependentAurasAndCasts( Item * pItem ) { AuraMap& auras = GetAuras(); - for (AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) + for (AuraMap::iterator itr = auras.begin(); itr != auras.end();) { Aura* aura = itr->second; @@ -20208,7 +20208,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) if(pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse()) { // normal creature (not pet/etc) can be only in !PvP case - if(pVictim->GetTypeId()==TYPEID_UNIT) + if(pVictim->GetTypeId() == TYPEID_UNIT) pGroupGuy->KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetGUID()); } } @@ -20239,7 +20239,7 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim) pet->GivePetXP(xp); // normal creature (not pet/etc) can be only in !PvP case - if(pVictim->GetTypeId()==TYPEID_UNIT) + if(pVictim->GetTypeId() == TYPEID_UNIT) KilledMonster(((Creature*)pVictim)->GetCreatureInfo(), pVictim->GetGUID()); } } @@ -20356,7 +20356,7 @@ void Player::UpdateZoneDependentAuras( uint32 newZone ) void Player::UpdateAreaDependentAuras( uint32 newArea ) { // remove auras from spells with area limitations - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) { // use m_zoneUpdateId for speed: UpdateArea called from UpdateZone or instead UpdateZone in both cases m_zoneUpdateId up-to-date if(spellmgr.GetSpellAllowedInLocationError(iter->second->GetSpellProto(),GetMapId(),m_zoneUpdateId,newArea,this) != SPELL_CAST_OK) @@ -21780,7 +21780,7 @@ void Player::SetEquipmentSet(uint32 index, EquipmentSet eqset) void Player::_SaveEquipmentSets() { - for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ) + for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end();) { uint32 index = itr->first; EquipmentSet& eqset = itr->second; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 9ec20a11c40..ad2fadab592 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -725,7 +725,7 @@ void Spell::SelectSpellTargets() else if (m_auraScaleMask) { bool checkLvl = !m_UniqueTargetInfo.empty(); - for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ) + for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end();) { // remove targets which did not pass min level check if(m_auraScaleMask && ihit->effectMask == m_auraScaleMask) @@ -834,7 +834,7 @@ void Spell::prepareDataForTriggerSystem(AuraEffect * triggeredByAura) m_procEx |= PROC_EX_INTERNAL_TRIGGERED; } // Totem casts require spellfamilymask defined in spell_proc_event to proc - if (m_originalCaster && m_caster != m_originalCaster && m_caster->GetTypeId()==TYPEID_UNIT && ((Creature*)m_caster)->isTotem() && m_caster->IsControlledByPlayer()) + if (m_originalCaster && m_caster != m_originalCaster && m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isTotem() && m_caster->IsControlledByPlayer()) { m_procEx |= PROC_EX_INTERNAL_REQ_FAMILY; } @@ -2298,7 +2298,7 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur) if (!(m_targets.getUnitTarget() && (m_targets.getUnitTarget()->GetEntry() == 26125 && m_targets.getUnitTarget()->GetOwnerGUID() == m_caster->GetGUID() || (m_targets.getUnitTarget()->getDeathState() == CORPSE && m_targets.getUnitTarget()->GetDisplayId() == m_targets.getUnitTarget()->GetNativeDisplayId() - && m_targets.getUnitTarget()->GetTypeId()== TYPEID_UNIT + && m_targets.getUnitTarget()->GetTypeId() == TYPEID_UNIT && !((Creature*)m_targets.getUnitTarget())->isDeadByDefault() && !(m_targets.getUnitTarget()->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL)) && m_targets.getUnitTarget()->GetDisplayId() == m_targets.getUnitTarget()->GetNativeDisplayId()))) @@ -3324,7 +3324,7 @@ void Spell::finish(bool ok) if(!ok) return; - if (m_caster->GetTypeId()==TYPEID_UNIT && ((Creature*)m_caster)->isSummon()) + if (m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->isSummon()) { // Unsummon statue uint32 spell = m_caster->GetUInt32Value(UNIT_CREATED_BY_SPELL); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 93ad35d7dbc..15893c51adb 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -3899,7 +3899,7 @@ void AuraEffect::HandleChannelDeathItem(bool apply, bool Real, bool /*changeAmou // Soul Shard only from non-grey units if( spellInfo->EffectItemType[m_effIndex] == 6265 && (victim->getLevel() <= Trinity::XP::GetGrayLevel(caster->getLevel()) || - victim->GetTypeId()==TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) ) + victim->GetTypeId() == TYPEID_UNIT && !((Player*)caster)->isAllowedToLoot((Creature*)victim)) ) return; //Adding items uint32 noSpaceForCount = 0; @@ -4476,7 +4476,7 @@ void AuraEffect::HandleModMechanicImmunity(bool apply, bool Real, bool /*changeA if(apply && GetSpellProto()->AttributesEx & SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) { Unit::AuraMap& Auras = m_target->GetAuras(); - for (Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ) + for (Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end();) { SpellEntry const *spell = iter->second->GetSpellProto(); if (spell->Id != GetId()) @@ -4557,7 +4557,7 @@ void AuraEffect::HandleAuraModSchoolImmunity(bool apply, bool Real, bool /*chang { uint32 school_mask = GetMiscValue(); Unit::AuraMap& Auras = m_target->GetAuras(); - for (Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ) + for (Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end();) { SpellEntry const *spell = iter->second->GetSpellProto(); if((GetSpellSchoolMask(spell) & school_mask)//Check for school mask diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 1b84686ae9b..3712e1a1140 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1438,7 +1438,7 @@ void Spell::EffectDummy(uint32 i) // immediately finishes the cooldown on Frost spells const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap(); - for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end(); ) + for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); @@ -1696,7 +1696,7 @@ void Spell::EffectDummy(uint32 i) //immediately finishes the cooldown on certain Rogue abilities const SpellCooldowns& cm = ((Player *)m_caster)->GetSpellCooldownMap(); - for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end(); ) + for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); @@ -1739,7 +1739,7 @@ void Spell::EffectDummy(uint32 i) // immediately finishes the cooldown on your other Hunter abilities except Bestial Wrath const SpellCooldowns& cm = ((Player*)m_caster)->GetSpellCooldownMap(); - for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end(); ) + for (SpellCooldowns::const_iterator itr = cm.begin(); itr != cm.end();) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); @@ -2145,7 +2145,7 @@ void Spell::EffectDummy(uint32 i) // So called only for not proccessed cases if(gameObjTarget) Script->EffectDummyGameObj(m_caster, m_spellInfo->Id, i, gameObjTarget); - else if(unitTarget && unitTarget->GetTypeId()==TYPEID_UNIT) + else if(unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT) Script->EffectDummyCreature(m_caster, m_spellInfo->Id, i, (Creature*)unitTarget); else if(itemTarget) Script->EffectDummyItem(m_caster, m_spellInfo->Id, i, itemTarget); @@ -2337,7 +2337,7 @@ void Spell::EffectTriggerSpell(uint32 effIndex) { uint32 dispelMask = GetDispellMask(DISPEL_ALL); Unit::AuraMap& Auras = unitTarget->GetAuras(); - for (Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end(); ) + for (Unit::AuraMap::iterator iter = Auras.begin(); iter != Auras.end();) { // remove all harmful spells on you... SpellEntry const* spell = iter->second->GetSpellProto(); @@ -5772,7 +5772,7 @@ void Spell::EffectScriptEffect(uint32 effIndex) case 55709: { int pct = 100; - if (unitTarget->GetTypeId()==TYPEID_UNIT && ((Creature*)unitTarget)->isPet()) + if (unitTarget->GetTypeId() == TYPEID_UNIT && ((Creature*)unitTarget)->isPet()) if (Unit* owner = ((Creature*)unitTarget)->GetOwner()) owner->CastCustomSpell(unitTarget, 54114, &pct, NULL, NULL, true); break; diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 119412da607..21e9b4e8702 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -3202,7 +3202,7 @@ void SpellMgr::LoadSpellEnchantProcData() mSpellEnchantProcEventMap[enchantId] = spe; ++count; - } while( result->NextRow() ); + } while(result->NextRow()); delete result; @@ -3218,17 +3218,17 @@ void SpellMgr::LoadSpellRequired() if(result == NULL) { - barGoLink bar( 1 ); + barGoLink bar(1); bar.step(); sLog.outString(); - sLog.outString( ">> Loaded 0 spell required records" ); + sLog.outString(">> Loaded 0 spell required records"); sLog.outErrorDb("`spell_required` table is empty!"); return; } uint32 rows = 0; - barGoLink bar( result->GetRowCount() ); + barGoLink bar(result->GetRowCount()); do { bar.step(); @@ -3240,7 +3240,7 @@ void SpellMgr::LoadSpellRequired() mSpellsReqSpell.insert (std::pair<uint32, uint32>(spell_req, spell_id)); mSpellReq[spell_id] = spell_req; ++rows; - } while( result->NextRow() ); + } while (result->NextRow()); delete result; sLog.outString(); @@ -3266,19 +3266,19 @@ struct SpellRankEntry bool operator < (const SpellRankEntry & _Right) const { return (SkillId != _Right.SkillId ? SkillId < _Right.SkillId - : SpellName!=_Right.SpellName ? SpellName < _Right.SpellName - : ProcFlags!=_Right.ProcFlags ? ProcFlags < _Right.ProcFlags - - : Effect!=_Right.Effect ? Effect < _Right.Effect - : Aura!=_Right.Aura ? Aura < _Right.Aura - : TalentID!=_Right.TalentID ? TalentID < _Right.TalentID - : (CastingTimeIndex!=_Right.CastingTimeIndex) && (!CastingTimeIndex || !_Right.CastingTimeIndex || CastingTimeIndex==1 || !_Right.CastingTimeIndex==1) ? CastingTimeIndex < _Right.CastingTimeIndex - - : SpellFamilyFlags!=_Right.SpellFamilyFlags ? SpellFamilyFlags < _Right.SpellFamilyFlags - : (SpellVisual!=_Right.SpellVisual) && (!SpellVisual || !_Right.SpellVisual) ? SpellVisual < _Right.SpellVisual - : (ManaCost!=_Right.ManaCost) && (!ManaCost || !_Right.ManaCost) ? ManaCost < _Right.ManaCost - : (DurationIndex!=_Right.DurationIndex) && (!DurationIndex || !_Right.DurationIndex)? DurationIndex < _Right.DurationIndex - : (RangeIndex!=_Right.RangeIndex) && (!RangeIndex || !_Right.RangeIndex || RangeIndex==1 || !_Right.RangeIndex==1) ? RangeIndex < _Right.RangeIndex + : SpellName != _Right.SpellName ? SpellName < _Right.SpellName + : ProcFlags != _Right.ProcFlags ? ProcFlags < _Right.ProcFlags + + : Effect != _Right.Effect ? Effect < _Right.Effect + : Aura != _Right.Aura ? Aura < _Right.Aura + : TalentID != _Right.TalentID ? TalentID < _Right.TalentID + : (CastingTimeIndex != _Right.CastingTimeIndex) && (!CastingTimeIndex || !_Right.CastingTimeIndex || CastingTimeIndex == 1 || !_Right.CastingTimeIndex == 1) ? CastingTimeIndex < _Right.CastingTimeIndex + + : SpellFamilyFlags != _Right.SpellFamilyFlags ? SpellFamilyFlags < _Right.SpellFamilyFlags + : (SpellVisual != _Right.SpellVisual) && (!SpellVisual || !_Right.SpellVisual) ? SpellVisual < _Right.SpellVisual + : (ManaCost != _Right.ManaCost) && (!ManaCost || !_Right.ManaCost) ? ManaCost < _Right.ManaCost + : (DurationIndex != _Right.DurationIndex) && (!DurationIndex || !_Right.DurationIndex)? DurationIndex < _Right.DurationIndex + : (RangeIndex != _Right.RangeIndex) && (!RangeIndex || !_Right.RangeIndex || RangeIndex == 1 || !_Right.RangeIndex == 1) ? RangeIndex < _Right.RangeIndex : TargetAuraState < _Right.TargetAuraState ); } @@ -3296,7 +3296,7 @@ void SpellMgr::LoadSpellChains() mSpellChains.clear(); // need for reload case std::vector<uint32> ChainedSpells; - for (uint32 ability_id=0; ability_id<sSkillLineAbilityStore.GetNumRows(); ability_id++) + for (uint32 ability_id = 0; ability_id < sSkillLineAbilityStore.GetNumRows(); ++ability_id) { SkillLineAbilityEntry const *AbilityInfo=sSkillLineAbilityStore.LookupEntry(ability_id); if (!AbilityInfo) @@ -3308,24 +3308,24 @@ void SpellMgr::LoadSpellChains() std::multimap<SpellRankEntry, SpellRankValue> RankMap; - for (uint32 ability_id=0; ability_id<sSkillLineAbilityStore.GetNumRows(); ability_id++) + for (uint32 ability_id = 0; ability_id < sSkillLineAbilityStore.GetNumRows(); ++ability_id) { SkillLineAbilityEntry const *AbilityInfo=sSkillLineAbilityStore.LookupEntry(ability_id); if (!AbilityInfo) continue; //get only spell with lowest ability_id to prevent doubles - uint32 spell_id=AbilityInfo->spellId; - bool found=false; - for (uint32 i=0; i<ChainedSpells.size(); i++) + uint32 spell_id = AbilityInfo->spellId; + bool found = false; + for (uint32 i = 0; i < ChainedSpells.size(); ++i) { - if (ChainedSpells.at(i)==spell_id) - found=true; + if (ChainedSpells.at(i) == spell_id) + found = true; } if (found) continue; - if(mSkillLineAbilityMap.lower_bound(spell_id)->second->id!=ability_id) + if(mSkillLineAbilityMap.lower_bound(spell_id)->second->id != ability_id) continue; SpellEntry const *SpellInfo=sSpellStore.LookupEntry(spell_id); if (!SpellInfo) @@ -3334,31 +3334,31 @@ void SpellMgr::LoadSpellChains() if(sRank.empty()) continue; //exception to polymorph spells-make pig and turtle other chain than sheep - if ((SpellInfo->SpellFamilyName==SPELLFAMILY_MAGE) && (SpellInfo->SpellFamilyFlags[0] & 0x1000000) && (SpellInfo->SpellIconID!=82)) + if (SpellInfo->SpellFamilyName == SPELLFAMILY_MAGE && (SpellInfo->SpellFamilyFlags[0] & 0x1000000) && SpellInfo->SpellIconID != 82) continue; SpellRankEntry entry; SpellRankValue value; - entry.SkillId=AbilityInfo->skillId; - entry.SpellName=SpellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; - entry.DurationIndex=SpellInfo->DurationIndex; - entry.RangeIndex=SpellInfo->rangeIndex; - entry.ProcFlags=SpellInfo->procFlags; - entry.SpellFamilyFlags=SpellInfo->SpellFamilyFlags; - entry.TargetAuraState=SpellInfo->TargetAuraState; - entry.SpellVisual=SpellInfo->SpellVisual[0]; - entry.ManaCost=SpellInfo->manaCost; - entry.CastingTimeIndex=0; - entry.TalentID=0; - for (; ; ) - { - AbilityInfo=mSkillLineAbilityMap.lower_bound(spell_id)->second; - value.Id=spell_id; - value.Rank=SpellInfo->Rank[sWorld.GetDefaultDbcLocale()]; - value.strict=false; + entry.SkillId = AbilityInfo->skillId; + entry.SpellName = SpellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; + entry.DurationIndex = SpellInfo->DurationIndex; + entry.RangeIndex = SpellInfo->rangeIndex; + entry.ProcFlags = SpellInfo->procFlags; + entry.SpellFamilyFlags = SpellInfo->SpellFamilyFlags; + entry.TargetAuraState = SpellInfo->TargetAuraState; + entry.SpellVisual = SpellInfo->SpellVisual[0]; + entry.ManaCost = SpellInfo->manaCost; + entry.CastingTimeIndex = 0; + entry.TalentID = 0; + for (;;) + { + AbilityInfo = mSkillLineAbilityMap.lower_bound(spell_id)->second; + value.Id = spell_id; + value.Rank = SpellInfo->Rank[sWorld.GetDefaultDbcLocale()]; + value.strict = false; RankMap.insert(std::pair<SpellRankEntry, SpellRankValue>(entry,value)); - spell_id=AbilityInfo->forward_spellid; - SpellInfo=sSpellStore.LookupEntry(spell_id); + spell_id = AbilityInfo->forward_spellid; + SpellInfo = sSpellStore.LookupEntry(spell_id); if (!SpellInfo) break; } @@ -3366,117 +3366,117 @@ void SpellMgr::LoadSpellChains() barGoLink bar(RankMap.size()); - uint32 count=0; + uint32 count = 0; - for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr = RankMap.begin(); itr!=RankMap.end(); ) + for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr = RankMap.begin(); itr!=RankMap.end();) { - SpellRankEntry entry=itr->first; + SpellRankEntry entry = itr->first; //trac errors in extracted data std::multimap<char const *, std::multimap<SpellRankEntry, SpellRankValue>::iterator> RankErrorMap; - for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr2 = RankMap.lower_bound(entry); itr2!=RankMap.upper_bound(entry); itr2++) + for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr2 = RankMap.lower_bound(entry); itr2 != RankMap.upper_bound(entry); ++itr2) { bar.step(); RankErrorMap.insert(std::pair<char const *, std::multimap<SpellRankEntry, SpellRankValue>::iterator>(itr2->second.Rank,itr2)); } - bool error=false; + bool error = false; //if strict == true strict check is not needed if (!itr->second.strict) //check for rank duplicates, if there are any do strict check - for (std::multimap<char const *, std::multimap<SpellRankEntry, SpellRankValue>::iterator>::iterator itr2 = RankErrorMap.begin(); itr2!=RankErrorMap.end(); ) + for (std::multimap<char const *, std::multimap<SpellRankEntry, SpellRankValue>::iterator>::iterator itr2 = RankErrorMap.begin(); itr2!=RankErrorMap.end();) { - char const * err_entry=itr2->first; + char const *err_entry = itr2->first; uint32 rank_count=RankErrorMap.count(itr2->first); - if (rank_count>1) + if (rank_count > 1) { - error=true; + error = true; break; } else - itr2++; + ++itr2; } - bool allHaveTalents=true; + bool allHaveTalents = true; if (error) { std::list<uint32> ConflictedSpells; - for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr2 = RankMap.lower_bound(entry); itr2!=RankMap.upper_bound(entry); itr2=RankMap.lower_bound(entry)) + for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr2 = RankMap.lower_bound(entry); itr2 != RankMap.upper_bound(entry); itr2 = RankMap.lower_bound(entry)) { ConflictedSpells.push_back(itr2->second.Id); if (!GetTalentSpellPos(itr2->second.Id)) - allHaveTalents=false; + allHaveTalents = false; RankMap.erase(itr2); } SpellRankEntry nextEntry, currEntry; for (; !ConflictedSpells.empty(); ConflictedSpells.pop_front()) { - SpellEntry const *SpellInfo=sSpellStore.LookupEntry(ConflictedSpells.front()); - currEntry.SkillId=entry.SkillId; - currEntry.SpellName=SpellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; - currEntry.DurationIndex=SpellInfo->DurationIndex; - currEntry.RangeIndex=SpellInfo->rangeIndex; - currEntry.ProcFlags=SpellInfo->procFlags; - currEntry.SpellFamilyFlags=SpellInfo->SpellFamilyFlags; + SpellEntry const *SpellInfo = sSpellStore.LookupEntry(ConflictedSpells.front()); + currEntry.SkillId = entry.SkillId; + currEntry.SpellName = SpellInfo->SpellName[sWorld.GetDefaultDbcLocale()]; + currEntry.DurationIndex = SpellInfo->DurationIndex; + currEntry.RangeIndex = SpellInfo->rangeIndex; + currEntry.ProcFlags = SpellInfo->procFlags; + currEntry.SpellFamilyFlags = SpellInfo->SpellFamilyFlags; //compare talents only when all spells from chain have entry //to prevent wrong results with spells which have first rank talented and other not if (allHaveTalents) currEntry.TalentID=GetTalentSpellPos(ConflictedSpells.front())->talent_id; else - currEntry.TalentID=0; - currEntry.TargetAuraState=SpellInfo->TargetAuraState; - currEntry.SpellVisual=SpellInfo->SpellVisual[0]; - currEntry.ManaCost=SpellInfo->manaCost; + currEntry.TalentID = 0; + currEntry.TargetAuraState = SpellInfo->TargetAuraState; + currEntry.SpellVisual = SpellInfo->SpellVisual[0]; + currEntry.ManaCost = SpellInfo->manaCost; //compare effects and casting time - currEntry.CastingTimeIndex=SpellInfo->CastingTimeIndex; - currEntry.Effect[0]=SpellInfo->Effect[0]; - currEntry.Effect[1]=SpellInfo->Effect[1]; - currEntry.Effect[2]=SpellInfo->Effect[2]; + currEntry.CastingTimeIndex = SpellInfo->CastingTimeIndex; + currEntry.Effect[0] = SpellInfo->Effect[0]; + currEntry.Effect[1] = SpellInfo->Effect[1]; + currEntry.Effect[2] = SpellInfo->Effect[2]; - currEntry.Aura[0]=SpellInfo->EffectApplyAuraName[0]; - currEntry.Aura[1]=SpellInfo->EffectApplyAuraName[1]; - currEntry.Aura[2]=SpellInfo->EffectApplyAuraName[2]; + currEntry.Aura[0] = SpellInfo->EffectApplyAuraName[0]; + currEntry.Aura[1] = SpellInfo->EffectApplyAuraName[1]; + currEntry.Aura[2] = SpellInfo->EffectApplyAuraName[2]; SpellRankValue currValue; - currValue.Id=ConflictedSpells.front(); - currValue.Rank=SpellInfo->Rank[sWorld.GetDefaultDbcLocale()]; - currValue.strict=true; + currValue.Id = ConflictedSpells.front(); + currValue.Rank = SpellInfo->Rank[sWorld.GetDefaultDbcLocale()]; + currValue.strict = true; RankMap.insert(std::pair<SpellRankEntry, SpellRankValue>(currEntry,currValue)); } - itr=RankMap.begin(); + itr = RankMap.begin(); continue; } else - for (std::multimap<char const *, std::multimap<SpellRankEntry, SpellRankValue>::iterator>::iterator itr2 = RankErrorMap.begin(); itr2!=RankErrorMap.end(); ) + for (std::multimap<char const *, std::multimap<SpellRankEntry, SpellRankValue>::iterator>::iterator itr2 = RankErrorMap.begin(); itr2!=RankErrorMap.end();) { - char const * err_entry=itr2->first; - uint32 rank_count=RankErrorMap.count(itr2->first); - if (rank_count>1) - for (itr2 = RankErrorMap.lower_bound(err_entry); itr2!=RankErrorMap.upper_bound(err_entry); itr2++) + char const *err_entry = itr2->first; + uint32 rank_count = RankErrorMap.count(itr2->first); + if (rank_count > 1) + for (itr2 = RankErrorMap.lower_bound(err_entry); itr2 != RankErrorMap.upper_bound(err_entry); ++itr2) { sLog.outDebug("There is a duplicate rank entry (%s) for spell: %u",itr2->first,itr2->second->second.Id); - if (!(itr2->second->second.Id==47541 || itr2->second->second.Id==45902 || itr2->second->second.Id==7620)) + if (itr2->second->second.Id != 47541 && itr2->second->second.Id != 45902 && itr2->second->second.Id != 7620) { sLog.outDebug("Spell %u removed from chain data.",itr2->second->second.Id); RankMap.erase(itr2->second); } } else - itr2++; + ++itr2; } //order spells by spellLevel std::list<uint32> RankedSpells; - uint32 min_spell_lvl=0; + uint32 min_spell_lvl = 0; std::multimap<SpellRankEntry, SpellRankValue>::iterator min_itr; - for (; RankMap.count(entry); ) + for (; RankMap.count(entry);) { - for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr2 = RankMap.lower_bound(entry); itr2!=RankMap.upper_bound(entry); itr2++) + for (std::multimap<SpellRankEntry, SpellRankValue>::iterator itr2 = RankMap.lower_bound(entry); itr2!=RankMap.upper_bound(entry); ++itr2) { SpellEntry const *SpellInfo=sSpellStore.LookupEntry(itr2->second.Id); - if (SpellInfo->spellLevel<min_spell_lvl || itr2==RankMap.lower_bound(entry)) + if (SpellInfo->spellLevel<min_spell_lvl || itr2 == RankMap.lower_bound(entry)) { - min_spell_lvl=SpellInfo->spellLevel; - min_itr=itr2; + min_spell_lvl = SpellInfo->spellLevel; + min_itr = itr2; } } RankedSpells.push_back(min_itr->second.Id); @@ -3484,63 +3484,61 @@ void SpellMgr::LoadSpellChains() } //use data from talent.dbc - uint16 talent_id=0; - for (std::list<uint32>::iterator itr2 = RankedSpells.begin(); itr2!=RankedSpells.end(); ) + uint16 talent_id = 0; + for (std::list<uint32>::iterator itr2 = RankedSpells.begin(); itr2 != RankedSpells.end();) { - if (TalentSpellPos const* TalentPos=GetTalentSpellPos(*itr2)) + if (TalentSpellPos const *TalentPos = GetTalentSpellPos(*itr2)) { - talent_id=TalentPos->talent_id; + talent_id = TalentPos->talent_id; RankedSpells.erase(itr2); itr2 = RankedSpells.begin(); } else - itr2++; + ++itr2; } if (talent_id) { TalentEntry const *TalentInfo = sTalentStore.LookupEntry(talent_id); - for (uint8 rank=5; rank; rank--) - { + for (uint8 rank = MAX_TALENT_RANK; rank > 0; --rank) if (TalentInfo->RankID[rank-1]) RankedSpells.push_front(TalentInfo->RankID[rank-1]); - } } //do not proceed for spells with less than 2 ranks - itr=RankMap.begin(); - if (RankedSpells.size()<2) + itr = RankMap.begin(); + if (RankedSpells.size() < 2) continue; - count++; + ++count; - uint32 spell_rank=1; - for (std::list<uint32>::iterator itr2 = RankedSpells.begin(); itr2!=RankedSpells.end(); spell_rank++) + uint32 spell_rank = 1; + for (std::list<uint32>::iterator itr2 = RankedSpells.begin(); itr2 != RankedSpells.end(); ++spell_rank) { - uint32 spell_id=*itr2; - mSpellChains[spell_id].rank=spell_rank; - mSpellChains[spell_id].first=RankedSpells.front(); - mSpellChains[spell_id].last=RankedSpells.back(); + uint32 spell_id = *itr2; + mSpellChains[spell_id].rank = spell_rank; + mSpellChains[spell_id].first = RankedSpells.front(); + mSpellChains[spell_id].last = RankedSpells.back(); - itr2++; + ++itr2; if (spell_rank<2) - mSpellChains[spell_id].prev=0; + mSpellChains[spell_id].prev = 0; - if (spell_id==RankedSpells.back()) - mSpellChains[spell_id].next=0; + if (spell_id == RankedSpells.back()) + mSpellChains[spell_id].next = 0; else { - mSpellChains[*itr2].prev=spell_id; - mSpellChains[spell_id].next=*itr2; + mSpellChains[*itr2].prev = spell_id; + mSpellChains[spell_id].next = *itr2; } } } //uncomment these two lines to print yourself list of spell_chains on startup - //for (UNORDERED_MAP<uint32, SpellChainNode>::iterator itr=mSpellChains.begin(); itr!=mSpellChains.end(); itr++) - //sLog.outString( "Id: %u, Rank: %d , %s, %u, %u, %u, %u",itr->first,itr->second.rank, sSpellStore.LookupEntry(itr->first)->Rank[sWorld.GetDefaultDbcLocale()], itr->second.first, itr->second.last,itr->second.next ,itr->second.prev); + //for(UNORDERED_MAP<uint32, SpellChainNode>::iterator itr = mSpellChains.begin(); itr != mSpellChains.end(); ++itr) + //sLog.outString("Id: %u, Rank: %d , %s, %u, %u, %u, %u",itr->first,itr->second.rank, sSpellStore.LookupEntry(itr->first)->Rank[sWorld.GetDefaultDbcLocale()], itr->second.first, itr->second.last,itr->second.next, itr->second.prev); sLog.outString(); - sLog.outString( ">> Loaded %u spell chains",count); + sLog.outString(">> Loaded %u spell chains",count); } // set data in core for now @@ -3553,12 +3551,12 @@ void SpellMgr::LoadSpellCustomAttr() { mSpellCustomAttr[i] = 0; spellInfo = (SpellEntry*)GetSpellStore()->LookupEntry(i); - if(!spellInfo) + if (!spellInfo) continue; for (uint32 j = 0; j < 3; ++j) { - switch(spellInfo->EffectApplyAuraName[j]) + switch (spellInfo->EffectApplyAuraName[j]) { case SPELL_AURA_MOD_ROOT: mSpellCustomAttr[i] |= SPELL_ATTR_CU_AURA_CC; @@ -3571,7 +3569,7 @@ void SpellMgr::LoadSpellCustomAttr() break; } - switch(spellInfo->Effect[j]) + switch (spellInfo->Effect[j]) { case SPELL_EFFECT_SCHOOL_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE: @@ -3596,7 +3594,7 @@ void SpellMgr::LoadSpellCustomAttr() break; } - switch(SpellTargetType[spellInfo->EffectImplicitTargetA[j]]) + switch (SpellTargetType[spellInfo->EffectImplicitTargetA[j]]) { case TARGET_TYPE_UNIT_TARGET: case TARGET_TYPE_DEST_TARGET: @@ -3611,7 +3609,7 @@ void SpellMgr::LoadSpellCustomAttr() for (uint32 j = 0; j < 3; ++j) { - switch(spellInfo->EffectApplyAuraName[j]) + switch (spellInfo->EffectApplyAuraName[j]) { case SPELL_AURA_MOD_POSSESS: case SPELL_AURA_MOD_CONFUSE: @@ -3625,17 +3623,17 @@ void SpellMgr::LoadSpellCustomAttr() } } - if(!_isPositiveEffect(i, 0, false)) + if (!_isPositiveEffect(i, 0, false)) mSpellCustomAttr[i] |= SPELL_ATTR_CU_NEGATIVE_EFF0; - if(!_isPositiveEffect(i, 1, false)) + if (!_isPositiveEffect(i, 1, false)) mSpellCustomAttr[i] |= SPELL_ATTR_CU_NEGATIVE_EFF1; - if(!_isPositiveEffect(i, 2, false)) + if (!_isPositiveEffect(i, 2, false)) mSpellCustomAttr[i] |= SPELL_ATTR_CU_NEGATIVE_EFF2; - if(spellInfo->SpellVisual[0] == 3879) + if (spellInfo->SpellVisual[0] == 3879) mSpellCustomAttr[i] |= SPELL_ATTR_CU_CONE_BACK; - if(spellInfo->activeIconID == 2158) //flight + if (spellInfo->activeIconID == 2158) // flight spellInfo->Attributes |= SPELL_ATTR_PASSIVE; switch(i) @@ -3752,14 +3750,14 @@ void SpellMgr::LoadSpellCustomAttr() case 39805: // Lightning Overload case 52437: // Sudden Death case 64823: // Item - Druid T8 Balance 4P Bonus - spellInfo->procCharges=1; + spellInfo->procCharges = 1; break; case 44544: // Fingers of Frost - spellInfo->procCharges=2; + spellInfo->procCharges = 2; spellInfo->EffectSpellClassMask[0] = flag96(685904631,1151048,0); break; case 28200: // Ascendance (Talisman of Ascendance trinket) - spellInfo->procCharges=6; + spellInfo->procCharges = 6; break; case 51852: // The Eye of Acherus (no spawn in phase 2 in db) spellInfo->EffectMiscValue[0] |= 1; diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 0b31eea9707..f6188c4ca04 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -214,7 +214,7 @@ void TempSummon::InitSummon() Unit* owner = GetSummoner(); if(owner) { - if(owner->GetTypeId()==TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled) + if(owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled) ((Creature*)owner)->AI()->JustSummoned(this); if(IsAIEnabled) AI()->IsSummonedBy(owner); diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index 0305bf875e6..5788d954882 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -277,7 +277,7 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe std::list<HostilReference*>::const_iterator lastRef = iThreatList.end(); lastRef--; - for (std::list<HostilReference*>::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found; ) + for (std::list<HostilReference*>::const_iterator iter = iThreatList.begin(); iter != iThreatList.end() && !found;) { currentRef = (*iter); @@ -377,7 +377,7 @@ void ThreatManager::addThreat(Unit* pVictim, float fThreat, SpellSchoolMask scho if (!pVictim->isAlive() || !getOwner()->isAlive()) return; - assert(getOwner()->GetTypeId()== TYPEID_UNIT); + assert(getOwner()->GetTypeId() == TYPEID_UNIT); float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, fThreat, schoolMask, pThreatSpell); diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 03f6fced048..81b122604db 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -440,7 +440,7 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) Map const* oldMap = GetMap(); Relocate(x, y, z); - for (PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end(); ) + for (PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end();) { Player *plr = *itr; ++itr; @@ -536,7 +536,7 @@ void Transport::Update(uint32 /*p_time*/) } */ /* - for (PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end(); ) + for (PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end();) { PlayerSet::const_iterator it2 = itr; ++itr; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index bc6d714bf6c..01c6202456d 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -102,8 +102,8 @@ Unit::Unit() m_updateFlag = (UPDATEFLAG_HIGHGUID | UPDATEFLAG_LIVING | UPDATEFLAG_HAS_POSITION); - m_attackTimer[BASE_ATTACK] = 0; - m_attackTimer[OFF_ATTACK] = 0; + m_attackTimer[BASE_ATTACK] = 0; + m_attackTimer[OFF_ATTACK] = 0; m_attackTimer[RANGED_ATTACK] = 0; m_modAttackSpeedPct[BASE_ATTACK] = 1.0f; m_modAttackSpeedPct[OFF_ATTACK] = 1.0f; @@ -116,7 +116,7 @@ Unit::Unit() m_form = FORM_NONE; m_deathState = ALIVE; - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) + for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) m_currentSpells[i] = NULL; m_addDmgOnce = 0; @@ -189,7 +189,7 @@ Unit::Unit() Unit::~Unit() { // set current spells as deletable - for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++) + for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i) { if (m_currentSpells[i]) { @@ -202,8 +202,10 @@ Unit::~Unit() RemoveAllDynObjects(); _DeleteAuras(); - if(m_charmInfo) delete m_charmInfo; - if(m_vehicleKit) delete m_vehicleKit; + if (m_charmInfo) + delete m_charmInfo; + if (m_vehicleKit) + delete m_vehicleKit; assert(!m_attacking); assert(m_attackers.empty()); @@ -211,9 +213,9 @@ Unit::~Unit() assert(m_Controlled.empty()); } -void Unit::Update( uint32 p_time ) +void Unit::Update(uint32 p_time) { - /*if(p_time > m_AurasCheck) + /*if (p_time > m_AurasCheck) { m_AurasCheck = 2000; _UpdateAura(); @@ -225,8 +227,8 @@ void Unit::Update( uint32 p_time ) // Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad. #pragma omp critical(UpdateThreadSafety) { - m_Events.Update( p_time ); - _UpdateSpells( p_time ); + m_Events.Update(p_time); + _UpdateSpells(p_time); } // If this is set during update SetCantProc(false) call is missing somewhere in the code @@ -242,10 +244,10 @@ void Unit::Update( uint32 p_time ) // 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. // These flags are reset after target dies or another command is given. - if( m_HostilRefManager.isEmpty()) + if (m_HostilRefManager.isEmpty()) { // m_CombatTimer set at aura start and it will be freeze until aura removing - if ( m_CombatTimer <= p_time ) + if (m_CombatTimer <= p_time) ClearInCombat(); else m_CombatTimer -= p_time; @@ -253,7 +255,7 @@ void Unit::Update( uint32 p_time ) } //not implemented before 3.0.2 - //if(!hasUnitState(UNIT_STAT_CASTING)) + //if (!hasUnitState(UNIT_STAT_CASTING)) { if (uint32 base_att = getAttackTimer(BASE_ATTACK)) setAttackTimer(BASE_ATTACK, (p_time >= base_att ? 0 : base_att - p_time)); @@ -275,7 +277,7 @@ void Unit::Update( uint32 p_time ) bool Unit::haveOffhandWeapon() const { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK,true); else return m_canDualWield; @@ -284,7 +286,7 @@ bool Unit::haveOffhandWeapon() const void Unit::SendMonsterMoveWithSpeedToCurrentDestination(Player* player) { float x, y, z; - if(GetMotionMaster()->GetDestination(x, y, z)) + if (GetMotionMaster()->GetDestination(x, y, z)) SendMonsterMoveWithSpeed(x, y, z, 0, player); } @@ -292,7 +294,7 @@ void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTim { if (!transitTime) { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Traveller<Player> traveller(*(Player*)this); transitTime = traveller.GetTotalTrevelTimeTo(x,y,z); @@ -309,7 +311,7 @@ void Unit::SendMonsterMoveWithSpeed(float x, float y, float z, uint32 transitTim void Unit::SendMonsterStop() { - WorldPacket data( SMSG_MONSTER_MOVE, (17 + GetPackGUID().size()) ); + WorldPacket data(SMSG_MONSTER_MOVE, (17 + GetPackGUID().size())); data.append(GetPackGUID()); data << uint8(0); // new in 3.1 data << GetPositionX() << GetPositionY() << GetPositionZ(); @@ -335,10 +337,10 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 T data << uint32(1); // 1 single waypoint data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B - if(player) + if (player) player->GetSession()->SendPacket(&data); else - SendMessageToSet( &data, true ); + SendMessageToSet(&data, true); addUnitState(UNIT_STAT_MOVE); } @@ -355,7 +357,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M data << uint8(0); data << MoveFlags; - if(MoveFlags & MOVEFLAG_JUMP) + if (MoveFlags & MOVEFLAG_JUMP) { data << time; data << speedZ; @@ -367,17 +369,17 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M data << uint32(1); // 1 single waypoint data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B - if(player) + if (player) player->GetSession()->SendPacket(&data); else - SendMessageToSet( &data, true ); + SendMessageToSet(&data, true); } /*void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player) { float moveTime = Time; - WorldPacket data( SMSG_MONSTER_MOVE, (41 + GetPackGUID().size()) ); + WorldPacket data(SMSG_MONSTER_MOVE, (41 + GetPackGUID().size())); data.append(GetPackGUID()); data << uint8(0); // new in 3.1 data << GetPositionX() << GetPositionY() << GetPositionZ(); @@ -389,7 +391,7 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M case 0: // normal packet break; case 1: // stop packet (raw pos?) - SendMessageToSet( &data, true ); + SendMessageToSet(&data, true); return; case 2: // facing spot, not used currently data << float(0); @@ -406,17 +408,17 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint32 M data << uint32(MovementFlags); - if(MovementFlags & MONSTER_MOVE_WALK) + if (MovementFlags & MONSTER_MOVE_WALK) moveTime *= 1.05f; data << uint32(moveTime); // Time in between points data << uint32(1); // 1 single waypoint data << NewPosX << NewPosY << NewPosZ; // the single waypoint Point B - if(player) + if (player) player->GetSession()->SendPacket(&data); else - SendMessageToSet( &data, true ); + SendMessageToSet(&data, true); }*/ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end) @@ -436,7 +438,7 @@ void Unit::SendMonsterMoveByPath(Path const& path, uint32 start, uint32 end) data << uint32(((GetUnitMovementFlags() & MOVEMENTFLAG_LEVITATING) || isInFlight())? (MOVEFLAG_FLY|MOVEFLAG_WALK) : MOVEFLAG_WALK); data << uint32( traveltime ); data << uint32( pathSize ); - data.append( (char*)path.GetNodes(start), pathSize * 4 * 3 ); + data.append((char*)path.GetNodes(start), pathSize * 4 * 3); SendMessageToSet(&data, true); //MONSTER_MOVE_SPLINE_FLY addUnitState(UNIT_STAT_MOVE); @@ -456,7 +458,7 @@ void Unit::SendMonsterMoveTransport(Unit *vehicleOwner) data << uint8(4); data << GetTransOffsetO(); data << uint32(MOVEFLAG_ENTER_TRANSPORT); - data << uint32(0); // move time + data << uint32(0);// move time data << uint32(0);//GetTransOffsetX(); data << uint32(0);//GetTransOffsetY(); data << uint32(0);//GetTransOffsetZ(); @@ -498,20 +500,21 @@ bool Unit::IsWithinMeleeRange(const Unit *obj, float dist) const return distsq < maxdist * maxdist; } -void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax ) const +void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const { float combat_reach = GetCombatReach(); if(combat_reach < 0.1) // sometimes bugged for players { //sLog.outError("Unit %u (Type: %u) has invalid combat_reach %f",GetGUIDLow(),GetTypeId(),combat_reach); - // if(GetTypeId() == TYPEID_UNIT) - // sLog.outError("Creature entry %u has invalid combat_reach", ((Creature*)this)->GetEntry()); + //if (GetTypeId() == TYPEID_UNIT) + // sLog.outError("Creature entry %u has invalid combat_reach", ((Creature*)this)->GetEntry()); combat_reach = DEFAULT_COMBAT_REACH; } uint32 attacker_number = getAttackers().size(); - if(attacker_number > 0) --attacker_number; + if (attacker_number > 0) + --attacker_number; GetNearPoint(obj,x,y,z,obj->GetCombatReach(), distance2dMin+(distance2dMax-distance2dMin)*rand_norm() - , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach * 0.3 : 0)); + , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * float(attacker_number) / combat_reach * 0.3 : 0)); } void Unit::RemoveMovementImpairingAuras() @@ -519,9 +522,9 @@ void Unit::RemoveMovementImpairingAuras() RemoveAurasWithMechanic((1<<MECHANIC_SNARE)|(1<<MECHANIC_ROOT)); return; - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) { - if(spellmgr.GetSpellCustomAttr(iter->second->GetId()) & SPELL_ATTR_CU_MOVEMENT_IMPAIR) + if (spellmgr.GetSpellCustomAttr(iter->second->GetId()) & SPELL_ATTR_CU_MOVEMENT_IMPAIR) RemoveAura(iter); else ++iter; @@ -530,11 +533,11 @@ void Unit::RemoveMovementImpairingAuras() void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) { - if(!(m_interruptMask & flag)) + if (!(m_interruptMask & flag)) return; // interrupt auras - for (AuraList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); ) + for (AuraList::iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end();) { Aura * aur = *iter; ++iter; @@ -548,8 +551,8 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except) } // interrupt channeled spell - if(Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) - if(spell->getState() == SPELL_STATE_CASTING + if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) + if (spell->getState() == SPELL_STATE_CASTING && (spell->m_spellInfo->ChannelInterruptFlags & flag) && spell->m_spellInfo->Id != except) InterruptNonMeleeSpells(false); @@ -580,7 +583,7 @@ void Unit::RemoveAurasWithMechanic(uint32 mechanic_mask, AuraRemoveMode removemo { if (!except || iter->second->GetId() != except) { - if(GetAllSpellMechanicMask(iter->second->GetSpellProto()) & mechanic_mask) + if (GetAllSpellMechanicMask(iter->second->GetSpellProto()) & mechanic_mask) { RemoveAura(iter, removemode); continue; @@ -596,18 +599,19 @@ void Unit::UpdateInterruptMask() for (AuraList::const_iterator i = m_interruptableAuras.begin(); i != m_interruptableAuras.end(); ++i) m_interruptMask |= (*i)->GetSpellProto()->AuraInterruptFlags; - if(Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) - if(spell->getState() == SPELL_STATE_CASTING) + if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL]) + if (spell->getState() == SPELL_STATE_CASTING) m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags; } bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const { - if(!HasAuraType(auraType)) return false; + if (!HasAuraType(auraType)) + return false; AuraEffectList const &auras = GetAurasByType(auraType); for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - if(SpellEntry const *iterSpellProto = (*itr)->GetSpellProto()) - if(iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags) + if (SpellEntry const *iterSpellProto = (*itr)->GetSpellProto()) + if (iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags) return true; return false; } @@ -624,7 +628,7 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) //You don't lose health from damage taken from another player while in a sanctuary //You still see it in the combat log though - if(pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer()) + if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer()) { const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); if (area && area->IsSanctuary()) //sanctuary @@ -638,13 +642,13 @@ void Unit::DealDamageMods(Unit *pVictim, uint32 &damage, uint32* absorb) uint32 originalDamage = damage; //Script Event damage Deal - //if( GetTypeId()== TYPEID_UNIT && ((Creature *)this)->AI()) + //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 ) + //if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature *)pVictim)->IsAIEnabled) // ((Creature *)pVictim)->AI()->DamageTaken(this, damage); - if(absorb && originalDamage > damage) + if (absorb && originalDamage > damage) absorb += (originalDamage - damage); } @@ -666,7 +670,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } } - if(pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled) + if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsAIEnabled) ((Creature*)pVictim)->AI()->DamageTaken(this, damage); if (damagetype != NODAMAGE) @@ -675,31 +679,31 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TAKE_DAMAGE, spellProto ? spellProto->Id : 0); } - if(!damage) + if (!damage) { // Rage from absorbed damage - if(cleanDamage && cleanDamage->absorbed_damage && pVictim->getPowerType() == POWER_RAGE) + if (cleanDamage && cleanDamage->absorbed_damage && pVictim->getPowerType() == POWER_RAGE) pVictim->RewardRage(cleanDamage->absorbed_damage, 0, false); return 0; } // no xp,health if type 8 /critters/ - if(pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER) + if (pVictim->GetTypeId() != TYPEID_PLAYER && pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER) { // allow loot only if has loot_id in creature_template - if(damage >= pVictim->GetHealth()) + if (damage >= pVictim->GetHealth()) { pVictim->setDeathState(JUST_DIED); pVictim->SetHealth(0); CreatureInfo const* cInfo = ((Creature*)pVictim)->GetCreatureInfo(); - if(cInfo && cInfo->lootid) + if (cInfo && cInfo->lootid) pVictim->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); // some critters required for quests (need normal entry instead possible heroic in any cases) - if(GetTypeId() == TYPEID_PLAYER) - if(CreatureInfo const* normalInfo = objmgr.GetCreatureTemplate(pVictim->GetEntry())) + if (GetTypeId() == TYPEID_PLAYER) + if (CreatureInfo const* normalInfo = objmgr.GetCreatureTemplate(pVictim->GetEntry())) ((Player*)this)->KilledMonster(normalInfo,pVictim->GetGUID()); } else @@ -715,17 +719,17 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa // duel ends when player has 1 or less hp bool duel_hasEnded = false; - if(pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1)) + if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1)) { // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if(((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetGUID() == GetOwnerGUID()) + if (((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetGUID() == GetOwnerGUID()) damage = health-1; duel_hasEnded = true; } // Rage from Damage made (only from direct weapon damage) - if(cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && getPowerType() == POWER_RAGE) + if (cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && getPowerType() == POWER_RAGE) { uint32 weaponSpeedHitFactor; uint32 rage_damage = damage + cleanDamage->absorbed_damage; @@ -734,7 +738,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa { case BASE_ATTACK: { - if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) + if (cleanDamage->hitOutCome == MELEE_HIT_CRIT) weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 7); else weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); @@ -745,7 +749,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } case OFF_ATTACK: { - if(cleanDamage->hitOutCome == MELEE_HIT_CRIT) + if (cleanDamage->hitOutCome == MELEE_HIT_CRIT) weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); else weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f); @@ -779,13 +783,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (pVictim->GetTypeId() == TYPEID_PLAYER) ((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, damage); - else if(!pVictim->IsControlledByPlayer()) + else if (!pVictim->IsControlledByPlayer()) { //!pVictim->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_OTHER_TAGGER) - if(!((Creature*)pVictim)->hasLootRecipient()) + if (!((Creature*)pVictim)->hasLootRecipient()) ((Creature*)pVictim)->SetLootRecipient(this); - if(IsControlledByPlayer()) + if (IsControlledByPlayer()) ((Creature*)pVictim)->LowerPlayerDamageReq(health < damage ? health : damage); } @@ -821,7 +825,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->ModifyHealth(- (int32)damage); - if(damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE) + if (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE) { //TODO: This is from procflag, I do not know which spell needs this //Maim? @@ -830,7 +834,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } if (pVictim->GetTypeId() != TYPEID_PLAYER) { - if(spellProto && IsDamageToThreatSpell(spellProto)) + if (spellProto && IsDamageToThreatSpell(spellProto)) pVictim->AddThreat(this, damage*2, damageSchoolMask, spellProto); else pVictim->AddThreat(this, damage, damageSchoolMask, spellProto); @@ -846,13 +850,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } // Rage from damage received - if(this != pVictim && pVictim->getPowerType() == POWER_RAGE) + if (this != pVictim && pVictim->getPowerType() == POWER_RAGE) { uint32 rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0); pVictim->RewardRage(rage_damage, 0, false); } - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { // random durability for items (HIT DONE) if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) @@ -864,29 +868,29 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if (damagetype != NODAMAGE && damage)// && pVictim->GetTypeId() == TYPEID_PLAYER) { - if(pVictim != this && pVictim->GetTypeId() == TYPEID_PLAYER) // does not support creature push_back + if (pVictim != this && pVictim->GetTypeId() == TYPEID_PLAYER) // does not support creature push_back { - if(damagetype != DOT) + if (damagetype != DOT) { - if(Spell* spell = pVictim->m_currentSpells[CURRENT_GENERIC_SPELL]) + if (Spell* spell = pVictim->m_currentSpells[CURRENT_GENERIC_SPELL]) { - if(spell->getState() == SPELL_STATE_PREPARING) + if (spell->getState() == SPELL_STATE_PREPARING) { uint32 interruptFlags = spell->m_spellInfo->InterruptFlags; - if(interruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG) + if (interruptFlags & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG) pVictim->InterruptNonMeleeSpells(false); - else if(interruptFlags & SPELL_INTERRUPT_FLAG_PUSH_BACK) + else if (interruptFlags & SPELL_INTERRUPT_FLAG_PUSH_BACK) spell->Delayed(); } } } - if(Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL]) + if (Spell* spell = pVictim->m_currentSpells[CURRENT_CHANNELED_SPELL]) { - if(spell->getState() == SPELL_STATE_CASTING) + if (spell->getState() == SPELL_STATE_CASTING) { uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags; - if( channelInterruptFlags & CHANNEL_FLAG_DELAY ) + if (channelInterruptFlags & CHANNEL_FLAG_DELAY) spell->DelayedChannel(); } } @@ -894,7 +898,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa } // last damage from duel opponent - if(duel_hasEnded) + if (duel_hasEnded) { assert(pVictim->GetTypeId() == TYPEID_PLAYER); Player *he = (Player*)pVictim; @@ -927,7 +931,7 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - if(!spellInfo) + if (!spellInfo) { sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -938,30 +942,30 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castIte void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) { - if(!spellInfo) + if (!spellInfo) { sLog.outError("CastSpell: unknown spell by caster: %s %u)", (GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; } - if (!originalCaster && GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem() && IsControlledByPlayer()) + if (!originalCaster && GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem() && IsControlledByPlayer()) if (Unit * owner = GetOwner()) originalCaster=owner->GetGUID(); SpellCastTargets targets; uint32 targetMask = spellInfo->Targets; - //if(targetMask & (TARGET_FLAG_UNIT|TARGET_FLAG_UNK2)) + //if (targetMask & (TARGET_FLAG_UNIT|TARGET_FLAG_UNK2)) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - if(SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET) + if (SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET) { /*SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); - if(srange && GetSpellMaxRange(srange) == 0.0f) + if (srange && GetSpellMaxRange(srange) == 0.0f) { Victim = this; break; } - else */if(!Victim) + else */if (!Victim) { sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have unit target", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -972,9 +976,9 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I } targets.setUnitTarget(Victim); - if(targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION)) + if (targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION)) { - if(!Victim) + if (!Victim) { sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have destination", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -985,7 +989,7 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggeredByAura) + if (!originalCaster && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); @@ -997,9 +1001,12 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) { CustomSpellValues values; - if(bp0) values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0); - if(bp1) values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1); - if(bp2) values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2); + if (bp0) + values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0); + if (bp1) + values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1); + if (bp2) + values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2); CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster); } @@ -1013,7 +1020,7 @@ void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - if(!spellInfo) + if (!spellInfo) { sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -1025,9 +1032,9 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* //check unit target for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - if(SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET) + if (SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET) { - if(!Victim) + if (!Victim) { sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have unit target", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -1039,9 +1046,9 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* targets.setUnitTarget(Victim); //check destination - if(targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION)) + if (targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION)) { - if(!Victim) + if (!Victim) { sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have destination", spellInfo->Id,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -1049,12 +1056,12 @@ void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* targets.setDst(Victim); } - if(!originalCaster && triggeredByAura) + if (!originalCaster && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); - if(castItem) + if (castItem) { DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); spell->m_CastItem = castItem; @@ -1071,7 +1078,7 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - if(!spellInfo) + if (!spellInfo) { sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -1080,14 +1087,14 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggeredByAura) + if (!originalCaster && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); SpellCastTargets targets; targets.setDst(x, y, z, GetOrientation()); - if(OriginalVictim) + if (OriginalVictim) targets.setUnitTarget(OriginalVictim); spell->m_CastItem = castItem; spell->prepare(&targets, triggeredByAura); @@ -1096,18 +1103,18 @@ void Unit::CastSpell(float x, float y, float z, uint32 spellId, bool triggered, // used for scripting void Unit::CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) { - if(!go) + if (!go) return; SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - if(!spellInfo) + if (!spellInfo) { sLog.outError("CastSpell(x,y,z): unknown spell id %i by caster: %s %u)", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; } - if(!(spellInfo->Targets & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK))) + if (!(spellInfo->Targets & ( TARGET_FLAG_OBJECT | TARGET_FLAG_OBJECT_UNK))) { sLog.outError("CastSpell: spell id %i by caster: %s %u) is not gameobject spell", spellId,(GetTypeId() == TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId() == TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; @@ -1116,7 +1123,7 @@ void Unit::CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castI if (castItem) DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggeredByAura) + if (!originalCaster && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); @@ -1145,14 +1152,14 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama if (damage < 0) return; - if(spellInfo->AttributesEx4 & SPELL_ATTR_EX4_FIXED_DAMAGE) + if (spellInfo->AttributesEx4 & SPELL_ATTR_EX4_FIXED_DAMAGE) { damageInfo->damage = damage; return; } Unit *pVictim = damageInfo->target; - if(!pVictim || !pVictim->isAlive()) + if (!pVictim || !pVictim->isAlive()) return; SpellSchoolMask damageSchoolMask = SpellSchoolMask(damageInfo->schoolMask); @@ -1181,13 +1188,13 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama // Calculate crit bonus uint32 crit_bonus = damage; // Apply crit_damage bonus for melee spells - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); damage += crit_bonus; // Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE int32 critPctDamageMod = 0; - if(attackType == RANGED_ATTACK) + if (attackType == RANGED_ATTACK) critPctDamageMod += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE); else { @@ -1238,7 +1245,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama damage = CalcArmorReducedDamage(pVictim, damage, spellInfo, attackType); // Calculate absorb resist - if(damage > 0) + if (damage > 0) { CalcAbsorbResist(pVictim, damageSchoolMask, SPELL_DIRECT_DAMAGE, damage, &damageInfo->absorb, &damageInfo->resist, spellInfo); damage-= damageInfo->absorb + damageInfo->resist; @@ -1255,7 +1262,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss) Unit *pVictim = damageInfo->target; - if(!pVictim) + if (!pVictim) return; if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) @@ -1270,10 +1277,10 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss) //You don't lose health from damage taken from another player while in a sanctuary //You still see it in the combat log though - if(pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer()) + if (pVictim != this && IsControlledByPlayer() && pVictim->IsControlledByPlayer()) { const AreaTableEntry *area = GetAreaEntryByAreaID(pVictim->GetAreaId()); - if(area && area->IsSanctuary()) // sanctuary + if (area && area->IsSanctuary()) // sanctuary return; } @@ -1330,7 +1337,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da } // Physical Immune check - if(damageInfo->target->IsImmunedToDamage(SpellSchoolMask(damageInfo->damageSchoolMask))) + if (damageInfo->target->IsImmunedToDamage(SpellSchoolMask(damageInfo->damageSchoolMask))) { damageInfo->HitInfo |= HITINFO_NORMALSWING; damageInfo->TargetState = VICTIMSTATE_IS_IMMUNE; @@ -1350,10 +1357,12 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da damageInfo->hitOutCome = RollMeleeOutcomeAgainst(damageInfo->target, damageInfo->attackType); // Disable parry or dodge for ranged attack - if(damageInfo->attackType == RANGED_ATTACK) + if (damageInfo->attackType == RANGED_ATTACK) { - if (damageInfo->hitOutCome == MELEE_HIT_PARRY) damageInfo->hitOutCome = MELEE_HIT_NORMAL; - if (damageInfo->hitOutCome == MELEE_HIT_DODGE) damageInfo->hitOutCome = MELEE_HIT_MISS; + if (damageInfo->hitOutCome == MELEE_HIT_PARRY) + damageInfo->hitOutCome = MELEE_HIT_NORMAL; + else if (damageInfo->hitOutCome == MELEE_HIT_DODGE) + damageInfo->hitOutCome = MELEE_HIT_MISS; } switch (damageInfo->hitOutCome) @@ -1475,7 +1484,7 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da } // Calculate absorb resist - if(int32(damageInfo->damage) > 0) + if (int32(damageInfo->damage) > 0) { damageInfo->procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; // Calculate absorb & resists @@ -1499,7 +1508,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) return; Unit *pVictim = damageInfo->target; - if(!pVictim) + if (!pVictim) return; if (!pVictim->isAlive() || pVictim->hasUnitState(UNIT_STAT_UNATTACKABLE) || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) @@ -1520,7 +1529,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS) pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); - if(damageInfo->TargetState == VICTIMSTATE_PARRY) + if (damageInfo->TargetState == VICTIMSTATE_PARRY) { // Get attack timers float offtime = float(pVictim->getAttackTimer(OFF_ATTACK)); @@ -1530,11 +1539,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) { float percent20 = pVictim->GetAttackTime(OFF_ATTACK) * 0.20f; float percent60 = 3.0f * percent20; - if(offtime > percent20 && offtime <= percent60) - { + if (offtime > percent20 && offtime <= percent60) pVictim->setAttackTimer(OFF_ATTACK, uint32(percent20)); - } - else if(offtime > percent60) + else if (offtime > percent60) { offtime -= 2.0f * percent20; pVictim->setAttackTimer(OFF_ATTACK, uint32(offtime)); @@ -1544,11 +1551,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) { float percent20 = pVictim->GetAttackTime(BASE_ATTACK) * 0.20; float percent60 = 3.0f * percent20; - if(basetime > percent20 && basetime <= percent60) - { + if (basetime > percent20 && basetime <= percent60) pVictim->setAttackTimer(BASE_ATTACK, uint32(percent20)); - } - else if(basetime > percent60) + else if (basetime > percent60) { basetime -= 2.0f * percent20; pVictim->setAttackTimer(BASE_ATTACK, uint32(basetime)); @@ -1561,7 +1566,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) DealDamage(pVictim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), NULL, durabilityLoss); // If this is a creature and it attacks from behind it has a probability to daze it's victim - if( (damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) && + if ((damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) && GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->IsControlledByPlayer() && !pVictim->HasInArc(M_PI, this) && (pVictim->GetTypeId() == TYPEID_PLAYER || !((Creature*)pVictim)->isWorldBoss())) { @@ -1570,7 +1575,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) float Probability = 20.0f; //there is a newbie protection, at level 10 just 7% base chance; assuming linear function - if( pVictim->getLevel() < 30 ) + if (pVictim->getLevel() < 30) Probability = 0.65f*pVictim->getLevel()+0.5f; uint32 VictimDefense=pVictim->GetDefenseSkillValue(); @@ -1578,14 +1583,14 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss) Probability *= AttackerMeleeSkill/(float)VictimDefense; - if(Probability > 40.0f) + if (Probability > 40.0f) Probability = 40.0f; - if(roll_chance_f(Probability)) + if (roll_chance_f(Probability)) CastSpell(pVictim, 1604, true); } - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) ((Player *)this)->CastItemCombatSpell(pVictim, damageInfo->attackType, damageInfo->procVictim, damageInfo->procEx); // Do effect if any damage done to target @@ -1648,14 +1653,14 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt // Ignore enemy armor by SPELL_AURA_MOD_TARGET_RESISTANCE aura armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); - if(spellInfo) - if(Player *modOwner = GetSpellModOwner()) + if (spellInfo) + if (Player *modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor); AuraEffectList const& ResIgnoreAurasAb = GetAurasByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST); for (AuraEffectList::const_iterator j = ResIgnoreAurasAb.begin(); j != ResIgnoreAurasAb.end(); ++j) { - if( (*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL + if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL && (*j)->isAffectedOnSpell(spellInfo)) armor= int32(float(armor) * (float(100-(*j)->GetAmount())/100.0f)); } @@ -1663,19 +1668,19 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt AuraEffectList const& ResIgnoreAuras = GetAurasByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST); for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j) { - if( (*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) + if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) armor= int32(float(armor) * (float(100-(*j)->GetAmount())/100.0f)); } - if ( GetTypeId() == TYPEID_PLAYER ) + if (GetTypeId() == TYPEID_PLAYER) { AuraEffectList const& ResIgnoreAuras = GetAurasByType(SPELL_AURA_MOD_ARMOR_PENETRATION_PCT); for (AuraEffectList::const_iterator itr = ResIgnoreAuras.begin(); itr != ResIgnoreAuras.end(); ++itr) { // item neutral spell - if((*itr)->GetSpellProto()->EquippedItemClass == -1) + if ((*itr)->GetSpellProto()->EquippedItemClass == -1) { - armor= int32(float(armor) * (float(100-(*itr)->GetAmount())/100.0f)); + armor = int32(float(armor) * (float(100-(*itr)->GetAmount())/100.0f)); continue; } @@ -1684,7 +1689,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt { Item *weapon = ((Player *)this)->GetWeaponForAttack(WeaponAttackType(i)); - if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) + if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) { armor= int32(float(armor) * (float(100-(*itr)->GetAmount())/100.0f)); break; @@ -1733,11 +1738,11 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEnt void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32 *absorb, uint32 *resist, SpellEntry const *spellInfo) { - if(!pVictim || !pVictim->isAlive() || !damage) + if (!pVictim || !pVictim->isAlive() || !damage) return; // Magic damage, check for resists - if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL)==0) + if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) { // Get base victim resistance for school float tmpvalue2 = (float)pVictim->GetResistance(GetFirstSchoolInMask(schoolMask)); @@ -1753,7 +1758,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe uint32 faq[4] = {24,6,4,6}; uint8 m = 0; float Binom = 0.0f; - for (uint8 i = 0; i < 4; i++) + for (uint8 i = 0; i < 4; ++i) { Binom += 2400 *( powf(tmpvalue2, i) * powf( (1-tmpvalue2), (4-i)))/faq[i]; if (ran > Binom ) @@ -1765,13 +1770,13 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe *resist += uint32(damage - 1); else *resist += uint32(damage * m / 4); - if(*resist > damage) + if (*resist > damage) *resist = damage; AuraEffectList const& ResIgnoreAurasAb = GetAurasByType(SPELL_AURA_MOD_ABILITY_IGNORE_TARGET_RESIST); for (AuraEffectList::const_iterator j = ResIgnoreAurasAb.begin(); j != ResIgnoreAurasAb.end(); ++j) { - if( (*j)->GetMiscValue() & schoolMask + if ((*j)->GetMiscValue() & schoolMask && (*j)->isAffectedOnSpell(spellInfo)) *resist= int32(float(*resist) * (float(100-(*j)->GetAmount())/100.0f)); } @@ -1779,7 +1784,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe AuraEffectList const& ResIgnoreAuras = GetAurasByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST); for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j) { - if( (*j)->GetMiscValue() & schoolMask) + if ((*j)->GetMiscValue() & schoolMask) *resist= int32(float(*resist) * (float(100-(*j)->GetAmount())/100.0f)); } } @@ -1951,7 +1956,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe switch(spellProto->Id) { case 51271: // Unbreakable Armor - if(Unit *caster = (*i)->GetCaster()) + if (Unit *caster = (*i)->GetCaster()) { uint32 absorbed = uint32( currentAbsorb * caster->GetArmor() * 0.01f ); @@ -1975,7 +1980,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe RemainingDamage -= RemainingDamage * currentAbsorb / 100; continue; case 50461: // Anti-Magic Zone - if(Unit *caster = (*i)->GetCaster()) + if (Unit *caster = (*i)->GetCaster()) { int32 absorbed = RemainingDamage * currentAbsorb / 100; int32 canabsorb = caster->GetHealth(); @@ -2011,11 +2016,9 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe for (TriggeredSpellInfoVct::const_iterator itr = triggeredSpells.begin(); itr != triggeredSpells.end(); ++itr) { - if(itr->spell) - { + if (itr->spell) itr->source->CastCustomSpell(itr->spell, SPELLVALUE_BASE_POINT0, itr->amount, itr->target, true, NULL, itr->auraEff); - } - else if(itr->amount > 0) + else if (itr->amount > 0) { uint32 damage = (uint32)itr->amount; itr->source->DealDamageMods(itr->target, damage, NULL); @@ -2026,7 +2029,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe // Remove all expired absorb auras if (existExpired) { - for (AuraEffectList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end(); ) + for (AuraEffectList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end();) { Aura *aura=(*i)->GetParentAura(); AuraEffect *auraeff =(*i); @@ -2048,7 +2051,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe next = i; ++next; // check damage school mask - if(((*i)->GetMiscValue() & schoolMask)==0) + if (((*i)->GetMiscValue() & schoolMask)==0) continue; int32 currentAbsorb; @@ -2058,7 +2061,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe currentAbsorb = RemainingDamage; float manaMultiplier = (*i)->GetSpellProto()->EffectMultipleValue[(*i)->GetEffIndex()]; - if(Player *modOwner = pVictim->GetSpellModOwner()) + if (Player *modOwner = pVictim->GetSpellModOwner()) modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); int32 maxAbsorb = int32(pVictim->GetPower(POWER_MANA) / manaMultiplier); @@ -2066,7 +2069,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe currentAbsorb = maxAbsorb; (*i)->SetAmount((*i)->GetAmount()-currentAbsorb); - if((*i)->GetAmount() <= 0) + if ((*i)->GetAmount() <= 0) { pVictim->RemoveAura((*i)->GetParentAura(), AURA_REMOVE_BY_ENEMY_SPELL); next = vManaShield.begin(); @@ -2079,7 +2082,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe } // only split damage if not damaging yourself - if(pVictim != this) + if (pVictim != this) { AuraEffectList const& vSplitDamageFlat = pVictim->GetAurasByType(SPELL_AURA_SPLIT_DAMAGE_FLAT); for (AuraEffectList::const_iterator i = vSplitDamageFlat.begin(), next; i != vSplitDamageFlat.end() && RemainingDamage >= 0; i = next) @@ -2087,12 +2090,12 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe next = i; ++next; // check damage school mask - if(((*i)->GetMiscValue() & schoolMask)==0) + if (((*i)->GetMiscValue() & schoolMask) == 0) continue; // Damage can be splitted only if aura has an alive caster Unit *caster = (*i)->GetCaster(); - if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) + if (!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) continue; int32 currentAbsorb; @@ -2119,12 +2122,12 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe next = i; ++next; // check damage school mask - if(((*i)->GetMiscValue() & schoolMask)==0) + if (((*i)->GetMiscValue() & schoolMask)==0) continue; // Damage can be splitted only if aura has an alive caster Unit *caster = (*i)->GetCaster(); - if(!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) + if (!caster || caster == pVictim || !caster->IsInWorld() || !caster->isAlive()) continue; uint32 splitted = uint32(RemainingDamage * (*i)->GetAmount() / 100.0f); @@ -2206,9 +2209,9 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe int32 new_dmg = (int32)*absorb * aurEff->GetAmount() / 100; int32 max_dmg = (int32)pVictim->GetMaxHealth() * 5 / 100; // Do not apply more auras if more than 5% hp - if(current_dmg + new_dmg > max_dmg) + if (current_dmg + new_dmg > max_dmg) new_dmg = max_dmg - current_dmg; - if(new_dmg > 0) + if (new_dmg > 0) pVictim->CastCustomSpell(pVictim, 44413, &new_dmg, NULL, NULL, true); } } @@ -2216,7 +2219,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool extra ) { - if(hasUnitState(UNIT_STAT_CANNOT_AUTOATTACK) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) + if (hasUnitState(UNIT_STAT_CANNOT_AUTOATTACK) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED) ) return; if (!pVictim->isAlive()) @@ -2260,7 +2263,7 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); // if damage pVictim call AI reaction - //if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI()) + //if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->AI()) // ((Creature*)pVictim)->AI()->AttackedBy(this); } @@ -2289,7 +2292,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit *pVictim, WeaponAttackT MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const { - if(pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) return MELEE_HIT_EVADE; int32 attackerMaxSkillValueForLevel = GetMaxSkillValueForLevel(pVictim); @@ -2316,7 +2319,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack } // always crit against a sitting target (except 0 crit chance) - if( pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState() ) + if (pVictim->GetTypeId() == TYPEID_PLAYER && crit_chance > 0 && !pVictim->IsStandState() ) { DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT (sitting victim)"); return MELEE_HIT_CRIT; @@ -2366,24 +2369,24 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack else parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25; - if(pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) ) + if (pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY) ) { int32 tmp2 = int32(parry_chance); - if ( (tmp2 > 0) // check if unit _can_ parry - && ((tmp2 -= skillBonus) > 0) - && (roll < (sum += tmp2))) + if (tmp2 > 0 // check if unit _can_ parry + && (tmp2 -= skillBonus) > 0 + && roll < (sum += tmp2)) { DEBUG_LOG ("RollMeleeOutcomeAgainst: PARRY <%d, %d)", sum-tmp2, sum); return MELEE_HIT_PARRY; } } - if(pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) ) + if (pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK) ) { tmp = block_chance; - if ( (tmp > 0) // check if unit _can_ block - && ((tmp -= skillBonus) > 0) - && (roll < (sum += tmp))) + if (tmp > 0 // check if unit _can_ block + && (tmp -= skillBonus) > 0 + && roll < (sum += tmp)) { DEBUG_LOG ("RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum-tmp, sum); return MELEE_HIT_BLOCK; @@ -2397,17 +2400,17 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack if (tmp > 0 && roll < (sum += tmp)) { DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum); - if(GetTypeId() == TYPEID_UNIT && (((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) + if (GetTypeId() == TYPEID_UNIT && (((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT DISABLED)"); else return MELEE_HIT_CRIT; } // Max 40% chance to score a glancing blow against mobs that are higher level (can do only players and pets and not with ranged weapon) - if( attType != RANGED_ATTACK && + if (attType != RANGED_ATTACK && (GetTypeId() == TYPEID_PLAYER || ((Creature*)this)->isPet()) && pVictim->GetTypeId() != TYPEID_PLAYER && !((Creature*)pVictim)->isPet() && - getLevel() < pVictim->getLevelForTarget(this) ) + getLevel() < pVictim->getLevelForTarget(this)) { // cap possible value (with bonuses > max skill) int32 skill = attackerWeaponSkill; @@ -2436,7 +2439,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack tmp = tmp > tmpmax ? tmpmax : tmp; // tmp = mob's level * 5 - player's current defense skill tmp = attackerMaxSkillValueForLevel - tmp; - if(tmp >= 15) + if (tmp >= 15) { // add 2% chance per lacking skill point, min. is 15% tmp = tmp * 200 - 1500; @@ -2487,7 +2490,7 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add std::swap(min_damage,max_damage); } - if(max_damage == 0.0f) + if (max_damage == 0.0f) max_damage = 5.0f; return urand((uint32)min_damage, (uint32)max_damage); @@ -2495,15 +2498,15 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized, bool add float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const { - if(spellProto->spellLevel <= 0) + if (spellProto->spellLevel <= 0) return 1.0f; float LvlPenalty = 0.0f; - if(spellProto->spellLevel < 20) + if (spellProto->spellLevel < 20) LvlPenalty = 20.0f - spellProto->spellLevel * 3.75f; float LvlFactor = (float(spellProto->spellLevel) + 6.0f) / float(getLevel()); - if(LvlFactor > 1.0f) + if (LvlFactor > 1.0f) LvlFactor = 1.0f; return (100.0f - LvlPenalty) * LvlFactor / 100.0f; @@ -2521,7 +2524,7 @@ void Unit::SendMeleeAttackStart(Unit* pVictim) void Unit::SendMeleeAttackStop(Unit* victim) { - if(!victim) + if (!victim) return; WorldPacket data( SMSG_ATTACKSTOP, (4+16) ); // we guess size @@ -2531,7 +2534,7 @@ void Unit::SendMeleeAttackStop(Unit* victim) SendMessageToSet(&data, true); sLog.outDetail("%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"),victim->GetGUIDLow()); - /*if(victim->GetTypeId() == TYPEID_UNIT) + /*if (victim->GetTypeId() == TYPEID_UNIT) ((Creature*)victim)->AI().EnterEvadeMode(this);*/ } @@ -2552,7 +2555,7 @@ bool Unit::isSpellBlocked(Unit *pVictim, SpellEntry const * /*spellProto*/, Weap */ // Check creatures flags_extra for disable block - if(pVictim->GetTypeId()==TYPEID_UNIT && + if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK ) return false; @@ -2581,19 +2584,19 @@ bool Unit::isBlockCritical() // PvP - PvE melee chances int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7; int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim); - if(leveldif < 3) + if (leveldif < 3) HitChance = 95 - leveldif; else HitChance = 93 - (leveldif - 2) * lchance; // Hit chance depends from victim auras - if(attType == RANGED_ATTACK) + if (attType == RANGED_ATTACK) HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); else HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); // Spellmod from SPELLMOD_RESIST_MISS_CHANCE - if(Player *modOwner = GetSpellModOwner()) + if (Player *modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, HitChance); // Miss = 100 - hit @@ -2618,12 +2621,12 @@ bool Unit::isBlockCritical() int32 Unit::GetMechanicResistChance(const SpellEntry *spell) { - if(!spell) + if (!spell) return 0; int32 resist_mech = 0; for (uint8 eff = 0; eff < MAX_SPELL_EFFECTS; ++eff) { - if(spell->Effect[eff] == 0) + if (spell->Effect[eff] == 0) break; int32 effect_mech = GetEffectMechanic(spell, eff); if (effect_mech) @@ -2722,22 +2725,22 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) canBlock = false; } // Check creatures flags_extra for disable parry - if(pVictim->GetTypeId()==TYPEID_UNIT) + if (pVictim->GetTypeId() == TYPEID_UNIT) { uint32 flagEx = ((Creature*)pVictim)->GetCreatureInfo()->flags_extra; - if( flagEx & CREATURE_FLAG_EXTRA_NO_PARRY ) + if (flagEx & CREATURE_FLAG_EXTRA_NO_PARRY) canParry = false; // Check creatures flags_extra for disable block - if( flagEx & CREATURE_FLAG_EXTRA_NO_BLOCK ) + if (flagEx & CREATURE_FLAG_EXTRA_NO_BLOCK) canBlock = false; } // Ignore combat result aura - AuraEffectList const& ignore = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); + AuraEffectList const &ignore = GetAurasByType(SPELL_AURA_IGNORE_COMBAT_RESULT); for (AuraEffectList::const_iterator i = ignore.begin(); i != ignore.end(); ++i) { if (!(*i)->isAffectedOnSpell(spell)) continue; - switch((*i)->GetMiscValue()) + switch ((*i)->GetMiscValue()) { case MELEE_HIT_DODGE: canDodge = false; break; case MELEE_HIT_BLOCK: canBlock = false; break; @@ -2753,8 +2756,8 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Roll dodge int32 dodgeChance = int32(pVictim->GetUnitDodgeChance()*100.0f) - skillDiff * 4; // Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE - dodgeChance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100; - dodgeChance = int32 (float (dodgeChance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE)); + dodgeChance += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100; + dodgeChance = int32(float(dodgeChance) * GetTotalAuraMultiplier(SPELL_AURA_MOD_ENEMY_DODGE)); // Reduce dodge chance by attacker expertise rating if (GetTypeId() == TYPEID_PLAYER) dodgeChance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); @@ -2763,8 +2766,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) if (dodgeChance < 0) dodgeChance = 0; - tmp += dodgeChance; - if (roll < tmp) + if (roll < (tmp += dodgeChance)) return SPELL_MISS_DODGE; } @@ -2788,7 +2790,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell) if (canBlock) { int32 blockChance = int32(pVictim->GetUnitBlockChance()*100.0f) - skillDiff * 4; - if ( blockChance < 0 ) + if (blockChance < 0) blockChance = 0; tmp += blockChance; @@ -2813,13 +2815,13 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) // Base hit chance from attacker and victim levels int32 modHitChance; - if(leveldif < 3) + if (leveldif < 3) modHitChance = 96 - leveldif; else modHitChance = 94 - (leveldif - 2) * lchance; // Spellmod from SPELLMOD_RESIST_MISS_CHANCE - if(Player *modOwner = GetSpellModOwner()) + if (Player *modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance); // Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask); @@ -2840,8 +2842,10 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) if (pVictim->GetTypeId() == TYPEID_PLAYER) HitChance -= int32(((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_SPELL)*100.0f); - if (HitChance < 100) HitChance = 100; - if (HitChance > 10000) HitChance = 10000; + if (HitChance < 100) + HitChance = 100; + else if (HitChance > 10000) + HitChance = 10000; int32 tmp = 10000 - HitChance; @@ -2884,7 +2888,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell) SpellMissInfo Unit::SpellHitResult(Unit *pVictim, SpellEntry const *spell, bool CanReflect) { // Return evade for units in evade mode - if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode() && this != pVictim) + if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode() && this != pVictim) return SPELL_MISS_EVADE; // Check for immune @@ -3218,7 +3222,7 @@ void Unit::_UpdateSpells( uint32 time ) // update auras // m_AurasUpdateIterator can be updated in inderect called code at aura remove to skip next planned to update but removed auras - for (m_AurasUpdateIterator = m_Auras.begin(); m_AurasUpdateIterator != m_Auras.end(); ) + for (m_AurasUpdateIterator = m_Auras.begin(); m_AurasUpdateIterator != m_Auras.end();) { Aura* i_aura = m_AurasUpdateIterator->second; ++m_AurasUpdateIterator; // need shift to next for allow update if need into aura update @@ -3226,7 +3230,7 @@ void Unit::_UpdateSpells( uint32 time ) } // remove expired auras - for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end(); ) + for (AuraMap::iterator i = m_Auras.begin(); i != m_Auras.end();) { if(i->second->IsExpired()) RemoveAura(i, AURA_REMOVE_BY_EXPIRE); @@ -3239,7 +3243,7 @@ void Unit::_UpdateSpells( uint32 time ) if(!m_gameObj.empty()) { GameObjectList::iterator itr; - for (itr = m_gameObj.begin(); itr != m_gameObj.end(); ) + for (itr = m_gameObj.begin(); itr != m_gameObj.end();) { if( !(*itr)->isSpawned() ) { @@ -3742,7 +3746,7 @@ bool Unit::AddAura(Aura *Aur, bool handleEffects) if (Aur->IsSingleTarget()) { // caster pointer can be deleted in time aura remove, find it by guid at each iteration - for (; ; ) + for (;;) { Unit* caster = Aur->GetCaster(); assert(caster); @@ -3885,9 +3889,9 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) void Unit::RemoveAura(uint32 spellId, uint64 caster, AuraRemoveMode removeMode) { - for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId); ) + for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);) { - if (!caster || iter->second->GetCasterGUID()==caster) + if (!caster || iter->second->GetCasterGUID() == caster) { RemoveAura(iter, removeMode); return; @@ -4028,7 +4032,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) { - for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId); ) + for (AuraMap::iterator iter = m_Auras.lower_bound(spellId); iter != m_Auras.upper_bound(spellId);) { if (!castItem || iter->second->GetCastItemGUID()==castItem->GetGUID()) { @@ -4042,7 +4046,7 @@ void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except, bool negative, bool positive) { - for (AuraEffectList::const_iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end(); ) + for (AuraEffectList::const_iterator iter = m_modAuras[auraType].begin(); iter != m_modAuras[auraType].end();) { Aura * aur = (*iter)->GetParentAura(); ++iter; @@ -4060,16 +4064,16 @@ void Unit::RemoveAurasByType(AuraType auraType, uint64 casterGUID, Aura * except void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) { // single target auras from other casters - for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) { if (iter->second->GetCasterGUID()!=GetGUID() && IsSingleTargetSpell(iter->second->GetSpellProto())) { - if(!newPhase) + if (!newPhase) RemoveAura(iter); else { Unit* caster = iter->second->GetCaster(); - if(!caster || !caster->InSamePhase(newPhase)) + if (!caster || !caster->InSamePhase(newPhase)) RemoveAura(iter); else ++iter; @@ -4081,7 +4085,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase) // single target auras at other targets AuraList& scAuras = GetSingleCastAuras(); - for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end(); ) + for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();) { Aura * aura=*iter; ++iter; @@ -4136,7 +4140,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) { bool canBreak = false; // Get mask of all aurastates from remaining auras - for (AuraStateAurasMap::iterator itr = m_auraStateAuras.lower_bound(auraState); itr != m_auraStateAuras.upper_bound(auraState) && !(auraStateFound && canBreak); ) + for (AuraStateAurasMap::iterator itr = m_auraStateAuras.lower_bound(auraState); itr != m_auraStateAuras.upper_bound(auraState) && !(auraStateFound && canBreak);) { if (itr->second == Aur) { @@ -4154,7 +4158,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) } // Remove totem at next update if totem looses its aura - if (Aur->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem()&& ((TempSummon*)this)->GetSummonerGUID()==Aur->GetCasterGUID()) + if (Aur->GetRemoveMode() == AURA_REMOVE_BY_EXPIRE && GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem()&& ((TempSummon*)this)->GetSummonerGUID()==Aur->GetCasterGUID()) { if (((Totem*)this)->GetSpell()==Aur->GetId() && ((Totem*)this)->GetTotemType()==TOTEM_PASSIVE) ((Totem*)this)->setDeathState(JUST_DIED); @@ -4278,7 +4282,7 @@ bool Unit::HasAura(Aura * aur) const // no need to find aura if (!aur || aur->IsRemoved()) return false; - for (AuraMap::const_iterator iter = m_Auras.lower_bound(aur->GetId()); iter != m_Auras.upper_bound(aur->GetId()); ) + for (AuraMap::const_iterator iter = m_Auras.lower_bound(aur->GetId()); iter != m_Auras.upper_bound(aur->GetId());) { if (aur == iter->second) return true; @@ -4359,7 +4363,7 @@ uint32 Unit::GetDiseasesByCaster(uint64 casterGUID, bool remove) uint32 diseases=0; for (AuraType const* itr = &diseaseAuraTypes[0]; itr && itr[0] != SPELL_AURA_NONE; ++itr) { - for (AuraEffectList::iterator i = m_modAuras[*itr].begin(); i != m_modAuras[*itr].end(); ) + for (AuraEffectList::iterator i = m_modAuras[*itr].begin(); i != m_modAuras[*itr].end();) { // Get auras with disease dispel type by caster if ((*i)->GetSpellProto()->Dispel == DISPEL_DISEASE @@ -4412,7 +4416,7 @@ void Unit::RemoveDynObject(uint32 spellid) { if(m_dynObjGUIDs.empty()) return; - for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end(); ) + for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) { DynamicObject* dynObj = GetMap()->GetDynamicObject(*i); if(!dynObj) // may happen if a dynobj is removed when grid unload @@ -4442,7 +4446,7 @@ void Unit::RemoveAllDynObjects() DynamicObject * Unit::GetDynObject(uint32 spellId) { - for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end(); ) + for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) { DynamicObject* dynObj = GetMap()->GetDynamicObject(*i); if(!dynObj) @@ -4549,7 +4553,7 @@ void Unit::RemoveGameObject(uint32 spellid, bool del) void Unit::RemoveAllGameObjects() { // remove references to unit - for (GameObjectList::iterator i = m_gameObj.begin(); i != m_gameObj.end(); ) + for (GameObjectList::iterator i = m_gameObj.begin(); i != m_gameObj.end();) { (*i)->SetOwnerGUID(0); (*i)->SetRespawnTime(0); @@ -8230,41 +8234,41 @@ bool Unit::IsFriendlyTo(Unit const* unit) const } // faction base cases - FactionTemplateEntry const*tester_faction = tester->getFactionTemplateEntry(); - FactionTemplateEntry const*target_faction = target->getFactionTemplateEntry(); - if(!tester_faction || !target_faction) + FactionTemplateEntry const *tester_faction = tester->getFactionTemplateEntry(); + FactionTemplateEntry const *target_faction = target->getFactionTemplateEntry(); + if (!tester_faction || !target_faction) return false; - if(target->isAttackingPlayer() && tester->IsContestedGuard()) + if (target->isAttackingPlayer() && tester->IsContestedGuard()) return false; // PvC forced reaction and reputation case - if(tester->GetTypeId() == TYPEID_PLAYER) + if (tester->GetTypeId() == TYPEID_PLAYER) { // forced reaction - if(target_faction->faction) + if (target_faction->faction) { - if(ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction)) + if (ReputationRank const *force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction)) return *force >= REP_FRIENDLY; // if faction have reputation then friendly state for tester at 100% dependent from at_war state - if(FactionEntry const* raw_target_faction = sFactionStore.LookupEntry(target_faction->faction)) - if(FactionState const* factionState = ((Player*)tester)->GetReputationMgr().GetState(raw_target_faction)) + if (FactionEntry const *raw_target_faction = sFactionStore.LookupEntry(target_faction->faction)) + if (FactionState const *factionState = ((Player*)tester)->GetReputationMgr().GetState(raw_target_faction)) return !(factionState->Flags & FACTION_FLAG_AT_WAR); } } // CvP forced reaction and reputation case - else if(target->GetTypeId() == TYPEID_PLAYER) + else if (target->GetTypeId() == TYPEID_PLAYER) { // forced reaction - if(tester_faction->faction) + if (tester_faction->faction) { - if(ReputationRank const* force =((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) + if (ReputationRank const *force =((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) return *force >= REP_FRIENDLY; // apply reputation state - if(FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction)) - if(raw_tester_faction->reputationListID >=0 ) + if (FactionEntry const *raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction)) + if (raw_tester_faction->reputationListID >= 0) return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY; } } @@ -8275,12 +8279,12 @@ bool Unit::IsFriendlyTo(Unit const* unit) const bool Unit::IsHostileToPlayers() const { - FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); - if(!my_faction || !my_faction->faction) + FactionTemplateEntry const *my_faction = getFactionTemplateEntry(); + if (!my_faction || !my_faction->faction) return false; - FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if(raw_faction && raw_faction->reputationListID >=0 ) + FactionEntry const *raw_faction = sFactionStore.LookupEntry(my_faction->faction); + if (raw_faction && raw_faction->reputationListID >= 0) return false; return my_faction->IsHostileToPlayers(); @@ -8288,12 +8292,12 @@ bool Unit::IsHostileToPlayers() const bool Unit::IsNeutralToAll() const { - FactionTemplateEntry const* my_faction = getFactionTemplateEntry(); - if(!my_faction || !my_faction->faction) + FactionTemplateEntry const *my_faction = getFactionTemplateEntry(); + if (!my_faction || !my_faction->faction) return true; - FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if(raw_faction && raw_faction->reputationListID >=0 ) + FactionEntry const *raw_faction = sFactionStore.LookupEntry(my_faction->faction); + if (raw_faction && raw_faction->reputationListID >= 0) return false; return my_faction->IsNeutralToAll(); @@ -8333,16 +8337,16 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) if (m_attacking == victim) { // switch to melee attack from ranged/magic - if(meleeAttack) + if (meleeAttack) { - if(!hasUnitState(UNIT_STAT_MELEE_ATTACKING)) + if (!hasUnitState(UNIT_STAT_MELEE_ATTACKING)) { addUnitState(UNIT_STAT_MELEE_ATTACKING); SendMeleeAttackStart(victim); return true; } } - else if(hasUnitState(UNIT_STAT_MELEE_ATTACKING)) + else if (hasUnitState(UNIT_STAT_MELEE_ATTACKING)) { clearUnitState(UNIT_STAT_MELEE_ATTACKING); SendMeleeAttackStop(victim); @@ -8353,11 +8357,11 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) //switch target InterruptSpell(CURRENT_MELEE_SPELL); - if(!meleeAttack) + if (!meleeAttack) clearUnitState(UNIT_STAT_MELEE_ATTACKING); } - if(m_attacking) + if (m_attacking) m_attacking->_removeAttacker(this); m_attacking = victim; @@ -8366,18 +8370,18 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) //Set our target SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); - if(meleeAttack) + if (meleeAttack) addUnitState(UNIT_STAT_MELEE_ATTACKING); // set position before any AI calls/assistance - //if(GetTypeId()==TYPEID_UNIT) + //if(GetTypeId() == TYPEID_UNIT) // ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); - if(GetTypeId()==TYPEID_UNIT) + if (GetTypeId() == TYPEID_UNIT) { // should not let player enter combat by right clicking target SetInCombatWith(victim); - if(victim->GetTypeId() == TYPEID_PLAYER) + if (victim->GetTypeId() == TYPEID_PLAYER) victim->SetInCombatWith(this); AddThreat(victim, 0.0f); @@ -8393,7 +8397,7 @@ bool Unit::Attack(Unit *victim, bool meleeAttack) if(haveOffhandWeapon()) resetAttackTimer(OFF_ATTACK); - if(meleeAttack) + if (meleeAttack) SendMeleeAttackStart(victim); return true; @@ -8417,7 +8421,7 @@ bool Unit::AttackStop() InterruptSpell(CURRENT_MELEE_SPELL); // reset only at real combat stop - if(GetTypeId()==TYPEID_UNIT ) + if (GetTypeId() == TYPEID_UNIT) { ((Creature*)this)->SetNoCallAssistance(false); ((Creature*)this)->SetNoSearchAssistance(false); @@ -8435,7 +8439,7 @@ void Unit::CombatStop(bool includingCast) AttackStop(); RemoveAllAttackers(); - if( GetTypeId() == TYPEID_PLAYER ) + if (GetTypeId() == TYPEID_PLAYER) ((Player*)this)->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel ClearInCombat(); } @@ -8450,17 +8454,17 @@ void Unit::CombatStopWithPets(bool includingCast) bool Unit::isAttackingPlayer() const { - if(hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + if (hasUnitState(UNIT_STAT_ATTACK_PLAYER)) return true; for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) - if((*itr)->isAttackingPlayer()) + if ((*itr)->isAttackingPlayer()) return true; for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i) - if(m_SummonSlot[i]) - if(Creature *summon = GetMap()->GetCreature(m_SummonSlot[i])) - if(summon->isAttackingPlayer()) + if (m_SummonSlot[i]) + if (Creature *summon = GetMap()->GetCreature(m_SummonSlot[i])) + if (summon->isAttackingPlayer()) return true; return false; @@ -8471,7 +8475,7 @@ void Unit::RemoveAllAttackers() while (!m_attackers.empty()) { AttackerSet::iterator iter = m_attackers.begin(); - if(!(*iter)->AttackStop()) + if (!(*iter)->AttackStop()) { sLog.outError("WORLD: Unit has an attacker that isn't attacking it!"); m_attackers.erase(iter); @@ -8486,12 +8490,12 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1))) { SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { PlayerSpellMap const& sp_list = ((Player*)this)->GetSpellMap(); for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { - if(itr->second->state == PLAYERSPELL_REMOVED) continue; + if (itr->second->state == PLAYERSPELL_REMOVED) continue; SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); if (!spellInfo || !IsPassiveSpell(itr->first)) continue; if (spellInfo->CasterAuraState == flag) @@ -8503,7 +8507,7 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) Pet *pet = ((Pet*)this); for (PetSpellMap::const_iterator itr = pet->m_spells.begin(); itr != pet->m_spells.end(); ++itr) { - if(itr->second.state == PLAYERSPELL_REMOVED) continue; + if (itr->second.state == PLAYERSPELL_REMOVED) continue; SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first); if (!spellInfo || !IsPassiveSpell(itr->first)) continue; if (spellInfo->CasterAuraState == flag) @@ -8521,13 +8525,11 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) if (flag != AURA_STATE_ENRAGE) // enrage aura state triggering continues auras { Unit::AuraMap& tAuras = GetAuras(); - for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end(); ) + for (Unit::AuraMap::iterator itr = tAuras.begin(); itr != tAuras.end();) { SpellEntry const* spellProto = (*itr).second->GetSpellProto(); if (spellProto->CasterAuraState == flag) - { RemoveAura(itr); - } else ++itr; } @@ -8540,13 +8542,10 @@ uint32 Unit::BuildAuraStateUpdateForTarget(Unit * target) const { uint32 auraStates = GetUInt32Value(UNIT_FIELD_AURASTATE) &~(PER_CASTER_AURA_STATE_MASK); for (AuraStateAurasMap::const_iterator itr = m_auraStateAuras.begin(); itr != m_auraStateAuras.end(); ++itr) - { if ((1<<(itr->first-1)) & PER_CASTER_AURA_STATE_MASK) - { if (itr->second->GetCasterGUID() == target->GetGUID()) auraStates |= (1<<(itr->first-1)); - } - } + return auraStates; } @@ -8554,11 +8553,11 @@ bool Unit::HasAuraState(AuraState flag, SpellEntry const *spellProto, Unit const { if (Caster) { - if(spellProto) + if (spellProto) { AuraEffectList const& stateAuras = Caster->GetAurasByType(SPELL_AURA_ABILITY_IGNORE_AURASTATE); for (AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j) - if((*j)->isAffectedOnSpell(spellProto)) + if ((*j)->isAffectedOnSpell(spellProto)) return true; } // Check per caster aura state @@ -8577,7 +8576,7 @@ bool Unit::HasAuraState(AuraState flag, SpellEntry const *spellProto, Unit const Unit *Unit::GetOwner(bool inWorld) const { - if(uint64 ownerid = GetOwnerGUID()) + if (uint64 ownerid = GetOwnerGUID()) { if (inWorld) return ObjectAccessor::GetUnit(*this, ownerid); @@ -8588,7 +8587,7 @@ Unit *Unit::GetOwner(bool inWorld) const Unit *Unit::GetCharmer() const { - if(uint64 charmerid = GetCharmerGUID()) + if (uint64 charmerid = GetCharmerGUID()) return ObjectAccessor::GetUnit(*this, charmerid); return NULL; } @@ -8596,7 +8595,7 @@ Unit *Unit::GetCharmer() const Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const { uint64 guid = GetCharmerOrOwnerGUID(); - if(IS_PLAYER_GUID(guid)) + if (IS_PLAYER_GUID(guid)) return ObjectAccessor::GetPlayer(*this, guid); return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL; @@ -8604,10 +8603,10 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const Minion *Unit::GetFirstMinion() const { - if(uint64 pet_guid = GetMinionGUID()) + if (uint64 pet_guid = GetMinionGUID()) { - if(Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid)) - if(pet->HasUnitTypeMask(UNIT_MASK_MINION)) + if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid)) + if (pet->HasUnitTypeMask(UNIT_MASK_MINION)) return (Minion*)pet; sLog.outError("Unit::GetFirstMinion: Minion %u not exist.",GUID_LOPART(pet_guid)); @@ -8619,10 +8618,10 @@ Minion *Unit::GetFirstMinion() const Guardian* Unit::GetGuardianPet() const { - if(uint64 pet_guid = GetPetGUID()) + if (uint64 pet_guid = GetPetGUID()) { - if(Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid)) - if(pet->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) + if (Creature* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, pet_guid)) + if (pet->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) return (Guardian*)pet; sLog.outCrash("Unit::GetGuardianPet: Guardian " I64FMT " not exist.", pet_guid); @@ -8634,9 +8633,9 @@ Guardian* Unit::GetGuardianPet() const Unit* Unit::GetCharm() const { - if(uint64 charm_guid = GetCharmGUID()) + if (uint64 charm_guid = GetCharmGUID()) { - if(Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) + if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) return pet; sLog.outError("Unit::GetCharm: Charmed creature %u not exist.",GUID_LOPART(charm_guid)); @@ -8650,9 +8649,9 @@ void Unit::SetMinion(Minion *minion, bool apply) { sLog.outDebug("SetMinion %u for %u, apply %u", minion->GetEntry(), GetEntry(), apply); - if(apply) + if (apply) { - if(!minion->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) + if (!minion->AddUInt64Value(UNIT_FIELD_SUMMONEDBY, GetGUID())) { sLog.outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry()); return; @@ -8660,21 +8659,21 @@ void Unit::SetMinion(Minion *minion, bool apply) m_Controlled.insert(minion); - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { minion->m_ControlledByPlayer = true; minion->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); } // Can only have one pet. If a new one is summoned, dismiss the old one. - if(minion->IsGuardianPet()) + if (minion->IsGuardianPet()) { - if(Guardian* oldPet = GetGuardianPet()) + if (Guardian* oldPet = GetGuardianPet()) { - if(oldPet != minion && (oldPet->isPet() || minion->isPet() || oldPet->GetEntry() != minion->GetEntry())) + if (oldPet != minion && (oldPet->isPet() || minion->isPet() || oldPet->GetEntry() != minion->GetEntry())) { // remove existing minion pet - if(oldPet->isPet()) + if (oldPet->isPet()) ((Pet*)oldPet)->Remove(PET_SAVE_AS_CURRENT); else oldPet->UnSummon(); @@ -8689,9 +8688,9 @@ void Unit::SetMinion(Minion *minion, bool apply) } } - if(minion->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) + if (minion->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) { - if(AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID())) + if (AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID())) { } } @@ -8702,29 +8701,25 @@ void Unit::SetMinion(Minion *minion, bool apply) minion->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1)); // FIXME: hack, speed must be set only at follow - if(GetTypeId() == TYPEID_PLAYER && minion->isPet()) + if (GetTypeId() == TYPEID_PLAYER && minion->isPet()) for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i) minion->SetSpeed(UnitMoveType(i), m_speed_rate[i], true); // Ghoul pets have energy instead of mana (is anywhere better place for this code?) if (minion->IsPetGhoul()) - { minion->setPowerType(POWER_ENERGY); - } if (GetTypeId() == TYPEID_PLAYER) { // Send infinity cooldown - client does that automatically but after relog cooldown needs to be set again SpellEntry const *spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL)); if (spellInfo && (spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)) - { ((Player*)this)->AddSpellAndCategoryCooldowns(spellInfo, 0, NULL ,true); - } } } else { - if(minion->GetOwnerGUID() != GetGUID()) + if (minion->GetOwnerGUID() != GetGUID()) { sLog.outCrash("SetMinion: Minion %u is not the minion of owner %u", minion->GetEntry(), GetEntry()); return; @@ -8732,8 +8727,8 @@ void Unit::SetMinion(Minion *minion, bool apply) m_Controlled.erase(minion); - if(minion->IsGuardianPet()) - if(GetPetGUID() == minion->GetGUID()) + if (minion->IsGuardianPet()) + if (GetPetGUID() == minion->GetGUID()) SetPetGUID(0); if (GetTypeId() == TYPEID_PLAYER) @@ -8741,25 +8736,23 @@ void Unit::SetMinion(Minion *minion, bool apply) SpellEntry const *spellInfo = sSpellStore.LookupEntry(minion->GetUInt32Value(UNIT_CREATED_BY_SPELL)); // Remove infinity cooldown if (spellInfo && (spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE)) - { ((Player*)this)->SendCooldownEvent(spellInfo); - } } //if(minion->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) { - if(RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID())) + if (RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID())) { //Check if there is another minion for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) { // do not use this check, creature do not have charm guid //if(GetCharmGUID() == (*itr)->GetGUID()) - if(GetGUID() == (*itr)->GetCharmerGUID()) + if (GetGUID() == (*itr)->GetCharmerGUID()) continue; //assert((*itr)->GetOwnerGUID() == GetGUID()); - if((*itr)->GetOwnerGUID() != GetGUID()) + if ((*itr)->GetOwnerGUID() != GetGUID()) { OutDebugInfo(); (*itr)->OutDebugInfo(); @@ -8767,15 +8760,15 @@ void Unit::SetMinion(Minion *minion, bool apply) } assert((*itr)->GetTypeId() == TYPEID_UNIT); - if(!(*itr)->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) + if (!(*itr)->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)) continue; - if(AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID())) + if (AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID())) { //show another pet bar if there is no charm bar - if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID()) + if (GetTypeId() == TYPEID_PLAYER && !GetCharmGUID()) { - if((*itr)->isPet()) + if ((*itr)->isPet()) ((Player*)this)->PetSpellInitialize(); else ((Player*)this)->CharmSpellInitialize(); @@ -8792,11 +8785,11 @@ void Unit::SetMinion(Minion *minion, bool apply) void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry) { - for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ) + for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();) { Unit *unit = *itr; ++itr; - if(unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT + if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->isSummon()) // minion, actually Minions.push_back((Creature*)unit); } @@ -8804,11 +8797,11 @@ void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry) void Unit::RemoveAllMinionsByEntry(uint32 entry) { - for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ) + for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();) { Unit *unit = *itr; ++itr; - if(unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT + if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->isSummon()) // minion, actually ((TempSummon*)unit)->UnSummon(); // i think this is safe because i have never heard that a despawned minion will trigger a same minion @@ -8817,11 +8810,11 @@ void Unit::RemoveAllMinionsByEntry(uint32 entry) void Unit::SetCharm(Unit* charm, bool apply) { - if(apply) + if (apply) { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) + if (!AddUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) sLog.outCrash("Player %s is trying to charm unit %u, but it already has a charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID()); charm->m_ControlledByPlayer = true; @@ -8834,10 +8827,10 @@ void Unit::SetCharm(Unit* charm, bool apply) // PvP, FFAPvP charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, GetByteValue(UNIT_FIELD_BYTES_2, 1)); - if(!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) + if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog.outCrash("Unit %u is being charmed, but it already has a charmer %u", charm->GetEntry(), charm->GetCharmerGUID()); - if(charm->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) + if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE)) { charm->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); charm->SendMovementFlagUpdate(); @@ -8847,16 +8840,16 @@ void Unit::SetCharm(Unit* charm, bool apply) } else { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(!RemoveUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) + if (!RemoveUInt64Value(UNIT_FIELD_CHARM, charm->GetGUID())) sLog.outCrash("Player %s is trying to uncharm unit %u, but it has another charmed unit %u", GetName(), charm->GetEntry(), GetCharmGUID()); } - if(!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) + if (!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID())) sLog.outCrash("Unit %u is being uncharmed, but it has another charmer %u", charm->GetEntry(), charm->GetCharmerGUID()); - if(charm->GetTypeId() == TYPEID_PLAYER) + if (charm->GetTypeId() == TYPEID_PLAYER) { charm->m_ControlledByPlayer = true; charm->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); @@ -8875,7 +8868,7 @@ void Unit::SetCharm(Unit* charm, bool apply) charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0); } - if(charm->GetTypeId() == TYPEID_PLAYER + if (charm->GetTypeId() == TYPEID_PLAYER || !((Creature*)charm)->HasUnitTypeMask(UNIT_MASK_MINION) || charm->GetOwnerGUID() != GetGUID()) m_Controlled.erase(charm); @@ -8888,7 +8881,7 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellPro Unit* unit = this; - if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem()) unit = GetOwner(); if (unit->GetTypeId() == TYPEID_PLAYER) @@ -8974,7 +8967,7 @@ void Unit::RemoveAllControlled() { Unit *target = *m_Controlled.begin(); m_Controlled.erase(m_Controlled.begin()); - if(target->GetCharmerGUID() == GetGUID()) + if (target->GetCharmerGUID() == GetGUID()) target->RemoveCharmAuras(); else if (target->GetOwnerGUID() == GetGUID() && target->isSummon()) ((TempSummon*)target)->UnSummon(); @@ -8992,7 +8985,7 @@ void Unit::RemoveAllControlled() Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) { Player* player = NULL; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) player = (Player*)this; // Should we enable this also for charmed units? else if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) @@ -9005,7 +8998,7 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) if (!pGroup) { // We are pet now, return owner - if(player!=this) + if (player!=this) return IsWithinDistInMap(player, radius) ? player : NULL; Unit * pet = GetGuardianPet(); //No pet, no group, nothing to return @@ -9020,20 +9013,17 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) nearMembers.reserve(pGroup->GetMembersCount()*2); for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player* Target = itr->getSource(); - - // IsHostileTo check duel and controlled by enemy - if( Target && Target !=this && Target->isAlive() && IsWithinDistInMap(Target, radius) && - !IsHostileTo(Target) ) - nearMembers.push_back(Target); + if (Player *Target = itr->getSource()) + { + // IsHostileTo check duel and controlled by enemy + if (Target !=this && Target->isAlive() && IsWithinDistInMap(Target, radius) && !IsHostileTo(Target)) + nearMembers.push_back(Target); // Push player's pet to vector - Unit * pet = Target->GetGuardianPet(); - if (pet && pet !=this && pet->isAlive() && IsWithinDistInMap(pet, radius) && - !IsHostileTo(pet) ) - nearMembers.push_back(pet); - } + if (Unit *pet = Target->GetGuardianPet()) + if (pet != this && pet->isAlive() && IsWithinDistInMap(pet, radius) && !IsHostileTo(pet)) + nearMembers.push_back(pet); + } if (nearMembers.empty()) return NULL; @@ -9045,10 +9035,10 @@ Unit* Unit::GetNextRandomRaidMemberOrPet(float radius) /* Player * Unit::GetMoverSource() const { - if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->m_mover == this) + if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->m_mover == this) return (Player*)this; - if(Unit *charmer = GetCharmer()) - if(charmer->GetTypeId() == TYPEID_PLAYER && ((Player*)charmer)->m_mover == this) + if (Unit *charmer = GetCharmer()) + if (charmer->GetTypeId() == TYPEID_PLAYER && ((Player*)charmer)->m_mover == this) return (Player*)charmer; return NULL; } @@ -9057,7 +9047,7 @@ Player * Unit::GetMoverSource() const //only called in Player::SetSeer void Unit::AddPlayerToVision(Player* plr) { - if(m_sharedVision.empty()) + if (m_sharedVision.empty()) { setActive(true); SetWorldObject(true); @@ -9069,7 +9059,7 @@ void Unit::AddPlayerToVision(Player* plr) void Unit::RemovePlayerFromVision(Player* plr) { m_sharedVision.remove(plr); - if(m_sharedVision.empty()) + if (m_sharedVision.empty()) { setActive(false); SetWorldObject(false); @@ -9091,14 +9081,14 @@ void Unit::RemoveCharmAuras() void Unit::UnsummonAllTotems() { - for (int8 i = 0; i < MAX_SUMMON_SLOT; ++i) + for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i) { - if(!m_SummonSlot[i]) + if (!m_SummonSlot[i]) continue; - Creature *OldTotem = GetMap()->GetCreature(m_SummonSlot[i]); - if(OldTotem && OldTotem->isSummon()) - ((TempSummon*)OldTotem)->UnSummon(); + if (Creature *OldTotem = GetMap()->GetCreature(m_SummonSlot[i])) + if (OldTotem->isSummon()) + ((TempSummon*)OldTotem)->UnSummon(); } } @@ -9136,15 +9126,13 @@ void Unit::EnergizeBySpell(Unit *pVictim, uint32 SpellID, uint32 Damage, Powers uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { - if(!spellProto || !pVictim || damagetype==DIRECT_DAMAGE ) + if (!spellProto || !pVictim || damagetype == DIRECT_DAMAGE) return pdamage; // For totems get damage bonus from owner - if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem()) - { - if(Unit* owner = GetOwner()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem()) + if (Unit *owner = GetOwner()) return owner->SpellDamageBonus(pVictim, spellProto, pdamage, damagetype); - } // Taken/Done total percent damage auras float DoneTotalMod = 1.0f; @@ -9158,9 +9146,9 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet()) DoneTotalMod *= ((Creature*)this)->GetSpellDamageMod(((Creature*)this)->GetCreatureInfo()->rank); - AuraEffectList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); + AuraEffectList const &mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); for (AuraEffectList::const_iterator i = mModDamagePercentDone.begin(); i != mModDamagePercentDone.end(); ++i) - if(((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto)) && + if (((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto)) && (*i)->GetSpellProto()->EquippedItemClass == -1 && // -1 == any item class (not wand) (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0) // 0 == any inventory type (not wand) DoneTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f; @@ -9168,21 +9156,19 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); // Add flat bonus from spell damage versus DoneTotal += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_FLAT_SPELL_DAMAGE_VERSUS, creatureTypeMask); - AuraEffectList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); + AuraEffectList const &mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetMiscValue())) + if (creatureTypeMask & uint32((*i)->GetMiscValue())) DoneTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f; // done scripted mod (take it from owner) - Unit *owner = GetOwner(); - if (!owner) - owner = this; - AuraEffectList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit *owner = GetOwner() ? GetOwner() : this; + AuraEffectList const &mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) continue; - switch((*i)->GetMiscValue()) + switch ((*i)->GetMiscValue()) { case 4920: // Molten Fury case 4919: @@ -9190,7 +9176,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 case 6926: case 6928: { - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this)) + if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this)) DoneTotalMod *= (100.0f+(*i)->GetAmount())/100.0f; break; } @@ -9204,10 +9190,10 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 int32 stepPercent = CalculateSpellDamage((*i)->GetSpellProto(), 0, (*i)->GetSpellProto()->EffectBasePoints[0], this); // count affliction effects and calc additional damage in percentage int32 modPercent = 0; - AuraMap const& victimAuras = pVictim->GetAuras(); + AuraMap const &victimAuras = pVictim->GetAuras(); for (AuraMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr) { - SpellEntry const* m_spell = itr->second->GetSpellProto(); + SpellEntry const *m_spell = itr->second->GetSpellProto(); if (m_spell->SpellFamilyName != SPELLFAMILY_WARLOCK || !(m_spell->SpellFamilyFlags[1] & 0x0004071B || m_spell->SpellFamilyFlags[0] & 0x8044C402)) continue; modPercent += stepPercent * itr->second->GetStackAmount(); @@ -9250,7 +9236,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // Merciless Combat if ((*i)->GetSpellProto()->SpellIconID == 2656) { - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this)) + if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this)) DoneTotalMod *= (100.0f+(*i)->GetAmount())/100.0f; } // Tundra Stalker @@ -9313,7 +9299,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // Torment the weak if (spellProto->SpellFamilyFlags[0]&0x20200021 || spellProto->SpellFamilyFlags[1]& 0x9000) - if(pVictim->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED)) + if (pVictim->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED)) { AuraEffectList const& mDumyAuras = GetAurasByType(SPELL_AURA_DUMMY); for (AuraEffectList::const_iterator i = mDumyAuras.begin(); i != mDumyAuras.end(); ++i) @@ -9338,26 +9324,26 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 case SPELLFAMILY_PALADIN: // Judgement of Vengeance/Judgement of Corruption - if((spellProto->SpellFamilyFlags[1] & 0x400000) && spellProto->SpellIconID==2292) + if ((spellProto->SpellFamilyFlags[1] & 0x400000) && spellProto->SpellIconID==2292) { // Get stack of Holy Vengeance/Blood Corruption on the target added by caster uint32 stacks = 0; Unit::AuraEffectList const& auras = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) - if(((*itr)->GetId() == 31803 || (*itr)->GetId() == 53742) && (*itr)->GetCasterGUID()==GetGUID()) + if (((*itr)->GetId() == 31803 || (*itr)->GetId() == 53742) && (*itr)->GetCasterGUID()==GetGUID()) { stacks = (*itr)->GetParentAura()->GetStackAmount(); break; } // + 10% for each application of Holy Vengeance/Blood Corruption on the target - if(stacks) - DoneTotalMod *= (10.0f + (float)stacks) / 10.0f; + if (stacks) + DoneTotalMod *= (10.0f + float(stacks)) / 10.0f; } break; case SPELLFAMILY_WARLOCK: //Fire and Brimstone - if(spellProto->SpellFamilyFlags[1] & 0x00020040) - if(pVictim->HasAuraState(AURA_STATE_CONFLAGRATE)) + if (spellProto->SpellFamilyFlags[1] & 0x00020040) + if (pVictim->HasAuraState(AURA_STATE_CONFLAGRATE)) { AuraEffectList const& mDumyAuras = GetAurasByType(SPELL_AURA_DUMMY); for (AuraEffectList::const_iterator i = mDumyAuras.begin(); i != mDumyAuras.end(); ++i) @@ -9388,7 +9374,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // ..taken AuraEffectList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); for (AuraEffectList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) - if( (*i)->GetMiscValue() & GetSpellSchoolMask(spellProto) ) + if ((*i)->GetMiscValue() & GetSpellSchoolMask(spellProto) ) TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f; // .. taken pct: dummy auras @@ -9404,14 +9390,14 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 } // Ebon Plague if (AuraEffect *dummy = pVictim->GetDummyAura(SPELLFAMILY_DEATHKNIGHT, 1933, 1)) - if(dummy->GetMiscValue() & GetSpellSchoolMask(spellProto)) + if (dummy->GetMiscValue() & GetSpellSchoolMask(spellProto)) TakenTotalMod *= (dummy->GetAmount()+100.0f)/100.0f; } // From caster spells AuraEffectList const& mOwnerTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER); for (AuraEffectList::const_iterator i = mOwnerTaken.begin(); i != mOwnerTaken.end(); ++i) - if( (*i)->GetCasterGUID() == GetGUID() && (*i)->isAffectedOnSpell(spellProto)) + if ((*i)->GetCasterGUID() == GetGUID() && (*i)->isAffectedOnSpell(spellProto)) TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f; // Mod damage from spell mechanic @@ -9419,7 +9405,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 { AuraEffectList const& mDamageDoneMechanic = pVictim->GetAurasByType(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT); for (AuraEffectList::const_iterator i = mDamageDoneMechanic.begin(); i != mDamageDoneMechanic.end(); ++i) - if(mechanicMask & uint32(1<<((*i)->GetMiscValue()))) + if (mechanicMask & uint32(1<<((*i)->GetMiscValue()))) TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f; } @@ -9433,7 +9419,7 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // Check for table values float coeff = 0; - SpellBonusEntry const* bonus = spellmgr.GetSpellBonusData(spellProto->Id); + SpellBonusEntry const *bonus = spellmgr.GetSpellBonusData(spellProto->Id); if (bonus) { if (damagetype == DOT) @@ -9454,64 +9440,66 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3 // Default calculation if (DoneAdvertisedBenefit || TakenAdvertisedBenefit) { - if(!bonus || coeff < 0) - { - // Damage Done from spell damage bonus - int32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto); - // Damage over Time spells bonus calculation - float DotFactor = 1.0f; - if(damagetype == DOT) + if (!bonus || coeff < 0) { - int32 DotDuration = GetSpellDuration(spellProto); - // 200% limit - if(DotDuration > 0) + // Damage Done from spell damage bonus + int32 CastingTime = IsChanneledSpell(spellProto) ? GetSpellDuration(spellProto) : GetSpellCastTime(spellProto); + // Damage over Time spells bonus calculation + float DotFactor = 1.0f; + if (damagetype == DOT) { - if(DotDuration > 30000) DotDuration = 30000; - if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f; - int x = 0; - for (uint8 j = 0; j < MAX_SPELL_EFFECTS; j++) - { - if( spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( - spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE || - spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) ) + int32 DotDuration = GetSpellDuration(spellProto); + // 200% limit + if (DotDuration > 0) + { + if (DotDuration > 30000) + DotDuration = 30000; + if (!IsChanneledSpell(spellProto)) + DotFactor = DotDuration / 15000.0f; + uint8 x = 0; + for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) { - x = j; - break; + if (spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && ( + spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_DAMAGE || + spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH)) + { + x = j; + break; + } + } + int32 DotTicks = 6; + if (spellProto->EffectAmplitude[x] != 0) + DotTicks = DotDuration / spellProto->EffectAmplitude[x]; + if (DotTicks) + { + DoneAdvertisedBenefit /= DotTicks; + TakenAdvertisedBenefit /= DotTicks; } - } - int32 DotTicks = 6; - if(spellProto->EffectAmplitude[x] != 0) - DotTicks = DotDuration / spellProto->EffectAmplitude[x]; - if(DotTicks) - { - DoneAdvertisedBenefit /= DotTicks; - TakenAdvertisedBenefit /= DotTicks; } } - } - // Distribute Damage over multiple effects, reduce by AoE - CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); + // Distribute Damage over multiple effects, reduce by AoE + CastingTime = GetCastingTimeForBonus( spellProto, damagetype, CastingTime ); - // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing - for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) - { - if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || - spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH ) + // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing + for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) { - CastingTime /= 2; - break; + if (spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || + spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH) + { + CastingTime /= 2; + break; + } } - } - if(spellProto->SchoolMask != SPELL_SCHOOL_MASK_NORMAL) - coeff = (CastingTime / 3500.0f) * DotFactor; - else - coeff = DotFactor; + if (spellProto->SchoolMask != SPELL_SCHOOL_MASK_NORMAL) + coeff = (CastingTime / 3500.0f) * DotFactor; + else + coeff = DotFactor; } float coeff2 = CalculateLevelPenalty(spellProto) * stack; - if(spellProto->SpellFamilyName) //TODO: fix this + if (spellProto->SpellFamilyName) //TODO: fix this TakenTotal+= TakenAdvertisedBenefit * coeff * coeff2; - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_SPELL_BONUS_DAMAGE, coeff); @@ -9537,7 +9525,7 @@ int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask) // ..done AuraEffectList const& mDamageDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); for (AuraEffectList::const_iterator i = mDamageDone.begin(); i != mDamageDone.end(); ++i) - if(((*i)->GetMiscValue() & schoolMask) != 0 && + if (((*i)->GetMiscValue() & schoolMask) != 0 && (*i)->GetSpellProto()->EquippedItemClass == -1 && // -1 == any item class (not wand then) (*i)->GetSpellProto()->EquippedItemInventoryTypeMask == 0 ) @@ -9553,7 +9541,7 @@ int32 Unit::SpellBaseDamageBonus(SpellSchoolMask schoolMask) AuraEffectList const& mDamageDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT); for (AuraEffectList::const_iterator i = mDamageDoneOfStatPercent.begin(); i != mDamageDoneOfStatPercent.end(); ++i) { - if((*i)->GetMiscValue() & schoolMask) + if ((*i)->GetMiscValue() & schoolMask) { // stat used stored in miscValueB for this aura Stats usedStat = Stats((*i)->GetMiscBValue()); @@ -9578,13 +9566,13 @@ int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVic // ..done (for creature type by mask) in taken AuraEffectList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); for (AuraEffectList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetMiscValue())) + if (creatureTypeMask & uint32((*i)->GetMiscValue())) TakenAdvertisedBenefit += (*i)->GetAmount(); // ..taken AuraEffectList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i) - if(((*i)->GetMiscValue() & schoolMask) != 0) + if (((*i)->GetMiscValue() & schoolMask) != 0) TakenAdvertisedBenefit += (*i)->GetAmount(); return TakenAdvertisedBenefit; @@ -9593,7 +9581,7 @@ int32 Unit::SpellBaseDamageBonusForVictim(SpellSchoolMask schoolMask, Unit *pVic bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType) const { // not critting spell - if((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT)) + if ((spellProto->AttributesEx2 & SPELL_ATTR_EX2_CANT_CRIT)) return false; float crit_chance = 0.0f; @@ -9723,23 +9711,17 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM // Rend and Tear - bonus crit chance for bleeding targets of Ferocious Bite if (spellProto->SpellFamilyFlags[0] & 0x00800000 && pVictim->HasAuraState(AURA_STATE_BLEEDING, spellProto, this)) { - if (AuraEffect const* rendAndTear = GetDummyAura(SPELLFAMILY_DRUID, 2859, 1)) - { + if (AuraEffect const *rendAndTear = GetDummyAura(SPELLFAMILY_DRUID, 2859, 1)) crit_chance += rendAndTear->GetAmount(); - } break; } break; case SPELLFAMILY_PALADIN: - // Judgement of Command proc always crits on stunned target - if(spellProto->SpellFamilyName == SPELLFAMILY_PALADIN) - { - if(spellProto->SpellFamilyFlags[0] & 0x0000000000800000LL && spellProto->SpellIconID == 561) - { - if(pVictim->hasUnitState(UNIT_STAT_STUNNED)) - return true; - } - } + // Judgement of Command proc always crits on stunned target + if (spellProto->SpellFamilyName == SPELLFAMILY_PALADIN) + if (spellProto->SpellFamilyFlags[0] & 0x0000000000800000LL && spellProto->SpellIconID == 561) + if (pVictim->hasUnitState(UNIT_STAT_STUNNED)) + return true; } } case SPELL_DAMAGE_CLASS_RANGED: @@ -9756,7 +9738,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM } // percent done // only players use intelligence for critical chance computations - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); crit_chance = crit_chance > 0.0f ? crit_chance : 0.0f; @@ -9782,16 +9764,16 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const *spellProto, uint32 damag } // adds additional damage to crit_bonus (from talents) - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); - if(pVictim) + if (pVictim) { uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask)); } - if(crit_bonus > 0) + if (crit_bonus > 0) damage += crit_bonus; return damage; @@ -9813,13 +9795,13 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama break; } - if(pVictim) + if (pVictim) { uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask)); } - if(crit_bonus > 0) + if (crit_bonus > 0) damage += crit_bonus; damage = int32(float(damage) * GetTotalAuraMultiplier(SPELL_AURA_MOD_CRITICAL_HEALING_AMOUNT)); @@ -9830,8 +9812,8 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const *spellProto, uint32 dama uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) { // For totems get healing bonus from owner (statue isn't totem in fact) - if( GetTypeId()==TYPEID_UNIT && ((Creature*)this)->isTotem()) - if(Unit* owner = GetOwner()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isTotem()) + if (Unit* owner = GetOwner()) return owner->SpellHealingBonus(pVictim, spellProto, healamount, damagetype, stack); // Healing Done @@ -9847,9 +9829,8 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint DoneTotalMod *= (100.0f + (*i)->GetAmount()) / 100.0f; // done scripted mod (take it from owner) - Unit *owner = GetOwner(); - if (!owner) owner = this; - AuraEffectList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + Unit *owner = GetOwner() ? GetOwner() : this; + AuraEffectList const &mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) @@ -9963,9 +9944,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint } // Earthliving - 0.45% of normal hot coeff else if (spellProto->SpellFamilyName==SPELLFAMILY_SHAMAN && spellProto->SpellFamilyFlags[1] & 0x80000) - { factorMod *= 0.45f; - } // Already set to scripted? so not uses healing bonus coefficient // No heal coeff for SPELL_DAMAGE_CLASS_NONE class spells by default else if (scripted || spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE) @@ -9984,14 +9963,14 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint int32 CastingTime = !IsChanneledSpell(spellProto) ? GetSpellCastTime(spellProto) : GetSpellDuration(spellProto); // Damage over Time spells bonus calculation float DotFactor = 1.0f; - if(damagetype == DOT) + if (damagetype == DOT) { int32 DotDuration = GetSpellDuration(spellProto); // 200% limit - if(DotDuration > 0) + if (DotDuration > 0) { - if(DotDuration > 30000) DotDuration = 30000; - if(!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f; + if (DotDuration > 30000) DotDuration = 30000; + if (!IsChanneledSpell(spellProto)) DotFactor = DotDuration / 15000.0f; uint32 x = 0; for (uint8 j = 0; j < MAX_SPELL_EFFECTS; j++) { @@ -10004,9 +9983,9 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint } } int32 DotTicks = 6; - if(spellProto->EffectAmplitude[x] != 0) + if (spellProto->EffectAmplitude[x] != 0) DotTicks = DotDuration / spellProto->EffectAmplitude[x]; - if(DotTicks) + if (DotTicks) { DoneAdvertisedBenefit = DoneAdvertisedBenefit * int32(stack) / DotTicks; TakenAdvertisedBenefit = TakenAdvertisedBenefit * int32(stack) / DotTicks; @@ -10018,7 +9997,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint // 50% for damage and healing spells for leech spells from damage bonus and 0% from healing for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) { - if( spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || + if (spellProto->Effect[j] == SPELL_EFFECT_HEALTH_LEECH || spellProto->Effect[j] == SPELL_EFFECT_APPLY_AURA && spellProto->EffectApplyAuraName[j] == SPELL_AURA_PERIODIC_LEECH ) { CastingTime /= 2; @@ -10031,7 +10010,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint factorMod *= CalculateLevelPenalty(spellProto)* stack; TakenTotal += TakenAdvertisedBenefit * coeff * factorMod; - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_SPELL_BONUS_DAMAGE, coeff); @@ -10043,7 +10022,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint // use float as more appropriate for negative values and percent applying float heal = (int32(healamount) + DoneTotal) * DoneTotalMod; // apply spellmod to Done amount - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); // Nourish cast @@ -10078,7 +10057,7 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint { // Healing over time taken percent float minval_hot = pVictim->GetMaxNegativeAuraModifier(SPELL_AURA_MOD_HOT_PCT); - if(minval_hot) + if (minval_hot) TakenTotalMod *= (100.0f + minval_hot) / 100.0f; float maxval_hot = pVictim->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HOT_PCT); @@ -10102,7 +10081,7 @@ int32 Unit::SpellBaseHealingBonus(SpellSchoolMask schoolMask) AuraEffectList const& mHealingDone = GetAurasByType(SPELL_AURA_MOD_HEALING_DONE); for (AuraEffectList::const_iterator i = mHealingDone.begin(); i != mHealingDone.end(); ++i) - if(((*i)->GetMiscValue() & schoolMask) != 0) + if (((*i)->GetMiscValue() & schoolMask) != 0) AdvertisedBenefit += (*i)->GetAmount(); // Healing bonus of spirit, intellect and strength @@ -10134,7 +10113,7 @@ int32 Unit::SpellBaseHealingBonusForVictim(SpellSchoolMask schoolMask, Unit *pVi int32 AdvertisedBenefit = 0; AuraEffectList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_HEALING); for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i) - if(((*i)->GetMiscValue() & schoolMask) != 0) + if (((*i)->GetMiscValue() & schoolMask) != 0) AdvertisedBenefit += (*i)->GetAmount(); return AdvertisedBenefit; } @@ -10144,13 +10123,13 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) //If m_immuneToSchool type contain this school type, IMMUNE damage. SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if(itr->type & shoolMask) + if (itr->type & shoolMask) return true; //If m_immuneToDamage type contain magic, IMMUNE damage. SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE]; for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr) - if(itr->type & shoolMask) + if (itr->type & shoolMask) return true; return false; @@ -10159,19 +10138,19 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) bool Unit::IsImmunedToDamage(SpellEntry const* spellInfo) { uint32 shoolMask = GetSpellSchoolMask(spellInfo); - if(spellInfo->Id != 42292 && spellInfo->Id !=59752) + if (spellInfo->Id != 42292 && spellInfo->Id !=59752) { //If m_immuneToSchool type contain this school type, IMMUNE damage. SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if(itr->type & shoolMask &&!IsDispelableBySpell(spellInfo, itr->spellId)) + if (itr->type & shoolMask &&!IsDispelableBySpell(spellInfo, itr->spellId)) return true; } //If m_immuneToDamage type contain magic, IMMUNE damage. SpellImmuneList const& damageList = m_spellImmune[IMMUNITY_DAMAGE]; for (SpellImmuneList::const_iterator itr = damageList.begin(); itr != damageList.end(); ++itr) - if(itr->type & shoolMask) + if (itr->type & shoolMask) return true; return false; @@ -10185,30 +10164,30 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo) // Single spell immunity. SpellImmuneList const& idList = m_spellImmune[IMMUNITY_ID]; for (SpellImmuneList::const_iterator itr = idList.begin(); itr != idList.end(); ++itr) - if(itr->type == spellInfo->Id) + if (itr->type == spellInfo->Id) return true; - if(spellInfo->Dispel) + if (spellInfo->Dispel) { SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) - if(itr->type == spellInfo->Dispel) + if (itr->type == spellInfo->Dispel) return true; } - if(spellInfo->Mechanic) + if (spellInfo->Mechanic) { SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) - if(itr->type == spellInfo->Mechanic) + if (itr->type == spellInfo->Mechanic) return true; } - if(spellInfo->Id != 42292 && spellInfo->Id !=59752) + if (spellInfo->Id != 42292 && spellInfo->Id !=59752) { SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if((itr->type & GetSpellSchoolMask(spellInfo)) + if ((itr->type & GetSpellSchoolMask(spellInfo)) && !(IsPositiveSpell(itr->spellId) && IsPositiveSpell(spellInfo->Id)) && !IsDispelableBySpell(spellInfo, itr->spellId)) return true; @@ -10225,22 +10204,22 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con uint32 effect = spellInfo->Effect[index]; SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT]; for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr) - if(itr->type == effect) + if (itr->type == effect) return true; - if(uint32 mechanic = spellInfo->EffectMechanic[index]) + if (uint32 mechanic = spellInfo->EffectMechanic[index]) { SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) - if(itr->type == spellInfo->EffectMechanic[index]) + if (itr->type == spellInfo->EffectMechanic[index]) return true; } - if(uint32 aura = spellInfo->EffectApplyAuraName[index]) + if (uint32 aura = spellInfo->EffectApplyAuraName[index]) { SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE]; for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) - if(itr->type == aura) + if (itr->type == aura) return true; // Check for immune to application of harmful magical effects AuraEffectList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL); @@ -10256,21 +10235,21 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con bool Unit::IsDamageToThreatSpell(SpellEntry const * spellInfo) const { - if(!spellInfo) + if (!spellInfo) return false; switch(spellInfo->SpellFamilyName) { case SPELLFAMILY_WARLOCK: - if(spellInfo->SpellFamilyFlags[0] == 0x100) // Searing Pain + if (spellInfo->SpellFamilyFlags[0] == 0x100) // Searing Pain return true; break; case SPELLFAMILY_SHAMAN: - if(spellInfo->SpellFamilyFlags[0] == SPELLFAMILYFLAG_SHAMAN_FROST_SHOCK) + if (spellInfo->SpellFamilyFlags[0] == SPELLFAMILYFLAG_SHAMAN_FROST_SHOCK) return true; break; case SPELLFAMILY_DEATHKNIGHT: - if(spellInfo->SpellFamilyFlags[1] == 0x20000000) // Rune Strike + if (spellInfo->SpellFamilyFlags[1] == 0x20000000) // Rune Strike return true; break; } @@ -10295,7 +10274,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att // ..done (for creature type by mask) in taken AuraEffectList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); for (AuraEffectList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetMiscValue())) + if (creatureTypeMask & uint32((*i)->GetMiscValue())) DoneFlatBenefit += (*i)->GetAmount(); // ..done @@ -10310,7 +10289,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att // ..done (base at attack power and creature type) AuraEffectList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_VERSUS); for (AuraEffectList::const_iterator i = mCreatureAttackPower.begin(); i != mCreatureAttackPower.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetMiscValue())) + if (creatureTypeMask & uint32((*i)->GetMiscValue())) APbonus += (*i)->GetAmount(); } else @@ -10320,24 +10299,21 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att // ..done (base at attack power and creature type) AuraEffectList const& mCreatureAttackPower = GetAurasByType(SPELL_AURA_MOD_MELEE_ATTACK_POWER_VERSUS); for (AuraEffectList::const_iterator i = mCreatureAttackPower.begin(); i != mCreatureAttackPower.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetMiscValue())) + if (creatureTypeMask & uint32((*i)->GetMiscValue())) APbonus += (*i)->GetAmount(); } if (APbonus != 0) // Can be negative { bool normalized = false; - if(spellProto) - { + if (spellProto) for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - { if (spellProto->Effect[i] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) { normalized = true; break; } - } - } + // This is not a typo - Impurity has SPELLFAMILY_DRUID if (AuraEffect const * aurEff = GetDummyAura(SPELLFAMILY_DRUID, 1986, 0)) APbonus *= (100.0f + aurEff->GetAmount()) / 100.0f; @@ -10348,10 +10324,10 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att // ..taken AuraEffectList const& mDamageTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_TAKEN); for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i) - if((*i)->GetMiscValue() & GetMeleeDamageSchoolMask()) + if ((*i)->GetMiscValue() & GetMeleeDamageSchoolMask()) TakenFlatBenefit += (*i)->GetAmount(); - if(attType!=RANGED_ATTACK) + if (attType!=RANGED_ATTACK) TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN); else TakenFlatBenefit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_RANGED_DAMAGE_TAKEN); @@ -10376,7 +10352,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att AuraEffectList const &mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); for (AuraEffectList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i) - if(creatureTypeMask & uint32((*i)->GetMiscValue())) + if (creatureTypeMask & uint32((*i)->GetMiscValue())) DoneTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f; // done scripted mod (take it from owner) @@ -10421,7 +10397,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att // ..taken AuraEffectList const& mModDamagePercentTaken = pVictim->GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN); for (AuraEffectList::const_iterator i = mModDamagePercentTaken.begin(); i != mModDamagePercentTaken.end(); ++i) - if((*i)->GetMiscValue() & GetMeleeDamageSchoolMask()) + if ((*i)->GetMiscValue() & GetMeleeDamageSchoolMask()) TakenTotalMod *= ((*i)->GetAmount()+100.0f)/100.0f; // .. taken pct (special attacks) @@ -10451,9 +10427,9 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att { //Cheat Death case 2109: - if((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) + if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL) { - if(pVictim->GetTypeId() != TYPEID_PLAYER) + if (pVictim->GetTypeId() != TYPEID_PLAYER) continue; float mod = ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f); if (mod < (*i)->GetAmount()) @@ -10476,10 +10452,10 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att switch((*i)->GetMiscValue()) { case 6427: case 6428: // Dirty Deeds - if(pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this)) + if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, spellProto, this)) { AuraEffect* eff0 = (*i)->GetParentAura()->GetPartAura(0); - if(!eff0 || (*i)->GetEffIndex()!=1) + if (!eff0 || (*i)->GetEffIndex()!=1) { sLog.outError("Spell structure of DD (%u) changed.",(*i)->GetId()); continue; @@ -10492,7 +10468,7 @@ void Unit::MeleeDamageBonus(Unit *pVictim, uint32 *pdamage, WeaponAttackType att } } - if(attType != RANGED_ATTACK) + if (attType != RANGED_ATTACK) { AuraEffectList const& mModMeleeDamageTakenPercent = pVictim->GetAurasByType(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT); for (AuraEffectList::const_iterator i = mModMeleeDamageTakenPercent.begin(); i != mModMeleeDamageTakenPercent.end(); ++i) @@ -10525,7 +10501,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(), next; itr != m_spellImmune[op].end(); itr = next) { next = itr; ++next; - if(itr->type == type) + if (itr->type == type) { m_spellImmune[op].erase(itr); next = m_spellImmune[op].begin(); @@ -10540,7 +10516,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) { for (SpellImmuneList::iterator itr = m_spellImmune[op].begin(); itr != m_spellImmune[op].end(); ++itr) { - if(itr->spellId == spellId) + if (itr->spellId == spellId) { m_spellImmune[op].erase(itr); break; @@ -10560,10 +10536,10 @@ void Unit::ApplySpellDispelImmunity(const SpellEntry * spellProto, DispelType ty uint32 dispelMask = GetDispellMask(type); // Dispel all existing auras vs current dispel type AuraMap& auras = GetAuras(); - for (AuraMap::iterator itr = auras.begin(); itr != auras.end(); ) + for (AuraMap::iterator itr = auras.begin(); itr != auras.end();) { SpellEntry const* spell = itr->second->GetSpellProto(); - if( (1<<spell->Dispel) & dispelMask ) + if ((1<<spell->Dispel) & dispelMask ) { // Dispel aura RemoveAura(itr); @@ -10578,7 +10554,7 @@ float Unit::GetWeaponProcChance() const { // normalized proc chance for weapon attack speed // (odd formula...) - if(isAttackReady(BASE_ATTACK)) + if (isAttackReady(BASE_ATTACK)) return (GetAttackTime(BASE_ATTACK) * 1.8f / 1000.0f); else if (haveOffhandWeapon() && isAttackReady(OFF_ATTACK)) return (GetAttackTime(OFF_ATTACK) * 1.6f / 1000.0f); @@ -10591,7 +10567,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellEntry * s if (PPM <= 0) return 0.0f; // Apply chance modifer aura if (spellProto) - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_PROC_PER_MINUTE,PPM); return uint32((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) @@ -10601,20 +10577,20 @@ void Unit::Mount(uint32 mount) { RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNT); - if(mount) + if (mount) SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); SetFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT ); // unsummon pet - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Pet* pet = ((Player*)this)->GetPet(); - if(pet) + if (pet) { BattleGround *bg = ((Player *)this)->GetBattleGround(); // don't unsummon pet in arena but SetFlag UNIT_FLAG_STUNNED to disable pet's interface - if(bg && bg->isArena()) + if (bg && bg->isArena()) pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); else ((Player*)this)->UnsummonPetTemporaryIfAny(); @@ -10625,7 +10601,7 @@ void Unit::Mount(uint32 mount) void Unit::Unmount() { - if(!IsMounted()) + if (!IsMounted()) return; RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_MOUNTED); @@ -10636,11 +10612,11 @@ void Unit::Unmount() // only resummon old pet if the player is already added to a map // this prevents adding a pet to a not created map which would otherwise cause a crash // (it could probably happen when logging in after a previous crash) - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { - if(Pet *pPet = ((Player*)this)->GetPet()) + if (Pet *pPet = ((Player*)this)->GetPet()) { - if(pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->hasUnitState(UNIT_STAT_STUNNED)) + if (pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED) && !pPet->hasUnitState(UNIT_STAT_STUNNED)) pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } else @@ -10651,17 +10627,17 @@ void Unit::Unmount() void Unit::SetInCombatWith(Unit* enemy) { Unit* eOwner = enemy->GetCharmerOrOwnerOrSelf(); - if(eOwner->IsPvP()) + if (eOwner->IsPvP()) { SetInCombatState(true,enemy); return; } //check for duel - if(eOwner->GetTypeId() == TYPEID_PLAYER && ((Player*)eOwner)->duel) + if (eOwner->GetTypeId() == TYPEID_PLAYER && ((Player*)eOwner)->duel) { Unit const* myOwner = GetCharmerOrOwnerOrSelf(); - if(((Player const*)eOwner)->duel->opponent == myOwner) + if (((Player const*)eOwner)->duel->opponent == myOwner) { SetInCombatState(true,enemy); return; @@ -10674,10 +10650,10 @@ void Unit::CombatStart(Unit* target, bool initialAggro) { if (initialAggro) { - if(!target->IsStandState()/* && !target->hasUnitState(UNIT_STAT_STUNNED)*/) + if (!target->IsStandState()/* && !target->hasUnitState(UNIT_STAT_STUNNED)*/) target->SetStandState(UNIT_STAND_STATE_STAND); - if(!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER + if (!target->isInCombat() && target->GetTypeId() != TYPEID_PLAYER && !((Creature*)target)->HasReactState(REACT_PASSIVE) && ((Creature*)target)->IsAIEnabled) { ((Creature*)target)->AI()->AttackStart(this); @@ -10687,11 +10663,11 @@ void Unit::CombatStart(Unit* target, bool initialAggro) target->SetInCombatWith(this); } Unit *who = target->GetCharmerOrOwnerOrSelf(); - if(who->GetTypeId() == TYPEID_PLAYER) + if (who->GetTypeId() == TYPEID_PLAYER) SetContestedPvP((Player*)who); Player *me = GetCharmerOrOwnerPlayerOrPlayerItself(); - if(me && who->IsPvP() + if (me && who->IsPvP() && (who->GetTypeId() != TYPEID_PLAYER || !me->duel || me->duel->opponent != who)) { @@ -10717,7 +10693,7 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) if (GetTypeId() != TYPEID_PLAYER) { // Set home position at place of engaging combat for escorted creatures - if(( IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) || + if (( IsAIEnabled && ((Creature*)this)->AI()->IsEscorted() ) || GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE || GetMotionMaster()->GetCurrentMovementGeneratorType() == POINT_MOTION_TYPE) ((Creature*)this)->SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); @@ -10783,30 +10759,30 @@ bool Unit::canAttack(Unit const* target, bool force) const { assert(target); - if(force) + if (force) { - if(IsFriendlyTo(target)) + if (IsFriendlyTo(target)) return false; } - else if(!IsHostileTo(target)) + else if (!IsHostileTo(target)) return false; //if(m_Vehicle && m_Vehicle == target->m_Vehicle) // return true; - if(!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) + if (!target->isAttackableByAOE() || target->hasUnitState(UNIT_STAT_DIED)) return false; // shaman totem quests: spell 8898, shaman can detect elementals but elementals cannot see shaman - if(m_invisibilityMask || target->m_invisibilityMask) - if(!canDetectInvisibilityOf(target) && !target->canDetectInvisibilityOf(this)) + if (m_invisibilityMask || target->m_invisibilityMask) + if (!canDetectInvisibilityOf(target) && !target->canDetectInvisibilityOf(this)) return false; - if(target->GetVisibility() == VISIBILITY_GROUP_STEALTH && !canDetectStealthOf(target, GetDistance(target))) + if (target->GetVisibility() == VISIBILITY_GROUP_STEALTH && !canDetectStealthOf(target, GetDistance(target))) return false; - if(m_vehicle) - if(IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target)) + if (m_vehicle) + if (IsOnVehicle(target) || m_vehicle->GetBase()->IsOnVehicle(target)) return false; return true; @@ -10814,14 +10790,14 @@ bool Unit::canAttack(Unit const* target, bool force) const bool Unit::isAttackableByAOE() const { - if(!isAlive()) + if (!isAlive()) return false; - if(HasFlag(UNIT_FIELD_FLAGS, + if (HasFlag(UNIT_FIELD_FLAGS, 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 && ((Player *)this)->isGameMaster()) return false; return !hasUnitState(UNIT_STAT_UNATTACKABLE); @@ -10831,13 +10807,13 @@ int32 Unit::ModifyHealth(int32 dVal) { int32 gain = 0; - if(dVal==0) + if (dVal==0) return 0; int32 curHealth = (int32)GetHealth(); int32 val = dVal + curHealth; - if(val <= 0) + if (val <= 0) { SetHealth(0); return -curHealth; @@ -10845,12 +10821,12 @@ int32 Unit::ModifyHealth(int32 dVal) int32 maxHealth = (int32)GetMaxHealth(); - if(val < maxHealth) + if (val < maxHealth) { SetHealth(val); gain = val - curHealth; } - else if(curHealth != maxHealth) + else if (curHealth != maxHealth) { SetHealth(maxHealth); gain = maxHealth - curHealth; @@ -10863,27 +10839,23 @@ int32 Unit::GetHealthGain(int32 dVal) { int32 gain = 0; - if(dVal==0) + if (dVal==0) return 0; int32 curHealth = (int32)GetHealth(); int32 val = dVal + curHealth; - if(val <= 0) + if (val <= 0) { return -curHealth; } int32 maxHealth = (int32)GetMaxHealth(); - if(val < maxHealth) - { + if (val < maxHealth) gain = dVal; - } - else if(curHealth != maxHealth) - { + else if (curHealth != maxHealth) gain = maxHealth - curHealth; - } return gain; } @@ -10892,13 +10864,13 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) { int32 gain = 0; - if(dVal==0) + if (dVal==0) return 0; int32 curPower = (int32)GetPower(power); int32 val = dVal + curPower; - if(val <= 0) + if (val <= 0) { SetPower(power,0); return -curPower; @@ -10906,12 +10878,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) int32 maxPower = (int32)GetMaxPower(power); - if(val < maxPower) + if (val < maxPower) { SetPower(power,val); gain = val - curPower; } - else if(curPower != maxPower) + else if (curPower != maxPower) { SetPower(power,maxPower); gain = maxPower - curPower; @@ -10922,7 +10894,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) bool Unit::isVisibleForOrDetect(Unit const* u, bool detect, bool inVisibleList, bool is3dDistance) const { - if(!u || !IsInMap(u)) + if (!u || !IsInMap(u)) return false; return u->canSeeOrDetect(this, detect, inVisibleList, is3dDistance); @@ -10935,30 +10907,30 @@ bool Unit::canSeeOrDetect(Unit const* u, bool detect, bool inVisibleList, bool i bool Unit::canDetectInvisibilityOf(Unit const* u) const { - if(m_invisibilityMask & u->m_invisibilityMask) // same group + if (m_invisibilityMask & u->m_invisibilityMask) // same group return true; AuraEffectList const& auras = u->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark for (AuraEffectList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter) - if((*iter)->GetCasterGUID()==GetGUID()) + if ((*iter)->GetCasterGUID()==GetGUID()) return true; - if(uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask)) + if (uint32 mask = (m_detectInvisibilityMask & u->m_invisibilityMask)) { for (uint32 i = 0; i < 10; ++i) { - if(((1 << i) & mask)==0) + if (((1 << i) & mask)==0) continue; // find invisibility level uint32 invLevel = 0; Unit::AuraEffectList const& iAuras = u->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); for (Unit::AuraEffectList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr) - if(((*itr)->GetMiscValue())==i && invLevel < (*itr)->GetAmount()) + if (((*itr)->GetMiscValue())==i && invLevel < (*itr)->GetAmount()) invLevel = (*itr)->GetAmount(); // find invisibility detect level uint32 detectLevel = 0; - if(i==6 && GetTypeId() == TYPEID_PLAYER) // special drunk detection case + if (i==6 && GetTypeId() == TYPEID_PLAYER) // special drunk detection case { detectLevel = ((Player*)this)->GetDrunkValue(); } @@ -10966,11 +10938,11 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const { Unit::AuraEffectList const& dAuras = GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); for (Unit::AuraEffectList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr) - if(((*itr)->GetMiscValue())==i && detectLevel < (*itr)->GetAmount()) + if (((*itr)->GetMiscValue())==i && detectLevel < (*itr)->GetAmount()) detectLevel = (*itr)->GetAmount(); } - if(invLevel <= detectLevel) + if (invLevel <= detectLevel) return true; } } @@ -10980,18 +10952,18 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const bool Unit::canDetectStealthOf(Unit const* target, float distance) const { - if(hasUnitState(UNIT_STAT_STUNNED)) + if (hasUnitState(UNIT_STAT_STUNNED)) return false; - if(distance < 0.24f) //collision + if (distance < 0.24f) //collision return true; - if(!HasInArc(M_PI, target)) //behind + if (!HasInArc(M_PI, target)) //behind return false; - if(HasAuraType(SPELL_AURA_DETECT_STEALTH)) + if (HasAuraType(SPELL_AURA_DETECT_STEALTH)) return true; - AuraEffectList const& auras = target->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark + AuraEffectList const &auras = target->GetAurasByType(SPELL_AURA_MOD_STALKED); // Hunter mark for (AuraEffectList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter) - if((*iter)->GetCasterGUID()==GetGUID()) + if ((*iter)->GetCasterGUID() == GetGUID()) return true; //Visible distance based on stealth value (stealth rank 4 300MOD, 10.5 - 3 = 7.5) @@ -11012,7 +10984,7 @@ void Unit::SetVisibility(UnitVisibility x) SetToNotify(); - if(x == VISIBILITY_GROUP_STEALTH) + if (x == VISIBILITY_GROUP_STEALTH) DestroyForNearbyPlayers(); } @@ -11054,7 +11026,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) } case MOVE_FLIGHT: { - if (GetTypeId()==TYPEID_UNIT && IsControlledByPlayer()) // not sure if good for pet + if (GetTypeId() == TYPEID_UNIT && IsControlledByPlayer()) // not sure if good for pet { main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED); stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS); @@ -11104,7 +11076,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced) // Normalize speed by 191 aura SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED if need // TODO: possible affect only on MOVE_RUN - if(int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) + if (int32 normalization = GetMaxPositiveAuraModifier(SPELL_AURA_USE_NORMAL_MOVEMENT_SPEED)) { // Use speed from aura float max_speed = normalization / (IsControlledByPlayer() ? playerBaseMoveSpeed[mtype] : baseMoveSpeed[mtype]); @@ -11143,7 +11115,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) propagateSpeedChange(); WorldPacket data; - if(!forced) + if (!forced) { switch(mtype) { @@ -11193,14 +11165,14 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) } else { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { // register forced speed changes for WorldSession::HandleForceSpeedChangeAck // and do it only for real sent packets and use run for run/mounted as client expected ++((Player*)this)->m_forced_speed_changes[mtype]; - if(!isInCombat()) - if(Pet* pet = ((Player*)this)->GetPet()) + if (!isInCombat()) + if (Pet* pet = ((Player*)this)->GetPet()) pet->SetSpeed(mtype, m_speed_rate[mtype], forced); } @@ -11248,7 +11220,7 @@ void Unit::SetSpeed(UnitMoveType mtype, float rate, bool forced) void Unit::SetHover(bool on) { - if(on) + if (on) CastSpell(this, 11010, true); else RemoveAurasDueToSpell(11010); @@ -11281,7 +11253,8 @@ void Unit::setDeathState(DeathState s) ClearDiminishings(); GetMotionMaster()->Clear(false); GetMotionMaster()->MoveIdle(); - if(m_vehicleKit) m_vehicleKit->Die(); + if (m_vehicleKit) + m_vehicleKit->Die(); StopMoving(); //without this when removing IncreaseMaxHealth aura player may stuck with 1 hp //do not why since in IncreaseMaxHealth currenthealth is checked @@ -11363,7 +11336,7 @@ void Unit::DeleteThreatList() void Unit::TauntApply(Unit* taunter) { - assert(GetTypeId()== TYPEID_UNIT); + assert(GetTypeId() == TYPEID_UNIT); if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) return; @@ -11389,7 +11362,7 @@ void Unit::TauntApply(Unit* taunter) void Unit::TauntFadeOut(Unit *taunter) { - assert(GetTypeId()== TYPEID_UNIT); + assert(GetTypeId() == TYPEID_UNIT); if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) return; @@ -11406,7 +11379,7 @@ void Unit::TauntFadeOut(Unit *taunter) if (m_ThreatManager.isThreatListEmpty()) { - if(((Creature*)this)->IsAIEnabled) + if (((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->EnterEvadeMode(); return; } @@ -11565,13 +11538,13 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde int32 value = basePoints + randvalue; //random damage - //if(comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/) + //if (comboDamage != 0 && unitPlayer /*&& target && (target->GetGUID() == unitPlayer->GetComboTarget())*/) if (m_movedPlayer) if (uint8 comboPoints = m_movedPlayer->GetComboPoints()) if (float comboDamage = spellProto->EffectPointsPerComboPoint[effect_index]) value += int32(comboDamage * comboPoints); - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) { modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_ALL_EFFECTS, value); switch (effect_index) @@ -11588,7 +11561,7 @@ int32 Unit::CalculateSpellDamage(SpellEntry const* spellProto, uint8 effect_inde } } - if(!basePointsPerLevel && (spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel) && + if (!basePointsPerLevel && (spellProto->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION && spellProto->spellLevel) && spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE && spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK && spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_SPEED_ALWAYS && @@ -11778,7 +11751,7 @@ void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32 &duration,Un Unit const* target = targetOwner ? targetOwner : this; Unit const* source = casterOwner ? casterOwner : caster; - if(target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER && source->GetTypeId() == TYPEID_PLAYER) duration = limitduration; } @@ -11875,10 +11848,10 @@ bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const uint32 Unit::GetCreatureType() const { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(m_form); - if(ssEntry && ssEntry->creatureType > 0) + if (ssEntry && ssEntry->creatureType > 0) return ssEntry->creatureType; else return CREATURE_TYPE_HUMANOID; @@ -11911,7 +11884,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f break; case BASE_PCT: case TOTAL_PCT: - if(amount <= -100.0f) //small hack-fix for -100% modifiers + if (amount <= -100.0f) //small hack-fix for -100% modifiers amount = -200.0f; val = (100.0f + amount) / 100.0f; @@ -11967,13 +11940,13 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) const { - if( unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) + if (unitMod >= UNIT_MOD_END || modifierType >= MODIFIER_TYPE_END) { sLog.outError("trial to access non existed modifier value from UnitMods!"); return 0.0f; } - if(modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f) + if (modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f) return 0.0f; return m_auraModifiersGroup[unitMod][modifierType]; @@ -11983,7 +11956,7 @@ float Unit::GetTotalStatValue(Stats stat) const { UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat); - if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) return 0.0f; // value = ((base_value * base_pct) + total_value) * total_pct @@ -11997,13 +11970,13 @@ float Unit::GetTotalStatValue(Stats stat) const float Unit::GetTotalAuraModValue(UnitMods unitMod) const { - if(unitMod >= UNIT_MOD_END) + if (unitMod >= UNIT_MOD_END) { sLog.outError("trial to access non existed UnitMods in GetTotalAuraModValue()!"); return 0.0f; } - if(m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) return 0.0f; float value = m_auraModifiersGroup[unitMod][BASE_VALUE]; @@ -12112,7 +12085,7 @@ void Unit::SetHealth(uint32 val) else { uint32 maxHealth = GetMaxHealth(); - if(maxHealth < val) + if (maxHealth < val) val = maxHealth; } @@ -12130,7 +12103,7 @@ void Unit::SetHealth(uint32 val) if (pet->isControlled()) { Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_CUR_HP); } } @@ -12153,10 +12126,10 @@ void Unit::SetMaxHealth(uint32 val) else if (((Creature*)this)->isPet()) { Pet *pet = ((Pet*)this); - if(pet->isControlled()) + if (pet->isControlled()) { Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MAX_HP); } } @@ -12374,7 +12347,8 @@ void Unit::UpdateCharmAI() { if (!isCharmed()) { - if(i_AI) delete i_AI; + if (i_AI) + delete i_AI; i_AI = i_disabledAI; i_disabledAI = NULL; } @@ -12459,7 +12433,7 @@ void CharmInfo::InitEmptyActionBar(bool withAttack) void CharmInfo::InitPossessCreateSpells() { InitEmptyActionBar(); - if(m_unit->GetTypeId() == TYPEID_UNIT) + if (m_unit->GetTypeId() == TYPEID_UNIT) { for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) { @@ -12588,7 +12562,7 @@ void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply) return; for (uint32 x = 0; x < MAX_SPELL_CHARM; ++x) - if(spellid == m_charmspells[x].GetAction()) + if (spellid == m_charmspells[x].GetAction()) m_charmspells[x].SetType(apply ? ACT_ENABLED : ACT_DISABLED); } @@ -12843,7 +12817,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit * pTarget, uint32 procFlag, // Defensive procs are active on absorbs (so absorption effects are not a hindrance) bool active = (damage > 0) || ((procExtra & PROC_EX_ABSORB) && isVictim); - if(!IsTriggeredAtSpellProcEvent(pTarget, triggerData.aura, procSpell, procFlag, procExtra, attType, isVictim, active, triggerData.spellProcEvent)) + if (!IsTriggeredAtSpellProcEvent(pTarget, triggerData.aura, procSpell, procFlag, procExtra, attType, isVictim, active, triggerData.spellProcEvent)) continue; for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) @@ -13057,7 +13031,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit * pTarget, uint32 procFlag, } } // Remove charge (aura can be removed by triggers) - if(useCharges && takeCharges) + if (useCharges && takeCharges) i->aura->DropAuraCharge(); if (spellInfo->AttributesEx3 & SPELL_ATTR_EX3_DISABLE_PROC) @@ -13076,12 +13050,12 @@ SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const Player* Unit::GetSpellModOwner() const { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) return (Player*)this; - if(((Creature*)this)->isPet() || ((Creature*)this)->isTotem()) + if (((Creature*)this)->isPet() || ((Creature*)this)->isTotem()) { Unit* owner = GetOwner(); - if(owner && owner->GetTypeId() == TYPEID_PLAYER) + if (owner && owner->GetTypeId() == TYPEID_PLAYER) return (Player*)owner; } return NULL; @@ -13090,11 +13064,11 @@ Player* Unit::GetSpellModOwner() const ///----------Pet responses methods----------------- void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg) { - if(msg == SPELL_CAST_OK) + if (msg == SPELL_CAST_OK) return; Unit *owner = GetCharmerOrOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_CAST_FAILED, 1 + 4 + 1); @@ -13109,7 +13083,7 @@ void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg) void Unit::SendPetActionFeedback (uint8 msg) { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_ACTION_FEEDBACK, 1); @@ -13120,7 +13094,7 @@ void Unit::SendPetActionFeedback (uint8 msg) void Unit::SendPetTalk (uint32 pettalk) { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4); @@ -13132,7 +13106,7 @@ void Unit::SendPetTalk (uint32 pettalk) void Unit::SendPetAIReaction(uint64 guid) { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_AI_REACTION, 8 + 4); @@ -13191,7 +13165,7 @@ void Unit::SetStandState(uint8 state) if (IsStandState()) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_SEATED); - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_STANDSTATE_UPDATE, 1); data << (uint8)state; @@ -13208,13 +13182,13 @@ void Unit::SetDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId); - if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) { Pet *pet = ((Pet*)this); - if(!pet->isControlled()) + if (!pet->isControlled()) return; Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID); } } @@ -13226,7 +13200,7 @@ void Unit::ClearComboPointHolders() uint32 lowguid = *m_ComboPointHolders.begin(); Player* plr = objmgr.GetPlayer(MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER)); - if(plr && plr->GetComboTarget()==GetGUID()) // recheck for safe + if (plr && plr->GetComboTarget()==GetGUID()) // recheck for safe plr->ClearComboPoints(); // remove also guid from m_ComboPointHolders; else m_ComboPointHolders.erase(lowguid); // or remove manually @@ -13242,7 +13216,7 @@ void Unit::ClearAllReactives() ModifyAuraState(AURA_STATE_DEFENSE, false); if (getClass() == CLASS_HUNTER && HasAuraState(AURA_STATE_HUNTER_PARRY)) ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); - if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) + if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) ((Player*)this)->ClearComboPoints(); } @@ -13252,7 +13226,7 @@ void Unit::UpdateReactives( uint32 p_time ) { ReactiveType reactive = ReactiveType(i); - if(!m_reactiveTimer[reactive]) + if (!m_reactiveTimer[reactive]) continue; if ( m_reactiveTimer[reactive] <= p_time) @@ -13270,7 +13244,7 @@ void Unit::UpdateReactives( uint32 p_time ) ModifyAuraState(AURA_STATE_HUNTER_PARRY, false); break; case REACTIVE_OVERPOWER: - if(getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) + if (getClass() == CLASS_WARRIOR && GetTypeId() == TYPEID_PLAYER) ((Player*)this)->ClearComboPoints(); break; default: @@ -13292,13 +13266,13 @@ Unit* Unit::SelectNearbyTarget(float dist) const VisitNearbyObject(dist, searcher); // remove current target - if(getVictim()) + if (getVictim()) targets.remove(getVictim()); // remove not LoS targets - for (std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end(); ) + for (std::list<Unit *>::iterator tIter = targets.begin(); tIter != targets.end();) { - if(!IsWithinLOSInMap(*tIter)) + if (!IsWithinLOSInMap(*tIter)) { std::list<Unit *>::iterator tIter2 = tIter; ++tIter; @@ -13309,7 +13283,7 @@ Unit* Unit::SelectNearbyTarget(float dist) const } // no appropriate targets - if(targets.empty()) + if (targets.empty()) return NULL; // select random @@ -13334,7 +13308,7 @@ bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag) void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply ) { float remainingTimePct = (float)m_attackTimer[att] / (GetAttackTime(att) * m_modAttackSpeedPct[att]); - if(val > 0) + if (val > 0) { ApplyPercentModFloatVar(m_modAttackSpeedPct[att], val, !apply); ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val,!apply); @@ -13349,7 +13323,7 @@ void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply void Unit::ApplyCastTimePercentMod(float val, bool apply ) { - if(val > 0) + if (val > 0) ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,val,!apply); else ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,-val,apply); @@ -13358,13 +13332,13 @@ void Unit::ApplyCastTimePercentMod(float val, bool apply ) uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype, uint32 CastingTime ) { // Not apply this to creature casted spells with casttime==0 - if(CastingTime==0 && GetTypeId()==TYPEID_UNIT && !((Creature*)this)->isPet()) + if (CastingTime==0 && GetTypeId() == TYPEID_UNIT && !((Creature*)this)->isPet()) return 3500; if (CastingTime > 7000) CastingTime = 7000; if (CastingTime < 1500) CastingTime = 1500; - if(damagetype == DOT && !IsChanneledSpell(spellProto)) + if (damagetype == DOT && !IsChanneledSpell(spellProto)) CastingTime = 3500; int32 overTime = 0; @@ -13402,7 +13376,7 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT break; } - if(IsAreaEffectTarget[spellProto->EffectImplicitTargetA[i]] || IsAreaEffectTarget[spellProto->EffectImplicitTargetB[i]]) + if (IsAreaEffectTarget[spellProto->EffectImplicitTargetA[i]] || IsAreaEffectTarget[spellProto->EffectImplicitTargetB[i]]) AreaEffect = true; } @@ -13447,24 +13421,24 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT void Unit::UpdateAuraForGroup(uint8 slot) { - if(slot >= MAX_AURAS) // slot not found, return + if (slot >= MAX_AURAS) // slot not found, return return; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { Player* player = (Player*)this; - if(player->GetGroup()) + if (player->GetGroup()) { player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_AURAS); player->SetAuraUpdateMaskForRaid(slot); } } - else if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) + else if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet()) { Pet *pet = ((Pet*)this); - if(pet->isControlled()) + if (pet->isControlled()) { Unit *owner = GetOwner(); - if(owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) + if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) { ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_AURAS); pet->SetAuraUpdateMaskForRaid(slot); @@ -13522,18 +13496,18 @@ void Unit::SetContestedPvP(Player *attackedPlayer) { Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); - if(!player || attackedPlayer && (attackedPlayer == player || player->duel && player->duel->opponent == attackedPlayer)) + if (!player || attackedPlayer && (attackedPlayer == player || player->duel && player->duel->opponent == attackedPlayer)) return; player->SetContestedPvPTimer(30000); - if(!player->hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + if (!player->hasUnitState(UNIT_STAT_ATTACK_PLAYER)) { player->addUnitState(UNIT_STAT_ATTACK_PLAYER); player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP); // call MoveInLineOfSight for nearby contested guards player->SetVisibility(GetVisibility()); } - if(!hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + if (!hasUnitState(UNIT_STAT_ATTACK_PLAYER)) { addUnitState(UNIT_STAT_ATTACK_PLAYER); // call MoveInLineOfSight for nearby contested guards @@ -13543,32 +13517,32 @@ void Unit::SetContestedPvP(Player *attackedPlayer) void Unit::AddPetAura(PetAura const* petSpell) { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return; m_petAuras.insert(petSpell); - if(Pet* pet = ((Player*)this)->GetPet()) + if (Pet* pet = ((Player*)this)->GetPet()) pet->CastPetAura(petSpell); } void Unit::RemovePetAura(PetAura const* petSpell) { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return; m_petAuras.erase(petSpell); - if(Pet* pet = ((Player*)this)->GetPet()) + if (Pet* pet = ((Player*)this)->GetPet()) pet->RemoveAurasDueToSpell(petSpell->GetAura(pet->GetEntry())); } Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) { - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return NULL; Pet* pet = new Pet((Player*)this, HUNTER_PET); - if(!pet->CreateBaseAtCreature(creatureTarget)) + if (!pet->CreateBaseAtCreature(creatureTarget)) { delete pet; return NULL; @@ -13578,12 +13552,12 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) pet->setFaction(getFaction()); pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, spell_id); - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); uint8 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel(); - if(!pet->InitStatsForLevel(level)) + if (!pet->InitStatsForLevel(level)) { sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!",creatureTarget->GetEntry()); delete pet; @@ -13665,7 +13639,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co { // Check if player is wearing shield Item *item = ((Player*)this)->GetUseableItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + if (!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<<item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } } @@ -13689,7 +13663,7 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit *pVictim, Aura * aura, SpellEntry co } } // Apply chance modifer aura - if(Player* modOwner = GetSpellModOwner()) + if (Player* modOwner = GetSpellModOwner()) { modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); } @@ -13719,7 +13693,7 @@ bool Unit::HandleAuraRaidProcFromChargeWithValue(AuraEffect *triggeredByAura) else radius = GetSpellMaxRangeForTarget(triggeredByAura->GetCaster(), sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); - if(Player *caster = (Player*)triggeredByAura->GetCaster()) + if (Player *caster = (Player*)triggeredByAura->GetCaster()) { caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius, NULL); @@ -13778,7 +13752,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura) triggeredByAura->GetParentAura()->SetAuraCharges(1); // will removed at next charges decrease // next target selection - if(jumps > 0 && IS_PLAYER_GUID(caster_guid)) + if (jumps > 0 && IS_PLAYER_GUID(caster_guid)) { float radius; if (spellProto->EffectRadiusIndex[effIdx]) @@ -13786,7 +13760,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura) else radius = GetSpellMaxRangeForTarget(triggeredByAura->GetCaster() ,sSpellRangeStore.LookupEntry(spellProto->rangeIndex)); - if(Player* caster = ((Player*)triggeredByAura->GetCaster())) + if (Player* caster = ((Player*)triggeredByAura->GetCaster())) { caster->ApplySpellMod(spellProto->Id, SPELLMOD_RADIUS, radius,NULL); @@ -13808,7 +13782,7 @@ bool Unit::HandleAuraRaidProcFromCharge(AuraEffect* triggeredByAura) void Unit::SetToNotify() { // it is called somewhere when obj is not in world (crash when log in instance) - if(m_NotifyListPos < 0) + if (m_NotifyListPos < 0) GetMap()->AddUnitToNotify(this); } @@ -13835,20 +13809,20 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) Player *player = GetCharmerOrOwnerPlayerOrPlayerItself(); bool bRewardIsAllowed = true; - if(pVictim->GetTypeId() == TYPEID_UNIT) + if (pVictim->GetTypeId() == TYPEID_UNIT) { bRewardIsAllowed = ((Creature*)pVictim)->IsDamageEnoughForLootingAndReward(); - if(!bRewardIsAllowed) + if (!bRewardIsAllowed) ((Creature*)pVictim)->SetLootRecipient(NULL); } - if(bRewardIsAllowed && pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient()) + if (bRewardIsAllowed && pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->GetLootRecipient()) player = ((Creature*)pVictim)->GetLootRecipient(); // Reward player, his pets, and group/raid members // call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop) - if(bRewardIsAllowed && player && player!=pVictim) + if (bRewardIsAllowed && player && player!=pVictim) { - if(player->RewardPlayerAndGroupAtKill(pVictim)) + if (player->RewardPlayerAndGroupAtKill(pVictim)) player->ProcDamageAndSpell(pVictim, PROC_FLAG_KILL, PROC_FLAG_KILLED, PROC_EX_NONE, 0); else player->ProcDamageAndSpell(pVictim, PROC_FLAG_NONE, PROC_FLAG_KILLED, PROC_EX_NONE, 0); @@ -13859,16 +13833,16 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) // if talent known but not triggered (check priest class for speedup check) bool SpiritOfRedemption = false; - if(pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->getClass() == CLASS_PRIEST) + if (pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->getClass() == CLASS_PRIEST) { AuraEffectList const& vDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); for (AuraEffectList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr) { - if((*itr)->GetSpellProto()->SpellIconID==1654) + if ((*itr)->GetSpellProto()->SpellIconID==1654) { // save value before aura remove uint32 ressSpellId = pVictim->GetUInt32Value(PLAYER_SELF_RES_SPELL); - if(!ressSpellId) + if (!ressSpellId) ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId(); //Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers) pVictim->RemoveAllAurasOnDeath(); @@ -13940,17 +13914,17 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) cVictim->AI()->JustDied(this); // Dungeon specific stuff, only applies to players killing creatures - if(cVictim->GetInstanceId()) + if (cVictim->GetInstanceId()) { Map *m = cVictim->GetMap(); Player *creditedPlayer = GetCharmerOrOwnerPlayerOrPlayerItself(); // TODO: do instance binding anyway if the charmer/owner is offline - if(m->IsDungeon() && creditedPlayer) + if (m->IsDungeon() && creditedPlayer) { - if(m->IsRaid() || m->IsHeroic()) + if (m->IsRaid() || m->IsHeroic()) { - if(cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) + if (cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer); } else @@ -13958,8 +13932,8 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) // the reset time is set but not added to the scheduler // until the players leave the instance time_t resettime = cVictim->GetRespawnTimeEx() + 2 * HOUR; - if(InstanceSave *save = sInstanceSaveManager.GetInstanceSave(cVictim->GetInstanceId())) - if(save->GetResetTime() < resettime) save->SetResetTime(resettime); + if (InstanceSave *save = sInstanceSaveManager.GetInstanceSave(cVictim->GetInstanceId())) + if (save->GetResetTime() < resettime) save->SetResetTime(resettime); } } } @@ -13967,20 +13941,20 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) // outdoor pvp things, do these after setting the death state, else the player activity notify won't work... doh... // handle player kill only if not suicide (spirit of redemption for example) - if(player && this != pVictim) - if(OutdoorPvP * pvp = player->GetOutdoorPvP()) + if (player && this != pVictim) + if (OutdoorPvP * pvp = player->GetOutdoorPvP()) pvp->HandleKill(player, pVictim); - //if(pVictim->GetTypeId() == TYPEID_PLAYER) - // if(OutdoorPvP * pvp = ((Player*)pVictim)->GetOutdoorPvP()) + //if (pVictim->GetTypeId() == TYPEID_PLAYER) + // if (OutdoorPvP * pvp = ((Player*)pVictim)->GetOutdoorPvP()) // pvp->HandlePlayerActivityChanged((Player*)pVictim); // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill) - if(player && player->InBattleGround()) + if (player && player->InBattleGround()) { - if(BattleGround *bg = player->GetBattleGround()) + if (BattleGround *bg = player->GetBattleGround()) { - if(pVictim->GetTypeId() == TYPEID_PLAYER) + if (pVictim->GetTypeId() == TYPEID_PLAYER) bg->HandleKillPlayer((Player*)pVictim, player); else bg->HandleKillUnit((Creature*)pVictim, player); @@ -13992,16 +13966,16 @@ void Unit::Kill(Unit *pVictim, bool durabilityLoss) { if (GetTypeId() == TYPEID_UNIT) ((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE, GetEntry()); - else if(GetTypeId() == TYPEID_PLAYER && pVictim != this) + else if (GetTypeId() == TYPEID_PLAYER && pVictim != this) ((Player*)pVictim)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_PLAYER, 1, ((Player*)this)->GetTeam()); } } void Unit::SetControlled(bool apply, UnitState state) { - if(apply) + if (apply) { - if(hasUnitState(state)) + if (hasUnitState(state)) return; addUnitState(state); @@ -14012,15 +13986,15 @@ void Unit::SetControlled(bool apply, UnitState state) SetStunned(true); break; case UNIT_STAT_ROOT: - if(!hasUnitState(UNIT_STAT_STUNNED)) + if (!hasUnitState(UNIT_STAT_STUNNED)) SetRooted(true); break; case UNIT_STAT_CONFUSED: - if(!hasUnitState(UNIT_STAT_STUNNED)) + if (!hasUnitState(UNIT_STAT_STUNNED)) SetConfused(true); break; case UNIT_STAT_FLEEING: - if(!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED)) + if (!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_CONFUSED)) SetFeared(true); break; default: @@ -14031,29 +14005,29 @@ void Unit::SetControlled(bool apply, UnitState state) { switch(state) { - case UNIT_STAT_STUNNED: if(HasAuraType(SPELL_AURA_MOD_STUN)) return; + case UNIT_STAT_STUNNED: if (HasAuraType(SPELL_AURA_MOD_STUN)) return; else SetStunned(false); break; - case UNIT_STAT_ROOT: if(HasAuraType(SPELL_AURA_MOD_ROOT) || GetVehicle()) return; + case UNIT_STAT_ROOT: if (HasAuraType(SPELL_AURA_MOD_ROOT) || GetVehicle()) return; else SetRooted(false); break; - case UNIT_STAT_CONFUSED:if(HasAuraType(SPELL_AURA_MOD_CONFUSE)) return; + case UNIT_STAT_CONFUSED:if (HasAuraType(SPELL_AURA_MOD_CONFUSE)) return; else SetConfused(false); break; - case UNIT_STAT_FLEEING: if(HasAuraType(SPELL_AURA_MOD_FEAR)) return; + case UNIT_STAT_FLEEING: if (HasAuraType(SPELL_AURA_MOD_FEAR)) return; else SetFeared(false); break; default: return; } clearUnitState(state); - if(hasUnitState(UNIT_STAT_STUNNED)) + if (hasUnitState(UNIT_STAT_STUNNED)) SetStunned(true); else { - if(hasUnitState(UNIT_STAT_ROOT)) + if (hasUnitState(UNIT_STAT_ROOT)) SetRooted(true); - if(hasUnitState(UNIT_STAT_CONFUSED)) + if (hasUnitState(UNIT_STAT_CONFUSED)) SetConfused(true); - else if(hasUnitState(UNIT_STAT_FLEEING)) + else if (hasUnitState(UNIT_STAT_FLEEING)) SetFeared(true); } } @@ -14061,7 +14035,7 @@ void Unit::SetControlled(bool apply, UnitState state) void Unit::SetStunned(bool apply) { - if(apply) + if (apply) { SetUInt64Value(UNIT_FIELD_TARGET, 0); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); @@ -14069,7 +14043,7 @@ void Unit::SetStunned(bool apply) AddUnitMovementFlag(MOVEMENTFLAG_ROOT); // Creature specific - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) ((Creature*)this)->StopMoving(); else SetStandState(UNIT_STAND_STATE_STAND); @@ -14081,15 +14055,15 @@ void Unit::SetStunned(bool apply) } else { - if(isAlive() && getVictim()) + if (isAlive() && getVictim()) SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID()); // 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 && !((Player *)pOwner)->IsMounted())) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); - if(!hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect + if (!hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect { WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4); data.append(GetPackGUID()); @@ -14103,7 +14077,7 @@ void Unit::SetStunned(bool apply) void Unit::SetRooted(bool apply) { - if(apply) + if (apply) { AddUnitMovementFlag(MOVEMENTFLAG_ROOT); @@ -14112,12 +14086,12 @@ void Unit::SetRooted(bool apply) data << (uint32)2; SendMessageToSet(&data,true); - if(GetTypeId() != TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) ((Creature *)this)->StopMoving(); } else { - if(!hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect + if (!hasUnitState(UNIT_STAT_STUNNED)) // prevent allow move if have also stun effect { WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 10); data.append(GetPackGUID()); @@ -14131,25 +14105,25 @@ void Unit::SetRooted(bool apply) void Unit::SetFeared(bool apply) { - if(apply) + if (apply) { SetUInt64Value(UNIT_FIELD_TARGET, 0); Unit *caster = NULL; Unit::AuraEffectList const& fearAuras = GetAurasByType(SPELL_AURA_MOD_FEAR); - if(!fearAuras.empty()) + if (!fearAuras.empty()) caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID()); - if(!caster) + if (!caster) caster = getAttackerForHelper(); GetMotionMaster()->MoveFleeing(caster, fearAuras.empty() ? sWorld.getConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY) : 0); // caster==NULL processed in MoveFleeing } else { - if(isAlive()) + if (isAlive()) { - if(GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE) + if (GetMotionMaster()->GetCurrentMovementGeneratorType() == FLEEING_MOTION_TYPE) GetMotionMaster()->MovementExpired(); - if(getVictim()) + if (getVictim()) SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID()); } } @@ -14160,29 +14134,29 @@ void Unit::SetFeared(bool apply) void Unit::SetConfused(bool apply) { - if(apply) + if (apply) { SetUInt64Value(UNIT_FIELD_TARGET, 0); GetMotionMaster()->MoveConfused(); } else { - if(isAlive()) + if (isAlive()) { - if(GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE) + if (GetMotionMaster()->GetCurrentMovementGeneratorType() == CONFUSED_MOTION_TYPE) GetMotionMaster()->MovementExpired(); - if(getVictim()) + if (getVictim()) SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID()); } } - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) ((Player*)this)->SetClientControl(this, !apply); } bool Unit::SetCharmedBy(Unit* charmer, CharmType type) { - if(!charmer) + if (!charmer) return false; assert(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER); @@ -14190,23 +14164,23 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type) sLog.outDebug("SetCharmedBy: charmer %u, charmed %u, type %u.", charmer->GetEntry(), GetEntry(), (uint32)type); - if(this == charmer) + if (this == charmer) { sLog.outCrash("Unit::SetCharmedBy: Unit %u is trying to charm itself!", GetEntry()); return false; } - //if(hasUnitState(UNIT_STAT_UNATTACKABLE)) + //if (hasUnitState(UNIT_STAT_UNATTACKABLE)) // return false; - if(GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport()) + if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetTransport()) { sLog.outCrash("Unit::SetCharmedBy: Player on transport is trying to charm %u", GetEntry()); return false; } // Already charmed - if(GetCharmerGUID()) + if (GetCharmerGUID()) { sLog.outCrash("Unit::SetCharmedBy: %u has already been charmed but %u is trying to charm it!", GetEntry(), charmer->GetEntry()); return false; @@ -14217,21 +14191,21 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type) DeleteThreatList(); // Charmer stop charming - if(charmer->GetTypeId() == TYPEID_PLAYER) + if (charmer->GetTypeId() == TYPEID_PLAYER) { ((Player*)charmer)->StopCastingCharm(); ((Player*)charmer)->StopCastingBindSight(); } // Charmed stop charming - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { ((Player*)this)->StopCastingCharm(); ((Player*)this)->StopCastingBindSight(); } // StopCastingCharm may remove a possessed pet? - if(!IsInWorld()) + if (!IsInWorld()) { sLog.outCrash("Unit::SetCharmedBy: %u is not in world but %u is trying to charm it!", GetEntry(), charmer->GetEntry()); return false; @@ -14241,29 +14215,29 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type) setFaction(charmer->getFaction()); charmer->SetCharm(this, true); - if(GetTypeId() == TYPEID_UNIT) + if (GetTypeId() == TYPEID_UNIT) { ((Creature*)this)->AI()->OnCharmed(true); GetMotionMaster()->MoveIdle(); } else { - if(((Player*)this)->isAFK()) + if (((Player*)this)->isAFK()) ((Player*)this)->ToggleAFK(); ((Player*)this)->SetClientControl(this, 0); } // Pets already have a properly initialized CharmInfo, don't overwrite it. - if(type != CHARM_TYPE_VEHICLE && !GetCharmInfo()) + if (type != CHARM_TYPE_VEHICLE && !GetCharmInfo()) { CharmInfo *charmInfo = InitCharmInfo(); - if(type == CHARM_TYPE_POSSESS) + if (type == CHARM_TYPE_POSSESS) charmInfo->InitPossessCreateSpells(); else charmInfo->InitCharmCreateSpells(); } - if(charmer->GetTypeId() == TYPEID_PLAYER) + if (charmer->GetTypeId() == TYPEID_PLAYER) { switch(type) { @@ -14282,16 +14256,16 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type) ((Player*)charmer)->PossessSpellInitialize(); break; case CHARM_TYPE_CHARM: - if(GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) + if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) { CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo(); - if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) + if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) { //to prevent client crash SetByteValue(UNIT_FIELD_BYTES_0, 1, (uint8)CLASS_MAGE); //just to enable stat window - if(GetCharmInfo()) + if (GetCharmInfo()) GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true); //if charmed two demons the same session, the 2nd gets the 1st one's name @@ -14310,12 +14284,12 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type) void Unit::RemoveCharmedBy(Unit *charmer) { - if(!isCharmed()) + if (!isCharmed()) return; - if(!charmer) + if (!charmer) charmer = GetCharmer(); - if(charmer != GetCharmer()) // one aura overrides another? + if (charmer != GetCharmer()) // one aura overrides another? { // sLog.outCrash("Unit::RemoveCharmedBy: this: " UI64FMTD " true charmer: " UI64FMTD " false charmer: " UI64FMTD, // GetGUID(), GetCharmerGUID(), charmer->GetGUID()); @@ -14324,9 +14298,9 @@ void Unit::RemoveCharmedBy(Unit *charmer) } CharmType type; - if(hasUnitState(UNIT_STAT_POSSESSED)) + if (hasUnitState(UNIT_STAT_POSSESSED)) type = CHARM_TYPE_POSSESS; - else if(charmer->IsOnVehicle(this)) + else if (charmer->IsOnVehicle(this)) type = CHARM_TYPE_VEHICLE; else type = CHARM_TYPE_CHARM; @@ -14338,23 +14312,21 @@ void Unit::RemoveCharmedBy(Unit *charmer) RestoreFaction(); GetMotionMaster()->InitDefault(); - if(type == CHARM_TYPE_POSSESS) + if (type == CHARM_TYPE_POSSESS) { clearUnitState(UNIT_STAT_POSSESSED); RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); } - if(GetTypeId() == TYPEID_UNIT) + if (GetTypeId() == TYPEID_UNIT) { ((Creature*)this)->AI()->OnCharmed(false); - if(isAlive() && charmer && !IsFriendlyTo(charmer)) + if (isAlive() && charmer && !IsFriendlyTo(charmer)) ((Creature*)this)->AddThreat(charmer, 10000.0f); - /*if(isAlive() && ((Creature*)this)->IsAIEnabled) + /*if (isAlive() && ((Creature*)this)->IsAIEnabled) { - if(charmer && !IsFriendlyTo(charmer)) - { + if (charmer && !IsFriendlyTo(charmer)) ((Creature*)this)->AI()->AttackStart(charmer); - } else ((Creature*)this)->AI()->EnterEvadeMode(); }*/ @@ -14363,7 +14335,7 @@ void Unit::RemoveCharmedBy(Unit *charmer) ((Player*)this)->SetClientControl(this, 1); // If charmer still exists - if(!charmer) + if (!charmer) return; assert(type != CHARM_TYPE_POSSESS || charmer->GetTypeId() == TYPEID_PLAYER); @@ -14371,7 +14343,7 @@ void Unit::RemoveCharmedBy(Unit *charmer) charmer->SetCharm(this, false); - if(charmer->GetTypeId() == TYPEID_PLAYER) + if (charmer->GetTypeId() == TYPEID_PLAYER) { switch(type) { @@ -14385,13 +14357,13 @@ void Unit::RemoveCharmedBy(Unit *charmer) charmer->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE); break; case CHARM_TYPE_CHARM: - if(GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) + if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) { CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo(); - if(cinfo && cinfo->type == CREATURE_TYPE_DEMON) + if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) { SetByteValue(UNIT_FIELD_BYTES_0, 1, uint8(cinfo->unit_class)); - if(GetCharmInfo()) + if (GetCharmInfo()) GetCharmInfo()->SetPetNumber(0, true); else sLog.outError("Aura::HandleModCharm: target="UI64FMTD" with typeid=%d has a charm aura but no charm info!", GetGUID(), GetTypeId()); @@ -14426,7 +14398,7 @@ void Unit::RestoreFaction() } } - if(CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo()) // normal creature + if (CreatureInfo const *cinfo = ((Creature*)this)->GetCreatureInfo()) // normal creature { FactionTemplateEntry const *faction = getFactionTemplateEntry(); setFaction((faction && faction->friendlyMask & 0x004) ? cinfo->faction_H : cinfo->faction_A); @@ -14437,7 +14409,7 @@ void Unit::RestoreFaction() bool Unit::CreateVehicleKit(uint32 id) { VehicleEntry const *vehInfo = sVehicleStore.LookupEntry(id); - if(!vehInfo) + if (!vehInfo) return false; m_vehicleKit = new Vehicle(this, vehInfo); @@ -14569,7 +14541,7 @@ void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap) if (owner->GetTypeId() == TYPEID_PLAYER) pGroup = ((Player*)owner)->GetGroup(); - if(pGroup) + if (pGroup) { uint8 subgroup = ((Player*)owner)->GetSubGroup(); @@ -14591,10 +14563,10 @@ void Unit::GetPartyMembers(std::list<Unit*> &TagUnitMap) } else { - if(owner->isAlive() && (owner == this || IsInMap(owner))) + if (owner->isAlive() && (owner == this || IsInMap(owner))) TagUnitMap.push_back(owner); - if(Guardian* pet = owner->GetGuardianPet()) - if(pet->isAlive() && (pet == this || IsInMap(pet))) + if (Guardian* pet = owner->GetGuardianPet()) + if (pet->isAlive() && (pet == this || IsInMap(pet))) TagUnitMap.push_back(pet); } } @@ -14632,11 +14604,11 @@ void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply) void Unit::AddAura(uint32 spellId, Unit *target) { - if(!target || !target->isAlive()) + if (!target || !target->isAlive()) return; SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) + if (!spellInfo) return; if (target->IsImmunedToSpell(spellInfo)) @@ -14647,13 +14619,13 @@ void Unit::AddAura(uint32 spellId, Unit *target) for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - if(spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || IsAreaAuraEffect(spellInfo->Effect[i])) + if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || IsAreaAuraEffect(spellInfo->Effect[i])) { // Area auras applied as linked should have target as source (otherwise they'll be removed after first aura update) if (spellInfo->Effect[i] != SPELL_EFFECT_APPLY_AURA) source = target; - if(target->IsImmunedToSpellEffect(spellInfo, i)) + if (target->IsImmunedToSpellEffect(spellInfo, i)) continue; eff_mask|=1<<i; } @@ -14670,12 +14642,12 @@ void Unit::AddAura(uint32 spellId, Unit *target) void Unit::SetAuraStack(uint32 spellId, Unit *target, uint32 stack) { Aura *aur = target->GetAura(spellId, GetGUID()); - if(!aur) + if (!aur) { AddAura(spellId, target); aur = target->GetAura(spellId, GetGUID()); } - if(aur && stack) + if (aur && stack) aur->SetStackAmount(stack); } @@ -14690,16 +14662,16 @@ Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, WorldOb Aura *aur = GetAura(spellInfo->Id, caster->GetGUID()); // without this it may crash when shaman refresh totem? source is NULL - if(aur && aur->GetSourceGUID() != source->GetGUID()) + if (aur && aur->GetSourceGUID() != source->GetGUID()) { RemoveAura(aur); aur = NULL; } - if(aur) + if (aur) { - if(AuraEffect *aurEffect = CreateAuraEffect(aur, effIndex, basePoints)) - if(!aur->SetPartAura(aurEffect, effIndex)) + if (AuraEffect *aurEffect = CreateAuraEffect(aur, effIndex, basePoints)) + if (!aur->SetPartAura(aurEffect, effIndex)) delete aurEffect; } else @@ -14713,7 +14685,7 @@ Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, WorldOb else aur = new Aura(spellInfo, 1<<effIndex, this, source, caster, NULL, NULL); - if(!AddAura(aur)) + if (!AddAura(aur)) return NULL; } return aur; @@ -14729,7 +14701,7 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, // PvP - PvE melee chances /*int32 lchance = pVictim->GetTypeId() == TYPEID_PLAYER ? 5 : 7; int32 leveldif = pVictim->getLevelForTarget(this) - getLevelForTarget(pVictim); - if(leveldif < 3) + if (leveldif < 3) HitChance = 95 - leveldif; else HitChance = 93 - (leveldif - 2) * lchance;*/ @@ -14739,20 +14711,20 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, HitChance = 76.0f; // Hit chance depends from victim auras - if(attType == RANGED_ATTACK) + if (attType == RANGED_ATTACK) HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE); else HitChance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE); // Spellmod from SPELLMOD_RESIST_MISS_CHANCE - if(spellId) + if (spellId) { - if(Player *modOwner = GetSpellModOwner()) + if (Player *modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, HitChance); } // Miss = 100 - hit - float miss_chance= 100.0f - HitChance; + float miss_chance = 100.0f - HitChance; // Bonuses from attacker aura and ratings if (attType == RANGED_ATTACK) @@ -14763,7 +14735,7 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, // bonus from skills is 0.04% //miss_chance -= skillDiff * 0.04f; int32 diff = -skillDiff; - if(pVictim->GetTypeId() == TYPEID_PLAYER) + if (pVictim->GetTypeId() == TYPEID_PLAYER) miss_chance += diff > 0 ? diff * 0.04 : diff * 0.02; else miss_chance += diff > 10 ? 2 + (diff - 10) * 0.4 : diff * 0.1; @@ -14778,40 +14750,40 @@ float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) { - if(newPhaseMask==GetPhaseMask()) + if (newPhaseMask == GetPhaseMask()) return; - if(IsInWorld()) + if (IsInWorld()) RemoveNotOwnSingleTargetAuras(newPhaseMask); // we can lost access to caster or target WorldObject::SetPhaseMask(newPhaseMask,update); - if(!IsInWorld()) + if (!IsInWorld()) return; for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) - if((*itr)->GetTypeId() == TYPEID_UNIT) + if ((*itr)->GetTypeId() == TYPEID_UNIT) (*itr)->SetPhaseMask(newPhaseMask,true); for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i) - if(m_SummonSlot[i]) - if(Creature *summon = GetMap()->GetCreature(m_SummonSlot[i])) + if (m_SummonSlot[i]) + if (Creature *summon = GetMap()->GetCreature(m_SummonSlot[i])) summon->SetPhaseMask(newPhaseMask,true); } void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) { Player *player = NULL; - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) player = (Player*)this; else { player = dynamic_cast<Player*>(GetCharmer()); - if(player && player->m_mover != this) + if (player && player->m_mover != this) player = NULL; } - if(!player) + if (!player) { GetMotionMaster()->MoveKnockbackFrom(x, y, speedXY, speedZ); } @@ -14835,10 +14807,8 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ) void Unit::JumpTo(float speedXY, float speedZ, bool forward) { float angle = forward ? 0 : M_PI; - if(GetTypeId() == TYPEID_UNIT) - { + if (GetTypeId() == TYPEID_UNIT) GetMotionMaster()->MoveJumpTo(angle, speedXY, speedZ); - } else { float vcos = cos(angle+GetOrientation()); @@ -14866,14 +14836,14 @@ void Unit::JumpTo(WorldObject *obj, float speedZ) void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId) { - if(!isAlive() || GetVehicleKit() == vehicle) + if (!isAlive() || GetVehicleKit() == vehicle) return; - if(m_vehicle) + if (m_vehicle) { - if(m_vehicle == vehicle) + if (m_vehicle == vehicle) { - if(seatId >= 0) + if (seatId >= 0) { sLog.outDebug("EnterVehicle: %u leave vehicle %u seat %d and enter %d.", GetEntry(), m_vehicle->GetBase()->GetEntry(), GetTransSeat(), seatId); ChangeSeat(seatId); @@ -14887,7 +14857,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId) } } - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { ((Player*)this)->StopCastingCharm(); ((Player*)this)->StopCastingBindSight(); @@ -14897,7 +14867,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId) assert(!m_vehicle); m_vehicle = vehicle; - if(!m_vehicle->AddPassenger(this, seatId)) + if (!m_vehicle->AddPassenger(this, seatId)) { m_vehicle = NULL; return; @@ -14907,7 +14877,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId) //movementInfo is set in AddPassenger //packets are sent in AddPassenger - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { //((Player*)this)->SetClientControl(vehicle, 1); WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); @@ -14917,40 +14887,40 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId) void Unit::ChangeSeat(int8 seatId, bool next) { - if(!m_vehicle) + if (!m_vehicle) return; - if(seatId < 0) + if (seatId < 0) { seatId = m_vehicle->GetNextEmptySeat(GetTransSeat(), next); - if(seatId < 0) + if (seatId < 0) return; } - else if(seatId == GetTransSeat() || !m_vehicle->HasEmptySeat(seatId)) + else if (seatId == GetTransSeat() || !m_vehicle->HasEmptySeat(seatId)) return; m_vehicle->RemovePassenger(this); - if(!m_vehicle->AddPassenger(this, seatId)) + if (!m_vehicle->AddPassenger(this, seatId)) assert(false); } void Unit::ExitVehicle() { - if(!m_vehicle) + if (!m_vehicle) return; Unit *vehicleBase = m_vehicle->GetBase(); const AuraEffectList &modAuras = vehicleBase->GetAurasByType(SPELL_AURA_CONTROL_VEHICLE); for (AuraEffectList::const_iterator itr = modAuras.begin(); itr != modAuras.end(); ++itr) { - if((*itr)->GetParentAura()->GetSourceGUID() == GetGUID()) + if ((*itr)->GetParentAura()->GetSourceGUID() == GetGUID()) { vehicleBase->RemoveAura((*itr)->GetParentAura()); break; // there should be no case that a vehicle has two auras for one source } } - if(!m_vehicle) + if (!m_vehicle) return; //sLog.outError("exit vehicle"); @@ -14974,7 +14944,7 @@ void Unit::ExitVehicle() Relocate(vehicle->GetBase()); //Send leave vehicle, not correct - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { //((Player*)this)->SetClientControl(this, 1); ((Player*)this)->SendTeleportAckMsg(); @@ -14984,8 +14954,8 @@ void Unit::ExitVehicle() BuildHeartBeatMsg(&data); SendMessageToSet(&data, false); - if(vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION)) - if(((Minion*)vehicle->GetBase())->GetOwner() == this) + if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION)) + if (((Minion*)vehicle->GetBase())->GetOwner() == this) vehicle->Dismiss(); } @@ -15037,14 +15007,14 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const } // 0x02200000 - if((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) + if ((GetUnitMovementFlags() & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20)) *data << (float)m_movementInfo.s_pitch; *data << (uint32)m_movementInfo.fallTime; // 0x00001000 - if(GetUnitMovementFlags() & MOVEMENTFLAG_JUMPING) + if (GetUnitMovementFlags() & MOVEMENTFLAG_JUMPING) { *data << (float)m_movementInfo.j_zspeed; *data << (float)m_movementInfo.j_sinAngle; @@ -15053,10 +15023,10 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const } // 0x04000000 - if(GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE) + if (GetUnitMovementFlags() & MOVEMENTFLAG_SPLINE) *data << (float)m_movementInfo.u_unk1; - /*if(GetTypeId() == TYPEID_PLAYER) + /*if (GetTypeId() == TYPEID_PLAYER) { sLog.outString("Send MovementInfo:"); OutMovementInfo(); @@ -15066,19 +15036,19 @@ void Unit::BuildMovementPacket(ByteBuffer *data) const void Unit::OutMovementInfo() const { sLog.outString("MovementInfo for %u: Flag %u, Unk1 %u, Time %u, Pos %f %f %f %f, Fall %u", GetEntry(), m_movementInfo.flags, (uint32)m_movementInfo.unk1, m_movementInfo.time, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), m_movementInfo.fallTime); - if(m_movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT) + if (m_movementInfo.flags & MOVEMENTFLAG_ONTRANSPORT) sLog.outString("Transport: GUID " UI64FMTD ", Pos %f %f %f %f, Time %u, Seat %d", m_movementInfo.t_guid, m_movementInfo.t_x, m_movementInfo.t_y, m_movementInfo.t_z, m_movementInfo.t_o, m_movementInfo.t_time, (int32)m_movementInfo.t_seat); - if((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20)) + if ((m_movementInfo.flags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) || (m_movementInfo.unk1 & 0x20)) sLog.outString("Pitch: %f", m_movementInfo.s_pitch); - if(m_movementInfo.flags & MOVEMENTFLAG_JUMPING) + if (m_movementInfo.flags & MOVEMENTFLAG_JUMPING) sLog.outString("Jump: speedz %f, sin %f, cos %f, speedxy %f", m_movementInfo.j_zspeed, m_movementInfo.j_sinAngle, m_movementInfo.j_cosAngle, m_movementInfo.j_xyspeed); - if(m_movementInfo.flags & MOVEMENTFLAG_SPLINE) + if (m_movementInfo.flags & MOVEMENTFLAG_SPLINE) sLog.outString("Spline: %f", m_movementInfo.u_unk1); } void Unit::SetFlying(bool apply) { - if(apply) + if (apply) { SetByteFlag(UNIT_FIELD_BYTES_1, 3, 0x02); AddUnitMovementFlag(MOVEMENTFLAG_FLY_MODE + MOVEMENTFLAG_FLYING); @@ -15092,7 +15062,7 @@ void Unit::SetFlying(bool apply) void Unit::NearTeleportTo( float x, float y, float z, float orientation, bool casting /*= false*/ ) { - if(GetTypeId() == TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) ((Player*)this)->TeleportTo(GetMapId(), x, y, z, orientation, TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (casting ? TELE_TO_SPELL : 0)); else { @@ -15188,7 +15158,7 @@ void Unit::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker if (getLevel() > 70) rageconversion += 13.27f*(getLevel()-70); - if(attacker) + if (attacker) { addRage = ((damage/rageconversion*7.5 + weaponSpeedHitFactor)/2); @@ -15200,7 +15170,7 @@ void Unit::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker addRage = damage/rageconversion*2.5; // Berserker Rage effect - if(HasAura(18499)) + if (HasAura(18499)) addRage *= 2.0; } @@ -15231,16 +15201,16 @@ void Unit::OutDebugInfo() const sLog.outStringInLine("%u, ", itr->first); sLog.outString(); - if(IsVehicle()) + if (IsVehicle()) { sLog.outStringInLine("Passenger List: "); for (SeatMap::iterator itr = GetVehicleKit()->m_Seats.begin(); itr != GetVehicleKit()->m_Seats.end(); ++itr) - if(Unit *passenger = itr->second.passenger) + if (Unit *passenger = itr->second.passenger) sLog.outStringInLine(UI64FMTD", ", passenger->GetGUID()); sLog.outString(); } - if(GetVehicle()) + if (GetVehicle()) sLog.outString("On vehicle %u.", GetVehicleBase()->GetEntry()); } diff --git a/src/game/Wintergrasp.cpp b/src/game/Wintergrasp.cpp index 56bdd3df187..dcc27a3fb11 100644 --- a/src/game/Wintergrasp.cpp +++ b/src/game/Wintergrasp.cpp @@ -387,7 +387,7 @@ bool OPvPWintergrasp::SetupOutdoorPvP() // Load Graveyard GraveYardMap::const_iterator graveLow = objmgr.mGraveYardMap.lower_bound(ZONE_WINTERGRASP); GraveYardMap::const_iterator graveUp = objmgr.mGraveYardMap.upper_bound(ZONE_WINTERGRASP); - for (AreaPOIList::iterator itr = areaPOIs.begin(); itr != areaPOIs.end(); ) + for (AreaPOIList::iterator itr = areaPOIs.begin(); itr != areaPOIs.end();) { if ((*itr)->icon[1] == 8) { diff --git a/src/game/World.cpp b/src/game/World.cpp index 81784f2c09a..a231e4d78a5 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -280,7 +280,7 @@ bool World::HasRecentlyDisconnected(WorldSession* session) if (uint32 tolerance = getConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE)) { - for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end(); ) + for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();) { if (difftime(i->second, time(NULL)) < tolerance) { diff --git a/src/game/WorldSocketMgr.cpp b/src/game/WorldSocketMgr.cpp index 2a34041c43f..cc08962efa5 100644 --- a/src/game/WorldSocketMgr.cpp +++ b/src/game/WorldSocketMgr.cpp @@ -171,7 +171,7 @@ class ReactorRunnable : protected ACE_Task_Base AddNewSockets (); - for (i = m_Sockets.begin (); i != m_Sockets.end (); ) + for (i = m_Sockets.begin (); i != m_Sockets.end ();) { if ((*i)->Update () == -1) { diff --git a/src/shared/vmap/TileAssembler.cpp b/src/shared/vmap/TileAssembler.cpp index 5a9b35bb3a1..dad7d703771 100644 --- a/src/shared/vmap/TileAssembler.cpp +++ b/src/shared/vmap/TileAssembler.cpp @@ -524,7 +524,7 @@ namespace VMAP nindexes -= rest; } - for (unsigned int i=0; i<(nindexes); ) + for (unsigned int i=0; i<(nindexes);) { Triangle t = Triangle(tempVertexArray[tempIndexArray[i+2]], tempVertexArray[tempIndexArray[i+1]], tempVertexArray[tempIndexArray[i+0]] ); i+=3; |