diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h index 5c777aca4..d385e8420 100644 --- a/src/framework/GameSystem/TypeContainer.h +++ b/src/framework/GameSystem/TypeContainer.h @@ -212,7 +212,9 @@ class TypeUnorderedMapContainer return NULL; } else - { return i->second; } + { + return i->second; + } } template diff --git a/src/framework/Utilities/LinkedList.h b/src/framework/Utilities/LinkedList.h index 8644d25e5..bdfa7cedd 100644 --- a/src/framework/Utilities/LinkedList.h +++ b/src/framework/Utilities/LinkedList.h @@ -270,7 +270,9 @@ class LinkedListHead return result; } else - { return iSize; } + { + return iSize; + } } /** diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/game/AuctionHouseBot/AuctionHouseBot.cpp index ac6868754..989c0b2dd 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -148,9 +148,13 @@ class AHB_Seller_Config return 1; } else if ((m_maxTime) && (m_minTime > m_maxTime)) - { return m_maxTime; } + { + return m_maxTime; + } else - { return m_minTime; } + { + return m_minTime; + } } void SetMaxTime(uint32 value) { m_maxTime = value; } @@ -167,7 +171,9 @@ class AHB_Seller_Config m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems = m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems - found; } else - { m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems = 0; } + { + m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems = 0; + } } uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass) const { return m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems; } @@ -408,7 +414,9 @@ bool AuctionBotConfig::Initialize() return false; } else - { sLog.outString("AHBot using configuration file %s", m_configFileName.c_str()); } + { + sLog.outString("AHBot using configuration file %s", m_configFileName.c_str()); + } GetConfigFromFile(); @@ -747,14 +755,18 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config) buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount(); } else if (buyerItem.MinBuyPrice == 0) - { buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount(); } + { + buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount(); + } } if (Aentry->startbid / item->GetCount() < buyerItem.MinBidPrice) { buyerItem.MinBidPrice = Aentry->startbid / item->GetCount(); } else if (buyerItem.MinBidPrice == 0) - { buyerItem.MinBidPrice = Aentry->startbid / item->GetCount(); } + { + buyerItem.MinBidPrice = Aentry->startbid / item->GetCount(); + } if (Aentry->owner == sAuctionBotConfig.GetAHBotId()) { @@ -803,7 +815,9 @@ void AuctionBotBuyer::PrepareListOfEntry(AHB_Buyer_Config& config) config.CheckedEntry.erase(itr++); } else - { ++itr; } + { + ++itr; + } } DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: CheckedEntry size = " SIZEFMTD, config.CheckedEntry.size()); @@ -858,7 +872,9 @@ bool AuctionBotBuyer::IsBuyableEntry(uint64 buyoutPrice, double InGame_BuyPrice, } } else if (buyoutPrice <= MaxBuyablePrice) - { Chance = MaxChance / 10; } + { + Chance = MaxChance / 10; + } else { if ((buyoutPrice > 0) && (MaxBuyablePrice > 0)) @@ -909,12 +925,16 @@ bool AuctionBotBuyer::IsBidableEntry(uint64 bidPrice, double InGame_BuyPrice, do Chance = ((MaxChance / 500) * ratio); } else - { Chance = (MaxChance / 500); } + { + Chance = (MaxChance / 500); + } } } } else if (bidPrice < (InGame_BuyPrice - (InGame_BuyPrice / 30))) - { Chance = (MaxChance / 10); } + { + Chance = (MaxChance / 10); + } else { if (bidPrice < MaxBidablePrice) @@ -925,7 +945,9 @@ bool AuctionBotBuyer::IsBidableEntry(uint64 bidPrice, double InGame_BuyPrice, do Chance = ((MaxChance / 1000) * ratio); } else - { Chance = (MaxChance / 1000); } + { + Chance = (MaxChance / 1000); + } } } uint32 RandNum = urand(1, ChanceRatio); @@ -967,7 +989,9 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) BASIC_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Boost value used for Buyer! (if this happens often adjust both ItemsPerCycle in ahbot.conf)"); } else - { BuyCycles = sAuctionBotConfig.GetItemPerCycleNormal(); } + { + BuyCycles = sAuctionBotConfig.GetItemPerCycleNormal(); + } for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();) { @@ -1077,7 +1101,9 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) BuyEntry(auction); } else - { BuyEntry(auction); } + { + BuyEntry(auction); + } } else { @@ -1981,7 +2007,9 @@ void AuctionBotSeller::addNewAuctions(AHB_Seller_Config& config) buyoutPrice = prototype->BuyPrice * item->GetCount(); } else - { buyoutPrice = prototype->SellPrice * item->GetCount(); } + { + buyoutPrice = prototype->SellPrice * item->GetCount(); + } // Price of items are set here SetPricesOfItem(prototype, config, buyoutPrice, bidPrice, stackCount, ItemQualities(prototype->Quality)); @@ -2001,7 +2029,9 @@ bool AuctionBotSeller::Update(AuctionHouseType houseType) return true; } else - { return false; } + { + return false; + } } //== AuctionHouseBot functions ============================= diff --git a/src/game/BattleGround/BattleGround.cpp b/src/game/BattleGround/BattleGround.cpp index cb5a02f7f..dc213a930 100644 --- a/src/game/BattleGround/BattleGround.cpp +++ b/src/game/BattleGround/BattleGround.cpp @@ -76,7 +76,9 @@ namespace MaNGOS ChatHandler::BuildChatPacket(data, i_msgtype, &str[0], LANG_UNIVERSAL, CHAT_TAG_NONE, sourceGuid, sourceName.c_str()); } else - { ChatHandler::BuildChatPacket(data, i_msgtype, text, LANG_UNIVERSAL, CHAT_TAG_NONE, sourceGuid, sourceName.c_str(), sourceGuid, sourceName.c_str()); } + { + ChatHandler::BuildChatPacket(data, i_msgtype, text, LANG_UNIVERSAL, CHAT_TAG_NONE, sourceGuid, sourceName.c_str(), sourceGuid, sourceName.c_str()); + } } private: ChatMsg i_msgtype; @@ -114,7 +116,9 @@ namespace MaNGOS ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_YELL, &str[0], i_language, CHAT_TAG_NONE, i_source->GetObjectGuid(), i_source->GetName()); } else - { ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_YELL, text, i_language, CHAT_TAG_NONE, i_source->GetObjectGuid(), i_source->GetName()); } + { + ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_YELL, text, i_language, CHAT_TAG_NONE, i_source->GetObjectGuid(), i_source->GetName()); + } } private: Language i_language; @@ -401,7 +405,9 @@ void BattleGround::Update(uint32 diff) } } else if (m_PrematureCountDown) - { m_PrematureCountDown = false; } + { + m_PrematureCountDown = false; + } /*********************************************************/ /*** ARENA BUFF OBJECT SPAWNING ***/ @@ -574,7 +580,9 @@ void BattleGround::SendPacketToAll(WorldPacket* packet) plr->GetSession()->SendPacket(packet); } else - { sLog.outError("BattleGround:SendPacketToAll: %s not found!", itr->first.GetString().c_str()); } + { + sLog.outError("BattleGround:SendPacketToAll: %s not found!", itr->first.GetString().c_str()); + } } } @@ -1006,7 +1014,9 @@ void BattleGround::EndBattleGround(Team winner) plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1); } else - { RewardMark(plr, ITEM_LOSER_COUNT); } + { + RewardMark(plr, ITEM_LOSER_COUNT); + } plr->CombatStopWithPets(true); @@ -1081,7 +1091,9 @@ void BattleGround::RewardMark(Player* plr, uint32 count) RewardSpellCast(plr, SPELL_AV_MARK_WINNER); } else - { RewardSpellCast(plr, SPELL_AV_MARK_LOSER); } + { + RewardSpellCast(plr, SPELL_AV_MARK_LOSER); + } break; case BATTLEGROUND_WS: if (count == ITEM_WINNER_COUNT) @@ -1089,7 +1101,9 @@ void BattleGround::RewardMark(Player* plr, uint32 count) RewardSpellCast(plr, SPELL_WS_MARK_WINNER); } else - { RewardSpellCast(plr, SPELL_WS_MARK_LOSER); } + { + RewardSpellCast(plr, SPELL_WS_MARK_LOSER); + } break; case BATTLEGROUND_AB: if (count == ITEM_WINNER_COUNT) @@ -1097,7 +1111,9 @@ void BattleGround::RewardMark(Player* plr, uint32 count) RewardSpellCast(plr, SPELL_AB_MARK_WINNER); } else - { RewardSpellCast(plr, SPELL_AB_MARK_LOSER); } + { + RewardSpellCast(plr, SPELL_AB_MARK_LOSER); + } break; case BATTLEGROUND_EY: // no rewards default: @@ -1114,7 +1130,9 @@ void BattleGround::RewardSpellCast(Player* plr, uint32 spell_id) { // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) + { return; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) @@ -1136,7 +1154,9 @@ void BattleGround::RewardItem(Player* plr, uint32 item_id, uint32 count) { // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if (plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) + { return; + } ItemPosCountVec dest; uint32 no_space_count = 0; @@ -1740,7 +1760,9 @@ void BattleGround::DoorClose(ObjectGuid guid) } } else - { sLog.outError("BattleGround: Door %s not found (can not close doors)", guid.GetString().c_str()); } + { + sLog.outError("BattleGround: Door %s not found (can not close doors)", guid.GetString().c_str()); + } } /// @@ -1757,7 +1779,9 @@ void BattleGround::DoorOpen(ObjectGuid guid) obj->UseDoorOrButton(RESPAWN_ONE_DAY); } else - { sLog.outError("BattleGround: Door %s not found! - doors will be closed.", guid.GetString().c_str()); } + { + sLog.outError("BattleGround: Door %s not found! - doors will be closed.", guid.GetString().c_str()); + } } Team BattleGround::GetPrematureWinner() @@ -1766,9 +1790,13 @@ Team BattleGround::GetPrematureWinner() uint32 alliancePlayers = GetPlayersCountByTeam(ALLIANCE); if (hordePlayers > alliancePlayers) + { return HORDE; + } if (alliancePlayers > hordePlayers) + { return ALLIANCE; + } return TEAM_NONE; } diff --git a/src/game/BattleGround/BattleGround.h b/src/game/BattleGround/BattleGround.h index 08aabc777..780d5f44a 100644 --- a/src/game/BattleGround/BattleGround.h +++ b/src/game/BattleGround/BattleGround.h @@ -668,7 +668,9 @@ class BattleGround return m_InvitedAlliance; } else - { return m_InvitedHorde; } + { + return m_InvitedHorde; + } } /** * @brief @@ -1036,7 +1038,9 @@ class BattleGround --m_PlayersCount[GetTeamIndexByTeamId(team)]; } else - { ++m_PlayersCount[GetTeamIndexByTeamId(team)]; } + { + ++m_PlayersCount[GetTeamIndexByTeamId(team)]; + } } // used for rated arena battles diff --git a/src/game/BattleGround/BattleGroundAB.cpp b/src/game/BattleGround/BattleGroundAB.cpp index e7e7d0622..13e38eb86 100644 --- a/src/game/BattleGround/BattleGroundAB.cpp +++ b/src/game/BattleGround/BattleGroundAB.cpp @@ -150,7 +150,9 @@ void BattleGroundAB::Update(uint32 diff) SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); } else - { SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); } + { + SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); + } PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY); m_IsInformedNearVictory = true; } @@ -237,7 +239,9 @@ bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger) source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); } else - { source->LeaveBattleground(); } + { + source->LeaveBattleground(); + } break; case 3949: // Arathi Basin Horde Exit. if (source->GetTeam() != HORDE) @@ -245,7 +249,9 @@ bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger) source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); } else - { source->LeaveBattleground(); } + { + source->LeaveBattleground(); + } break; default: return false; @@ -327,7 +333,9 @@ void BattleGroundAB::FillInitialWorldStates(WorldPacket& data, uint32& count) ++ally; } else if (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_OCCUPIED) - { ++horde; } + { + ++horde; + } FillInitialWorldState(data, count, BG_AB_OP_OCCUPIED_BASES_ALLY, ally); FillInitialWorldState(data, count, BG_AB_OP_OCCUPIED_BASES_HORDE, horde); @@ -356,7 +364,9 @@ void BattleGroundAB::_SendNodeUpdate(uint8 node) UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_prevNodes[node]], WORLD_STATE_REMOVE); } else - { UpdateWorldState(BG_AB_OP_NODEICONS[node], WORLD_STATE_REMOVE); } + { + UpdateWorldState(BG_AB_OP_NODEICONS[node], WORLD_STATE_REMOVE); + } UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_Nodes[node]], WORLD_STATE_ADD); @@ -368,7 +378,9 @@ void BattleGroundAB::_SendNodeUpdate(uint8 node) ++ally; } else if (m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED) - { ++horde; } + { + ++horde; + } UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_ALLY, ally); UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_HORDE, horde); @@ -448,7 +460,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_ALLY); } else - { SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_HORDE); } + { + SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_HORDE); + } sound = BG_AB_SOUND_NODE_CLAIMED; } @@ -471,7 +485,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); } else - { SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } + { + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); + } } // If contested, change back to occupied else @@ -490,7 +506,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); } else - { SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } + { + SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); + } } sound = (teamIndex == TEAM_INDEX_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } @@ -510,7 +528,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); } else - { SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } + { + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); + } sound = (teamIndex == TEAM_INDEX_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } @@ -523,7 +543,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_ALLY, _GetNodeNameId(node)); } else - { SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node)); } + { + SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node)); + } } PlaySoundToAll(sound); } diff --git a/src/game/BattleGround/BattleGroundAV.cpp b/src/game/BattleGround/BattleGroundAV.cpp index bebb30f0c..e84e4e563 100644 --- a/src/game/BattleGround/BattleGroundAV.cpp +++ b/src/game/BattleGround/BattleGroundAV.cpp @@ -294,7 +294,9 @@ void BattleGroundAV::Update(uint32 diff) m_Mine_Reclaim_Timer[mine] -= diff; } else - { ChangeMineOwner(mine, BG_AV_TEAM_NEUTRAL); } + { + ChangeMineOwner(mine, BG_AV_TEAM_NEUTRAL); + } } } @@ -308,7 +310,9 @@ void BattleGroundAV::Update(uint32 diff) m_Nodes[i].Timer -= diff; } else - { EventPlayerDestroyedPoint(i); } + { + EventPlayerDestroyedPoint(i); + } } } } @@ -412,7 +416,9 @@ bool BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger) source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); } else - { source->LeaveBattleground(); } + { + source->LeaveBattleground(); + } break; case 2606: if (source->GetTeam() != HORDE) @@ -420,7 +426,9 @@ bool BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger) source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); } else - { source->LeaveBattleground(); } + { + source->LeaveBattleground(); + } break; default: return false; @@ -545,18 +553,26 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node) graveDefenderType = 0; } else if (m_Team_QuestStatus[teamIdx][0] < 1000) - { graveDefenderType = 1; } + { + graveDefenderType = 1; + } else if (m_Team_QuestStatus[teamIdx][0] < 1500) - { graveDefenderType = 2; } + { + graveDefenderType = 2; + } else - { graveDefenderType = 3; } + { + graveDefenderType = 3; + } if (m_Nodes[node].State == POINT_CONTROLLED) // we can spawn the current owner event { SpawnEvent(BG_AV_NODES_MAX + node, teamIdx * BG_AV_MAX_GRAVETYPES + graveDefenderType, true); } else // we despawn the event from the prevowner - { SpawnEvent(BG_AV_NODES_MAX + node, m_Nodes[node].PrevOwner * BG_AV_MAX_GRAVETYPES + graveDefenderType, false); } + { + SpawnEvent(BG_AV_NODES_MAX + node, m_Nodes[node].PrevOwner * BG_AV_MAX_GRAVETYPES + graveDefenderType, false); + } } SpawnEvent(node, (teamIdx * BG_AV_MAX_STATES) + m_Nodes[node].State, true); } @@ -724,7 +740,9 @@ void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node) UpdateWorldState(AV_SNOWFALL_N, WORLD_STATE_REMOVE); } else - { UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState, m_Nodes[node].PrevOwner)], WORLD_STATE_REMOVE); } + { + UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState, m_Nodes[node].PrevOwner)], WORLD_STATE_REMOVE); + } } void BattleGroundAV::SendMineWorldStates(uint32 mine) diff --git a/src/game/BattleGround/BattleGroundEY.cpp b/src/game/BattleGround/BattleGroundEY.cpp index ae1cfab8d..d9243507e 100644 --- a/src/game/BattleGround/BattleGroundEY.cpp +++ b/src/game/BattleGround/BattleGroundEY.cpp @@ -45,7 +45,9 @@ void BattleGroundEY::Update(uint32 diff) BattleGround::Update(diff); if (GetStatus() != STATUS_IN_PROGRESS) + { return; + } // resource counter if (m_resourceUpdateTimer < diff) @@ -299,10 +301,14 @@ void BattleGroundEY::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team te bool BattleGroundEY::HandleAreaTrigger(Player* source, uint32 trigger) { if (GetStatus() != STATUS_IN_PROGRESS) + { return false; + } if (!source->IsAlive()) // hack code, must be removed later + { return false; + } switch (trigger) { @@ -394,7 +400,9 @@ void BattleGroundEY::RespawnDroppedFlag() void BattleGroundEY::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) + { return; + } BattleGround::HandleKillPlayer(player, killer); EventPlayerDroppedFlag(player); @@ -403,10 +411,14 @@ void BattleGroundEY::HandleKillPlayer(Player* player, Player* killer) void BattleGroundEY::EventPlayerDroppedFlag(Player* source) { if (!IsFlagPickedUp()) + { return; + } if (GetFlagCarrierGuid() != source->GetObjectGuid()) + { return; + } ClearFlagCarrier(); source->RemoveAurasDueToSpell(EY_NETHERSTORM_FLAG_SPELL); @@ -437,7 +449,9 @@ void BattleGroundEY::EventPlayerDroppedFlag(Player* source) void BattleGroundEY::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS || IsFlagPickedUp() || !source->IsWithinDistInMap(target_obj, 10)) + { return; + } if (m_flagState == EY_FLAG_STATE_ON_BASE) UpdateWorldState(WORLD_STATE_EY_NETHERSTORM_FLAG_READY, WORLD_STATE_REMOVE); @@ -474,7 +488,9 @@ void BattleGroundEY::EventPlayerClickedOnFlag(Player* source, GameObject* target void BattleGroundEY::EventPlayerCapturedFlag(Player* source, EYNodes node) { if (GetStatus() != STATUS_IN_PROGRESS || GetFlagCarrierGuid() != source->GetObjectGuid()) + { return; + } ClearFlagCarrier(); @@ -512,7 +528,9 @@ void BattleGroundEY::UpdatePlayerScore(Player* source, uint32 type, uint32 value { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid()); if (itr == m_PlayerScores.end()) // player not found + { return; + } switch (type) { @@ -617,7 +635,9 @@ bool BattleGroundEY::IsAllNodesControlledByTeam(Team team) const { for (uint8 i = 0; i < EY_NODES_MAX; ++i) if (m_towerOwner[i] != team) + { return false; + } return true; } @@ -628,9 +648,13 @@ Team BattleGroundEY::GetPrematureWinner() int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE]; if (hordeScore > allianceScore) + { return HORDE; + } if (allianceScore > hordeScore) + { return ALLIANCE; + } // If the values are equal, fall back to number of players on each team return BattleGround::GetPrematureWinner(); diff --git a/src/game/BattleGround/BattleGroundHandler.cpp b/src/game/BattleGround/BattleGroundHandler.cpp index d4bf28fcc..b3c0aff79 100644 --- a/src/game/BattleGround/BattleGroundHandler.cpp +++ b/src/game/BattleGround/BattleGroundHandler.cpp @@ -147,7 +147,9 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) // expected bracket entry PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) + { return; + } GroupJoinBattlegroundResult err = ERR_BATTLEGROUND_NONE; @@ -319,7 +321,9 @@ void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/) // arena finish version will send in BattleGround::EndBattleGround directly if (bg->isArena()) + { return; + } WorldPacket data; sBattleGroundMgr.BuildPvpLogDataPacket(&data, bg); @@ -422,7 +426,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data) // expected bracket entry PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) + { return; + } // some checks if player isn't cheating - it is not exactly cheating, but we can not allow it if (action == 1 && ginfo.arenaType == ARENA_TYPE_NONE) @@ -670,7 +676,9 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data) // ignore if we already in BG or BG queue if (_player->InBattleGround()) + { return; + } ArenaType arenatype = ArenaTeam::GetTypeBySlot(arenaslot); uint32 arenaRating = 0; @@ -693,14 +701,20 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data) BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype); PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) + { return; + } Group* grp = _player->GetGroup(); // no group found, error if (!grp) + { return; + } if (grp->GetLeaderGuid() != _player->GetObjectGuid()) + { return; + } uint32 ateamId = _player->GetArenaTeamId(arenaslot); // check real arena team existence only here (if it was moved to group->CanJoin .. () then we would have to get it twice) @@ -720,7 +734,9 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data) { ArenaTeamMember const* at_member = at->GetMember(citr->guid); if (!at_member) // group member joining to arena must be in leader arena team + { return; + } // calc avg personal rating avg_pers_rating += at_member->personal_rating; diff --git a/src/game/BattleGround/BattleGroundMgr.cpp b/src/game/BattleGround/BattleGroundMgr.cpp index 2c46a7301..1558ccb34 100644 --- a/src/game/BattleGround/BattleGroundMgr.cpp +++ b/src/game/BattleGround/BattleGroundMgr.cpp @@ -117,7 +117,9 @@ bool BattleGroundQueue::SelectionPool::KickGroup(uint32 size) found = true; } else if (!found && (*itr)->Players.size() >= (*groupToKick)->Players.size()) - { groupToKick = itr; } + { + groupToKick = itr; + } } // if pool is empty, do nothing if (GetPlayerCount()) @@ -743,7 +745,9 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGround bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracket_id, uint32 minPlayersPerTeam) { if (m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() < minPlayersPerTeam && m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() < minPlayersPerTeam) + { return false; + } PvpTeamIndex teamIdx = TEAM_INDEX_ALLIANCE; PvpTeamIndex otherTeamIdx = TEAM_INDEX_HORDE; Team otherTeamId = HORDE; @@ -763,7 +767,9 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke if (ginfo == *itr_team) break; if (itr_team == m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + teamIdx].end()) + { return false; + } GroupsQueueType::iterator itr_team2 = itr_team; ++itr_team2; // invite players to other selection pool @@ -774,7 +780,9 @@ bool BattleGroundQueue::CheckSkirmishForSameFaction(BattleGroundBracketId bracke break; } if (m_SelectionPools[otherTeamIdx].GetPlayerCount() != minPlayersPerTeam) + { return false; + } // here we have correct 2 selections and we need to change one teams team and move selection pool teams to other team's queue for (GroupsQueueType::iterator itr = m_SelectionPools[otherTeamIdx].SelectedGroups.begin(); itr != m_SelectionPools[otherTeamIdx].SelectedGroups.end(); ++itr) @@ -1724,7 +1732,9 @@ BattleGround* BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 insta } if (bg->isArena()) + { return GetBattleGround(instanceId, bgTypeId); + } for (BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr) { @@ -2307,7 +2317,9 @@ void BattleGroundMgr::ToggleTesting() sWorld.SendWorldText(LANG_DEBUG_BG_ON); } else - { sWorld.SendWorldText(LANG_DEBUG_BG_OFF); } + { + sWorld.SendWorldText(LANG_DEBUG_BG_OFF); + } } void BattleGroundMgr::ToggleArenaTesting() @@ -2543,7 +2555,9 @@ void BattleGroundMgr::LoadBattleEventIndexes() m_GameObjectBattleEventIndexMap[dbTableGuidLow] = events; } else - { m_CreatureBattleEventIndexMap[dbTableGuidLow] = events; } + { + m_CreatureBattleEventIndexMap[dbTableGuidLow] = events; + } ++count; } diff --git a/src/game/BattleGround/BattleGroundWS.cpp b/src/game/BattleGround/BattleGroundWS.cpp index a89241cde..35f29d3b4 100644 --- a/src/game/BattleGround/BattleGroundWS.cpp +++ b/src/game/BattleGround/BattleGroundWS.cpp @@ -172,7 +172,9 @@ void BattleGroundWS::RespawnDroppedFlag(Team team) SendMessageToAll(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL); } else - { SendMessageToAll(LANG_BG_WS_HORDE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL); } + { + SendMessageToAll(LANG_BG_WS_HORDE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL); + } PlaySoundToAll(BG_WS_SOUND_FLAGS_RESPAWNED); @@ -182,7 +184,9 @@ void BattleGroundWS::RespawnDroppedFlag(Team team) obj->Delete(); } else - { sLog.outError("Unknown dropped flag bg: %s", GetDroppedFlagGuid(team).GetString().c_str()); } + { + sLog.outError("Unknown dropped flag bg: %s", GetDroppedFlagGuid(team).GetString().c_str()); + } ClearDroppedFlagGuid(team); } @@ -245,7 +249,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source) SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, source); } else - { SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, source); } + { + SendMessageToAll(LANG_BG_WS_CAPTURED_AF, CHAT_MSG_BG_SYSTEM_HORDE, source); + } UpdateFlagState(source->GetTeam(), 1); // flag state none UpdateTeamScore(source->GetTeam()); @@ -258,7 +264,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source) winner = ALLIANCE; } else if (m_TeamScores[TEAM_INDEX_HORDE] == BG_WS_MAX_TEAM_SCORE) - { winner = HORDE; } + { + winner = HORDE; + } if (winner) { @@ -482,7 +490,9 @@ void BattleGroundWS::RemovePlayer(Player* plr, ObjectGuid guid) RespawnFlag(ALLIANCE, false); } else - { EventPlayerDroppedFlag(plr); } + { + EventPlayerDroppedFlag(plr); + } } if (IsHordeFlagPickedUp() && m_flagCarrierHorde == guid) { @@ -493,7 +503,9 @@ void BattleGroundWS::RemovePlayer(Player* plr, ObjectGuid guid) RespawnFlag(HORDE, false); } else - { EventPlayerDroppedFlag(plr); } + { + EventPlayerDroppedFlag(plr); + } } } @@ -504,7 +516,9 @@ void BattleGroundWS::UpdateFlagState(Team team, uint32 value) UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, value); } else - { UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value); } + { + UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value); + } } void BattleGroundWS::UpdateTeamScore(Team team) @@ -636,7 +650,9 @@ WorldSafeLocsEntry const* BattleGroundWS::GetClosestGraveYard(Player* player) return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE); } else - { return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_ALLIANCE); } + { + return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_ALLIANCE); + } } else { @@ -645,7 +661,9 @@ WorldSafeLocsEntry const* BattleGroundWS::GetClosestGraveYard(Player* player) return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_HORDE); } else - { return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_HORDE); } + { + return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_HORDE); + } } } @@ -659,18 +677,26 @@ void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count) FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, -1); } else if (m_FlagState[TEAM_INDEX_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER) - { FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 1); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 1); + } else - { FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 0); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, 0); + } if (m_FlagState[TEAM_INDEX_HORDE] == BG_WS_FLAG_STATE_ON_GROUND) { FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, -1); } else if (m_FlagState[TEAM_INDEX_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER) - { FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 1); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 1); + } else - { FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 0); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_UNK_HORDE, 0); + } FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_MAX, BG_WS_MAX_TEAM_SCORE); @@ -679,14 +705,18 @@ void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count) FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 2); } else - { FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 1); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 1); + } if (m_FlagState[TEAM_INDEX_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER) { FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 2); } else - { FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 1); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 1); + } FillInitialWorldState(data, count, BG_WS_TIME_ENABLED, WORLD_STATE_ADD); FillInitialWorldState(data, count, BG_WS_TIME_REMAINING, GetRemainingTimeInMinutes()); diff --git a/src/game/ChatCommands/Level0.cpp b/src/game/ChatCommands/Level0.cpp index 151feb42b..6f586debb 100644 --- a/src/game/ChatCommands/Level0.cpp +++ b/src/game/ChatCommands/Level0.cpp @@ -116,10 +116,14 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/) PSendSysMessage(LANG_USING_SCRIPT_LIB, ver); } else - { SendSysMessage(LANG_USING_SCRIPT_LIB_UNKNOWN); } + { + SendSysMessage(LANG_USING_SCRIPT_LIB_UNKNOWN); + } } else - { SendSysMessage(LANG_USING_SCRIPT_LIB_NONE); } + { + SendSysMessage(LANG_USING_SCRIPT_LIB_NONE); + } PSendSysMessage(LANG_USING_WORLD_DB, sWorld.GetDBVersion()); PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum); @@ -201,7 +205,9 @@ bool ChatHandler::HandleGMListIngameCommand(char* /*args*/) { PSendSysMessage("%s - %s", iter->first.c_str(), iter->second ? accepts : not_accept); } } else - { SendSysMessage(LANG_GMS_NOT_LOGGED); } + { + SendSysMessage(LANG_GMS_NOT_LOGGED); + } return true; } diff --git a/src/game/ChatCommands/Level1.cpp b/src/game/ChatCommands/Level1.cpp index d39ecf469..bc8d646ba 100644 --- a/src/game/ChatCommands/Level1.cpp +++ b/src/game/ChatCommands/Level1.cpp @@ -221,7 +221,9 @@ bool ChatHandler::HandleGMChatCommand(char* args) m_session->SendNotification(LANG_GM_CHAT_ON); } else - { m_session->SendNotification(LANG_GM_CHAT_OFF); } + { + m_session->SendNotification(LANG_GM_CHAT_OFF); + } return true; } @@ -361,7 +363,9 @@ bool ChatHandler::HandleGPSCommand(char* args) PSendSysMessage("You are OUTdoor"); } else - { PSendSysMessage("You are INdoor"); } + { + PSendSysMessage("You are INdoor"); + } } else { @@ -512,7 +516,9 @@ bool ChatHandler::HandleSummonCommand(char* args) } // save only in non-flight case else - { target->SaveRecallPosition(); } + { + target->SaveRecallPosition(); + } // before GM float x, y, z; @@ -644,7 +650,9 @@ bool ChatHandler::HandleAppearCommand(char* args) group->BindToInstance(save, !save->CanReset()); } else - { _player->BindToInstance(save, !save->CanReset()); } + { + _player->BindToInstance(save, !save->CanReset()); + } } } @@ -668,7 +676,9 @@ bool ChatHandler::HandleAppearCommand(char* args) } // save only in non-flight case else - { _player->SaveRecallPosition(); } + { + _player->SaveRecallPosition(); + } // to point to see at target with same orientation float x, y, z; @@ -731,7 +741,9 @@ bool ChatHandler::HandleRecallCommand(char* args) bool ChatHandler::HandleModifyHolyPowerCommand(char* args) { if (!*args) + { return false; + } int32 power = atoi(args); @@ -752,7 +764,9 @@ bool ChatHandler::HandleModifyHolyPowerCommand(char* args) // check online security if (HasLowerSecurity(chr)) + { return false; + } int32 maxPower = int32(chr->GetMaxPower(POWER_HOLY_POWER)); if (power > maxPower) @@ -953,7 +967,9 @@ bool ChatHandler::HandleModifyRageCommand(char* args) bool ChatHandler::HandleModifyRunicPowerCommand(char* args) { if (!*args) + { return false; + } int32 rune = atoi(args) * 10; int32 runem = atoi(args) * 10; @@ -1096,7 +1112,9 @@ bool ChatHandler::HandleModifyTalentCommand(char* args) { // check online security if (HasLowerSecurity((Player*)owner)) + { return false; + } ((Pet*)target)->SetFreeTalentPoints(tp); ((Player*)owner)->SendTalentsInfoData(true); @@ -1127,7 +1145,9 @@ bool ChatHandler::HandleTaxiCheatCommand(char* args) } // check online security else if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } if (value) { @@ -1362,7 +1382,9 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args) bool ChatHandler::HandleModifyFlyCommand(char* args) { if (!*args) + { return false; + } float modSpeed = (float)atof(args); @@ -1383,7 +1405,9 @@ bool ChatHandler::HandleModifyFlyCommand(char* args) // check online security if (HasLowerSecurity(chr)) + { return false; + } PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, modSpeed, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) @@ -1734,7 +1758,9 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) int64 addmoney; if (!ExtractInt64(&args, addmoney)) + { return false; + } uint64 moneyuser = chr->GetMoney(); @@ -1780,7 +1806,9 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) chr->SetMoney(MAX_MONEY_AMOUNT); } else - { chr->ModifyMoney(addmoney); } + { + chr->ModifyMoney(addmoney); + } } DETAIL_LOG("USER2: %s, ADD: %s, RESULT: %s\n", @@ -1876,7 +1904,9 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc] << "]|h|r"; } else - { ss << areaEntry->ID << " - " << name << " " << localeNames[loc]; } + { + ss << areaEntry->ID << " - " << name << " " << localeNames[loc]; + } SendSysMessage(ss.str().c_str()); @@ -1931,7 +1961,9 @@ bool ChatHandler::HandleLookupTeleCommand(char* args) reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n"; } else - { reply << " " << itr->first << " " << tele->name << "\n"; } + { + reply << " " << itr->first << " " << tele->name << "\n"; + } } if (reply.str().empty()) @@ -1939,7 +1971,9 @@ bool ChatHandler::HandleLookupTeleCommand(char* args) SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); } else - { PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str()); } + { + PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str()); + } return true; } @@ -2159,7 +2193,9 @@ bool ChatHandler::HandleTeleGroupCommand(char* args) } // save only in non-flight case else - { pl->SaveRecallPosition(); } + { + pl->SaveRecallPosition(); + } pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation); } @@ -2259,7 +2295,9 @@ bool ChatHandler::HandleGroupgoCommand(char* args) } // save only in non-flight case else - { pl->SaveRecallPosition(); } + { + pl->SaveRecallPosition(); + } // before GM float x, y, z; @@ -2314,7 +2352,9 @@ bool ChatHandler::HandleGoHelper(Player* player, uint32 mapid, float x, float y, } // save only in non-flight case else - { player->SaveRecallPosition(); } + { + player->SaveRecallPosition(); + } player->TeleportTo(mapid, x, y, z, ort); @@ -2381,7 +2421,9 @@ bool ChatHandler::HandleGoCommand(char* args) } // link case else if (!ExtractLocationFromLink(&args, mapid, x, y, z)) - { return false; } + { + return false; + } return HandleGoHelper(_player, mapid, x, y, &z); } @@ -2472,7 +2514,9 @@ bool ChatHandler::HandleGoZoneXYCommand(char* args) } } else - { areaid = _player->GetZoneId(); } + { + areaid = _player->GetZoneId(); + } AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid); @@ -2540,7 +2584,9 @@ bool ChatHandler::HandleGoGridCommand(char* args) bool ChatHandler::HandleModifyDrunkCommand(char* args) { if (!*args) + { return false; + } uint8 drunkValue = (uint8)atoi(args); if (drunkValue > 100) diff --git a/src/game/ChatCommands/Level2.cpp b/src/game/ChatCommands/Level2.cpp index 447ca8fb5..6c3790b21 100644 --- a/src/game/ChatCommands/Level2.cpp +++ b/src/game/ChatCommands/Level2.cpp @@ -189,7 +189,9 @@ void ChatHandler::ShowTriggerTargetListHelper(uint32 id, AreaTrigger const* at, snprintf(dist_buf, 50, GetMangosString(LANG_TRIGGER_DIST), dist); } else - { dist_buf[0] = '\0'; } + { + dist_buf[0] = '\0'; + } PSendSysMessage(LANG_TRIGGER_TARGET_LIST_CHAT, subpart ? " -> " : "", id, id, at->target_mapId, at->target_X, at->target_Y, at->target_Z, dist_buf); @@ -526,7 +528,9 @@ bool ChatHandler::HandleGoTriggerCommand(char* args) return HandleGoHelper(_player, at->target_mapId, at->target_X, at->target_Y, &at->target_Z); } else - { return HandleGoHelper(_player, atEntry->mapid, atEntry->x, atEntry->y, &atEntry->z); } + { + return HandleGoHelper(_player, atEntry->mapid, atEntry->x, atEntry->y, &atEntry->z); + } } bool ChatHandler::HandleGoGraveyardCommand(char* args) @@ -927,7 +931,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) initString = false; } else - { eventFilter << "," << *itr; } + { + eventFilter << "," << *itr; + } } if (!initString) @@ -935,7 +941,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) eventFilter << "))"; } else - { eventFilter << ")"; } + { + eventFilter << ")"; + } result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, " "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " @@ -1012,7 +1020,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) PSendSysMessage(LANG_COMMAND_GO_STATUS_DOOR, target->GetGoState(), target->getLootState(), GetOnOffStr(target->IsCollisionEnabled()), goI->door.startOpen ? "open" : "closed"); } else - { PSendSysMessage(LANG_COMMAND_GO_STATUS, target->GetGoState(), target->getLootState(), GetOnOffStr(target->IsCollisionEnabled())); } + { + PSendSysMessage(LANG_COMMAND_GO_STATUS, target->GetGoState(), target->getLootState(), GetOnOffStr(target->IsCollisionEnabled())); + } } return true; } @@ -1288,10 +1298,14 @@ bool ChatHandler::HandleGameObjectPhaseCommand(char* args) // number or [name] Shift-click form |color|Hgameobject:go_id|h[name]|h|r uint32 lowguid; if (!ExtractUint32KeyFromLink(&args, "Hgameobject", lowguid)) + { return false; + } if (!lowguid) + { return false; + } GameObject* obj = NULL; @@ -1440,7 +1454,9 @@ void ChatHandler::ShowAchievementListHelper(AchievementEntry const* achEntry, Lo bool ChatHandler::HandleLookupAchievementCommand(char* args) { if (!*args) + { return false; + } // Can be NULL at console call Player* target = getSelectedPlayer(); @@ -1449,7 +1465,9 @@ bool ChatHandler::HandleLookupAchievementCommand(char* args) std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) + { return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -1501,7 +1519,9 @@ bool ChatHandler::HandleCharacterAchievementsCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) + { return false; + } LocaleConstant loc = GetSessionDbcLocale(); @@ -1526,7 +1546,9 @@ void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, Locale ss << factionEntry->ID << " - |cffffffff|Hfaction:" << factionEntry->ID << "|h[" << name << " " << localeNames[loc] << "]|h|r"; } else - { ss << factionEntry->ID << " - " << name << " " << localeNames[loc]; } + { + ss << factionEntry->ID << " - " << name << " " << localeNames[loc]; + } if (repState) // and then target!=NULL also { @@ -1561,7 +1583,9 @@ void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, Locale } } else if (target) - { ss << GetMangosString(LANG_FACTION_NOREPUTATION); } + { + ss << GetMangosString(LANG_FACTION_NOREPUTATION); + } SendSysMessage(ss.str().c_str()); } @@ -1821,15 +1845,21 @@ bool ChatHandler::HandleNpcAddVendorCurrencyCommand(char* args) uint32 maxcount; if (!ExtractUInt32(&args, maxcount)) + { return false; + } uint32 incrtime; if (!ExtractOptUInt32(&args, incrtime, 0)) + { return false; + } uint32 extendedcost; if (!ExtractUInt32(&args, extendedcost)) + { return false; + } Creature* vendor = getSelectedCreature(); @@ -1874,7 +1904,9 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(char* args) uint32 extendedcost; if (!ExtractOptUInt32(&args, extendedcost, 0)) + { return false; + } Creature* vendor = getSelectedCreature(); @@ -1898,7 +1930,9 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(char* args) bool ChatHandler::HandleNpcDelVendorCurrencyCommand(char* args) { if (!*args) + { return false; + } Creature* vendor = getSelectedCreature(); if (!vendor || !vendor->IsVendor()) @@ -2092,7 +2126,9 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args) } } else - { unit = getSelectedCreature(); } + { + unit = getSelectedCreature(); + } if (!unit) { @@ -2112,7 +2148,9 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args) Creature::DeleteFromDB(unit->GetGUIDLow(), data); } else - { unit->AddObjectToRemoveList(); } + { + unit->AddObjectToRemoveList(); + } break; } case CREATURE_SUBTYPE_PET: @@ -2167,7 +2205,9 @@ bool ChatHandler::HandleNpcMoveCommand(char* args) pCreature = player->GetMap()->GetCreature(data->GetObjectGuid(lowguid)); } else - { lowguid = pCreature->GetGUIDLow(); } + { + lowguid = pCreature->GetGUIDLow(); + } float x = player->GetPositionX(); float y = player->GetPositionY(); @@ -2264,11 +2304,17 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args) move_type = IDLE_MOTION_TYPE; } else if (strncmp(type_str, "random", strlen(type_str)) == 0) - { move_type = RANDOM_MOTION_TYPE; } + { + move_type = RANDOM_MOTION_TYPE; + } else if (strncmp(type_str, "way", strlen(type_str)) == 0) - { move_type = WAYPOINT_MOTION_TYPE; } + { + move_type = WAYPOINT_MOTION_TYPE; + } else - { return false; } + { + return false; + } bool doNotDelete = ExtractLiteralArg(&args, "NODEL") != NULL; if (!doNotDelete && *args) // need fail if false in result wrong literal @@ -2302,7 +2348,9 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args) PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL, type_str); } else - { PSendSysMessage(LANG_MOVE_TYPE_SET, type_str); } + { + PSendSysMessage(LANG_MOVE_TYPE_SET, type_str); + } return true; } @@ -2407,7 +2455,9 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args) u_guidlow = pCreature->GetGUIDLow(); } else - { return false; } + { + return false; + } pCreature->SetRespawnRadius((float)option); pCreature->SetDefaultMovementType(mtype); @@ -2532,7 +2582,9 @@ bool ChatHandler::HandleNpcTameCommand(char* /*args*/) bool ChatHandler::HandleNpcSetPhaseCommand(char* args) { if (!*args) + { return false; + } uint32 phasemask = (uint32) atoi(args); if (phasemask == 0) @@ -2581,7 +2633,9 @@ bool ChatHandler::HandleNpcSetDeathStateCommand(char* args) pCreature->SetDeadByDefault(true); } else - { pCreature->SetDeadByDefault(false); } + { + pCreature->SetDeadByDefault(false); + } pCreature->SaveToDB(); pCreature->Respawn(); @@ -2595,7 +2649,9 @@ bool ChatHandler::HandleNpcNameCommand(char* /*args*/) { /* Temp. disabled if (!*args) + { return false; + } if (strlen((char*)args)>75) { @@ -2742,7 +2798,9 @@ bool ChatHandler::HandleDeMorphCommand(char* /*args*/) // check online security else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) - { return false; } + { + return false; + } target->DeMorph(); @@ -2775,7 +2833,9 @@ bool ChatHandler::HandleModifyMorphCommand(char* args) // check online security else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) - { return false; } + { + return false; + } target->SetDisplayId(display_id); @@ -2814,7 +2874,9 @@ bool ChatHandler::HandleKickPlayerCommand(char* args) bool ChatHandler::HandleModifyPhaseCommand(char* args) { if (!*args) + { return false; + } uint32 phasemask = (uint32)atoi(args); @@ -2824,7 +2886,9 @@ bool ChatHandler::HandleModifyPhaseCommand(char* args) // check online security else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) + { return false; + } target->SetPhaseMask(phasemask, true); @@ -2962,7 +3026,9 @@ bool ChatHandler::HandleTicketCommand(char* args) PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, GetOnOffStr(accept)); } else - { PSendSysMessage(LANG_COMMAND_TICKETCOUNT_CONSOLE, count); } + { + PSendSysMessage(LANG_COMMAND_TICKETCOUNT_CONSOLE, count); + } return true; } @@ -3146,7 +3212,9 @@ bool ChatHandler::HandleDelTicketCommand(char* args) PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL, GetNameLink(pl).c_str()); } else - { PSendSysMessage(LANG_COMMAND_TICKETDEL); } + { + PSendSysMessage(LANG_COMMAND_TICKETDEL); + } return true; } @@ -3591,7 +3659,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args) { uint32 waittime; if (!ExtractUInt32(&args, waittime)) + { return false; + } sWaypointMgr.SetNodeWaittime(wpOwner->GetEntry(), wpOwner->GetGUIDLow(), wpId, wpPathId, wpSource, waittime); } @@ -3599,7 +3669,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args) { uint32 scriptId; if (!ExtractUInt32(&args, scriptId)) + { return false; + } if (!sWaypointMgr.SetNodeScriptId(wpOwner->GetEntry(), wpOwner->GetGUIDLow(), wpId, wpPathId, wpSource, scriptId)) PSendSysMessage(LANG_WAYPOINT_INFO_UNK_SCRIPTID, scriptId); @@ -3608,7 +3680,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args) { float ori; if (!ExtractFloat(&args, ori)) + { return false; + } sWaypointMgr.SetNodeOrientation(wpOwner->GetEntry(), wpOwner->GetGUIDLow(), wpId, wpPathId, wpSource, ori); } @@ -3649,7 +3723,9 @@ bool ChatHandler::HandleWpShowCommand(char* args) char* subCmd_str = ExtractLiteralArg(&args); if (!subCmd_str) + { return false; + } std::string subCmd = subCmd_str; ///< info, on, off, first, last uint32 dbGuid = 0; @@ -3670,7 +3746,9 @@ bool ChatHandler::HandleWpShowCommand(char* args) else // Guid must be provided { if (!ExtractUInt32(&args, dbGuid)) // No creature selected and no dbGuid provided + { return false; + } if (ExtractOptInt32(&args, wpPathId, 0)) // Fill path-id and source { @@ -3846,7 +3924,9 @@ bool ChatHandler::HandleWpShowCommand(char* args) bool ChatHandler::HandleWpExportCommand(char* args) { if (!*args) + { return false; + } Creature* wpOwner = NULL; WaypointPathOrigin wpOrigin = PATH_NO_PATH; @@ -4047,7 +4127,9 @@ bool ChatHandler::HandleCharacterCustomizeCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) + { return false; + } if (target) { @@ -4163,7 +4245,9 @@ bool ChatHandler::HandleHonorKillsUpdateCommand(char* /*args*/) // check online security if (HasLowerSecurity(target)) + { return false; + } target->UpdateHonorKills(); return true; @@ -4215,7 +4299,9 @@ bool ChatHandler::HandleLookupEventCommand(char* args) PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description.c_str(), active); } else - { PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description.c_str(), active); } + { + PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description.c_str(), active); + } ++counter; } @@ -4261,7 +4347,9 @@ bool ChatHandler::HandleEventListCommand(char* args) state = inactive; } else - { state = active; } + { + state = active; + } GameEventData const& eventData = events[event_id]; @@ -4270,7 +4358,9 @@ bool ChatHandler::HandleEventListCommand(char* args) PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, event_id, event_id, eventData.description.c_str(), state); } else - { PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, event_id, eventData.description.c_str(), state); } + { + PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, event_id, eventData.description.c_str(), state); + } ++counter; } @@ -4831,7 +4921,9 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, uint32* limit) ShowPlayerListHelper(chars, limit, true, false); } else - { delete chars; } + { + delete chars; + } } } while (result->NextRow()); @@ -5220,7 +5312,9 @@ bool ChatHandler::HandleWaterwalkCommand(char* args) bool ChatHandler::HandleLookupTitleCommand(char* args) { if (!*args) + { return false; + } // can be NULL in console call Player* target = getSelectedPlayer(); @@ -5232,7 +5326,9 @@ bool ChatHandler::HandleLookupTitleCommand(char* args) std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) + { return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -5298,7 +5394,9 @@ bool ChatHandler::HandleTitlesAddCommand(char* args) // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r uint32 id; if (!ExtractUint32KeyFromLink(&args, "Htitle", id)) + { return false; + } if (id <= 0) { @@ -5317,7 +5415,9 @@ bool ChatHandler::HandleTitlesAddCommand(char* args) // check online security if (HasLowerSecurity(target)) + { return false; + } CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); if (!titleInfo) @@ -5344,7 +5444,9 @@ bool ChatHandler::HandleTitlesRemoveCommand(char* args) // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r uint32 id; if (!ExtractUint32KeyFromLink(&args, "Htitle", id)) + { return false; + } if (id <= 0) { @@ -5363,7 +5465,9 @@ bool ChatHandler::HandleTitlesRemoveCommand(char* args) // check online security if (HasLowerSecurity(target)) + { return false; + } CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); if (!titleInfo) @@ -5396,7 +5500,9 @@ bool ChatHandler::HandleTitlesRemoveCommand(char* args) bool ChatHandler::HandleTitlesSetMaskCommand(char* args) { if (!*args) + { return false; + } uint64 titles = 0; @@ -5412,7 +5518,9 @@ bool ChatHandler::HandleTitlesSetMaskCommand(char* args) // check online security if (HasLowerSecurity(target)) + { return false; + } uint64 titles2 = titles; @@ -5438,7 +5546,9 @@ bool ChatHandler::HandleCharacterTitlesCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) + { return false; + } LocaleConstant loc = GetSessionDbcLocale(); char const* targetName = target->GetName(); @@ -5476,7 +5586,9 @@ bool ChatHandler::HandleTitlesCurrentCommand(char* args) // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r uint32 id; if (!ExtractUint32KeyFromLink(&args, "Htitle", id)) + { return false; + } if (id <= 0) { @@ -5495,7 +5607,9 @@ bool ChatHandler::HandleTitlesCurrentCommand(char* args) // check online security if (HasLowerSecurity(target)) + { return false; + } CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); if (!titleInfo) @@ -5669,7 +5783,9 @@ bool ChatHandler::HandleMmapLocCommand(char* /*args*/) PSendSysMessage("Dt [%02i,%02i]", tile->header->x, tile->header->y); } else - { PSendSysMessage("Dt [??,??] (no tile loaded)"); } + { + PSendSysMessage("Dt [??,??] (no tile loaded)"); + } } return true; diff --git a/src/game/ChatCommands/Level3.cpp b/src/game/ChatCommands/Level3.cpp index 197814e05..a84693584 100644 --- a/src/game/ChatCommands/Level3.cpp +++ b/src/game/ChatCommands/Level3.cpp @@ -198,7 +198,9 @@ bool ChatHandler::HandleAHBotStatusCommand(char* args) SendSysMessage(LANG_AHBOT_STATUS_MIDBAR_CONSOLE); } else - { SendSysMessage(LANG_AHBOT_STATUS_TITLE1_CHAT); } + { + SendSysMessage(LANG_AHBOT_STATUS_TITLE1_CHAT); + } uint32 fmtId = m_session ? LANG_AHBOT_STATUS_FORMAT_CHAT : LANG_AHBOT_STATUS_FORMAT_CONSOLE; @@ -227,7 +229,9 @@ bool ChatHandler::HandleAHBotStatusCommand(char* args) SendSysMessage(LANG_AHBOT_STATUS_MIDBAR_CONSOLE); } else - { SendSysMessage(LANG_AHBOT_STATUS_TITLE2_CHAT); } + { + SendSysMessage(LANG_AHBOT_STATUS_TITLE2_CHAT); + } for (int i = 0; i < MAX_AUCTION_QUALITY; ++i) PSendSysMessage(fmtId, GetMangosString(ahbotQualityIds[i]), @@ -1367,14 +1371,18 @@ bool ChatHandler::HandleAchievementCommand(char* args) if (nameStr) { if (!ExtractPlayerTarget(&nameStr, &target)) + { return false; + } } else target = getSelectedPlayer(); uint32 achId; if (!ExtractUint32KeyFromLink(&args, "Hachievement", achId)) + { return false; + } AchievementEntry const* achEntry = sAchievementStore.LookupEntry(achId); if (!achEntry) @@ -1406,11 +1414,15 @@ bool ChatHandler::HandleAchievementAddCommand(char* args) Player* target; if (!ExtractPlayerTarget(&nameStr, &target)) + { return false; + } uint32 achId; if (!ExtractUint32KeyFromLink(&args, "Hachievement", achId)) + { return false; + } AchievementEntry const* achEntry = sAchievementStore.LookupEntry(achId); if (!achEntry || achEntry->flags & ACHIEVEMENT_FLAG_COUNTER) @@ -1448,11 +1460,15 @@ bool ChatHandler::HandleAchievementRemoveCommand(char* args) Player* target; if (!ExtractPlayerTarget(&nameStr, &target)) + { return false; + } uint32 achId; if (!ExtractUint32KeyFromLink(&args, "Hachievement", achId)) + { return false; + } AchievementEntry const* achEntry = sAchievementStore.LookupEntry(achId); if (!achEntry) @@ -1484,10 +1500,14 @@ bool ChatHandler::HandleAchievementCriteriaAddCommand(char* args) // maybe player first char* nameStr = ExtractArg(&args); if (!ExtractPlayerTarget(&nameStr, &target)) + { return false; + } if (!ExtractUint32KeyFromLink(&args, "Hachievement_criteria", criId)) + { return false; + } } else target = getSelectedPlayer(); @@ -1502,7 +1522,9 @@ bool ChatHandler::HandleAchievementCriteriaAddCommand(char* args) AchievementEntry const* achEntry = sAchievementStore.LookupEntry(criEntry->referredAchievement); if (!achEntry) + { return false; + } LocaleConstant loc = GetSessionDbcLocale(); @@ -1523,7 +1545,9 @@ bool ChatHandler::HandleAchievementCriteriaAddCommand(char* args) uint32 val; if (!ExtractOptUInt32(&args, val, maxValue ? maxValue : 1)) + { return false; + } uint32 new_val; @@ -1551,10 +1575,14 @@ bool ChatHandler::HandleAchievementCriteriaRemoveCommand(char* args) // maybe player first char* nameStr = ExtractArg(&args); if (!ExtractPlayerTarget(&nameStr, &target)) + { return false; + } if (!ExtractUint32KeyFromLink(&args, "Hachievement_criteria", criId)) + { return false; + } } else target = getSelectedPlayer(); @@ -1569,7 +1597,9 @@ bool ChatHandler::HandleAchievementCriteriaRemoveCommand(char* args) AchievementEntry const* achEntry = sAchievementStore.LookupEntry(criEntry->referredAchievement); if (!achEntry) + { return false; + } LocaleConstant loc = GetSessionDbcLocale(); @@ -1590,7 +1620,9 @@ bool ChatHandler::HandleAchievementCriteriaRemoveCommand(char* args) uint32 change; if (!ExtractOptUInt32(&args, change, maxValue ? maxValue : 1)) + { return false; + } uint32 newval = change < progress ? progress - change : 0; @@ -1723,7 +1755,9 @@ bool ChatHandler::HandleUnLearnCommand(char* args) target->removeSpell(spell_id, false, !allRanks); } else - { SendSysMessage(LANG_FORGET_SPELL); } + { + SendSysMessage(LANG_FORGET_SPELL); + } if (GetTalentSpellCost(spell_id)) target->SendTalentsInfoData(false); @@ -2721,7 +2755,9 @@ bool ChatHandler::HandleLearnCommand(char* args) targetPlayer->learnSpellHighRank(spell); } else - { targetPlayer->learnSpell(spell, false); } + { + targetPlayer->learnSpell(spell, false); + } uint32 first_spell = sSpellMgr.GetFirstSpellInChain(spell); if (GetTalentSpellCost(first_spell)) @@ -2969,11 +3005,17 @@ bool ChatHandler::HandleListItemCommand(char* args) item_pos = "[equipped]"; } else if (Player::IsInventoryPos(item_bag, item_slot)) - { item_pos = "[in inventory]"; } + { + item_pos = "[in inventory]"; + } else if (Player::IsBankPos(item_bag, item_slot)) - { item_pos = "[in bank]"; } + { + item_pos = "[in bank]"; + } else - { item_pos = ""; } + { + item_pos = ""; + } PSendSysMessage(LANG_ITEMLIST_SLOT, item_guid, owner_name.c_str(), owner_guid, owner_acc, item_pos); @@ -2989,7 +3031,9 @@ bool ChatHandler::HandleListItemCommand(char* args) count -= res_count; } else if (count) - { count = 0; } + { + count = 0; + } } // mail case @@ -3011,7 +3055,9 @@ bool ChatHandler::HandleListItemCommand(char* args) item_id, uint32(count)); } else - { result = NULL; } + { + result = NULL; + } if (result) { @@ -3042,7 +3088,9 @@ bool ChatHandler::HandleListItemCommand(char* args) count -= res_count; } else if (count) - { count = 0; } + { + count = 0; + } } // auction case @@ -3063,7 +3111,9 @@ bool ChatHandler::HandleListItemCommand(char* args) item_id, uint32(count)); } else - { result = NULL; } + { + result = NULL; + } if (result) { @@ -3202,7 +3252,9 @@ bool ChatHandler::HandleListObjectCommand(char* args) PSendSysMessage(LANG_GO_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), guid, gInfo->name, x, y, z, mapid); } else - { PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), gInfo->name, x, y, z, mapid); } + { + PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), gInfo->name, x, y, z, mapid); + } } while (result->NextRow()); @@ -3279,7 +3331,9 @@ bool ChatHandler::HandleListCreatureCommand(char* args) PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), guid, cInfo->Name, x, y, z, mapid); } else - { PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), cInfo->Name, x, y, z, mapid); } + { + PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), cInfo->Name, x, y, z, mapid); + } } while (result->NextRow()); @@ -3317,7 +3371,9 @@ void ChatHandler::ShowItemListHelper(uint32 itemId, int loc_idx, Player* target PSendSysMessage(LANG_ITEM_LIST_CHAT, itemId, itemId, name.c_str(), usableStr); } else - { PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemId, name.c_str(), usableStr); } + { + PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemId, name.c_str(), usableStr); + } } bool ChatHandler::HandleLookupItemCommand(char* args) @@ -3436,7 +3492,9 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name.c_str(), localeNames[loc]); } else - { PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), localeNames[loc]); } + { + PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), localeNames[loc]); + } ++counter; } } @@ -3529,7 +3587,9 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), localeNames[loc], knownStr, valStr); } else - { PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), localeNames[loc], knownStr, valStr); } + { + PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), localeNames[loc], knownStr, valStr); + } ++counter; } @@ -3593,7 +3653,9 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf ss << id << " - |cffffffff|Hspell:" << id << "|h[" << spellInfo->SpellName[loc]; } else - { ss << id << " - " << spellInfo->SpellName[loc]; } + { + ss << id << " - " << spellInfo->SpellName[loc]; + } // include rank in link name if (rank) @@ -3606,7 +3668,9 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf ss << " " << localeNames[loc] << "]|h|r"; } else - { ss << " " << localeNames[loc]; } + { + ss << " " << localeNames[loc]; + } if (talent) { @@ -3635,7 +3699,9 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf bool ChatHandler::HandleLookupCurrencyCommand(char* args) { if (!*args) + { return false; + } // can be NULL at console call Player* target = getSelectedPlayer(); @@ -3644,7 +3710,9 @@ bool ChatHandler::HandleLookupCurrencyCommand(char* args) std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) + { return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -3792,10 +3860,14 @@ void ChatHandler::ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* tar statusStr = GetMangosString(LANG_COMMAND_QUEST_REWARDED); } else - { statusStr = GetMangosString(LANG_COMMAND_QUEST_COMPLETE); } + { + statusStr = GetMangosString(LANG_COMMAND_QUEST_COMPLETE); + } } else if (status == QUEST_STATUS_INCOMPLETE) - { statusStr = GetMangosString(LANG_COMMAND_QUEST_ACTIVE); } + { + statusStr = GetMangosString(LANG_COMMAND_QUEST_ACTIVE); + } } if (m_session) @@ -3803,7 +3875,9 @@ void ChatHandler::ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* tar PSendSysMessage(LANG_QUEST_LIST_CHAT, qinfo->GetQuestId(), qinfo->GetQuestId(), qinfo->GetQuestLevel(), title.c_str(), statusStr); } else - { PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qinfo->GetQuestId(), title.c_str(), statusStr); } + { + PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qinfo->GetQuestId(), title.c_str(), statusStr); + } } bool ChatHandler::HandleLookupQuestCommand(char* args) @@ -3902,7 +3976,9 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); } else - { PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name); } + { + PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name); + } ++counter; } @@ -3954,7 +4030,9 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->id, itr->id, name.c_str()); } else - { PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->id, name.c_str()); } + { + PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->id, name.c_str()); + } ++counter; continue; } @@ -3975,7 +4053,9 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->id, itr->id, name.c_str()); } else - { PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->id, name.c_str()); } + { + PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->id, name.c_str()); + } ++counter; } } @@ -4417,19 +4497,27 @@ bool ChatHandler::HandleDamageCommand(char* args) bool ChatHandler::HandleModifyCurrencyCommand(char* args) { if (!*args) + { return false; + } uint32 currencyId; if (!ExtractUint32KeyFromLink(&args, "Hcurrency", currencyId)) + { return false; + } CurrencyTypesEntry const * entry = sCurrencyTypesStore.LookupEntry(currencyId); if (!entry) + { return false; + } int32 amount; if (!ExtractInt32(&args, amount)) + { return false; + } Player* target = getSelectedPlayer(); if (!target) @@ -4565,11 +4653,17 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) g_team = TEAM_BOTH_ALLOWED; } else if (strncmp(teamStr, "horde", strlen(teamStr)) == 0) - { g_team = HORDE; } + { + g_team = HORDE; + } else if (strncmp(teamStr, "alliance", strlen(teamStr)) == 0) - { g_team = ALLIANCE; } + { + g_team = ALLIANCE; + } else - { return false; } + { + return false; + } WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(g_id); if (!graveyard) @@ -4596,7 +4690,9 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id, zoneId); } else - { PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id, zoneId); } + { + PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id, zoneId); + } return true; } @@ -4612,11 +4708,17 @@ bool ChatHandler::HandleNearGraveCommand(char* args) g_team = TEAM_BOTH_ALLOWED; } else if (strncmp(args, "horde", argslen) == 0) - { g_team = HORDE; } + { + g_team = HORDE; + } else if (strncmp(args, "alliance", argslen) == 0) - { g_team = ALLIANCE; } + { + g_team = ALLIANCE; + } else - { return false; } + { + return false; + } Player* player = m_session->GetPlayer(); uint32 zone_id = player->GetZoneId(); @@ -4642,11 +4744,17 @@ bool ChatHandler::HandleNearGraveCommand(char* args) team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); } else if (data->team == HORDE) - { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); } + { + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); + } else if (data->team == ALLIANCE) - { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); } + { + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); + } else // Actually, this case can not happen - { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_NOTEAM); } + { + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_NOTEAM); + } PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, g_id, team_name.c_str(), zone_id); } @@ -4659,16 +4767,22 @@ bool ChatHandler::HandleNearGraveCommand(char* args) team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); } else if (g_team == HORDE) - { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); } + { + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); + } else if (g_team == ALLIANCE) - { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); } + { + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); + } if (g_team == TEAM_BOTH_ALLOWED) { PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id); } else - { PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str()); } + { + PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str()); + } } return true; @@ -4716,7 +4830,9 @@ bool ChatHandler::HandleNpcChangeEntryCommand(char* args) SendSysMessage(LANG_DONE); } else - { SendSysMessage(LANG_ERROR); } + { + SendSysMessage(LANG_ERROR); + } return true; } @@ -4823,11 +4939,15 @@ bool ChatHandler::HandleNpcAddWeaponCommand(char* /*args*/) char* pSlotID = strtok((char*)args, " "); if (!pSlotID) + { return false; + } char* pItemID = strtok(NULL, " "); if (!pItemID) + { return false; + } uint32 ItemID = atoi(pItemID); uint32 SlotID = atoi(pSlotID); @@ -4934,9 +5054,13 @@ void ChatHandler::HandleCharacterLevel(Player* player, ObjectGuid player_guid, u ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, GetNameLink().c_str()); } else if (oldlevel < newlevel) - { ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP, GetNameLink().c_str(), newlevel); } + { + ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP, GetNameLink().c_str(), newlevel); + } else // if(oldlevel > newlevel) - { ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, GetNameLink().c_str(), newlevel); } + { + ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, GetNameLink().c_str(), newlevel); + } } } else @@ -4966,7 +5090,9 @@ bool ChatHandler::HandleCharacterLevelCommand(char* args) nolevel = true; } else - { return false; } + { + return false; + } } Player* target; @@ -5019,7 +5145,9 @@ bool ChatHandler::HandleLevelUpCommand(char* args) nameStr = ExtractArg(&args); } else - { return false; } + { + return false; + } } } @@ -5192,11 +5320,17 @@ bool ChatHandler::HandleAuctionItemCommand(char* args) houseid = 1; } else if (strncmp(typeStr, "horde", strlen(typeStr)) == 0) - { houseid = 6; } + { + houseid = 6; + } else if (strncmp(typeStr, "goblin", strlen(typeStr)) == 0) - { houseid = 7; } + { + houseid = 7; + } else - { return false; } + { + return false; + } // parse item str char* itemStr = ExtractArg(&args); @@ -5233,11 +5367,17 @@ bool ChatHandler::HandleAuctionItemCommand(char* args) etime = 1 * MIN_AUCTION_TIME; } else if (strncmp(timeStr, "long", strlen(timeStr)) == 0) - { etime = 2 * MIN_AUCTION_TIME; } + { + etime = 2 * MIN_AUCTION_TIME; + } else if (strncmp(timeStr, "verylong", strlen(timeStr)) == 0) - { etime = 4 * MIN_AUCTION_TIME; } + { + etime = 4 * MIN_AUCTION_TIME; + } else - { return false; } + { + return false; + } } AuctionHouseEntry const* auctionHouseEntry = sAuctionHouseStore.LookupEntry(houseid); @@ -5543,7 +5683,9 @@ bool ChatHandler::HandleResetAchievementsCommand(char* args) Player* target; ObjectGuid target_guid; if (!ExtractPlayerTarget(&args, &target, &target_guid)) + { return false; + } if (target) target->GetAchievementMgr().Reset(); @@ -5844,7 +5986,9 @@ bool ChatHandler::HandleServerShutDownCommand(char* args) { uint32 delay; if (!ExtractUInt32(&args, delay)) + { return false; + } uint32 exitcode; if (!ExtractOptUInt32(&args, exitcode, SHUTDOWN_EXIT_CODE)) @@ -6232,7 +6376,9 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(duration_secs, true).c_str(), reason); } else - { PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reason); } + { + PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reason); + } break; case BAN_SYNTAX_ERROR: return false; @@ -6317,7 +6463,9 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str()); } else - { PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str()); } + { + PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str()); + } return true; } @@ -6524,7 +6672,9 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) } // "character" case, name need extract from another DB else - { sAccountMgr.GetName(account_id, account_name); } + { + sAccountMgr.GetName(account_id, account_name); + } // No SQL injection. id is uint32. QueryResult* banInfo = LoginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); @@ -6817,7 +6967,9 @@ bool ChatHandler::HandlePDumpWriteCommand(char* args) lowguid = guid.GetCounter(); } else - { guid = ObjectGuid(HIGHGUID_PLAYER, lowguid); } + { + guid = ObjectGuid(HIGHGUID_PLAYER, lowguid); + } if (!sObjectMgr.GetPlayerAccountIdByGUID(guid)) { @@ -6876,16 +7028,22 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) target = static_cast const*>(*itr)->GetTarget(); } else - { target = static_cast const*>(*itr)->GetTarget(); } + { + target = static_cast const*>(*itr)->GetTarget(); + } if (!target) { SendSysMessage(LANG_MOVEGENS_CHASE_NULL); } else if (target->GetTypeId() == TYPEID_PLAYER) - { PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); } + { + PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); + } else - { PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); } + { + PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); + } break; } case FOLLOW_MOTION_TYPE: @@ -6896,16 +7054,22 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) target = static_cast const*>(*itr)->GetTarget(); } else - { target = static_cast const*>(*itr)->GetTarget(); } + { + target = static_cast const*>(*itr)->GetTarget(); + } if (!target) { SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); } else if (target->GetTypeId() == TYPEID_PLAYER) - { PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); } + { + PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); + } else - { PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); } + { + PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); + } break; } case HOME_MOTION_TYPE: @@ -6914,7 +7078,9 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); } else - { SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); } + { + SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); + } break; case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break; case POINT_MOTION_TYPE: @@ -6951,13 +7117,21 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) sWorld.SetPlayerLimit(-SEC_PLAYER); } else if (strncmp(param, "moderator", l) == 0) - { sWorld.SetPlayerLimit(-SEC_MODERATOR); } + { + sWorld.SetPlayerLimit(-SEC_MODERATOR); + } else if (strncmp(param, "gamemaster", l) == 0) - { sWorld.SetPlayerLimit(-SEC_GAMEMASTER); } + { + sWorld.SetPlayerLimit(-SEC_GAMEMASTER); + } else if (strncmp(param, "administrator", l) == 0) - { sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); } + { + sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); + } else if (strncmp(param, "reset", l) == 0) - { sWorld.SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT)); } + { + sWorld.SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT)); + } else if (ExtractInt32(¶m, val)) { if (val < -SEC_ADMINISTRATOR) @@ -6968,7 +7142,9 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) sWorld.SetPlayerLimit(val); } else - { return false; } + { + return false; + } // kick all low security level players if (sWorld.GetPlayerAmountLimit() > SEC_PLAYER) @@ -7398,7 +7574,9 @@ bool ChatHandler::HandleGMListFullCommand(char* /*args*/) delete result; } else - { PSendSysMessage(LANG_GMLIST_EMPTY); } + { + PSendSysMessage(LANG_GMLIST_EMPTY); + } return true; } @@ -7462,7 +7640,9 @@ bool ChatHandler::ShowPlayerListHelper(QueryResult* result, uint32* limit, bool PSendSysMessage(LANG_CHARACTERS_LIST_LINE_CONSOLE, guid, name.c_str(), race_name, class_name, level); } else - { PSendSysMessage(LANG_CHARACTERS_LIST_LINE_CHAT, guid, name.c_str(), name.c_str(), race_name, class_name, level); } + { + PSendSysMessage(LANG_CHARACTERS_LIST_LINE_CHAT, guid, name.c_str(), name.c_str(), race_name, class_name, level); + } } while (result->NextRow()); @@ -7941,10 +8121,14 @@ bool ChatHandler::HandleShowGearScoreCommand(char* args) uint32 withBags, withBank; if (!ExtractOptUInt32(&args, withBags, 1)) + { return false; + } if (!ExtractOptUInt32(&args, withBank, 0)) + { return false; + } // always recalculate gear score for display player->ResetCachedGearScore(); diff --git a/src/game/ChatCommands/Level4.cpp b/src/game/ChatCommands/Level4.cpp index d349c31d7..5d29ebd89 100644 --- a/src/game/ChatCommands/Level4.cpp +++ b/src/game/ChatCommands/Level4.cpp @@ -115,7 +115,9 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::s } } else - { resultChar = CharacterDatabase.Query("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL"); } + { + resultChar = CharacterDatabase.Query("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL"); + } if (resultChar) { @@ -344,7 +346,9 @@ bool ChatHandler::HandleCharacterDeletedRestoreCommand(char* args) HandleCharacterDeletedRestoreHelper(delInfo); } else - { SendSysMessage(LANG_CHARACTER_DELETED_ERR_RENAME); } + { + SendSysMessage(LANG_CHARACTER_DELETED_ERR_RENAME); + } return true; } @@ -442,7 +446,9 @@ bool ChatHandler::HandleCharacterEraseCommand(char* args) target->GetSession()->KickPlayer(); } else - { account_id = sObjectMgr.GetPlayerAccountIdByGUID(target_guid); } + { + account_id = sObjectMgr.GetPlayerAccountIdByGUID(target_guid); + } std::string account_name; sAccountMgr.GetName(account_id, account_name); diff --git a/src/game/ChatCommands/debugcmds.cpp b/src/game/ChatCommands/debugcmds.cpp index 3d9c7d8fc..cc17e0f43 100644 --- a/src/game/ChatCommands/debugcmds.cpp +++ b/src/game/ChatCommands/debugcmds.cpp @@ -278,7 +278,9 @@ bool ChatHandler::HandleDebugPlayMovieCommand(char* args) // #movieid - ID decimal number from Movie.dbc (1st column) uint32 dwId; if (!ExtractUInt32(&args, dwId)) + { return false; + } if (!sMovieStore.LookupEntry(dwId)) { @@ -322,7 +324,9 @@ bool ChatHandler::HandleDebugPlaySoundCommand(char* args) unit->PlayDistanceSound(dwSoundId, m_session->GetPlayer()); } else - { unit->PlayDirectSound(dwSoundId, m_session->GetPlayer()); } + { + unit->PlayDirectSound(dwSoundId, m_session->GetPlayer()); + } PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId); return true; @@ -395,7 +399,9 @@ bool ChatHandler::HandleDebugGetLootRecipientCommand(char* /*args*/) target->GetLootRecipientGuid().GetString().c_str(), target->GetLootGroupRecipientId()); else - { SendSysMessage("loot recipient: offline "); } + { + SendSysMessage("loot recipient: offline "); + } return true; } @@ -440,11 +446,17 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args) state_str = "removed"; } else if (strncmp(args, "queue", strlen(args)) == 0) - { list_queue = true; } + { + list_queue = true; + } else if (strncmp(args, "all", strlen(args)) == 0) - { check_all = true; } + { + check_all = true; + } else - { return false; } + { + return false; + } Player* player = getSelectedPlayer(); if (!player) @@ -755,7 +767,9 @@ bool ChatHandler::HandleDebugSendLargePacketCommand(char* /*args*/) bool ChatHandler::HandleDebugSendSetPhaseShiftCommand(char* args) { if (!*args) + { return false; + } char* m = strtok((char*)args, " "); char* p = strtok(NULL, " "); @@ -836,15 +850,25 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS base = 10; } else if (strncmp(typeStr, "int", strlen(typeStr)) == 0) - { base = 10; } + { + base = 10; + } else if (strncmp(typeStr, "hex", strlen(typeStr)) == 0) - { base = 16; } + { + base = 16; + } else if (strncmp(typeStr, "bit", strlen(typeStr)) == 0) - { base = 2; } + { + base = 2; + } else if (strncmp(typeStr, "float", strlen(typeStr)) == 0) - { base = 0; } + { + base = 0; + } else - { return false; } + { + return false; + } if (base) { @@ -956,15 +980,25 @@ bool ChatHandler::HandleGetValueHelper(Object* target, uint32 field, char* typeS base = 10; } else if (strncmp(typeStr, "int", strlen(typeStr)) == 0) - { base = 10; } + { + base = 10; + } else if (strncmp(typeStr, "hex", strlen(typeStr)) == 0) - { base = 16; } + { + base = 16; + } else if (strncmp(typeStr, "bit", strlen(typeStr)) == 0) - { base = 2; } + { + base = 2; + } else if (strncmp(typeStr, "float", strlen(typeStr)) == 0) - { base = 0; } + { + base = 0; + } else - { return false; } + { + return false; + } if (base) { @@ -1075,15 +1109,25 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char* type = 1; } else if (strncmp(typeStr, "float", strlen(typeStr)) == 0) - { type = 0; } + { + type = 0; + } else if (strncmp(typeStr, "|=", strlen("|=") + 1) == 0) // exactly copy - { type = 2; } + { + type = 2; + } else if (strncmp(typeStr, "&=", strlen("&=") + 1) == 0) // exactly copy - { type = 3; } + { + type = 3; + } else if (strncmp(typeStr, "&=~", strlen("&=~") + 1) == 0) // exactly copy - { type = 4; } + { + type = 4; + } else - { return false; } + { + return false; + } if (type) { @@ -1285,9 +1329,13 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args) opcode = SMSG_SET_FLAT_SPELL_MODIFIER; } else if (strncmp(typeStr, "pct", strlen(typeStr)) == 0) - { opcode = SMSG_SET_PCT_SPELL_MODIFIER; } + { + opcode = SMSG_SET_PCT_SPELL_MODIFIER; + } else - { return false; } + { + return false; + } uint32 effidx; if (!ExtractUInt32(&args, effidx) || effidx >= 64 + 32) diff --git a/src/game/MotionGenerators/FleeingMovementGenerator.cpp b/src/game/MotionGenerators/FleeingMovementGenerator.cpp index 5ee7c0df6..678a2c4dd 100644 --- a/src/game/MotionGenerators/FleeingMovementGenerator.cpp +++ b/src/game/MotionGenerators/FleeingMovementGenerator.cpp @@ -82,7 +82,9 @@ bool FleeingMovementGenerator::_getPoint(T& owner, float& x, float& y, float& angle_to_caster = fright->GetAngle(&owner); } else - { angle_to_caster = frand(0, 2 * M_PI_F); } + { + angle_to_caster = frand(0, 2 * M_PI_F); + } } else { @@ -116,7 +118,9 @@ bool FleeingMovementGenerator::_getPoint(T& owner, float& x, float& y, float& // try to fix z if (!owner.GetMap()->GetHeightInRange(owner.GetPhaseMask(), x, y, z)) + { return false; + } if (owner.GetTypeId() == TYPEID_PLAYER) { @@ -126,7 +130,9 @@ bool FleeingMovementGenerator::_getPoint(T& owner, float& x, float& y, float& { z = testZ; if (!owner.GetMap()->GetHeightInRange(owner.GetPhaseMask(), x, y, z)) + { return false; + } } } diff --git a/src/game/MotionGenerators/MotionMaster.cpp b/src/game/MotionGenerators/MotionMaster.cpp index 4fde108b4..c0423e4cf 100644 --- a/src/game/MotionGenerators/MotionMaster.cpp +++ b/src/game/MotionGenerators/MotionMaster.cpp @@ -65,7 +65,9 @@ void MotionMaster::Initialize() (static_cast*>(top()))->InitializeWaypointPath(*((Creature*)(m_owner)), 0, PATH_NO_PATH, 0, 0); } else - { push(&si_idleMovement); } + { + push(&si_idleMovement); + } } MotionMaster::~MotionMaster() @@ -98,7 +100,9 @@ void MotionMaster::UpdateMotion(uint32 diff) MovementExpired(); } else - { m_cleanFlag &= ~MMCF_UPDATE; } + { + m_cleanFlag &= ~MMCF_UPDATE; + } if (m_expList) { @@ -155,7 +159,9 @@ void MotionMaster::DelayedClean(bool reset, bool all) m_cleanFlag |= MMCF_RESET; } else - { m_cleanFlag &= ~MMCF_RESET; } + { + m_cleanFlag &= ~MMCF_RESET; + } if (empty() || (!all && size() == 1)) { @@ -228,7 +234,9 @@ void MotionMaster::DelayedExpire(bool reset) m_cleanFlag |= MMCF_RESET; } else - { m_cleanFlag &= ~MMCF_RESET; } + { + m_cleanFlag &= ~MMCF_RESET; + } if (empty() || size() == 1) { @@ -316,7 +324,9 @@ void MotionMaster::MoveTargetedHome() } } else - { sLog.outError("%s attempt targeted home", m_owner->GetGuidStr().c_str()); } + { + sLog.outError("%s attempt targeted home", m_owner->GetGuidStr().c_str()); + } } void MotionMaster::MoveConfused() @@ -328,7 +338,9 @@ void MotionMaster::MoveConfused() Mutate(new ConfusedMovementGenerator()); } else - { Mutate(new ConfusedMovementGenerator()); } + { + Mutate(new ConfusedMovementGenerator()); + } } void MotionMaster::MoveChase(Unit* target, float dist, float angle) @@ -346,7 +358,9 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle) Mutate(new ChaseMovementGenerator(*target, dist, angle)); } else - { Mutate(new ChaseMovementGenerator(*target, dist, angle)); } + { + Mutate(new ChaseMovementGenerator(*target, dist, angle)); + } } void MotionMaster::MoveFollow(Unit* target, float dist, float angle) @@ -371,7 +385,9 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle) Mutate(new FollowMovementGenerator(*target, dist, angle)); } else - { Mutate(new FollowMovementGenerator(*target, dist, angle)); } + { + Mutate(new FollowMovementGenerator(*target, dist, angle)); + } } void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath) @@ -383,7 +399,9 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate Mutate(new PointMovementGenerator(id, x, y, z, generatePath)); } else - { Mutate(new PointMovementGenerator(id, x, y, z, generatePath)); } + { + Mutate(new PointMovementGenerator(id, x, y, z, generatePath)); + } } void MotionMaster::MoveSeekAssistance(float x, float y, float z) @@ -434,7 +452,9 @@ void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); } else - { Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); } + { + Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); + } } } @@ -542,7 +562,9 @@ bool MotionMaster::SetNextWaypoint(uint32 pointId) for (Impl::container_type::reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr) { if ((*rItr)->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE) + { return (static_cast*>(*rItr))->SetNextWaypoint(pointId); + } } return false; } diff --git a/src/game/MotionGenerators/MotionMaster.h b/src/game/MotionGenerators/MotionMaster.h index 6aaeddfaf..37f64e511 100644 --- a/src/game/MotionGenerators/MotionMaster.h +++ b/src/game/MotionGenerators/MotionMaster.h @@ -99,7 +99,9 @@ class MotionMaster : private std::stack DelayedClean(reset, all); } else - { DirectClean(reset, all); } + { + DirectClean(reset, all); + } } void MovementExpired(bool reset = true) { @@ -108,7 +110,9 @@ class MotionMaster : private std::stack DelayedExpire(reset); } else - { DirectExpire(reset); } + { + DirectExpire(reset); + } } void MoveIdle(); diff --git a/src/game/MotionGenerators/PathFinder.cpp b/src/game/MotionGenerators/PathFinder.cpp index 01e36e1f3..a210de000 100644 --- a/src/game/MotionGenerators/PathFinder.cpp +++ b/src/game/MotionGenerators/PathFinder.cpp @@ -189,10 +189,14 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) (endPoly == INVALID_POLYREF && m_sourceUnit->GetTerrain()->IsUnderWater(endPos.x, endPos.y, endPos.z))) { m_type = ((Creature*)m_sourceUnit)->CanSwim() ? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH; } else - { m_type = ((Creature*)m_sourceUnit)->CanFly() ? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH; } + { + m_type = ((Creature*)m_sourceUnit)->CanFly() ? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH; + } } else - { m_type = PATHFIND_NOPATH; } + { + m_type = PATHFIND_NOPATH; + } return; } @@ -407,7 +411,9 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) m_type = PATHFIND_NORMAL; } else - { m_type = PATHFIND_INCOMPLETE; } + { + m_type = PATHFIND_INCOMPLETE; + } // generate the point-path out of our up-to-date poly-path BuildPointPath(startPoint, endPoint); @@ -719,7 +725,9 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, len = 1.0f; } else - { len = SMOOTH_PATH_STEP_SIZE / len; } + { + len = SMOOTH_PATH_STEP_SIZE / len; + } float moveTgt[VERTEX_SIZE]; dtVmad(moveTgt, iterPos, delta, len); diff --git a/src/game/MotionGenerators/PointMovementGenerator.cpp b/src/game/MotionGenerators/PointMovementGenerator.cpp index 8f1146307..201d34cfc 100644 --- a/src/game/MotionGenerators/PointMovementGenerator.cpp +++ b/src/game/MotionGenerators/PointMovementGenerator.cpp @@ -162,7 +162,9 @@ void EffectMovementGenerator::Finalize(Unit& unit) unit.GetMotionMaster()->MoveChase(victim); } else - { unit.GetMotionMaster()->Initialize(); } + { + unit.GetMotionMaster()->Initialize(); + } } } diff --git a/src/game/MotionGenerators/TargetedMovementGenerator.cpp b/src/game/MotionGenerators/TargetedMovementGenerator.cpp index 9983d36b4..bfd4ed6d9 100644 --- a/src/game/MotionGenerators/TargetedMovementGenerator.cpp +++ b/src/game/MotionGenerators/TargetedMovementGenerator.cpp @@ -194,7 +194,9 @@ bool TargetedMovementGeneratorMedium::RequiresNewPosition(T& owner, float return !i_target->IsWithinDist3d(x, y, z, this->GetDynamicTargetDistance(owner, true)); } else - { return !i_target->IsWithinDist2d(x, y, this->GetDynamicTargetDistance(owner, true)); } + { + return !i_target->IsWithinDist2d(x, y, this->GetDynamicTargetDistance(owner, true)); + } } //-----------------------------------------------// diff --git a/src/game/MotionGenerators/WaypointMovementGenerator.cpp b/src/game/MotionGenerators/WaypointMovementGenerator.cpp index a1a7887f9..c6508dba5 100644 --- a/src/game/MotionGenerators/WaypointMovementGenerator.cpp +++ b/src/game/MotionGenerators/WaypointMovementGenerator.cpp @@ -175,7 +175,9 @@ void WaypointMovementGenerator::OnArrived(Creature& creature) creature.MonsterText(textData, NULL); } else - { sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId); } + { + sLog.outErrorDb("%s reached waypoint %u, attempted to do text %i, but required text-data could not be found", creature.GetGuidStr().c_str(), i_currentNode, textId); + } } } @@ -240,7 +242,9 @@ void WaypointMovementGenerator::StartMove(Creature& creature) creature.AI()->MovementInform(EXTERNAL_WAYPOINT_FINISHED_LAST + m_pathId, currPoint->first); if (creature.IsDead() || !creature.IsInWorld()) // Might have happened with above calls + { return; + } } i_currentNode = currPoint->first; @@ -382,11 +386,15 @@ void WaypointMovementGenerator::AddToWaypointPauseTime(int32 waitTimeD bool WaypointMovementGenerator::SetNextWaypoint(uint32 pointId) { if (!i_path || i_path->empty()) + { return false; + } WaypointPath::const_iterator currPoint = i_path->find(pointId); if (currPoint == i_path->end()) + { return false; + } // Allow Moving with next tick // Handle allow movement this way to not interact with PAUSED state. diff --git a/src/game/Object/ArenaTeam.cpp b/src/game/Object/ArenaTeam.cpp index e9125b943..dc8b33415 100644 --- a/src/game/Object/ArenaTeam.cpp +++ b/src/game/Object/ArenaTeam.cpp @@ -74,11 +74,17 @@ ArenaTeam::~ArenaTeam() bool ArenaTeam::Create(ObjectGuid captainGuid, ArenaType type, std::string arenaTeamName) { if (!IsArenaTypeValid(type)) + { return false; + } if (!sObjectMgr.GetPlayer(captainGuid)) // player not exist + { return false; + } if (sObjectMgr.GetArenaTeamByName(arenaTeamName)) // arena team with this name already exist + { return false; + } DEBUG_LOG("GUILD: creating arena team %s to leader: %s", arenaTeamName.c_str(), captainGuid.GetString().c_str()); @@ -113,7 +119,9 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) // arena team is full (can't have more than type * 2 players!) if (GetMembersSize() >= GetMaxMembersSize()) + { return false; + } Player* pl = sObjectMgr.GetPlayer(playerGuid); if (pl) @@ -132,7 +140,9 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) // 0 1 QueryResult* result = CharacterDatabase.PQuery("SELECT name, class FROM characters WHERE guid='%u'", playerGuid.GetCounter()); if (!result) + { return false; + } plName = (*result)[0].GetCppString(); plClass = (*result)[1].GetUInt8(); @@ -193,7 +203,9 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid) bool ArenaTeam::LoadArenaTeamFromDB(QueryResult* arenaTeamDataResult) { if (!arenaTeamDataResult) + { return false; + } Field* fields = arenaTeamDataResult->Fetch(); @@ -203,7 +215,9 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult* arenaTeamDataResult) m_Type = ArenaType(fields[3].GetUInt32()); if (!IsArenaTypeValid(m_Type)) + { return false; + } m_BackgroundColor = fields[4].GetUInt32(); m_EmblemStyle = fields[5].GetUInt32(); @@ -224,7 +238,9 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult* arenaTeamDataResult) bool ArenaTeam::LoadMembersFromDB(QueryResult* arenaTeamMembersResult) { if (!arenaTeamMembersResult) + { return false; + } bool captainPresentInTeam = false; @@ -267,7 +283,9 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult* arenaTeamMembersResult) // arena team can't be > 2 * arenatype (2 for 2x2, 3 for 3x3, 5 for 5x5) if (GetMembersSize() >= GetMaxMembersSize()) + { return false; + } if (newmember.guid == GetCaptainGuid()) captainPresentInTeam = true; @@ -429,7 +447,9 @@ void ArenaTeam::InspectStats(WorldSession* session, ObjectGuid guid) { ArenaTeamMember* member = GetMember(guid); if (!member) + { return; + } WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8 + 1 + 4 * 6); data << guid; // player guid @@ -587,7 +607,9 @@ bool ArenaTeam::HaveMember(ObjectGuid guid) const { for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) if (itr->guid == guid) + { return true; + } return false; } @@ -734,7 +756,9 @@ void ArenaTeam::UpdateArenaPointsHelper(std::map& PlayerPoints) // helper function for arena point distribution (this way, when distributing, no actual calculation is required, just a few comparisons) // 10 played games per week is a minimum if (m_stats.games_week < 10) + { return; + } // to get points, a player has to participate in at least 30% of the matches uint32 min_plays = (uint32) ceil(m_stats.games_week * 0.3); for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) @@ -788,7 +812,9 @@ bool ArenaTeam::IsFighting() const if (Player* p = sObjectMgr.GetPlayer(itr->guid)) { if (p->GetMap()->IsBattleArena()) + { return true; + } } } return false; diff --git a/src/game/Object/AuctionHouseMgr.cpp b/src/game/Object/AuctionHouseMgr.cpp index dff698432..cc0495982 100644 --- a/src/game/Object/AuctionHouseMgr.cpp +++ b/src/game/Object/AuctionHouseMgr.cpp @@ -141,7 +141,9 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) if (auction_owner) owner_name = auction_owner->GetName(); else if (ownerGuid && !sObjectMgr.GetPlayerNameByGUID(ownerGuid, owner_name)) - { owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); } + { + owner_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); + } uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid); @@ -150,7 +152,9 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) } } else if (!bidder) - { bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid); } + { + bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid); + } if (auction_owner) auction_owner->GetSession()->SendAuctionOwnerNotification(auction); @@ -679,11 +683,17 @@ int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry* auc, Pl ItemPrototype const* itemProto1 = ObjectMgr::GetItemPrototype(itemTemplate); ItemPrototype const* itemProto2 = ObjectMgr::GetItemPrototype(auc->itemTemplate); if (!itemProto2 || !itemProto1) + { return 0; + } if (itemProto1->RequiredLevel < itemProto2->RequiredLevel) + { return -1; + } else if (itemProto1->RequiredLevel > itemProto2->RequiredLevel) + { return +1; + } break; } case 1: // quality = 1 @@ -691,47 +701,71 @@ int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry* auc, Pl ItemPrototype const* itemProto1 = ObjectMgr::GetItemPrototype(itemTemplate); ItemPrototype const* itemProto2 = ObjectMgr::GetItemPrototype(auc->itemTemplate); if (!itemProto2 || !itemProto1) + { return 0; + } if (itemProto1->Quality < itemProto2->Quality) + { return -1; + } else if (itemProto1->Quality > itemProto2->Quality) + { return +1; + } break; } case 2: // buyoutthenbid = 2 if (buyout != auc->buyout) { if (buyout < auc->buyout) + { return -1; + } else if (buyout > auc->buyout) + { return +1; + } } else { if (bid < auc->bid) + { return -1; + } else if (bid > auc->bid) + { return +1; + } } break; case 3: // duration = 3 if (expireTime < auc->expireTime) + { return -1; + } else if (expireTime > auc->expireTime) + { return +1; + } break; case 4: // status = 4 if (bidder < auc->bidder) + { return -1; + } else if (bidder > auc->bidder) + { return +1; + } break; case 5: // name = 5 { ItemPrototype const* itemProto1 = ObjectMgr::GetItemPrototype(itemTemplate); ItemPrototype const* itemProto2 = ObjectMgr::GetItemPrototype(auc->itemTemplate); if (!itemProto2 || !itemProto1) + { return 0; + } int32 loc_idx = viewPlayer->GetSession()->GetSessionDbLocaleIndex(); @@ -754,16 +788,24 @@ int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry* auc, Pl if (bid1 != bid2) { if (bid1 < bid2) + { return -1; + } else if (bid1 > bid2) + { return +1; + } } else { if (buyout < auc->buyout) + { return -1; + } else if (buyout > auc->buyout) + { return +1; + } } break; @@ -776,24 +818,36 @@ int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry* auc, Pl uint64 bid2 = auc->bid ? auc->bid : auc->startbid; if (bid1 < bid2) + { return -1; + } else if (bid1 > bid2) + { return +1; + } break; } case 9: // quantity = 9 { if (itemCount < auc->itemCount) + { return -1; + } else if (itemCount > auc->itemCount) + { return +1; + } break; } case 10: // buyout = 10 if (buyout < auc->buyout) + { return -1; + } else if (buyout > auc->buyout) + { return +1; + } break; case 11: // unused = 11 default: @@ -806,12 +860,16 @@ int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry* auc, Pl bool AuctionSorter::operator()(const AuctionEntry* auc1, const AuctionEntry* auc2) const { if (m_sort[0] == MAX_AUCTION_SORT) // not sorted + { return false; + } for (uint32 i = 0; i < MAX_AUCTION_SORT; ++i) { if (m_sort[i] == MAX_AUCTION_SORT) // end of sort + { return false; + } int res = auc1->CompareAuctionEntry(m_sort[i] & ~AUCTION_SORT_REVERSED, auc2, m_viewPlayer); // "equal" by used column diff --git a/src/game/Object/Bag.cpp b/src/game/Object/Bag.cpp index bb7b2386b..e6eee7b60 100644 --- a/src/game/Object/Bag.cpp +++ b/src/game/Object/Bag.cpp @@ -212,7 +212,9 @@ Item* Bag::GetItemByLimitedCategory(uint32 limitedCategory) const { for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i] && m_bagslot[i]->GetProto()->ItemLimitCategory == limitedCategory) + { return m_bagslot[i]; + } return NULL; } diff --git a/src/game/Object/Calendar.cpp b/src/game/Object/Calendar.cpp index c0681f677..d355a0ac8 100644 --- a/src/game/Object/Calendar.cpp +++ b/src/game/Object/Calendar.cpp @@ -42,7 +42,9 @@ CalendarEvent::~CalendarEvent() bool CalendarEvent::AddInvite(CalendarInvite* invite) { if (!invite) + { return false; + } return m_Invitee.insert(CalendarInviteMap::value_type(invite->InviteId, invite)).second; } @@ -51,7 +53,9 @@ CalendarInvite* CalendarEvent::GetInviteById(uint64 inviteId) { CalendarInviteMap::iterator itr = m_Invitee.find(inviteId); if (itr != m_Invitee.end()) + { return itr->second; + } return NULL; } @@ -61,7 +65,9 @@ CalendarInvite* CalendarEvent::GetInviteByGuid(ObjectGuid const& guid) while (inviteItr != m_Invitee.end()) { if (inviteItr->second->InviteeGuid == guid) + { return inviteItr->second; + } ++inviteItr; } @@ -249,7 +255,9 @@ CalendarEvent* CalendarMgr::AddEvent(ObjectGuid const& guid, std::string title, { Player* player = sObjectMgr.GetPlayer(guid); if (!player) + { return NULL; + } if (title.empty()) { @@ -356,7 +364,9 @@ CalendarInvite* CalendarMgr::AddInvite(CalendarEvent* event, ObjectGuid const& s { Player* sender = sObjectMgr.GetPlayer(senderGuid); if (!event || !sender) + { return NULL; + } std::string name; sObjectMgr.GetPlayerNameByGUID(inviteeGuid, name); @@ -477,7 +487,9 @@ void CalendarMgr::CopyEvent(uint64 eventId, time_t newTime, ObjectGuid const& gu CALENDAR_MAX_INVITES, event->DungeonId, newTime, event->UnknownTime, event->Flags); if (!newEvent) + { return; + } if (newEvent->IsGuildAnnouncement()) AddInvite(newEvent, guid, guid, CALENDAR_STATUS_CONFIRMED, CALENDAR_RANK_OWNER, "", time(NULL)); @@ -686,7 +698,9 @@ bool CalendarMgr::CanAddEvent(ObjectGuid const& guid) // count all event created by guid for (CalendarEventStore::iterator itr = m_EventStore.begin(); itr != m_EventStore.end(); ++itr) if ((itr->second.CreatorGuid == guid) && (++totalEvents >= CALENDAR_MAX_EVENTS)) + { return false; + } return true; } @@ -694,13 +708,17 @@ bool CalendarMgr::CanAddEvent(ObjectGuid const& guid) bool CalendarMgr::CanAddGuildEvent(uint32 guildId) { if (!guildId) + { return false; + } uint32 totalEvents = 0; // count all guild events in a guild for (CalendarEventStore::iterator itr = m_EventStore.begin(); itr != m_EventStore.end(); ++itr) if ((itr->second.GuildId == guildId) && (++totalEvents >= CALENDAR_MAX_GUILD_EVENTS)) + { return false; + } return true; } @@ -721,7 +739,9 @@ bool CalendarMgr::CanAddInviteTo(ObjectGuid const& guid) while (ci_itr != cInvMap->end()) { if ((ci_itr->second->InviteeGuid == guid) && (++totalInvites >= CALENDAR_MAX_INVITES)) + { return false; + } ++ci_itr; } } diff --git a/src/game/Object/Corpse.cpp b/src/game/Object/Corpse.cpp index f84f1b0eb..fc148e32a 100644 --- a/src/game/Object/Corpse.cpp +++ b/src/game/Object/Corpse.cpp @@ -277,7 +277,9 @@ bool Corpse::IsHostileTo(Unit const* unit) const return owner->IsHostileTo(unit); } else - { return false; } + { + return false; + } } bool Corpse::IsFriendlyTo(Unit const* unit) const @@ -287,7 +289,9 @@ bool Corpse::IsFriendlyTo(Unit const* unit) const return owner->IsFriendlyTo(unit); } else - { return true; } + { + return true; + } } bool Corpse::IsExpired(time_t t) const @@ -297,5 +301,7 @@ bool Corpse::IsExpired(time_t t) const return m_time < t - 60 * MINUTE; } else - { return m_time < t - 3 * DAY; } + { + return m_time < t - 3 * DAY; + } } diff --git a/src/game/Object/Creature.cpp b/src/game/Object/Creature.cpp index ec89c7e75..af9385d1d 100644 --- a/src/game/Object/Creature.cpp +++ b/src/game/Object/Creature.cpp @@ -143,7 +143,9 @@ void CreatureCreatePos::SelectFinalPoint(Creature* cr) m_pos.z = m_closeObject->GetPositionZ(); } else - { m_closeObject->GetClosePoint(m_pos.x, m_pos.y, m_pos.z, cr->GetObjectBoundingRadius(), m_dist, m_angle); } + { + m_closeObject->GetClosePoint(m_pos.x, m_pos.y, m_pos.z, cr->GetObjectBoundingRadius(), m_dist, m_angle); + } } } @@ -638,7 +640,9 @@ void Creature::Update(uint32 update_diff, uint32 diff) LoadCreatureAddon(true); } else - { SetDeathState(JUST_ALIVED); } + { + SetDeathState(JUST_ALIVED); + } // Call AI respawn virtual function if (AI()) @@ -679,7 +683,9 @@ void Creature::Update(uint32 update_diff, uint32 diff) StopGroupLoot(); } else - { m_groupLootTimer -= update_diff; } + { + m_groupLootTimer -= update_diff; + } } break; @@ -767,7 +773,9 @@ void Creature::RegenerateAll(uint32 update_diff) m_regenTimer = 0; } else - { m_regenTimer -= update_diff; } + { + m_regenTimer -= update_diff; + } } if (m_regenTimer != 0) { @@ -787,7 +795,9 @@ void Creature::RegenerateAll(uint32 update_diff) void Creature::RegeneratePower() { if (!IsRegeneratingPower()) + { return; + } Powers powerType = GetPowerType(); uint32 curValue = GetPower(powerType); @@ -877,10 +887,14 @@ void Creature::RegenerateHealth() addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); } else - { addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); } + { + addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); + } } else - { addvalue = maxValue / 3; } + { + addvalue = maxValue / 3; + } ModifyHealth(addvalue); } @@ -1318,7 +1332,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) } } else - { displayId = 0; } + { + displayId = 0; + } } // data->guid = guid don't must be update at save @@ -1378,7 +1394,9 @@ void Creature::SelectLevel(uint32 forcedLevel /*= USE_DEFAULT_DATABASE_LEVEL*/) { CreatureInfo const* cinfo = GetCreatureInfo(); if (!cinfo) + { return; + } uint32 rank = IsPet() ? 0 : cinfo->Rank; // TODO :: IsPet probably not needed here @@ -1555,7 +1573,9 @@ void Creature::SelectLevel(const CreatureInfo* cinfo, float percentHealth /*= 10 SetHealth(health); } else - { SetHealthPercent(percentHealth); } + { + SetHealthPercent(percentHealth); + } SetModifierValue(UNIT_MOD_HEALTH, BASE_VALUE, float(health)); @@ -1812,7 +1832,9 @@ void Creature::LoadEquipment(uint32 equip_entry, bool force) EquipmentInfo const* einfo = sObjectMgr.GetEquipmentInfo(equip_entry); if (!einfo) + { return; + } m_equipmentId = equip_entry; for (uint8 i = 0; i < MAX_VIRTUAL_ITEM_SLOT; ++i) @@ -2060,7 +2082,9 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd { SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(index); if (!spellEffect) + { return false; + } if (!castOnSelf && GetCreatureInfo()->MechanicImmuneMask & (1 << (spellEffect->EffectMechanic - 1))) { @@ -2080,7 +2104,9 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd } // Spell effect taunt check else if (spellEffect->Effect == SPELL_EFFECT_ATTACK_ME) - { return true; } + { + return true; + } } return Unit::IsImmuneToSpellEffect(spellInfo, index, castOnSelf); @@ -2090,7 +2116,9 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd void Creature::SetLootStatus(CreatureLootStatus status) { if (status <= m_lootStatus) + { return; + } m_lootStatus = status; switch (status) @@ -2122,14 +2150,18 @@ bool Creature::IsTappedBy(Player* plr) const if (Player* recipient = GetLootRecipient()) { if (recipient == plr) + { return true; + } if (Group* grp = recipient->GetGroup()) { if (Group* plrGroup = plr->GetGroup()) { if (plrGroup == grp) + { return true; + } } } return false; @@ -2334,7 +2366,9 @@ void Creature::CallAssistance() SetNoCallAssistance(true); if (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_CALL_ASSIST) + { return; + } AI()->SendAIEventAround(AI_EVENT_CALL_ASSISTANCE, getVictim(), sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY), sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_ASSISTANCE_RADIUS)); } @@ -2507,7 +2541,9 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const { // If CreatureTemplateAddon for difficulty_entry_N exist, it's there for a reason if (CreatureDataAddon const* addon = ObjectMgr::GetCreatureTemplateAddon(GetCreatureInfo()->Entry)) + { return addon; + } } // Return CreatureTemplateAddon when nothing else exist @@ -2649,11 +2685,17 @@ bool Creature::MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* return false; } else if (selectFlags & SELECT_FLAG_POWER_RAGE && pTarget->GetPowerType() != POWER_RAGE) - { return false; } + { + return false; + } else if (selectFlags & SELECT_FLAG_POWER_ENERGY && pTarget->GetPowerType() != POWER_ENERGY) - { return false; } + { + return false; + } else if (selectFlags & SELECT_FLAG_POWER_RUNIC && pTarget->GetPowerType() != POWER_RUNIC_POWER) - { return false; } + { + return false; + } if (selectFlags & SELECT_FLAG_IN_MELEE_RANGE && !CanReachWithMeleeAttack(pTarget)) { @@ -2844,9 +2886,13 @@ time_t Creature::GetRespawnTimeEx() const return m_respawnTime; } else if (m_corpseDecayTimer > 0) // dead (corpse) + { return now + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS; + } else - { return now; } + { + return now; + } } void Creature::GetRespawnCoord(float& x, float& y, float& z, float* ori, float* dist) const @@ -3051,7 +3097,9 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us vCount->count += diff * pProto->BuyCount; } else - { vCount->count = vItem->maxcount; } + { + vCount->count = vItem->maxcount; + } } vCount->count = vCount->count > used_count ? vCount->count - used_count : 0; @@ -3258,7 +3306,9 @@ void Creature::SetWalk(bool enable, bool asDefault) clearUnitState(UNIT_STAT_RUNNING); } else - { addUnitState(UNIT_STAT_RUNNING); } + { + addUnitState(UNIT_STAT_RUNNING); + } } // Nothing changed? @@ -3272,7 +3322,9 @@ void Creature::SetWalk(bool enable, bool asDefault) m_movementInfo.AddMovementFlag(MOVEFLAG_WALK_MODE); } else - { m_movementInfo.RemoveMovementFlag(MOVEFLAG_WALK_MODE); } + { + m_movementInfo.RemoveMovementFlag(MOVEFLAG_WALK_MODE); + } if (IsInWorld()) { @@ -3299,7 +3351,9 @@ void Creature::SetLevitate(bool enable) m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING); } else - { m_movementInfo.RemoveMovementFlag(MOVEFLAG_LEVITATING); } + { + m_movementInfo.RemoveMovementFlag(MOVEFLAG_LEVITATING); + } if (IsInWorld()) { @@ -3374,7 +3428,9 @@ void Creature::SetRoot(bool enable) m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT); } else - { m_movementInfo.RemoveMovementFlag(MOVEFLAG_ROOT); } + { + m_movementInfo.RemoveMovementFlag(MOVEFLAG_ROOT); + } if (IsInWorld()) { diff --git a/src/game/Object/Creature.h b/src/game/Object/Creature.h index f199cf521..bb111df83 100644 --- a/src/game/Object/Creature.h +++ b/src/game/Object/Creature.h @@ -170,9 +170,13 @@ struct CreatureInfo return SKILL_HERBALISM; } else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT) - { return SKILL_MINING; } + { + return SKILL_MINING; + } else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT) + { return SKILL_ENGINEERING; + } else { return SKILL_SKINNING; } // normal case } @@ -185,7 +189,9 @@ struct CreatureInfo bool isTameable(bool exotic) const { if (CreatureType != CREATURE_TYPE_BEAST || Family == 0 || (CreatureTypeFlags & CREATURE_TYPEFLAGS_TAMEABLE) == 0) + { return false; + } // if can tame exotic then can tame any temable return exotic || !IsExotic(); @@ -798,7 +804,9 @@ class Creature : public Unit return 0; } else - { return m_charmInfo->GetCharmSpell(pos)->GetAction(); } + { + return m_charmInfo->GetCharmSpell(pos)->GetAction(); + } } void SetCombatStartPosition(float x, float y, float z) { m_combatStartX = x; m_combatStartY = y; m_combatStartZ = z; } diff --git a/src/game/Object/CreatureAI.cpp b/src/game/Object/CreatureAI.cpp index 875697749..6e70d9751 100644 --- a/src/game/Object/CreatureAI.cpp +++ b/src/game/Object/CreatureAI.cpp @@ -73,7 +73,9 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, } if (!pSpell->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !m_creature->IsWithinLOSInMap(pTarget) && m_creature != pTarget) + { return CAST_FAIL_NOT_IN_LOS; + } } if (const SpellRangeEntry* pSpellRange = sSpellRangeStore.LookupEntry(pSpell->rangeIndex)) @@ -99,7 +101,9 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, return CAST_OK; } else - { return CAST_FAIL_OTHER; } + { + return CAST_FAIL_OTHER; + } } CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags, ObjectGuid uiOriginalCasterGUID) @@ -162,7 +166,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 } } else - { return CAST_FAIL_IS_CASTING; } + { + return CAST_FAIL_IS_CASTING; + } } bool CreatureAI::DoMeleeAttackIfReady() @@ -179,7 +185,9 @@ void CreatureAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=fals m_creature->clearUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); } else - { m_creature->addUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); } + { + m_creature->addUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); + } if (stopOrStartMovement && m_creature->getVictim()) // Only change current movement while in combat { @@ -188,7 +196,9 @@ void CreatureAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=fals m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle); } else if (!enable && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) - { m_creature->StopMoving(); } + { + m_creature->StopMoving(); + } } } diff --git a/src/game/Object/CreatureAISelector.cpp b/src/game/Object/CreatureAISelector.cpp index 175d21e84..92ea55b71 100644 --- a/src/game/Object/CreatureAISelector.cpp +++ b/src/game/Object/CreatureAISelector.cpp @@ -44,7 +44,9 @@ namespace FactorySelector { // charmed creature may have some script even if its not supposed to be that way (ex: Eye of Acherus) if (creature->IsCharmed()) + { return scriptedAI; + } // Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets) if (!creature->IsPet() || !static_cast(creature)->isControlled()) @@ -71,7 +73,9 @@ namespace FactorySelector } } else if (creature->IsTotem()) - { ai_factory = ai_registry.GetRegistryItem("TotemAI"); } + { + ai_factory = ai_registry.GetRegistryItem("TotemAI"); + } // select by script name if (!ai_factory && !ainame.empty()) diff --git a/src/game/Object/CreatureEventAI.cpp b/src/game/Object/CreatureEventAI.cpp index 00a5595af..67178febf 100644 --- a/src/game/Object/CreatureEventAI.cpp +++ b/src/game/Object/CreatureEventAI.cpp @@ -44,7 +44,9 @@ bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatM Time = repeatMin; } else if (repeatMax > repeatMin) - { Time = urand(repeatMin, repeatMax); } + { + Time = urand(repeatMin, repeatMax); + } else { sLog.outErrorEventAI("Creature %u using Event %u (Type = %u) has RandomMax < RandomMin. Event repeating disabled.", creature->GetEntry(), Event.event_id, Event.event_type); @@ -83,9 +85,13 @@ void CreatureEventAI::GetAIInformation(ChatHandler& reader) reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1, itr->Event.action[2].type, itr->Event.action[2].raw.param1); } else if (itr->Event.action[1].type != ACTION_T_NONE) - { reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1); } + { + reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) actions[type(param1)]: %2u(%5u) -- %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1, itr->Event.action[1].type, itr->Event.action[1].raw.param1); + } else - { reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) action[type(param1)]: %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1); } + { + reader.PSendSysMessage("%u Type%3u (%s) Timer(%3us) action[type(param1)]: %2u(%5u)", itr->Event.event_id, itr->Event.event_type, itr->Enabled ? "On" : "Off", itr->Time / 1000, itr->Event.action[0].type, itr->Event.action[0].raw.param1); + } } } @@ -130,7 +136,9 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c), } } else if (IsEventFlagsFitForNormalMap(i->event_flags)) - { ++events_count; } + { + ++events_count; + } } // EventMap had events but they were not added because they must be for instance if (events_count == 0) @@ -158,7 +166,9 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c), } } else if (IsEventFlagsFitForNormalMap(i->event_flags)) - { storeEvent = true; } + { + storeEvent = true; + } if (storeEvent) { @@ -313,11 +323,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction break; case EVENT_T_RANGE: if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->IsInMap(m_creature->getVictim())) + { return false; + } // DISCUSS TODO - Likely replace IsInRange check with CombatReach checks (as used rather for such checks) if (!m_creature->IsInRange(m_creature->getVictim(), (float)event.range.minDist, (float)event.range.maxDist)) + { return false; + } // Repeat Timers pHolder.UpdateRepeatTimer(m_creature, event.range.repeatMin, event.range.repeatMax); @@ -645,9 +659,13 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 textId = action.text.TextId[rnd % 3]; } else if (action.text.TextId[1] && (rnd % 2)) - { textId = action.text.TextId[1]; } + { + textId = action.text.TextId[1]; + } else - { textId = action.text.TextId[0]; } + { + textId = action.text.TextId[0]; + } } // ACTION_T_CHANCED_TEXT, chance hits else if ((rnd % 100) < action.chanced_text.chance) @@ -657,7 +675,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 textId = action.chanced_text.TextId[rnd % 2]; } else - { textId = action.chanced_text.TextId[0]; } + { + textId = action.chanced_text.TextId[0]; + } } if (textId) @@ -702,7 +722,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); } else // no id provided, assume reset and then use default - { m_creature->ClearTemporaryFaction(); } + { + m_creature->ClearTemporaryFaction(); + } break; } @@ -721,10 +743,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } // if no param1, then use value from param2 (modelId) else - { m_creature->SetDisplayId(action.morph.modelId); } + { + m_creature->SetDisplayId(action.morph.modelId); + } } else - { m_creature->DeMorph(); } + { + m_creature->DeMorph(); + } break; } case ACTION_T_SOUND: //4 @@ -842,14 +868,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, action.summon.duration); } else - { pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); } + { + pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); + } if (!pCreature) { sLog.outErrorEventAI("failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry()); } else if (action.summon.target != TARGET_T_SELF && target) - { pCreature->AI()->AttackStart(target); } + { + pCreature->AI()->AttackStart(target); + } break; } case ACTION_T_THREAT_SINGLE_PCT: //13 @@ -858,7 +888,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->GetThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_THREAT_SINGLE_PCT(%u), target-type %u", EventId, action.type, action.threat_single_pct.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_THREAT_SINGLE_PCT(%u), target-type %u", EventId, action.type, action.threat_single_pct.target); + } break; case ACTION_T_THREAT_ALL_PCT: //14 { @@ -879,7 +911,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_QUEST_EVENT(%u), target-type %u", EventId, action.type, action.quest_event.target); + } break; case ACTION_T_CAST_EVENT: //16 if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER)) @@ -890,7 +924,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_CST_EVENT(%u), target-type %u", EventId, action.type, action.cast_event.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_CST_EVENT(%u), target-type %u", EventId, action.type, action.cast_event.target); + } break; case ACTION_T_SET_UNIT_FIELD: //17 { @@ -903,7 +939,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FIELD(%u), target-type %u", EventId, action.type, action.set_unit_field.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FIELD(%u), target-type %u", EventId, action.type, action.set_unit_field.target); + } break; } @@ -913,7 +951,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SET_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); + } break; case ACTION_T_REMOVE_UNIT_FLAG: //19 if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError)) @@ -921,7 +961,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVE_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVE_UNIT_FLAG(%u), target-type %u", EventId, action.type, action.unit_flag.target); + } case ACTION_T_AUTO_ATTACK: //20 m_MeleeEnabled = action.auto_attack.state != 0; break; @@ -939,7 +981,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_creature->SendMeleeAttackStart(m_creature->getVictim()); } else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim()) - { m_creature->SendMeleeAttackStop(m_creature->getVictim()); } + { + m_creature->SendMeleeAttackStop(m_creature->getVictim()); + } break; case ACTION_T_SET_PHASE: //22 m_Phase = action.set_phase.phase; @@ -959,7 +1003,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_Phase = MAX_PHASE - 1; } else - { m_Phase = new_phase; } + { + m_Phase = new_phase; + } DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: ACTION_T_INC_PHASE - script %u for %s, phase is now %u", EventId, m_creature->GetGuidStr().c_str(), m_Phase); break; @@ -979,7 +1025,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 temp->GroupEventHappens(action.quest_event_all.questId, m_creature); } else if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER) - { ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); } + { + ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); + } break; case ACTION_T_CAST_EVENT_ALL: //27 { @@ -997,7 +1045,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 target->RemoveAurasDueToSpell(action.remove_aura.spellId); } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVEAURASFROMSPELL(%u), target-type %u", EventId, action.type, action.remove_aura.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_REMOVEAURASFROMSPELL(%u), target-type %u", EventId, action.type, action.remove_aura.target); + } break; case ACTION_T_RANGED_MOVEMENT: //29 m_attackDistance = (float)action.ranged_movement.distance; @@ -1023,7 +1073,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin)); } else - { sLog.outErrorEventAI("ACTION_T_RANDOM_PHASE_RANGE can not have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); } + { + sLog.outErrorEventAI("ACTION_T_RANDOM_PHASE_RANGE can not have Param2 <= Param1. Divide by Zero. Event = %d. CreatureEntry = %d", EventId, m_creature->GetEntry()); + } break; case ACTION_T_SUMMON_ID: //32 { @@ -1046,14 +1098,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, i->second.SpawnTimeSecs); } else - { pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); } + { + pCreature = m_creature->SummonCreature(action.summon_id.creatureId, i->second.position_x, i->second.position_y, i->second.position_z, i->second.orientation, TEMPSUMMON_TIMED_OOC_DESPAWN, 0); + } if (!pCreature) { sLog.outErrorEventAI("failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); } else if (action.summon_id.target != TARGET_T_SELF && target) - { pCreature->AI()->AttackStart(target); } + { + pCreature->AI()->AttackStart(target); + } break; } @@ -1074,7 +1130,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } } else if (reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_KILLED_MONSTER(%u), target-type %u", EventId, action.type, action.killed_monster.target); + } } break; case ACTION_T_SET_INST_DATA: //34 @@ -1155,7 +1213,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; } else - { m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; } + { + m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; + } break; } case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL: //43 @@ -1173,10 +1233,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } // if no param1, then use value from param2 (modelId) else - { m_creature->Mount(action.mount.modelId); } + { + m_creature->Mount(action.mount.modelId); + } } else - { m_creature->Unmount(); } + { + m_creature->Unmount(); + } break; } @@ -1242,7 +1306,9 @@ void CreatureEventAI::JustRespawned() // NOTE that this is } // Handle Spawned Events else if (SpawnedEventConditionsCheck((*i).Event)) - { ProcessEvent(*i); } + { + ProcessEvent(*i); + } } } @@ -1763,7 +1829,9 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage) damage = 0; } else - { damage = m_creature->GetHealth() - m_InvinceabilityHpLevel; } + { + damage = m_creature->GetHealth() - m_InvinceabilityHpLevel; + } } uint32 step = m_throwAIEventStep != 100 ? m_throwAIEventStep : 0; diff --git a/src/game/Object/CreatureEventAIMgr.cpp b/src/game/Object/CreatureEventAIMgr.cpp index 67c1ba5fb..d86adf606 100644 --- a/src/game/Object/CreatureEventAIMgr.cpp +++ b/src/game/Object/CreatureEventAIMgr.cpp @@ -598,7 +598,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() sLog.outErrorEventAI("Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1); } else if (action.chanced_text.chance >= 100) - { sLog.outErrorEventAI("Event %u Action %u has set chance param1 >= 100. Text will always be displayed", i, j + 1); } + { + sLog.outErrorEventAI("Event %u Action %u has set chance param1 >= 100. Text will always be displayed", i, j + 1); + } // no break here to check texts case ACTION_T_TEXT: { @@ -629,7 +631,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() action.text.TextId[k] = 0; } else - { usedTextIds.insert(action.text.TextId[k]); } + { + usedTextIds.insert(action.text.TextId[k]); + } } } break; @@ -786,7 +790,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() } } else - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId); + } IsValidTargetType(temp.event_type, action.type, action.quest_event.target, i, j + 1); break; @@ -824,7 +830,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() sLog.outErrorEventAI("Event %u Action %u is incrementing phase by 0. Was this intended?", i, j + 1); } else if (std::abs(action.set_inc_phase.step) > MAX_PHASE - 1) - { sLog.outErrorEventAI("Event %u Action %u is change phase by too large for any use %i.", i, j + 1, action.set_inc_phase.step); } + { + sLog.outErrorEventAI("Event %u Action %u is change phase by too large for any use %i.", i, j + 1, action.set_inc_phase.step); + } break; case ACTION_T_QUEST_EVENT_ALL: if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event_all.questId)) @@ -835,7 +843,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() } } else - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event_all.questId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event_all.questId); + } break; case ACTION_T_CAST_EVENT_ALL: if (!sCreatureStorage.LookupEntry(action.cast_event_all.creatureId)) @@ -1047,7 +1057,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() sLog.outErrorEventAI("EventAI not has script for creature entry (%u), but AIName = '%s'.", i, cInfo->AIName); } else if (!ainame && hasevent) - { sLog.outErrorEventAI("EventAI has script for creature entry (%u), but AIName = '%s' instead 'EventAI'.", i, cInfo->AIName); } + { + sLog.outErrorEventAI("EventAI has script for creature entry (%u), but AIName = '%s' instead 'EventAI'.", i, cInfo->AIName); + } } } diff --git a/src/game/Object/DynamicObject.cpp b/src/game/Object/DynamicObject.cpp index 8f3e42f34..a7d799de2 100644 --- a/src/game/Object/DynamicObject.cpp +++ b/src/game/Object/DynamicObject.cpp @@ -140,7 +140,9 @@ void DynamicObject::Update(uint32 /*update_diff*/, uint32 p_time) m_aliveDuration -= p_time; } else - { deleteThis = true; } + { + deleteThis = true; + } // have radius and work as persistent effect if (m_radius) @@ -201,7 +203,9 @@ void DynamicObject::Delay(int32 delaytime) ++iter; } else - { m_affected.erase(iter++); } + { + m_affected.erase(iter++); + } } } @@ -229,7 +233,9 @@ bool DynamicObject::IsHostileTo(Unit const* unit) const return owner->IsHostileTo(unit); } else - { return false; } + { + return false; + } } bool DynamicObject::IsFriendlyTo(Unit const* unit) const @@ -239,5 +245,7 @@ bool DynamicObject::IsFriendlyTo(Unit const* unit) const return owner->IsFriendlyTo(unit); } else - { return true; } + { + return true; + } } diff --git a/src/game/Object/Formulas.h b/src/game/Object/Formulas.h index 294aa9b18..c629d296c 100644 --- a/src/game/Object/Formulas.h +++ b/src/game/Object/Formulas.h @@ -49,11 +49,17 @@ namespace MaNGOS return 0; } else if (pl_level <= 39) - { return pl_level - 5 - pl_level / 10; } + { + return pl_level - 5 - pl_level / 10; + } else if (pl_level <= 59) + { return pl_level - 1 - pl_level / 5; + } else + { return pl_level - 9; + } } inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level) @@ -63,13 +69,21 @@ namespace MaNGOS return RED; } else if (mob_level >= pl_level + 3) - { return ORANGE; } + { + return ORANGE; + } else if (mob_level >= pl_level - 2) - { return YELLOW; } + { + return YELLOW; + } else if (mob_level > GetGrayLevel(pl_level)) - { return GREEN; } + { + return GREEN; + } else - { return GRAY; } + { + return GRAY; + } } inline uint32 GetZeroDifference(uint32 pl_level) diff --git a/src/game/Object/GameObject.cpp b/src/game/Object/GameObject.cpp index cff545554..5e50f5fe6 100644 --- a/src/game/Object/GameObject.cpp +++ b/src/game/Object/GameObject.cpp @@ -253,7 +253,9 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa ((BattleGroundMap*)map)->GetBG()->HandleGameObjectCreate(this); } else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) - { outdoorPvP->HandleGameObjectCreate(this); } + { + outdoorPvP->HandleGameObjectCreate(this); + } // Notify the map's instance data. // Only works if you create the object in it, not if it is moves to that map. @@ -539,7 +541,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) SetUInt32Value(GAMEOBJECT_FLAGS, (GetGOInfo()->flags & ~(GO_FLAG_LOCKED | GO_FLAG_INTERACT_COND | GO_FLAG_NO_INTERACT)) | currentLockOrInteractFlags); } else - { SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); } + { + SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); + } } loot.clear(); @@ -615,7 +619,9 @@ void GameObject::Delete() sPoolMgr.UpdatePool(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); } else - { AddObjectToRemoveList(); } + { + AddObjectToRemoveList(); + } } void GameObject::SaveToDB() @@ -845,7 +851,9 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi // invisible at client always if (!GetGOInfo()->displayId) + { return false; + } // Transport always visible at this step implementation if (IsTransport() && IsInMap(u)) @@ -881,14 +889,18 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi else { if (u->IsFriendlyTo(owner)) + { return true; + } } } // handle environment traps (spawned by DB) else { if (this->IsFriendlyTo(u)) + { return true; + } else trapNotVisible = true; } @@ -897,11 +909,15 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi if (Aura* aura = ((Player*)u)->GetAura(2836, EFFECT_INDEX_0)) { if (roll_chance_i(aura->GetModifier()->m_amount) && u->IsInFront(this, 15.0f)) + { return true; + } } if (trapNotVisible) + { return false; + } } } @@ -1156,14 +1172,18 @@ void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false * SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); } else - { RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); } + { + RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + } if (GetGoState() == GO_STATE_READY) // if closed -> open { SetGoState(alternative ? GO_STATE_ACTIVE_ALTERNATIVE : GO_STATE_ACTIVE); } else // if open -> close - { SetGoState(GO_STATE_READY); } + { + SetGoState(GO_STATE_READY); + } } void GameObject::Use(Unit* user) @@ -1412,7 +1432,9 @@ void GameObject::Use(Unit* user) SendGameObjectCustomAnim(GetObjectGuid()); } else - { SetGoState(GO_STATE_ACTIVE); } + { + SetGoState(GO_STATE_ACTIVE); + } m_cooldownTime = time(NULL) + info->GetAutoCloseTime(); @@ -1460,7 +1482,9 @@ void GameObject::Use(Unit* user) GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); } else - { return; } + { + return; + } // cast this spell later if provided spellId = info->goober.spellId; @@ -1587,7 +1611,9 @@ void GameObject::Use(Unit* user) SetLootState(GO_JUST_DEACTIVATED); } else - { player->SendLoot(GetObjectGuid(), success ? LOOT_FISHING : LOOT_FISHING_FAIL); } + { + player->SendLoot(GetObjectGuid(), success ? LOOT_FISHING : LOOT_FISHING_FAIL); + } } else { @@ -1661,7 +1687,9 @@ void GameObject::Use(Unit* user) } } else - { return; } + { + return; + } } spellCaster = player; @@ -1712,7 +1740,9 @@ void GameObject::Use(Unit* user) } // reset ritual for this GO else - { ClearAllUsesData(); } + { + ClearAllUsesData(); + } // go to end function to spell casting break; @@ -1879,10 +1909,14 @@ void GameObject::Use(Unit* user) { GameObjectInfo const* info = GetGOInfo(); if (!info) + { return; + } if (user->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)user; @@ -2379,13 +2413,21 @@ void GameObject::SetCapturePointSlider(float value, bool isLocked) m_captureState = CAPTURE_STATE_WIN_ALLIANCE; } else if ((int)m_captureSlider == CAPTURE_SLIDER_HORDE) - { m_captureState = CAPTURE_STATE_WIN_HORDE; } + { + m_captureState = CAPTURE_STATE_WIN_HORDE; + } else if (m_captureSlider > CAPTURE_SLIDER_MIDDLE + info->capturePoint.neutralPercent * 0.5f) - { m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; } + { + m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; + } else if (m_captureSlider < CAPTURE_SLIDER_MIDDLE - info->capturePoint.neutralPercent * 0.5f) - { m_captureState = CAPTURE_STATE_PROGRESS_HORDE; } + { + m_captureState = CAPTURE_STATE_PROGRESS_HORDE; + } else - { m_captureState = CAPTURE_STATE_NEUTRAL; } + { + m_captureState = CAPTURE_STATE_NEUTRAL; + } } void GameObject::TickCapturePoint() @@ -2413,7 +2455,9 @@ void GameObject::TickCapturePoint() ++rangePlayers; } else - { --rangePlayers; } + { + --rangePlayers; + } ObjectGuid guid = (*itr)->GetObjectGuid(); if (!tempUsers.erase(guid)) @@ -2462,7 +2506,9 @@ void GameObject::TickCapturePoint() rangePlayers = maxSuperiority; } else if (rangePlayers < -maxSuperiority) - { rangePlayers = -maxSuperiority; } + { + rangePlayers = -maxSuperiority; + } // time to capture from 0% to 100% is maxTime for minSuperiority amount of players and minTime for maxSuperiority amount of players (linear function: y = dy/dx*x+d) float deltaSlider = info->capturePoint.minTime; @@ -2597,7 +2643,9 @@ void GameObject::DealGameObjectDamage(uint32 damage, uint32 spell, Unit* caster) MANGOS_ASSERT(spell && sSpellStore.LookupEntry(spell) && caster); if (!damage) + { return; + } ForceGameObjectHealth(-int32(damage), caster); diff --git a/src/game/Object/GameObject.h b/src/game/Object/GameObject.h index 0b01bdba7..f573a0829 100644 --- a/src/game/Object/GameObject.h +++ b/src/game/Object/GameObject.h @@ -694,7 +694,9 @@ class GameObject : public WorldObject return m_respawnTime; } else - { return now; } + { + return now; + } } void SetRespawnTime(time_t respawn) diff --git a/src/game/Object/Guild.cpp b/src/game/Object/Guild.cpp index 92b24e2e3..07cc41dba 100644 --- a/src/game/Object/Guild.cpp +++ b/src/game/Object/Guild.cpp @@ -350,7 +350,9 @@ bool Guild::CheckGuildStructure() { return false; } // guild will disbanded and deleted in caller } else if (GM_rights != GR_GUILDMASTER) - { SetLeader(m_LeaderGuid); } + { + SetLeader(m_LeaderGuid); + } // Allow only 1 guildmaster, set other to officer for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) @@ -825,7 +827,9 @@ void Guild::AddRank(const std::string& name_, uint32 rights, uint32 money) void Guild::DelRank(uint32 rankId) { if (rankId >= m_Ranks.size()) + { return; + } // client won't allow to have less than GUILD_RANKS_MIN_COUNT ranks in guild if (m_Ranks.size() <= GUILD_RANKS_MIN_COUNT || rankId < GUILD_RANKS_MIN_COUNT) @@ -846,10 +850,14 @@ void Guild::DelRank(uint32 rankId) void Guild::SwitchRank(uint32 rankId, bool up) { if (rankId >= m_Ranks.size()) + { return; + } if ((rankId == GR_GUILDMASTER && up) || (rankId == GetLowestRank() && !up)) + { return; + } uint32 otherRankId = rankId + (up ? -1 : 1); DEBUG_LOG("rank: %u otherrank %u", rankId, otherRankId); @@ -1048,7 +1056,9 @@ void Guild::Roster(WorldSession* session /*= NULL*/) session->SendPacket(&data); } else - { BroadcastPacket(&data); } + { + BroadcastPacket(&data); + } DEBUG_LOG("WORLD: Sent (SMSG_GUILD_ROSTER)"); } @@ -1254,12 +1264,16 @@ void Guild::LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid pl void Guild::DisplayGuildBankContent(WorldSession* session, uint8 TabId) { if (TabId >= GetPurchasedTabs()) + { return; + } GuildBankTab const* tab = m_TabListMap[TabId]; if (!IsMemberHaveRights(session->GetPlayer()->GetGUIDLow(), TabId, GUILD_BANK_RIGHT_VIEW_TAB)) + { return; + } WorldPacket data(SMSG_GUILD_BANK_LIST, 1200); ByteBuffer buffer; @@ -1395,7 +1409,9 @@ void Guild::DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec cons Item* Guild::GetItem(uint8 TabId, uint8 SlotId) { if (TabId >= GetPurchasedTabs() || SlotId >= GUILD_BANK_MAX_SLOTS) + { return NULL; + } return m_TabListMap[TabId]->Slots[SlotId]; } @@ -1436,7 +1452,9 @@ void Guild::DisplayGuildBankTabsInfo(WorldSession* session) void Guild::CreateNewBankTab() { if (GetPurchasedTabs() >= GUILD_BANK_MAX_TABS) + { return; + } uint32 tabId = GetPurchasedTabs(); // next free id m_TabListMap.push_back(new GuildBankTab); @@ -1450,7 +1468,9 @@ void Guild::CreateNewBankTab() void Guild::SetGuildBankTabInfo(uint8 TabId, std::string Name, std::string Icon) { if (m_TabListMap[TabId]->Name == Name && m_TabListMap[TabId]->Icon == Icon) + { return; + } m_TabListMap[TabId]->Name = Name; m_TabListMap[TabId]->Icon = Icon; @@ -1463,7 +1483,9 @@ void Guild::SetGuildBankTabInfo(uint8 TabId, std::string Name, std::string Icon) uint32 Guild::GetBankRights(uint32 rankId, uint8 TabId) const { if (rankId >= m_Ranks.size() || TabId >= GUILD_BANK_MAX_TABS) + { return 0; + } return m_Ranks[rankId].TabRight[TabId]; } @@ -1508,7 +1530,9 @@ void Guild::LoadGuildBankFromDB() // 0 1 2 3 4 5 result = CharacterDatabase.PQuery("SELECT data, text, TabId, SlotId, item_guid, item_entry FROM guild_bank_item JOIN item_instance ON item_guid = guid WHERE guildid='%u' ORDER BY TabId", m_Id); if (!result) + { return; + } do { @@ -1571,7 +1595,9 @@ bool Guild::MemberMoneyWithdraw(uint64 amount, uint32 LowGuid) uint64 MoneyWithDrawRight = GetMemberMoneyWithdrawRem(LowGuid); if (MoneyWithDrawRight < amount || GetGuildBankMoney() < amount) + { return false; + } SetBankMoney(GetGuildBankMoney() - amount); @@ -1579,7 +1605,9 @@ bool Guild::MemberMoneyWithdraw(uint64 amount, uint32 LowGuid) { MemberList::iterator itr = members.find(LowGuid); if (itr == members.end()) + { return false; + } itr->second.BankRemMoney -= amount; CharacterDatabase.PExecute("UPDATE guild_member SET BankRemMoney='%u' WHERE guildid='%u' AND guid='%u'", itr->second.BankRemMoney, m_Id, LowGuid); @@ -1610,13 +1638,17 @@ bool Guild::MemberItemWithdraw(uint8 TabId, uint32 LowGuid) uint32 SlotsWithDrawRight = GetMemberSlotWithdrawRem(LowGuid, TabId); if (SlotsWithDrawRight == 0) + { return false; + } if (SlotsWithDrawRight < WITHDRAW_SLOT_UNLIMITED) { MemberList::iterator itr = members.find(LowGuid); if (itr == members.end()) + { return false; + } --itr->second.BankRemSlotsTab[TabId]; CharacterDatabase.PExecute("UPDATE guild_member SET BankRemSlotsTab%u='%u' WHERE guildid='%u' AND guid='%u'", uint32(TabId), itr->second.BankRemSlotsTab[TabId], m_Id, LowGuid); @@ -1628,10 +1660,14 @@ bool Guild::IsMemberHaveRights(uint32 LowGuid, uint8 TabId, uint32 rights) const { MemberList::const_iterator itr = members.find(LowGuid); if (itr == members.end()) + { return false; + } if (itr->second.RankId == GR_GUILDMASTER) + { return true; + } return (GetBankRights(itr->second.RankId, TabId) & rights) == rights; } @@ -1640,14 +1676,20 @@ uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId) { MemberList::iterator itr = members.find(LowGuid); if (itr == members.end()) + { return 0; + } MemberSlot& member = itr->second; if (member.RankId == GR_GUILDMASTER) + { return WITHDRAW_SLOT_UNLIMITED; + } if ((GetBankRights(member.RankId, TabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB) + { return 0; + } uint32 curTime = uint32(time(NULL) / MINUTE); if (curTime - member.BankResetTimeTab[TabId] >= 24 * HOUR / MINUTE) @@ -1664,11 +1706,15 @@ uint64 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid) { MemberList::iterator itr = members.find(LowGuid); if (itr == members.end()) + { return 0; + } MemberSlot& member = itr->second; if (member.RankId == GR_GUILDMASTER) + { return WITHDRAW_MONEY_UNLIMITED; + } uint32 curTime = uint32(time(NULL) / MINUTE); // minutes // 24 hours @@ -1685,7 +1731,9 @@ uint64 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid) void Guild::SetBankMoneyPerDay(uint32 rankId, uint32 money) { if (rankId >= m_Ranks.size()) + { return; + } if (rankId == GR_GUILDMASTER) money = (uint32)WITHDRAW_MONEY_UNLIMITED; @@ -1738,20 +1786,28 @@ void Guild::SetBankRightsAndSlots(uint32 rankId, uint8 TabId, uint32 right, uint uint32 Guild::GetBankMoneyPerDay(uint32 rankId) { if (rankId >= m_Ranks.size()) + { return 0; + } if (rankId == GR_GUILDMASTER) + { return (uint32)WITHDRAW_MONEY_UNLIMITED; + } return m_Ranks[rankId].BankMoneyPerDay; } uint32 Guild::GetBankSlotPerDay(uint32 rankId, uint8 TabId) { if (rankId >= m_Ranks.size() || TabId >= GUILD_BANK_MAX_TABS) + { return 0; + } if (rankId == GR_GUILDMASTER) + { return WITHDRAW_SLOT_UNLIMITED; + } return m_Ranks[rankId].TabSlotPerDay[TabId]; } @@ -1761,7 +1817,9 @@ uint32 Guild::GetBankSlotPerDay(uint32 rankId, uint8 TabId) bool Guild::LoadBankRightsFromDB(QueryResult* guildBankTabRightsResult) { if (!guildBankTabRightsResult) + { return true; + } do { @@ -1850,7 +1908,9 @@ void Guild::LoadGuildBankEventLogFromDB() // 0 1 2 3 4 5 6 QueryResult* result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog WHERE guildid='%u' AND TabId='%u' ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_BANK_MONEY_LOGS_TAB, GUILD_BANK_MAX_LOGS); if (!result) + { return; + } bool isNextMoneyLogGuidSet = false; do @@ -1886,7 +1946,9 @@ void Guild::LoadGuildBankEventLogFromDB() void Guild::DisplayGuildBankLogs(WorldSession* session, uint8 TabId) { if (TabId > GUILD_BANK_MAX_TABS) + { return; + } ByteBuffer buffer; bool hasCashFlow = GetLevel() >= 5 && TabId == GUILD_BANK_MAX_TABS; // has Cash Flow perk @@ -2013,7 +2075,9 @@ void Guild::AppendDisplayGuildBankSlot(WorldPacket& data, ByteBuffer& buffer, Gu Item* Guild::StoreItem(uint8 tabId, GuildItemPosCountVec const& dest, Item* pItem) { if (!pItem) + { return NULL; + } Item* lastItem = pItem; @@ -2040,7 +2104,9 @@ Item* Guild::StoreItem(uint8 tabId, GuildItemPosCountVec const& dest, Item* pIte Item* Guild::_StoreItem(uint8 tab, uint8 slot, Item* pItem, uint32 count, bool clone) { if (!pItem) + { return NULL; + } DEBUG_LOG("GUILD STORAGE: StoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count); @@ -2054,7 +2120,9 @@ Item* Guild::_StoreItem(uint8 tab, uint8 slot, Item* pItem, uint32 count, bool c pItem->SetCount(count); if (!pItem) + { return NULL; + } m_TabListMap[tab]->Slots[slot] = pItem; @@ -2111,11 +2179,15 @@ InventoryResult Guild::_CanStoreItem_InSpecificSlot(uint8 tab, uint8 slot, Guild { // check item type if (pItem2->GetEntry() != pSrcItem->GetEntry()) + { return EQUIP_ERR_ITEM_CANT_STACK; + } // check free space if (pItem2->GetCount() >= pSrcItem->GetMaxStackCount()) + { return EQUIP_ERR_ITEM_CANT_STACK; + } need_space = pSrcItem->GetMaxStackCount() - pItem2->GetCount(); } @@ -2166,7 +2238,9 @@ InventoryResult Guild::_CanStoreItem_InTab(uint8 tab, GuildItemPosCountVec& dest count -= need_space; if (count == 0) + { return EQUIP_ERR_OK; + } } } } @@ -2183,7 +2257,9 @@ InventoryResult Guild::_CanStoreItem_InTab(uint8 tab, GuildItemPosCountVec& dest count -= need_space; if (count == 0) + { return EQUIP_ERR_OK; + } } } } @@ -2195,20 +2271,28 @@ InventoryResult Guild::CanStoreItem(uint8 tab, uint8 slot, GuildItemPosCountVec& DEBUG_LOG("GUILD STORAGE: CanStoreItem tab = %u, slot = %u, item = %u, count = %u", tab, slot, pItem->GetEntry(), count); if (count > pItem->GetCount()) + { return EQUIP_ERR_COULDNT_SPLIT_ITEMS; + } if (pItem->IsSoulBound()) + { return EQUIP_ERR_CANT_DROP_SOULBOUND; + } // in specific slot if (slot != NULL_SLOT) { InventoryResult res = _CanStoreItem_InSpecificSlot(tab, slot, dest, count, swap, pItem); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } } // not specific slot or have space for partly store only in specific slot @@ -2218,19 +2302,27 @@ InventoryResult Guild::CanStoreItem(uint8 tab, uint8 slot, GuildItemPosCountVec& { InventoryResult res = _CanStoreItem_InTab(tab, dest, count, true, pItem, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } } // search free slot in bag for place to InventoryResult res = _CanStoreItem_InTab(tab, dest, count, false, pItem, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } return EQUIP_ERR_BANK_FULL; } @@ -2238,13 +2330,19 @@ InventoryResult Guild::CanStoreItem(uint8 tab, uint8 slot, GuildItemPosCountVec& void Guild::SetGuildBankTabText(uint8 TabId, std::string text) { if (TabId >= GetPurchasedTabs()) + { return; + } if (!m_TabListMap[TabId]) + { return; + } if (m_TabListMap[TabId]->Text == text) + { return; + } utf8truncate(text, 500); // DB and client size limitation @@ -2276,11 +2374,15 @@ void Guild::SwapItems(Player* pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTa { // empty operation if (BankTab == BankTabDst && BankTabSlot == BankTabSlotDst) + { return; + } Item* pItemSrc = GetItem(BankTab, BankTabSlot); if (!pItemSrc) // may prevent crash + { return; + } if (SplitedAmount > pItemSrc->GetCount()) return; // cheating? @@ -2293,12 +2395,16 @@ void Guild::SwapItems(Player* pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTa { // check dest pos rights (if different tabs) if (!IsMemberHaveRights(pl->GetGUIDLow(), BankTabDst, GUILD_BANK_RIGHT_DEPOSIT_ITEM)) + { return; + } // check source pos rights (if different tabs) uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab); if (remRight <= 0) + { return; + } } if (SplitedAmount) @@ -2368,12 +2474,16 @@ void Guild::SwapItems(Player* pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTa { // check source pos rights (item swapped to src) if (!IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM)) + { return; + } // check dest pos rights (item swapped to src) uint32 remRightDst = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTabDst); if (remRightDst <= 0) + { return; + } } CharacterDatabase.BeginTransaction(); @@ -2403,7 +2513,9 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin Item* pItemChar = pl->GetItemByPos(PlayerBag, PlayerSlot); if (!pItemBank) // Problem to get bank item + { return; + } if (SplitedAmount > pItemBank->GetCount()) return; // cheating? @@ -2458,7 +2570,9 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin // check source pos rights (item moved to inventory) uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab); if (remRight <= 0) + { return; + } CharacterDatabase.BeginTransaction(); LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), pItemBank->GetCount()); @@ -2474,7 +2588,9 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin { // check source pos rights (item swapped to bank) if (!IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM)) + { return; + } if (pItemChar) { @@ -2507,7 +2623,9 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin // check source pos rights (item moved to inventory) uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab); if (remRight <= 0) + { return; + } if (pItemChar) { @@ -2551,7 +2669,9 @@ void Guild::MoveFromCharToBank(Player* pl, uint8 PlayerBag, uint8 PlayerSlot, ui Item* pItemChar = pl->GetItemByPos(PlayerBag, PlayerSlot); if (!pItemChar) // Problem to get item from player + { return; + } if (!pItemChar->CanBeTraded()) { @@ -2561,7 +2681,9 @@ void Guild::MoveFromCharToBank(Player* pl, uint8 PlayerBag, uint8 PlayerSlot, ui // check source pos rights (item moved to bank) if (!IsMemberHaveRights(pl->GetGUIDLow(), BankTab, GUILD_BANK_RIGHT_DEPOSIT_ITEM)) + { return; + } if (SplitedAmount > pItemChar->GetCount()) return; // cheating? @@ -2659,7 +2781,9 @@ void Guild::MoveFromCharToBank(Player* pl, uint8 PlayerBag, uint8 PlayerSlot, ui // check bank pos rights (item swapped with inventory) uint32 remRight = GetMemberSlotWithdrawRem(pl->GetGUIDLow(), BankTab); if (remRight <= 0) + { return; + } } // logging item move to bank @@ -2714,7 +2838,9 @@ void Guild::BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1 data << str2; } else if (str1) - { data << str1; } + { + data << str1; + } if (guid) data << ObjectGuid(guid); @@ -2749,7 +2875,9 @@ bool GuildItemPosCount::isContainedIn(GuildItemPosCountVec const& vec) const { for (GuildItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end(); ++itr) if (itr->Slot == this->Slot) + { return true; + } return false; } diff --git a/src/game/Object/Guild.h b/src/game/Object/Guild.h index 7cd630d15..46b5a25a1 100644 --- a/src/game/Object/Guild.h +++ b/src/game/Object/Guild.h @@ -424,7 +424,9 @@ class Guild { for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) if (itr->second.RankId == rankId) + { return true; + } return false; } diff --git a/src/game/Object/Item.cpp b/src/game/Object/Item.cpp index 2de6f36c0..a0ad983d0 100644 --- a/src/game/Object/Item.cpp +++ b/src/game/Object/Item.cpp @@ -80,7 +80,9 @@ void AddItemsSetItem(Player* player, Item* item) player->ItemSetEff[x] = eff; } else - { player->ItemSetEff.push_back(eff); } + { + player->ItemSetEff.push_back(eff); + } } ++eff->item_count; @@ -228,7 +230,9 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt return true; case ITEM_SUBCLASS_MINING_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_MINING_SUPP)) + { return false; + } return true; case ITEM_SUBCLASS_ENGINEERING_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_ENGINEERING_SUPP)) @@ -238,19 +242,27 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt return true; case ITEM_SUBCLASS_GEM_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_GEMS)) + { return false; + } return true; case ITEM_SUBCLASS_LEATHERWORKING_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_LEATHERWORKING_SUPP)) + { return false; + } return true; case ITEM_SUBCLASS_INSCRIPTION_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_INSCRIPTION_SUPP)) + { return false; + } return true; case ITEM_SUBCLASS_FISHING_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_FISHING_SUPP)) + { return false; + } return true; default: return false; @@ -280,7 +292,9 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt uint32 ItemPrototype::GetArmor() const { if (Quality >= ITEM_QUALITY_HEIRLOOM) // heirlooms have it's own dbc... + { return 0; + } if (Class == ITEM_CLASS_ARMOR && SubClass == ITEM_SUBCLASS_ARMOR_SHIELD) { @@ -295,7 +309,9 @@ uint32 ItemPrototype::GetArmor() const ItemArmorTotalEntry const* iat = sItemArmorTotalStore.LookupEntry(ItemLevel); if (!iaq || !iat) + { return 0; + } if (InventoryType != INVTYPE_HEAD && InventoryType != INVTYPE_CHEST && InventoryType != INVTYPE_SHOULDERS && InventoryType != INVTYPE_LEGS && InventoryType != INVTYPE_FEET && InventoryType != INVTYPE_WRISTS && @@ -311,7 +327,9 @@ uint32 ItemPrototype::GetArmor() const al = sArmorLocationStore.LookupEntry(InventoryType); if (!al) + { return 0; + } float iatMult, alMult; @@ -347,7 +365,9 @@ float ItemPrototype::getDPS() const if (Class == ITEM_CLASS_WEAPON) { if (Quality >= ITEM_QUALITY_HEIRLOOM) // heirlooms have it's own dbc... + { return damage; + } ItemDamageEntry const* id = NULL; @@ -395,7 +415,9 @@ float ItemPrototype::getDPS() const } if (!id) + { return damage; + } return id->Value[Quality]; } @@ -455,7 +477,9 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) bool Item::IsNotEmptyBag() const { if (Bag const* bag = ToBag()) + { return !bag->IsEmpty(); + } return false; } @@ -820,7 +844,9 @@ uint32 Item::GetSkill() return 0; } else - { return item_weapon_skills[proto->SubClass]; } + { + return item_weapon_skills[proto->SubClass]; + } case ITEM_CLASS_ARMOR: if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR) @@ -828,7 +854,9 @@ uint32 Item::GetSkill() return 0; } else - { return item_armor_skills[proto->SubClass]; } + { + return item_armor_skills[proto->SubClass]; + } default: return 0; @@ -846,7 +874,9 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id) // item must have one from this field values not null if it can have random enchantments if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix)) + { return 0; + } // Random Property case if (itemProto->RandomProperty) @@ -920,7 +950,9 @@ bool Item::UpdateItemSuffixFactor() { uint32 suffixFactor = GenerateEnchSuffixFactor(GetEntry()); if (GetItemSuffixFactor() == suffixFactor) + { return false; + } SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, suffixFactor); return true; } @@ -1086,7 +1118,9 @@ bool Item::IsBoundByEnchant() const } if (enchant_slot == TRANSMOGRIFY_ENCHANTMENT_SLOT) + { return true; + } if (enchant_slot > PRISMATIC_ENCHANTMENT_SLOT && enchant_slot < PROP_ENCHANTMENT_SLOT_0) continue; @@ -1118,7 +1152,9 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const { // EffectItemType[0] is the associated scroll itemID, if a scroll can be made if (spellEffect_0->EffectItemType == 0) + { return false; + } // Other checks do not apply to vellum enchants, so return final result int32 eqItemClass = spellInfo->GetEquippedItemClass(); return proto->SubClass == ITEM_SUBCLASS_VELLUM && (eqItemClass == ITEM_CLASS_WEAPON || eqItemClass == ITEM_CLASS_ARMOR); @@ -1127,7 +1163,9 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const SpellEquippedItemsEntry const* equippedItems = spellInfo->GetSpellEquippedItems(); if (!equippedItems) + { return true; + } if (equippedItems->EquippedItemClass != -1) // -1 == any item class { @@ -1339,7 +1377,9 @@ void Item::SendTimeUpdate(Player* owner) { #ifdef ENABLE_PLAYERBOTS if (!owner || !owner->IsInWorld() || owner->GetPlayerbotAI()) + { return; + } #endif uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION); @@ -1380,7 +1420,9 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 r return pItem; } else - { delete pItem; } + { + delete pItem; + } } return NULL; } @@ -1422,7 +1464,9 @@ bool Item::IsBindedNotWith(Player const* player) const // not BOA item case if (!IsBoundAccountWide()) + { return true; + } // online if (Player* owner = GetOwner()) @@ -1514,7 +1558,9 @@ bool Item::HasMaxCharges() const for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) if (GetSpellCharges(i) != itemProto->Spells[i].SpellCharges) + { return false; + } return true; } @@ -1563,7 +1609,9 @@ void Item::SetLootState(ItemLootUpdateState state) } // temporary must stay until remove (ignore any changes) else if (m_lootState != ITEM_LOOT_TEMPORARY) - { m_lootState = ITEM_LOOT_UNCHANGED; } + { + m_lootState = ITEM_LOOT_UNCHANGED; + } break; case ITEM_LOOT_REMOVED: // if loot not saved then it existence in past can be just ignored @@ -1628,17 +1676,23 @@ int32 Item::GetReforgableStat(ItemModType statType) const ItemPrototype const* proto = GetProto(); for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i) if (proto->ItemStat[i].ItemStatType == statType) + { return proto->ItemStat[i].ItemStatValue; + } int32 randomPropId = GetItemRandomPropertyId(); if (!randomPropId) + { return 0; + } if (randomPropId < 0) { ItemRandomSuffixEntry const* randomSuffix = sItemRandomSuffixStore.LookupEntry(-randomPropId); if (!randomSuffix) + { return 0; + } for (uint32 e = PROP_ENCHANTMENT_SLOT_0; e <= PROP_ENCHANTMENT_SLOT_4; ++e) { @@ -1651,7 +1705,9 @@ int32 Item::GetReforgableStat(ItemModType statType) const for (int k = 0; k < 5; ++k) { if (randomSuffix->enchant_id[k] == enchant->ID) + { return int32((randomSuffix->prefix[k] * GetItemSuffixFactor()) / 10000); + } } } } @@ -1662,7 +1718,9 @@ int32 Item::GetReforgableStat(ItemModType statType) const { ItemRandomPropertiesEntry const* randomProp = sItemRandomPropertiesStore.LookupEntry(randomPropId); if (!randomProp) + { return 0; + } for (uint32 e = PROP_ENCHANTMENT_SLOT_0; e <= PROP_ENCHANTMENT_SLOT_4; ++e) { @@ -1675,7 +1733,9 @@ int32 Item::GetReforgableStat(ItemModType statType) const for (int k = 0; k < 3; ++k) { if (randomProp->enchant_id[k] == enchant->ID) + { return int32(enchant->amount[k]); + } } } } diff --git a/src/game/Object/ItemEnchantmentMgr.cpp b/src/game/Object/ItemEnchantmentMgr.cpp index 348ef7f4e..814988da7 100644 --- a/src/game/Object/ItemEnchantmentMgr.cpp +++ b/src/game/Object/ItemEnchantmentMgr.cpp @@ -168,13 +168,19 @@ uint32 GenerateEnchSuffixFactor(uint32 item_id) ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(item_id); if (!itemProto) + { return 0; + } if (!itemProto->RandomSuffix) + { return 0; + } RandomPropertiesPointsEntry const* randomProperty = sRandomPropertiesPointsStore.LookupEntry(itemProto->ItemLevel); if (!randomProperty) + { return 0; + } uint32 suffixFactor; switch (itemProto->InventoryType) diff --git a/src/game/Object/LootMgr.cpp b/src/game/Object/LootMgr.cpp index 9df3e460c..a19de936f 100644 --- a/src/game/Object/LootMgr.cpp +++ b/src/game/Object/LootMgr.cpp @@ -274,11 +274,15 @@ bool LootStoreItem::Roll(bool rate) const } if (type == LOOTITEM_TYPE_CURRENCY) + { return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_CURRENCY) : 1.0f)); + } else { if (needs_quest) + { return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_QUEST) : 1.0f)); + } ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); @@ -436,7 +440,9 @@ bool LootItem::AllowedForPlayer(Player const* player, WorldObject const* lootTar { // DB conditions check if (conditionId && !sObjectMgr.IsPlayerMeetToCondition(conditionId, player, player->GetMap(), lootTarget, CONDITION_FROM_LOOT)) + { return false; + } if (type == LOOT_ITEM_TYPE_ITEM) { @@ -592,7 +598,9 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, } // ... for personal loot else - { FillNotNormalLootFor(loot_owner); } + { + FillNotNormalLootFor(loot_owner); + } return true; } @@ -753,7 +761,9 @@ void Loot::NotifyItemRemoved(uint8 lootIndex) pl->SendNotifyLootItemRemoved(lootIndex); } else - { m_playersLooting.erase(i); } + { + m_playersLooting.erase(i); + } } } @@ -770,7 +780,9 @@ void Loot::NotifyMoneyRemoved() pl->SendNotifyLootMoneyRemoved(); } else - { m_playersLooting.erase(i); } + { + m_playersLooting.erase(i); + } } } @@ -808,7 +820,9 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) } } else - { m_playersLooting.erase(i); } + { + m_playersLooting.erase(i); + } } } @@ -821,9 +835,13 @@ void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount) gold = uint32(maxAmount * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); } else if ((maxAmount - minAmount) < 32700) - { gold = uint32(urand(minAmount, maxAmount) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); } + { + gold = uint32(urand(minAmount, maxAmount) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); + } else - { gold = uint32(urand(minAmount >> 8, maxAmount >> 8) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)) << 8; } + { + gold = uint32(urand(minAmount >> 8, maxAmount >> 8) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)) << 8; + } } } @@ -1071,7 +1089,9 @@ void LootTemplate::LootGroup::AddEntry(LootStoreItem& item) ExplicitlyChanced.push_back(item); } else - { EqualChanced.push_back(item); } + { + EqualChanced.push_back(item); + } } // Rolls an item from the group, returns NULL if all miss their chances @@ -1197,7 +1217,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); } else if (ref_set) - { ref_set->erase(-ieItr->mincountOrRef); } + { + ref_set->erase(-ieItr->mincountOrRef); + } } } @@ -1210,7 +1232,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); } else if (ref_set) - { ref_set->erase(-ieItr->mincountOrRef); } + { + ref_set->erase(-ieItr->mincountOrRef); + } } } } @@ -1229,7 +1253,9 @@ void LootTemplate::AddEntry(LootStoreItem& item) Groups[item.group - 1].AddEntry(item); // Adds new entry to the group } else // Non-grouped entries and references are stored together - { Entries.push_back(item); } + { + Entries.push_back(item); + } } // Rolls for every item in the template and adds the rolled items the the loot @@ -1369,7 +1395,9 @@ void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); } else if (ref_set) - { ref_set->erase(-ieItr->mincountOrRef); } + { + ref_set->erase(-ieItr->mincountOrRef); + } } } @@ -1394,7 +1422,9 @@ void LoadLootTemplates_Creature() LootTemplates_Creature.ReportNotExistedId(lootid); } else - { ids_setUsed.insert(lootid); } + { + ids_setUsed.insert(lootid); + } } } } @@ -1426,7 +1456,9 @@ void LoadLootTemplates_Disenchant() LootTemplates_Disenchant.ReportNotExistedId(lootid); } else - { ids_setUsed.insert(lootid); } + { + ids_setUsed.insert(lootid); + } } } } @@ -1473,7 +1505,9 @@ void LoadLootTemplates_Gameobject() LootTemplates_Gameobject.ReportNotExistedId(lootid); } else - { ids_setUsed.insert(lootid); } + { + ids_setUsed.insert(lootid); + } } } for (LootIdSet::const_iterator itr = ids_setUsed.begin(); itr != ids_setUsed.end(); ++itr) @@ -1504,7 +1538,9 @@ void LoadLootTemplates_Item() } // wdb have wrong data cases, so skip by default else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) - { LootTemplates_Item.ReportNotExistedId(proto->ItemId); } + { + LootTemplates_Item.ReportNotExistedId(proto->ItemId); + } } } @@ -1554,7 +1590,9 @@ void LoadLootTemplates_Pickpocketing() LootTemplates_Pickpocketing.ReportNotExistedId(lootid); } else - { ids_setUsed.insert(lootid); } + { + ids_setUsed.insert(lootid); + } } } } @@ -1624,7 +1662,9 @@ void LoadLootTemplates_Skinning() LootTemplates_Skinning.ReportNotExistedId(lootid); } else - { ids_setUsed.insert(lootid); } + { + ids_setUsed.insert(lootid); + } } } } diff --git a/src/game/Object/Object.cpp b/src/game/Object/Object.cpp index 5747f6383..481cf7333 100644 --- a/src/game/Object/Object.cpp +++ b/src/game/Object/Object.cpp @@ -1574,7 +1574,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap z = max_z; } else if (z < ground_z) - { z = ground_z; } + { + z = ground_z; + } } } else @@ -1601,7 +1603,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap z = max_z; } else if (z < ground_z) - { z = ground_z; } + { + z = ground_z; + } } } else @@ -1681,7 +1685,9 @@ namespace MaNGOS text = i_textData->Content[loc_idx + 1].c_str(); } else - { text = i_textData->Content[0].c_str(); } + { + text = i_textData->Content[0].c_str(); + } ChatHandler::BuildChatPacket(data, i_msgtype, text, i_language, CHAT_TAG_NONE, i_object.GetObjectGuid(), i_object.GetNameForLocaleIdx(loc_idx), i_target ? i_target->GetObjectGuid() : ObjectGuid(), i_target ? i_target->GetNameForLocaleIdx(loc_idx) : ""); @@ -1906,7 +1912,9 @@ GameObject* WorldObject::SummonGameObject(uint32 id, float x, float y, float z, Map *map = GetMap(); if (!map) + { return NULL; + } if (!pGameObj->Create(map->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), id, map, GetPhaseMask(), x, y, z, angle)) { @@ -2001,7 +2009,9 @@ namespace MaNGOS angle -= 2.0f * M_PI_F; } else if (angle < -M_PI_F) - { angle += 2.0f * M_PI_F; } + { + angle += 2.0f * M_PI_F; + } i_selector.AddUsedArea(u, angle, dist2d); } @@ -2035,7 +2045,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, if (searcher) { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available else - { UpdateGroundPositionZ(x, y, z); } + { + UpdateGroundPositionZ(x, y, z); + } return; } @@ -2063,7 +2075,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, if (searcher) { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available else - { UpdateGroundPositionZ(x, y, z); } + { + UpdateGroundPositionZ(x, y, z); + } if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) { @@ -2087,7 +2101,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, if (searcher) { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available else - { UpdateGroundPositionZ(x, y, z); } + { + UpdateGroundPositionZ(x, y, z); + } if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) { @@ -2105,7 +2121,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, if (searcher) { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available else - { UpdateGroundPositionZ(x, y, z); } + { + UpdateGroundPositionZ(x, y, z); + } return; } @@ -2121,7 +2139,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, if (searcher) { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available else - { UpdateGroundPositionZ(x, y, z); } + { + UpdateGroundPositionZ(x, y, z); + } if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) { @@ -2136,7 +2156,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, if (searcher) { searcher->UpdateAllowedPositionZ(x, y, z, GetMap()); } // update to LOS height if available else - { UpdateGroundPositionZ(x, y, z); } + { + UpdateGroundPositionZ(x, y, z); + } } void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update) @@ -2158,7 +2180,9 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player const* target /*= NU target->SendDirectMessage(&data); } else - { SendMessageToSet(&data, true); } + { + SendMessageToSet(&data, true); + } } void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL*/) const @@ -2171,7 +2195,9 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL target->SendDirectMessage(&data); } else - { SendMessageToSet(&data, true); } + { + SendMessageToSet(&data, true); + } } void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) const @@ -2183,7 +2209,9 @@ void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) co target->SendDirectMessage(&data); } else - { SendMessageToSet(&data, true); } + { + SendMessageToSet(&data, true); + } } void WorldObject::UpdateVisibilityAndView() @@ -2288,7 +2316,9 @@ void WorldObject::SetActiveObjectState(bool active) GetMap()->RemoveFromActive(this); } else if (!IsActiveObject() && active) - { GetMap()->AddToActive(this); } + { + GetMap()->AddToActive(this); + } } m_isActiveObject = active; } diff --git a/src/game/Object/Object.h b/src/game/Object/Object.h index 4582d145a..b24365f00 100644 --- a/src/game/Object/Object.h +++ b/src/game/Object/Object.h @@ -292,7 +292,9 @@ class Object RemoveFlag(index, flag); } else - { SetFlag(index, flag); } + { + SetFlag(index, flag); + } } /** @@ -316,7 +318,9 @@ class Object SetFlag(index, flag); } else - { RemoveFlag(index, flag); } + { + RemoveFlag(index, flag); + } } void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag); @@ -329,7 +333,9 @@ class Object RemoveByteFlag(index, offset, flag); } else - { SetByteFlag(index, offset, flag); } + { + SetByteFlag(index, offset, flag); + } } bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const @@ -346,7 +352,9 @@ class Object SetByteFlag(index, offset, flag); } else - { RemoveByteFlag(index, offset, flag); } + { + RemoveByteFlag(index, offset, flag); + } } void SetShortFlag(uint16 index, bool highpart, uint16 newFlag); @@ -359,7 +367,9 @@ class Object RemoveShortFlag(index, highpart, flag); } else - { SetShortFlag(index, highpart, flag); } + { + SetShortFlag(index, highpart, flag); + } } bool HasShortFlag(uint16 index, bool highpart, uint8 flag) const @@ -375,7 +385,9 @@ class Object SetShortFlag(index, highpart, flag); } else - { RemoveShortFlag(index, highpart, flag); } + { + RemoveShortFlag(index, highpart, flag); + } } void SetFlag64(uint16 index, uint64 newFlag) @@ -399,7 +411,9 @@ class Object RemoveFlag64(index, flag); } else - { SetFlag64(index, flag); } + { + SetFlag64(index, flag); + } } bool HasFlag64(uint16 index, uint64 flag) const @@ -415,7 +429,9 @@ class Object SetFlag64(index, flag); } else - { RemoveFlag64(index, flag); } + { + RemoveFlag64(index, flag); + } } void ClearUpdateMask(bool remove); diff --git a/src/game/Object/ObjectMgr.cpp b/src/game/Object/ObjectMgr.cpp index 95e2067c0..6d008940b 100644 --- a/src/game/Object/ObjectMgr.cpp +++ b/src/game/Object/ObjectMgr.cpp @@ -130,20 +130,26 @@ LanguageDesc const* GetLanguageDescByID(uint32 lang) bool SpellClickInfo::IsFitToRequirements(Player const* player, Creature const* clickedCreature) const { if (conditionId) + { return sObjectMgr.IsPlayerMeetToCondition(conditionId, player, player->GetMap(), clickedCreature, CONDITION_FROM_SPELLCLICK); + } if (questStart) { // not in expected required quest state if (!player || ((!questStartCanActive || !player->IsActiveQuest(questStart)) && !player->GetQuestRewardStatus(questStart))) + { return false; + } } if (questEnd) { // not in expected forbidden quest state if (!player || player->GetQuestRewardStatus(questEnd)) + { return false; + } } return true; @@ -220,7 +226,9 @@ ArenaTeam* ObjectMgr::GetArenaTeamById(uint32 arenateamid) const { ArenaTeamMap::const_iterator itr = mArenaTeamMap.find(arenateamid); if (itr != mArenaTeamMap.end()) + { return itr->second; + } return NULL; } @@ -229,7 +237,9 @@ ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const { for (ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) if (itr->second->GetName() == arenateamname) + { return itr->second; + } return NULL; } @@ -238,7 +248,9 @@ ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(ObjectGuid guid) const { for (ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) if (itr->second->GetCaptainGuid() == guid) + { return itr->second; + } return NULL; } @@ -641,7 +653,9 @@ void ObjectMgr::LoadCreatureTemplates() const_cast(cInfo)->ModelId[i] = 0; } else if (!displayScaleEntry) - { displayScaleEntry = displayEntry; } + { + displayScaleEntry = displayEntry; + } CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(cInfo->ModelId[i]); if (!minfo) @@ -791,7 +805,9 @@ void ObjectMgr::LoadCreatureTemplates() const_cast(cInfo)->Scale = displayScaleEntry->Scale; } else - { const_cast(cInfo)->Scale = DEFAULT_OBJECT_SCALE; } + { + const_cast(cInfo)->Scale = DEFAULT_OBJECT_SCALE; + } } } } @@ -1021,12 +1037,16 @@ void ObjectMgr::LoadCreatureClassLvlStats() CreatureClassLvlStats const* ObjectMgr::GetCreatureClassLvlStats(uint32 level, uint32 unitClass, int32 expansion) const { if (expansion < 0) + { return NULL; + } CreatureClassLvlStats const* cCLS = &m_creatureClassLvlStats[level][classToIndex[unitClass]][expansion]; if (cCLS->BaseHealth != 0 && cCLS->BaseDamage > 0.1f) + { return cCLS; + } return NULL; } @@ -1084,7 +1104,9 @@ void ObjectMgr::LoadEquipmentTemplates() uint32 ObjectMgr::GetCreatureModelAlternativeModel(uint32 modelId) const { if (const CreatureModelInfo* modelInfo = GetCreatureModelInfo(modelId)) + { return modelInfo->modelid_alternative; + } return 0; } @@ -1107,10 +1129,14 @@ CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_ return minfo; // not fatal, just use the previous one } else - { return minfo_tmp; } + { + return minfo_tmp; + } } else - { return minfo; } + { + return minfo; + } } uint32 ObjectMgr::GetModelForRace(uint32 sourceModelId, uint32 racemask) @@ -1230,7 +1256,9 @@ void ObjectMgr::LoadCreatureModelInfo() } } else - { sLog.outErrorDb("Table `creature_model_info` expect have data for character race %u female model id %u", race, raceEntry->model_f); } + { + sLog.outErrorDb("Table `creature_model_info` expect have data for character race %u female model id %u", race, raceEntry->model_f); + } if (CreatureModelInfo const* minfo = GetCreatureModelInfo(raceEntry->model_m)) { @@ -1257,7 +1285,9 @@ void ObjectMgr::LoadCreatureModelInfo() } } else - { sLog.outErrorDb("Table `creature_model_info` expect have data for character race %u male model id %u", race, raceEntry->model_m); } + { + sLog.outErrorDb("Table `creature_model_info` expect have data for character race %u male model id %u", race, raceEntry->model_m); + } } sLog.outString(">> Loaded %u creature model based info", sCreatureModelStorage.GetRecordCount()); @@ -3565,7 +3595,9 @@ void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, Pla *info = pInfo->levelInfo[level - 1]; } else - { BuildPlayerLevelInfo(race, class_, level, info); } + { + BuildPlayerLevelInfo(race, class_, level, info); + } } void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, PlayerLevelInfo* info) const @@ -3816,7 +3848,9 @@ void ObjectMgr::LoadGroups() mGroupMap.erase(itr++); } else - { ++itr; } + { + ++itr; + } } // -- loading instances -- @@ -4368,7 +4402,9 @@ void ObjectMgr::LoadQuests() qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this } else - { choice_found = true; } + { + choice_found = true; + } if (!qinfo->RewChoiceItemCount[j]) { @@ -4507,7 +4543,9 @@ void ObjectMgr::LoadQuests() qinfo->RewMailDelaySecs = 0; // no mail will send to player } else - { usedMailTemplates[qinfo->RewMailTemplateId] = qinfo->GetQuestId(); } + { + usedMailTemplates[qinfo->RewMailTemplateId] = qinfo->GetQuestId(); + } } if (qinfo->NextQuestInChain) @@ -4520,7 +4558,9 @@ void ObjectMgr::LoadQuests() qinfo->NextQuestInChain = 0; } else - { qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId()); } + { + qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId()); + } } // fill additional data stores @@ -6906,7 +6946,9 @@ void ObjectMgr::LoadPetNames() PetHalfName1[entry].push_back(word); } else - { PetHalfName0[entry].push_back(word); } + { + PetHalfName0[entry].push_back(word); + } ++count; } while (result->NextRow()); @@ -7702,7 +7744,9 @@ void ObjectMgr::GetConditions(uint32 conditionId, std::vector(conditionId); if (!condition) + { return; + } if (condition->m_condition == CONDITION_OR || condition->m_condition == CONDITION_AND) { @@ -7869,7 +7913,9 @@ void ObjectMgr::LoadGameobjectQuestRelations() sLog.outErrorDb("Table `quest_relations` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second); } else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER) - { sLog.outErrorDb("Table `quest_relations` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); } + { + sLog.outErrorDb("Table `quest_relations` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); + } } } @@ -7885,7 +7931,9 @@ void ObjectMgr::LoadGameobjectInvolvedRelations() sLog.outErrorDb("Table `quest_relations` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second); } else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER) - { sLog.outErrorDb("Table `quest_relations` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); } + { + sLog.outErrorDb("Table `quest_relations` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); + } } } @@ -7901,7 +7949,9 @@ void ObjectMgr::LoadCreatureQuestRelations() sLog.outErrorDb("Table `quest_relations` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); } else if (!(cInfo->NpcFlags & UNIT_NPC_FLAG_QUESTGIVER)) - { sLog.outErrorDb("Table `quest_relations` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); } + { + sLog.outErrorDb("Table `quest_relations` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); + } } } @@ -7917,7 +7967,9 @@ void ObjectMgr::LoadCreatureInvolvedRelations() sLog.outErrorDb("Table `quest_relations` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); } else if (!(cInfo->NpcFlags & UNIT_NPC_FLAG_QUESTGIVER)) - { sLog.outErrorDb("Table `quest_relations` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); } + { + sLog.outErrorDb("Table `quest_relations` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); + } } } @@ -8287,11 +8339,17 @@ inline void _DoStringError(int32 entry, char const* text, ...) sLog.outErrorScriptLib("%s", buf); } else if (entry <= MIN_CREATURE_AI_TEXT_STRING_ID) // eventAI error - { sLog.outErrorEventAI("%s", buf); } + { + sLog.outErrorEventAI("%s", buf); + } else if (entry < MIN_DB_SCRIPT_STRING_ID) // mangos string error - { sLog.outError("%s", buf); } + { + sLog.outError("%s", buf); + } else // if (entry > MIN_DB_SCRIPT_STRING_ID) // DB script text error - { sLog.outErrorDb("DB-SCRIPTS: %s", buf); } + { + sLog.outErrorDb("DB-SCRIPTS: %s", buf); + } } bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value, bool extra_content) @@ -8329,7 +8387,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min mMangosStringLocaleMap.erase(itr++); } else - { ++itr; } + { + ++itr; + } } sLog.outString("Loading texts from %s%s", table, extra_content ? ", with additional data" : ""); @@ -8349,7 +8409,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Can not continue.", table); } else - { sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.", table); } + { + sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.", table); + } return false; } @@ -8450,7 +8512,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min sLog.outString(">> Loaded %u MaNGOS strings from table %s", count, table); } else - { sLog.outString(">> Loaded %u %s templates from %s", count, extra_content ? "text" : "string", table); } + { + sLog.outString(">> Loaded %u %s templates from %s", count, extra_content ? "text" : "string", table); + } sLog.outString(); m_loadedStringCount[min_value] = count; @@ -8469,7 +8533,9 @@ const char* ObjectMgr::GetMangosString(int32 entry, int locale_idx) const return msl->Content[locale_idx + 1].c_str(); } else - { return msl->Content[0].c_str(); } + { + return msl->Content[0].c_str(); + } } _DoStringError(entry, "Entry %i not found but requested", entry); @@ -8537,10 +8603,14 @@ bool ObjectMgr::CheckDeclinedNames(const std::wstring& mainpart, DeclinedName co { std::wstring wname; if (!Utf8toWStr(names.name[i], wname)) + { return false; + } if (mainpart != GetMainPartOfName(wname, i + 1)) + { return false; + } } return true; } @@ -8609,7 +8679,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co return true; } else - { return uint32(player->GetTeam()) == m_value1; } + { + return uint32(player->GetTeam()) == m_value1; + } } case CONDITION_SKILL: return player->HasSkill(m_value1) && player->GetBaseSkillValue(m_value1) >= m_value2; @@ -8799,7 +8871,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co return !player->HasSkill(m_value1); } else - { return player->HasSkill(m_value1) && player->GetBaseSkillValue(m_value1) < m_value2; } + { + return player->HasSkill(m_value1) && player->GetBaseSkillValue(m_value1) < m_value2; + } } case CONDITION_REPUTATION_RANK_MAX: { @@ -8892,7 +8966,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co return true; } else - { return !player->IsAlive() || (m_value2 && source && !source->IsWithinDistInMap(player, m_value2)); } + { + return !player->IsAlive() || (m_value2 && source && !source->IsWithinDistInMap(player, m_value2)); + } case 2: // All players in instance dead or out of range for (Map::PlayerList::const_iterator itr = map->GetPlayers().begin(); itr != map->GetPlayers().end(); ++itr) { @@ -9456,9 +9532,13 @@ SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial) return SKILL_RANGE_RANK; } else if (racial) - { return SKILL_RANGE_NONE; } + { + return SKILL_RANGE_NONE; + } else - { return SKILL_RANGE_MONO; } + { + return SKILL_RANGE_MONO; + } default: case SKILL_CATEGORY_ATTRIBUTES: // not found in dbc case SKILL_CATEGORY_GENERIC: // only GENERIC(DND) @@ -9546,7 +9626,9 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const return &itr->second; } else if (alt == NULL && itr->second.wnameLow.find(wname) != std::wstring::npos) - { alt = &itr->second; } + { + alt = &itr->second; + } return alt; } @@ -10208,7 +10290,9 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) sLog.outErrorDb("Gossip menu option (MenuId: %u Id: %u) have action_menu_id = %u for nonexistent menu", gMenuItem.menu_id, gMenuItem.id, gMenuItem.action_menu_id); } else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) - { menu_ids.erase(gMenuItem.action_menu_id); } + { + menu_ids.erase(gMenuItem.action_menu_id); + } } if (gMenuItem.option_icon >= GOSSIP_ICON_MAX) @@ -10306,7 +10390,9 @@ void ObjectMgr::LoadGossipMenus() { ScriptChainMap const* scm = sScriptMgr.GetScriptChainMap(DBS_ON_GOSSIP); if (!scm) + { return; + } // Check which script-ids in db_scripts type DBS_ON_GOSSIP are not used std::set gossipScriptSet; @@ -10894,7 +10980,9 @@ bool FindCreatureData::operator()(CreatureDataPair const& dataPair) // skip not spawned (in any state), uint16 pool_id = sPoolMgr.IsPartOfAPool(dataPair.first); if (pool_id && !i_player->GetMap()->GetPersistentState()->IsSpawnedPoolObject(dataPair.first)) + { return false; + } if (!i_spawnedData || new_dist < i_spawnedDist) { @@ -10930,7 +11018,9 @@ bool DoDisplayText(WorldObject* source, int32 entry, Unit const* target /*=NULL* } } else - { source->PlayDirectSound(data->SoundId); } + { + source->PlayDirectSound(data->SoundId); + } } if (data->Emote) @@ -10959,10 +11049,14 @@ bool DoDisplayText(WorldObject* source, int32 entry, Unit const* target /*=NULL* CreatureDataPair const* FindCreatureData::GetResult() const { if (i_spawnedData) + { return i_spawnedData; + } if (i_mapData) + { return i_mapData; + } return i_anyData; } @@ -10971,18 +11065,24 @@ bool FindGOData::operator()(GameObjectDataPair const& dataPair) { // skip wrong entry ids if (i_id && dataPair.second.id != i_id) + { return false; + } if (!i_anyData) i_anyData = &dataPair; // without player we can't find more stricted cases, so use fouded if (!i_player) + { return true; + } // skip diff. map cases if (dataPair.second.mapid != i_player->GetMapId()) + { return false; + } float new_dist = i_player->GetDistance2d(dataPair.second.posX, dataPair.second.posY); @@ -10995,7 +11095,9 @@ bool FindGOData::operator()(GameObjectDataPair const& dataPair) // skip not spawned (in any state) uint16 pool_id = sPoolMgr.IsPartOfAPool(dataPair.first); if (pool_id && !i_player->GetMap()->GetPersistentState()->IsSpawnedPoolObject(dataPair.first)) + { return false; + } if (!i_spawnedData || new_dist < i_spawnedDist) { @@ -11009,10 +11111,14 @@ bool FindGOData::operator()(GameObjectDataPair const& dataPair) GameObjectDataPair const* FindGOData::GetResult() const { if (i_mapData) + { return i_mapData; + } if (i_spawnedData) + { return i_spawnedData; + } return i_anyData; } diff --git a/src/game/Object/ObjectMgr.h b/src/game/Object/ObjectMgr.h index d1fec1b09..d9f41951c 100644 --- a/src/game/Object/ObjectMgr.h +++ b/src/game/Object/ObjectMgr.h @@ -740,7 +740,9 @@ class ObjectMgr { QuestPOIMap::const_iterator itr = mQuestPOIMap.find(questId); if (itr != mQuestPOIMap.end()) + { return &itr->second; + } return NULL; } @@ -748,7 +750,9 @@ class ObjectMgr { DungeonFinderRequirementsMap::const_iterator itr = mDungeonFinderRequirementsMap.find(MAKE_PAIR32(mapId, difficulty)); if (itr != mDungeonFinderRequirementsMap.end()) + { return &itr->second; + } return NULL; } @@ -960,11 +964,15 @@ class ObjectMgr { MailLevelRewardMap::const_iterator map_itr = m_mailLevelRewardMap.find(level); if (map_itr == m_mailLevelRewardMap.end()) + { return NULL; + } for (MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr) if (set_itr->raceMask & raceMask) + { return &*set_itr; + } return NULL; } @@ -1277,7 +1285,9 @@ class ObjectMgr { ItemConvertMap::const_iterator iter = m_ItemConvert.find(itemEntry); if (iter == m_ItemConvert.end()) + { return 0; + } ItemPrototype const* proto = GetItemPrototype(iter->second); return (proto && proto->AllowableRace & raceMask) ? iter->second : 0; diff --git a/src/game/Object/ObjectPosSelector.cpp b/src/game/Object/ObjectPosSelector.cpp index ff753464c..9a10f98a3 100644 --- a/src/game/Object/ObjectPosSelector.cpp +++ b/src/game/Object/ObjectPosSelector.cpp @@ -80,7 +80,9 @@ void ObjectPosSelector::AddUsedArea(WorldObject const* obj, float angle, float d m_UsedAreaLists[USED_POS_PLUS].insert(UsedArea(angle, OccupiedArea(sr_angle, obj))); } else - { m_UsedAreaLists[USED_POS_MINUS].insert(UsedArea(-angle, OccupiedArea(sr_angle, obj))); } + { + m_UsedAreaLists[USED_POS_MINUS].insert(UsedArea(-angle, OccupiedArea(sr_angle, obj))); + } } /** @@ -135,7 +137,9 @@ void ObjectPosSelector::InitializeAngle(UsedAreaSide side) m_stepAngle[side] = std::max(m_searchedForReqHAngle + otherArea.second.angleOffset - otherArea.first, 0.0f); } else // Other side empty. start from 0 - { m_stepAngle[side] = 0.0f; } + { + m_stepAngle[side] = 0.0f; + } // As m_stepAngle will be incremented first in ::NextSideAngle m_stepAngle[side] -= m_searchedForReqHAngle; @@ -171,7 +175,9 @@ bool ObjectPosSelector::NextAngle(float& angle) } // both sides finishes else - { break; } + { + break; + } } // no angles diff --git a/src/game/Object/Pet.cpp b/src/game/Object/Pet.cpp index c37b5bb51..a7629b16b 100644 --- a/src/game/Object/Pet.cpp +++ b/src/game/Object/Pet.cpp @@ -116,7 +116,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c ownerid,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); if (!result) + { return false; + } Field* fields = result->Fetch(); @@ -601,7 +603,9 @@ void Pet::RegenerateAll(uint32 update_diff) m_regenTimer = 4000; } else - { m_regenTimer -= update_diff; } + { + m_regenTimer -= update_diff; + } } bool Pet::CanTakeMoreActiveSpells(uint32 spellid) @@ -842,7 +846,9 @@ bool Pet::CreateBaseAtCreature(Creature* creature) SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]); } else - { SetName(creature->GetNameForLocaleIdx(sObjectMgr.GetDBCLocaleIndex())); } + { + SetName(creature->GetNameForLocaleIdx(sObjectMgr.GetDBCLocaleIndex())); + } SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_WARRIOR); SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_NONE); @@ -1195,10 +1201,14 @@ uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) } // -10..-6 else if (getLevel() <= itemlevel + 10) // pure guess, but sounds good - { return 17000; } + { + return 17000; + } // -14..-11 else if (getLevel() <= itemlevel + 14) // level 55 food gets green on 70, makes sense to me - { return 8000; } + { + return 8000; + } // -15 or less else { return 0; } // food too low level @@ -1407,7 +1417,9 @@ void Pet::_LoadAuras(uint32 timediff) remaincharges = procCharges; } else - { remaincharges = 0; } + { + remaincharges = 0; + } uint32 defstackamount = spellproto->GetStackAmount(); if (!defstackamount) @@ -1417,7 +1429,9 @@ void Pet::_LoadAuras(uint32 timediff) else if (defstackamount < stackcount) stackcount = defstackamount; else if (!stackcount) - { stackcount = 1; } + { + stackcount = 1; + } SpellAuraHolder* holder = CreateSpellAuraHolder(spellproto, this, NULL); holder->SetLoadedState(casterGuid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime); @@ -1444,7 +1458,9 @@ void Pet::_LoadAuras(uint32 timediff) AddSpellAuraHolder(holder); } else - { delete holder; } + { + delete holder; + } } while (result->NextRow()); @@ -1557,7 +1573,9 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'", spell_id); } else - { sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request.", spell_id); } + { + sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request.", spell_id); + } return false; } @@ -1580,12 +1598,16 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe ToggleAutocast(spell_id, true); } else if (active == ACT_DISABLED) - { ToggleAutocast(spell_id, false); } + { + ToggleAutocast(spell_id, false); + } return false; } else - { return false; } + { + return false; + } } uint32 oldspell_id = 0; @@ -1601,10 +1623,14 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe newspell.active = ACT_PASSIVE; } else - { newspell.active = ACT_DISABLED; } + { + newspell.active = ACT_DISABLED; + } } else - { newspell.active = active; } + { + newspell.active = active; + } // talent: unlearn all other talent ranks (high and low) if (TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) @@ -1647,7 +1673,9 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe } // ignore new lesser rank else if (sSpellMgr.IsHighRankOfSpell(itr2->first, spell_id)) - { return false; } + { + return false; + } } } } @@ -1659,7 +1687,9 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe CastSpell(this, spell_id, true); } else - { m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); } + { + m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); + } if (newspell.active == ACT_ENABLED) { @@ -1776,7 +1806,9 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) m_spells.erase(itr); } else - { itr->second.state = PETSPELL_REMOVED; } + { + itr->second.state = PETSPELL_REMOVED; + } RemoveAurasDueToSpell(spell_id); @@ -1798,7 +1830,9 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) learnSpell(prev_id); } else - { learn_prev = false; } + { + learn_prev = false; + } } // if remove last rank or non-ranked then update action bar at server and client if need @@ -1843,7 +1877,9 @@ bool Pet::resetTalents(bool no_cost) { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return false; + } // not need after this call if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) @@ -1851,11 +1887,15 @@ bool Pet::resetTalents(bool no_cost) CreatureInfo const* ci = GetCreatureInfo(); if (!ci) + { return false; + } // Check pet talent type CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->Family); if (!pet_family || pet_family->petTalentType < 0) + { return false; + } Player* player = (Player*)owner; @@ -1930,7 +1970,9 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) // no offline pets if (!resultPets) + { return; + } QueryResult* result = CharacterDatabase.PQuery( "SELECT DISTINCT pet_spell.spell FROM pet_spell, character_pet " @@ -1988,7 +2030,9 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) delete result; if (!need_execute) + { return; + } ss << ")"; @@ -2024,7 +2068,9 @@ void Pet::InitTalentForLevel() Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!m_loading) ((Player*)owner)->SendTalentsInfoData(true); @@ -2041,13 +2087,19 @@ uint32 Pet::resetTalentsCost() const } // then 50 silver else if (m_resetTalentsCost < 50 * SILVER) - { return 50 * SILVER; } + { + return 50 * SILVER; + } // then 1 gold else if (m_resetTalentsCost < 1 * GOLD) - { return 1 * GOLD; } + { + return 1 * GOLD; + } // then increasing at a rate of 1 gold; cap 10 gold else - { return (m_resetTalentsCost + 1 * GOLD > 10 * GOLD ? 10 * GOLD : m_resetTalentsCost + 1 * GOLD); } + { + return (m_resetTalentsCost + 1 * GOLD > 10 * GOLD ? 10 * GOLD : m_resetTalentsCost + 1 * GOLD); + } } uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) @@ -2174,7 +2226,9 @@ void Pet::LearnPetPassives() void Pet::CastPetAuras(bool current) { if (!isControlled()) + { return; + } Unit* owner = GetOwner(); @@ -2188,14 +2242,18 @@ void Pet::CastPetAuras(bool current) owner->RemovePetAura(pa); } else - { CastPetAura(pa); } + { + CastPetAura(pa); + } } } void Pet::CastOwnerTalentAuras() { if (!GetOwner() || GetOwner()->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* pOwner = static_cast(GetOwner()); @@ -2244,7 +2302,9 @@ void Pet::CastPetAura(PetAura const* aura) CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true); } else - { CastSpell(this, auraId, true); } + { + CastSpell(this, auraId, true); + } } struct DoPetLearnSpell @@ -2335,7 +2395,9 @@ void Pet::ApplyModeFlags(PetModeFlags mode, bool apply) Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return; + } WorldPacket data(SMSG_PET_MODE, 12); data << GetObjectGuid(); diff --git a/src/game/Object/PetAI.cpp b/src/game/Object/PetAI.cpp index 83f41c4ad..b03c7bf39 100644 --- a/src/game/Object/PetAI.cpp +++ b/src/game/Object/PetAI.cpp @@ -54,7 +54,9 @@ void PetAI::MoveInLineOfSight(Unit* pWho) { if (Unit* victim = m_creature->getVictim()) if (victim->IsAlive()) + { return; + } if (CharmInfo* charmInfo = m_creature->GetCharmInfo()) { @@ -154,7 +156,9 @@ void PetAI::UpdateAI(const uint32 diff) // UpdateAllies self set update timer { UpdateAllies(); } else - { m_updateAlliesTimer -= diff; } + { + m_updateAlliesTimer -= diff; + } if (inCombat && !victim) { @@ -214,7 +218,9 @@ void PetAI::UpdateAI(const uint32 diff) ((Pet*)m_creature)->SetSpellOpener(); } else + { return; + } } // Autocast (casted only in combat or persistent spells in any state) else if (!m_creature->IsNonMeleeSpellCasted(false)) @@ -357,7 +363,9 @@ void PetAI::UpdateAI(const uint32 diff) // Stop here if casting spell (No melee and no movement) if (m_creature->IsNonMeleeSpellCasted(false)) + { return; + } if (victim) { @@ -465,7 +473,9 @@ void PetAI::UpdateAllies() return; } else if (owner->GetTypeId() == TYPEID_PLAYER) - { pGroup = ((Player*)owner)->GetGroup(); } + { + pGroup = ((Player*)owner)->GetGroup(); + } // only pet and owner/not in group->ok if (m_AllySet.size() == 2 && !pGroup) @@ -499,7 +509,9 @@ void PetAI::UpdateAllies() } } else // remove group - { m_AllySet.insert(owner->GetObjectGuid()); } + { + m_AllySet.insert(owner->GetObjectGuid()); + } } void PetAI::AttackedBy(Unit* attacker) diff --git a/src/game/Object/Player.cpp b/src/game/Object/Player.cpp index e4dda7730..4b97d2dbb 100644 --- a/src/game/Object/Player.cpp +++ b/src/game/Object/Player.cpp @@ -403,7 +403,9 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/) m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); } else - { m_player->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); } + { + m_player->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); + } } } @@ -994,7 +996,9 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist); } else if (type == DAMAGE_SLIME) - { CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist); } + { + CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist); + } damage -= absorb + resist; @@ -1104,7 +1108,9 @@ void Player::HandleDrowning(uint32 time_diff) EnvironmentalDamage(DAMAGE_DROWNING, damage); } else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need - { SendMirrorTimer(BREATH_TIMER, getMaxTimer(BREATH_TIMER), m_MirrorTimer[BREATH_TIMER], -1); } + { + SendMirrorTimer(BREATH_TIMER, getMaxTimer(BREATH_TIMER), m_MirrorTimer[BREATH_TIMER], -1); + } } } else if (m_MirrorTimer[BREATH_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer @@ -1117,7 +1123,9 @@ void Player::HandleDrowning(uint32 time_diff) StopMirrorTimer(BREATH_TIMER); } else if (m_MirrorTimerFlagsLast & UNDERWATER_INWATER) - { SendMirrorTimer(BREATH_TIMER, UnderWaterTime, m_MirrorTimer[BREATH_TIMER], 10); } + { + SendMirrorTimer(BREATH_TIMER, UnderWaterTime, m_MirrorTimer[BREATH_TIMER], 10); + } } // In dark water @@ -1142,10 +1150,14 @@ void Player::HandleDrowning(uint32 time_diff) EnvironmentalDamage(DAMAGE_EXHAUSTED, damage); } else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard - { RepopAtGraveyard(); } + { + RepopAtGraveyard(); + } } else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER)) - { SendMirrorTimer(FATIGUE_TIMER, getMaxTimer(FATIGUE_TIMER), m_MirrorTimer[FATIGUE_TIMER], -1); } + { + SendMirrorTimer(FATIGUE_TIMER, getMaxTimer(FATIGUE_TIMER), m_MirrorTimer[FATIGUE_TIMER], -1); + } } } else if (m_MirrorTimer[FATIGUE_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer @@ -1157,7 +1169,9 @@ void Player::HandleDrowning(uint32 time_diff) StopMirrorTimer(FATIGUE_TIMER); } else if (m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER) - { SendMirrorTimer(FATIGUE_TIMER, DarkWaterTime, m_MirrorTimer[FATIGUE_TIMER], 10); } + { + SendMirrorTimer(FATIGUE_TIMER, DarkWaterTime, m_MirrorTimer[FATIGUE_TIMER], 10); + } } if (m_MirrorTimerFlags & (UNDERWATER_INLAVA /*| UNDERWATER_INSLIME*/) && !(m_lastLiquid && m_lastLiquid->SpellId)) @@ -1188,7 +1202,9 @@ void Player::HandleDrowning(uint32 time_diff) } } else - { m_MirrorTimer[FIRE_TIMER] = DISABLED_MIRROR_TIMER; } + { + m_MirrorTimer[FIRE_TIMER] = DISABLED_MIRROR_TIMER; + } // Recheck timers flag m_MirrorTimerFlags &= ~UNDERWATER_EXIST_TIMERS; @@ -1215,11 +1231,17 @@ void Player::HandleSobering() DrunkenState Player::GetDrunkenstateByValue(uint8 value) { if (value >= 90) - return DRUNKEN_SMASHED; + { + return DRUNKEN_SMASHED; + } if (value >= 50) - return DRUNKEN_DRUNK; + { + return DRUNKEN_DRUNK; + } if (value) + { return DRUNKEN_TIPSY; + } return DRUNKEN_SOBER; } @@ -1244,7 +1266,9 @@ void Player::SetDrunkValue(uint8 newDrunkValue, uint32 itemId /*= 0*/) m_detectInvisibilityMask &= ~(1 << 6); if (newDrunkenState == oldDrunkenState) + { return; + } WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8 + 4 + 4)); data << GetObjectGuid(); @@ -1257,7 +1281,9 @@ void Player::SetDrunkValue(uint8 newDrunkValue, uint32 itemId /*= 0*/) void Player::Update(uint32 update_diff, uint32 p_time) { if (!IsInWorld()) + { return; + } // Remove failed timed Achievements GetAchievementMgr().DoFailedTimedAchievementCriterias(); @@ -1787,7 +1813,9 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // don't let enter battlegrounds without assigned battleground id (for example through areatrigger)... // don't let gm level > 1 either if (!InBattleGround() && mEntry->IsBattleGroundOrArena()) + { return false; + } // Get MapEntrance trigger if teleport to other -nonBG- map bool assignedAreaTrigger = false; @@ -2017,7 +2045,9 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati } } else // !map->CanEnter(this) + { return false; + } } return true; } @@ -2032,7 +2062,9 @@ bool Player::TeleportToBGEntryPoint() void Player::ProcessDelayedOperations() { if (m_DelayedOperations == 0) + { return; + } if (m_DelayedOperations & DELAYED_RESURRECT_PLAYER) { @@ -2196,11 +2228,15 @@ void Player::Regenerate(Powers power, uint32 diff) { uint32 powerIndex = GetPowerIndex(power); if (powerIndex == INVALID_POWER_INDEX) + { return; + } uint32 maxValue = GetMaxPowerByIndex(powerIndex); if (!maxValue) + { return; + } uint32 curValue = GetPowerByIndex(powerIndex); @@ -2238,7 +2274,9 @@ void Player::Regenerate(Powers power, uint32 diff) if (!m_holyPowerRegenTimer) addvalue = 1; else + { return; + } break; case POWER_ENERGY: // Regenerate energy { @@ -2365,48 +2403,68 @@ Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 NpcFlagsmask) { // some basic checks if (!guid || !IsInWorld() || IsTaxiFlying()) + { return NULL; + } // set player as interacting DoInteraction(guid); // not in interactive state if (hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL)) + { return NULL; + } // exist (we need look pets also for some interaction (quest/etc) Creature* unit = GetMap()->GetAnyTypeCreature(guid); if (!unit) + { return NULL; + } // appropriate npc type if (NpcFlagsmask && !unit->HasFlag(UNIT_NPC_FLAGS, NpcFlagsmask)) + { return NULL; + } if (NpcFlagsmask == UNIT_NPC_FLAG_STABLEMASTER) { if (getClass() != CLASS_HUNTER) + { return NULL; + } } // if a dead unit should be able to talk - the creature must be alive and have special flags if (!unit->IsAlive()) + { return NULL; + } if (IsAlive() && unit->isInvisibleForAlive()) + { return NULL; + } // not allow interaction under control, but allow with own pets if (unit->GetCharmerGuid()) + { return NULL; + } // not enemy if (unit->IsHostileTo(this)) + { return NULL; + } // not too far if (!unit->IsWithinDistInMap(this, INTERACTION_DISTANCE)) + { return NULL; + } return unit; } @@ -2415,14 +2473,18 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameo { // some basic checks if (!guid || !IsInWorld() || IsTaxiFlying()) + { return NULL; + } // set player as interacting DoInteraction(guid); // not in interactive state if (hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL)) + { return NULL; + } if (GameObject* go = GetMap()->GetGameObject(guid)) { @@ -2430,7 +2492,9 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameo { float maxdist = go->GetInteractionDistance(); if (go->IsWithinDistInMap(this, maxdist) && go->isSpawned()) + { return go; + } sLog.outError("GetGameObjectIfCanInteractWith: GameObject '%s' [GUID: %u] is too far away from player %s [GUID: %u] to be used by him (distance=%f, maximal %f is allowed)", go->GetGOInfo()->name, go->GetGUIDLow(), GetName(), GetGUIDLow(), go->GetDistance(this), maxdist); @@ -2447,7 +2511,9 @@ bool Player::IsUnderWater() const void Player::SetInWater(bool apply) { if (m_isInWater == apply) + { return; + } // define player in water by opcodes // move player's guid into HateOfflineList of those mobs @@ -2582,7 +2648,9 @@ void Player::UninviteFromGroup() { Group* group = GetGroupInvite(); if (!group) + { return; + } group->RemoveInvite(this); @@ -2632,13 +2700,19 @@ void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP) void Player::GiveXP(uint32 xp, Unit* victim) { if (xp < 1) + { return; + } if (!IsAlive()) + { return; + } if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_XP_USER_DISABLED)) + { return; + } uint32 level = getLevel(); @@ -2649,7 +2723,9 @@ void Player::GiveXP(uint32 xp, Unit* victim) // XP to money conversion processed in Player::RewardQuest if (level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + { return; + } if (victim) { @@ -2694,7 +2770,9 @@ void Player::GiveXP(uint32 xp, Unit* victim) void Player::GiveLevel(uint32 level) { if (level == getLevel()) + { return; + } PlayerLevelInfo info; sObjectMgr.GetPlayerLevelInfo(getRace(), getClass(), level, &info); @@ -3240,7 +3318,9 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen itr->second.disabled = disabled; if (disabled) + { return false; + } disabled_case = true; } @@ -3353,7 +3433,9 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen // return false if spell disabled if (newspell.disabled) + { return false; + } } if (talentPos) @@ -3504,7 +3586,9 @@ bool Player::IsNeedCastPassiveLikeSpellAtLearn(SpellEntry const* spellInfo) cons return true; // all stance req. cases, not have auarastate cases if (!spellInfo->HasAttribute(SPELL_ATTR_PASSIVE)) + { return false; + } // note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell // talent dependent passives activated at form apply have proper stance data @@ -3554,10 +3638,14 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo { PlayerSpellMap::iterator itr = m_spells.find(spell_id); if (itr == m_spells.end()) + { return; + } if (itr->second.state == PLAYERSPELL_REMOVED || (disabled && itr->second.disabled)) + { return; + } // unlearn non talent higher ranks (recursive) SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext(); @@ -3786,7 +3874,9 @@ void Player::RemoveSpellCategoryCooldown(uint32 cat, bool update /* = false */) { SpellCategoryStore::const_iterator ct = sSpellCategoryStore.find(cat); if (ct == sSpellCategoryStore.end()) + { return; + } const SpellCategorySet& ct_set = ct->second; for (SpellCooldowns::const_iterator i = m_spellCooldowns.begin(); i != m_spellCooldowns.end();) @@ -3912,13 +4002,19 @@ uint32 Player::resetTalentsCost() const { // The first time reset costs 1 gold if (m_resetTalentsCost < 1 * GOLD) + { return 1 * GOLD; + } // then 5 gold else if (m_resetTalentsCost < 5 * GOLD) + { return 5 * GOLD; + } // After that it increases in increments of 5 gold else if (m_resetTalentsCost < 10 * GOLD) + { return 10 * GOLD; + } else { time_t months = (sWorld.GetGameTime() - m_resetTalentsTime) / MONTH; @@ -4288,41 +4384,57 @@ bool Player::HasActiveSpell(uint32 spell) const TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell, uint32 reqLevel) const { if (!trainer_spell) + { return TRAINER_SPELL_RED; + } if (!trainer_spell->learnedSpell) + { return TRAINER_SPELL_RED; + } // known spell if (HasSpell(trainer_spell->learnedSpell)) + { return TRAINER_SPELL_GRAY; + } // check race/class requirement if (!IsSpellFitByClassAndRace(trainer_spell->learnedSpell)) + { return TRAINER_SPELL_RED; + } bool prof = SpellMgr::IsProfessionSpell(trainer_spell->learnedSpell); // check level requirement if (!prof || GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_LEVEL))) if (getLevel() < reqLevel) + { return TRAINER_SPELL_RED; + } if (SpellChainNode const* spell_chain = sSpellMgr.GetSpellChainNode(trainer_spell->learnedSpell)) { // check prev.rank requirement if (spell_chain->prev && !HasSpell(spell_chain->prev)) + { return TRAINER_SPELL_RED; + } // check additional spell requirement if (spell_chain->req && !HasSpell(spell_chain->req)) + { return TRAINER_SPELL_RED; + } } // check skill requirement if (!prof || GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_SKILL))) if (trainer_spell->reqSkill && GetBaseSkillValue(trainer_spell->reqSkill) < trainer_spell->reqSkillValue) + { return TRAINER_SPELL_RED; + } // exist, already checked at loading SpellEntry const* spell = sSpellStore.LookupEntry(trainer_spell->learnedSpell); @@ -4332,11 +4444,15 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell uint32 skill = spellEffect ? spellEffect->EffectMiscValue : 0; if(spellEffect && (spellEffect->Effect != SPELL_EFFECT_SKILL || !IsPrimaryProfessionSkill(skill))) + { return TRAINER_SPELL_GREEN; + } // check primary prof. limit if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell->Id) && GetFreePrimaryProfessionPoints() == 0) + { return TRAINER_SPELL_GREEN_DISABLED; + } return TRAINER_SPELL_GREEN; } @@ -4587,7 +4703,9 @@ void Player::DeleteOldCharacters() { uint32 keepDays = sWorld.getConfig(CONFIG_UINT32_CHARDELETE_KEEP_DAYS); if (!keepDays) + { return; + } Player::DeleteOldCharacters(keepDays); } @@ -4767,7 +4885,9 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) #endif /* ENABLE_ELUNA */ if (!applySickness) + { return; + } // Characters from level 1-10 are not affected by resurrection sickness. // Characters from level 11-19 will suffer from one minute of sickness @@ -4919,12 +5039,16 @@ void Player::DurabilityLossAll(double percent, bool inventory) void Player::DurabilityLoss(Item* item, double percent) { if (!item) + { return; + } uint32 pMaxDurability = item ->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); if (!pMaxDurability) + { return; + } uint32 pDurabilityLoss = uint32(pMaxDurability * percent); @@ -5012,11 +5136,15 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g uint32 TotalCost = 0; if (!item) + { return TotalCost; + } uint32 maxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY); if (!maxDurability) + { return TotalCost; + } uint32 curDurability = item->GetUInt32Value(ITEM_FIELD_DURABILITY); @@ -5060,7 +5188,9 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g Guild* pGuild = sGuildMgr.GetGuildById(GetGuildId()); if (!pGuild) + { return TotalCost; + } if (!pGuild->HasRankRight(GetRank(), GR_RIGHT_WITHDRAW_REPAIR)) { @@ -5173,15 +5303,21 @@ void Player::CleanupChannels() void Player::UpdateLocalChannels(uint32 newZone) { if (m_channels.empty()) + { return; + } AreaTableEntry const* current_zone = GetAreaEntryByAreaID(newZone); if (!current_zone) + { return; + } ChannelMgr* cMgr = channelMgr(GetTeam()); if (!cMgr) + { return; + } std::string current_zone_name = current_zone->area_name[GetSession()->GetSessionDbcLocale()]; @@ -5256,7 +5392,9 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa } if (!CanModifyStats()) + { return; + } switch (modGroup) { @@ -5277,7 +5415,9 @@ float Player::GetBaseModValue(BaseModGroup modGroup, BaseModType modType) const } if (modType == PCT_MOD && m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) + { return 0.0f; + } return m_auraBaseMod[modGroup][modType]; } @@ -5291,7 +5431,9 @@ float Player::GetTotalBaseModValue(BaseModGroup modGroup) const } if (m_auraBaseMod[modGroup][PCT_MOD] <= 0.0f) + { return 0.0f; + } return m_auraBaseMod[modGroup][FLAT_MOD] * m_auraBaseMod[modGroup][PCT_MOD]; } @@ -5316,7 +5458,9 @@ float Player::GetMeleeCritFromAgility() GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass - 1); GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (critBase == NULL || critRatio == NULL) + { return 0.0f; + } float crit = critBase->base + GetStat(STAT_AGILITY) * critRatio->ratio; return crit * 100.0f; @@ -5370,7 +5514,9 @@ void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing) // Dodge per agility is proportional to crit per agility, which is available from DBC files GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (dodgeRatio == NULL || pclass > MAX_CLASSES) + { return; + } // TODO: research if talents/effects that increase total agility by x% should increase non-diminishing part float base_agility = GetCreateStat(STAT_AGILITY) * m_auraModifiersGroup[UNIT_MOD_STAT_START + STAT_AGILITY][BASE_PCT]; @@ -5384,7 +5530,9 @@ void Player::GetParryFromStrength(float& diminishing, float& nondiminishing) { // other classes than these do not receive parry bonus from strength if (getClass() != CLASS_WARRIOR && getClass() != CLASS_PALADIN && getClass() != CLASS_DEATH_KNIGHT) + { return; + } float base_strength = GetCreateStat(STAT_STRENGTH) * m_auraModifiersGroup[UNIT_MOD_STAT_START + STAT_STRENGTH][BASE_PCT]; float bonus_strength = GetStat(STAT_STRENGTH) - base_strength; @@ -5403,7 +5551,9 @@ float Player::GetSpellCritFromIntellect() GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass - 1); GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (critBase == NULL || critRatio == NULL) + { return 0.0f; + } float crit = critBase->base + GetStat(STAT_INTELLECT) * critRatio->ratio; return crit * 100.0f; @@ -5448,7 +5598,9 @@ float Player::OCTRegenMPPerSpirit() // Only healers have regen bonus from spirit. Others regenerate by combat regen. uint32 rolesMask = GetTalentTreeRolesMask(m_talentsPrimaryTree[m_activeSpec]); if ((rolesMask & TALENT_ROLE_HEALER) == 0) + { return 0.0f; + } uint32 level = getLevel(); uint32 pclass = getClass(); @@ -5458,7 +5610,9 @@ float Player::OCTRegenMPPerSpirit() // GtOCTRegenMPEntry const *baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); if (moreRatio == NULL) + { return 0.0f; + } // Formula get from PaperDollFrame script float spirit = GetStat(STAT_SPIRIT); @@ -5611,18 +5765,24 @@ void Player::SetRegularAttackTime() bool Player::UpdateSkill(uint32 skill_id, uint32 step) { if (!skill_id) + { return false; + } if (skill_id == SKILL_FIST_WEAPONS) skill_id = SKILL_UNARMED; SkillStatusMap::iterator itr = mSkillStatus.find(skill_id); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return false; + } SkillStatusData& skillStatus = itr->second; if (skillStatus.uState == SKILL_DELETED) + { return false; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; // itr->second.pos % 2 @@ -5631,7 +5791,9 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset); if ((!max) || (!value) || (value >= max)) + { return false; + } uint32 new_value = value + step; if (new_value > max) @@ -5648,11 +5810,17 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) inline int SkillGainChance(uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel) { if (SkillValue >= GrayLevel) + { return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREY) * 10; + } if (SkillValue >= GreenLevel) + { return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREEN) * 10; + } if (SkillValue >= YellowLevel) + { return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_YELLOW) * 10; + } return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_ORANGE) * 10; } @@ -5707,14 +5875,22 @@ bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLeve return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); case SKILL_SKINNING: if (sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS) == 0) + { return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); + } else + { return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain); + } case SKILL_MINING: if (sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_MINING_STEPS) == 0) + { return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); + } else + { return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_MINING_STEPS)), gathering_skill_gain); + } } return false; } @@ -5741,7 +5917,9 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) { DEBUG_LOG("UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance / 10.0); if (!SkillId) + { return false; + } if (Chance <= 0) // speedup in 0 chance case { @@ -5751,7 +5929,9 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) SkillStatusMap::iterator itr = mSkillStatus.find(SkillId); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return false; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; // itr->second.pos % 2 @@ -5760,7 +5940,9 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) uint16 MaxValue = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset); if (!MaxValue || !SkillValue || SkillValue >= MaxValue) + { return false; + } int32 Roll = irand(1, 1000); @@ -5794,7 +5976,9 @@ void Player::ModifySkillBonus(uint32 skillid, int32 val, bool talent) { SkillStatusMap::const_iterator itr = mSkillStatus.find(skillid); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return; + } uint16 field = itr->second.pos / 2 + (talent ? PLAYER_SKILL_TALENT_0 : PLAYER_SKILL_MODIFIER_0); uint8 offset = itr->second.pos & 1; // itr->second.pos % 2 @@ -5868,7 +6052,9 @@ void Player::UpdateSkillsToMaxSkillsForLevel() void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0*/) { if (!id) + { return; + } uint16 oldVal; SkillStatusMap::iterator itr = mSkillStatus.find(id); @@ -5973,7 +6159,9 @@ void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0 bool Player::HasSkill(uint32 skill) const { if (!skill) + { return false; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); return (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED); @@ -5982,11 +6170,15 @@ bool Player::HasSkill(uint32 skill) const uint16 Player::GetSkillStep(uint16 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } return GetUInt16Value(PLAYER_SKILL_STEP_0 + itr->second.pos / 2, itr->second.pos & 1); } @@ -5994,11 +6186,15 @@ uint16 Player::GetSkillStep(uint16 skill) const uint16 Player::GetSkillValue(uint32 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; @@ -6012,11 +6208,15 @@ uint16 Player::GetSkillValue(uint32 skill) const uint16 Player::GetMaxSkillValue(uint32 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; @@ -6030,11 +6230,15 @@ uint16 Player::GetMaxSkillValue(uint32 skill) const uint16 Player::GetPureMaxSkillValue(uint32 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; @@ -6045,11 +6249,15 @@ uint16 Player::GetPureMaxSkillValue(uint32 skill) const uint16 Player::GetBaseSkillValue(uint32 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; @@ -6062,11 +6270,15 @@ uint16 Player::GetBaseSkillValue(uint32 skill) const uint16 Player::GetPureSkillValue(uint32 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; @@ -6077,11 +6289,15 @@ uint16 Player::GetPureSkillValue(uint32 skill) const int16 Player::GetSkillPermBonusValue(uint32 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; @@ -6092,11 +6308,15 @@ int16 Player::GetSkillPermBonusValue(uint32 skill) const int16 Player::GetSkillTempBonusValue(uint32 skill) const { if (!skill) + { return 0; + } SkillStatusMap::const_iterator itr = mSkillStatus.find(skill); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) + { return 0; + } uint16 field = itr->second.pos / 2; uint8 offset = itr->second.pos & 1; @@ -6227,7 +6447,9 @@ ActionButton* Player::addActionButton(uint8 spec, uint8 button, uint32 action, u { // check action only for active spec (so not check at copy/load passive spec) if (spec == GetActiveSpec() && !IsActionButtonDataValid(button, action, type, this)) + { return NULL; + } // it create new button (NEW state) if need or return existing ActionButton& ab = m_actionButtons[spec][button]; @@ -6244,7 +6466,9 @@ void Player::removeActionButton(uint8 spec, uint8 button) ActionButtonList& currentActionButtonList = m_actionButtons[spec]; ActionButtonList::iterator buttonItr = currentActionButtonList.find(button); if (buttonItr == currentActionButtonList.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED) + { return; + } if (buttonItr->second.uState == ACTIONBUTTON_NEW) currentActionButtonList.erase(buttonItr); // new and not saved @@ -6259,7 +6483,9 @@ ActionButton const* Player::GetActionButton(uint8 button) ActionButtonList& currentActionButtonList = m_actionButtons[m_activeSpec]; ActionButtonList::iterator buttonItr = currentActionButtonList.find(button); if (buttonItr == currentActionButtonList.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED) + { return NULL; + } return &buttonItr->second; } @@ -6304,7 +6530,9 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele } if (m_positionStatusUpdateTimer) // Update position's state only on interval + { return true; + } m_positionStatusUpdateTimer = 100; // code block for underwater state update @@ -6376,10 +6604,14 @@ void Player::SendMovieStart(uint32 MovieId) void Player::CheckAreaExploreAndOutdoor() { if (!IsAlive()) + { return; + } if (IsTaxiFlying()) + { return; + } bool isOutdoor; uint16 areaFlag = GetTerrain()->GetAreaFlag(GetPositionX(), GetPositionY(), GetPositionZ(), &isOutdoor); @@ -6416,7 +6648,9 @@ void Player::CheckAreaExploreAndOutdoor() RemoveAurasWithAttribute(SPELL_ATTR_OUTDOORS_ONLY); if (areaFlag == 0xffff) + { return; + } int offset = areaFlag / 32; if (offset >= PLAYER_EXPLORED_ZONES_SIZE) @@ -6552,7 +6786,9 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 percent *= rate; if (percent <= 0.0f) + { return 0; + } // Multiply result with the faction specific rate if (const RepRewardRate* repData = sObjectMgr.GetRepRewardRate(faction)) @@ -6573,7 +6809,9 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 // for custom, a rate of 0.0 will totally disable reputation gain for this faction/type if (repRate <= 0.0f) + { return 0; + } percent *= repRate; } @@ -6585,13 +6823,17 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 void Player::RewardReputation(Unit* pVictim, float rate) { if (!pVictim || pVictim->GetTypeId() == TYPEID_PLAYER) + { return; + } // used current difficulty creature entry instead normal version (GetEntry()) ReputationOnKillEntry const* Rep = sObjectMgr.GetReputationOnKillEntry(((Creature*)pVictim)->GetCreatureInfo()->Entry); if (!Rep) + { return; + } uint32 repFaction1 = Rep->repfaction1; uint32 repFaction2 = Rep->repfaction2; @@ -6735,17 +6977,23 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) if (InArena()) { if (!uVictim || uVictim == this || uVictim->GetTypeId() != TYPEID_PLAYER) + { return false; + } if (GetBGTeam() == ((Player*)uVictim)->GetBGTeam()) + { return false; + } return true; } // 'Inactive' this aura prevents the player from gaining honor points and battleground tokens if (GetDummyAura(SPELL_AURA_PLAYER_INACTIVE)) + { return false; + } ObjectGuid victim_guid; uint32 victim_rank = 0; @@ -6756,7 +7004,9 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) if (honor <= 0) { if (!uVictim || uVictim == this || uVictim->HasAuraType(SPELL_AURA_NO_PVP_CREDIT)) + { return false; + } victim_guid = uVictim->GetObjectGuid(); @@ -6765,7 +7015,9 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) Player* pVictim = (Player*)uVictim; if (GetTeam() == pVictim->GetTeam() && !sWorld.IsFFAPvPRealm()) + { return false; + } float f = 1; // need for total kills (?? need more info) uint32 k_grey = 0; @@ -6798,7 +7050,9 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) k_grey = MaNGOS::XP::GetGrayLevel(k_level); if (v_level <= k_grey) + { return false; + } float diff_level = (k_level == k_grey) ? 1 : ((float(v_level) - float(k_grey)) / (float(k_level) - float(k_grey))); @@ -6820,7 +7074,9 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) Creature* cVictim = (Creature*)uVictim; if (!cVictim->IsRacialLeader()) + { return false; + } honor = 100; // ??? need more info victim_rank = 19; // HK: Leader @@ -6869,7 +7125,9 @@ void Player::SetInGuild(uint32 GuildId) std::string Player::GetGuildName() const { if (Guild* guild = sGuildMgr.GetGuildById(GetGuildId())) + { return guild->GetName(); + } return ""; } @@ -6890,7 +7148,9 @@ uint32 Player::GetGuildIdFromDB(ObjectGuid guid) QueryResult* result = CharacterDatabase.PQuery("SELECT guildid FROM guild_member WHERE guid='%u'", lowguid); if (!result) + { return 0; + } uint32 id = result->Fetch()[0].GetUInt32(); delete result; @@ -6900,9 +7160,13 @@ uint32 Player::GetGuildIdFromDB(ObjectGuid guid) ObjectGuid Player::GetGuildGuidFromDB(ObjectGuid guid) { if (uint32 guildId = GetGuildIdFromDB(guid)) + { return ObjectGuid(HIGHGUID_GUILD, GetGuildIdFromDB(guid)); + } else + { return ObjectGuid(); + } } uint32 Player::GetRankFromDB(ObjectGuid guid) @@ -6915,7 +7179,9 @@ uint32 Player::GetRankFromDB(ObjectGuid guid) return v; } else + { return 0; + } } void Player::SendGuildDeclined(std::string name, bool autodecline) @@ -6931,7 +7197,9 @@ uint32 Player::GetArenaTeamIdFromDB(ObjectGuid guid, ArenaType type) { QueryResult* result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u' AND type='%u' LIMIT 1", guid.GetCounter(), type); if (!result) + { return 0; + } uint32 id = (*result)[0].GetUInt32(); delete result; @@ -6943,7 +7211,9 @@ uint32 Player::GetZoneIdFromDB(ObjectGuid guid) uint32 lowguid = guid.GetCounter(); QueryResult* result = CharacterDatabase.PQuery("SELECT zone FROM characters WHERE guid='%u'", lowguid); if (!result) + { return 0; + } Field* fields = result->Fetch(); uint32 zone = fields[0].GetUInt32(); delete result; @@ -6953,7 +7223,9 @@ uint32 Player::GetZoneIdFromDB(ObjectGuid guid) // stored zone is zero, use generic and slow zone detection result = CharacterDatabase.PQuery("SELECT map,position_x,position_y,position_z FROM characters WHERE guid='%u'", lowguid); if (!result) + { return 0; + } fields = result->Fetch(); uint32 map = fields[0].GetUInt32(); float posx = fields[1].GetFloat(); @@ -6976,7 +7248,9 @@ uint32 Player::GetLevelFromDB(ObjectGuid guid) QueryResult* result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid='%u'", lowguid); if (!result) + { return 0; + } Field* fields = result->Fetch(); uint32 level = fields[0].GetUInt32(); @@ -7024,7 +7298,9 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) { AreaTableEntry const* zone = GetAreaEntryByAreaID(newZone); if (!zone) + { return; + } if (m_zoneUpdateId != newZone) { @@ -7122,7 +7398,9 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) void Player::CheckDuelDistance(time_t currTime) { if (!duel) + { return; + } GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER)); if (!obj) @@ -7162,7 +7440,9 @@ void Player::DuelComplete(DuelCompleteType type) { // duel not requested if (!duel) + { return; + } WorldPacket data(SMSG_DUEL_COMPLETE, (1)); data << (uint8)((type != DUEL_INTERRUPTED) ? 1 : 0); @@ -7244,16 +7524,22 @@ void Player::DuelComplete(DuelCompleteType type) void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply) { if (slot >= INVENTORY_SLOT_BAG_END || !item) + { return; + } // not apply/remove mods for broken item if (item->IsBroken()) + { return; + } ItemPrototype const* proto = item->GetProto(); if (!proto) + { return; + } DETAIL_LOG("applying mods for item %u ", item->GetGUIDLow()); @@ -7278,11 +7564,15 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply) void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool apply, bool only_level_Scale /*= false*/) { if (slot >= INVENTORY_SLOT_BAG_END || !proto) + { return; + } ScalingStatDistributionEntry const* ssd = proto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(proto->ScalingStatDistribution) : NULL; if (only_level_Scale && !ssd) + { return; + } // req. check at equip, but allow use for extended range if range limit max level, set proper level uint32 ssd_level = getLevel(); @@ -7291,7 +7581,9 @@ void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool appl ScalingStatValuesEntry const* ssv = proto->StatScalingFactor ? sScalingStatValuesStore.LookupEntry(ssd_level) : NULL; if (only_level_Scale && !ssv) + { return; + } for (uint32 i = 0; i < MAX_ITEM_PROTO_STATS; ++i) { @@ -7494,7 +7786,9 @@ void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool appl } if (!CanUseEquippedWeapon(attType)) + { return; + } if (proto->Delay) { @@ -7529,7 +7823,9 @@ void Player::_ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attac { // generic not weapon specific case processes in aura code if(aura->GetSpellProto()->GetEquippedItemClass() == -1) + { return; + } BaseModGroup mod = BASEMOD_END; switch (attackType) @@ -7551,11 +7847,15 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType att // ignore spell mods for not wands Modifier const* modifier = aura->GetModifier(); if ((modifier->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) == 0 && (getClassMask() & CLASSMASK_WAND_USERS) == 0) + { return; + } // generic not weapon specific case processes in aura code if(aura->GetSpellProto()->GetEquippedItemClass() == -1) + { return; + } UnitMods unitMod = UNIT_MOD_END; switch (attackType) @@ -7583,11 +7883,15 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType att void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change) { if (!item) + { return; + } ItemPrototype const* proto = item->GetProto(); if (!proto) + { return; + } for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { @@ -7627,7 +7931,9 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply { // Cannot be used in this stance/form if (GetErrorAtShapeshiftedCast(spellInfo, GetShapeshiftForm()) != SPELL_CAST_OK) + { return; + } if (form_change) // check aura active state from other form { @@ -7705,11 +8011,15 @@ void Player::UpdateEquipSpellsAtFormChange() void Player::ApplyItemOnStoreSpell(Item* item, bool apply) { if (!item) + { return; + } ItemPrototype const* proto = item->GetProto(); if (!proto) + { return; + } for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { @@ -7737,11 +8047,15 @@ void Player::ApplyItemOnStoreSpell(Item* item, bool apply) void Player::DestroyItemWithOnStoreSpell(Item* item, uint32 spellId) { if (!item) + { return; + } ItemPrototype const* proto = item->GetProto(); if (!proto) + { return; + } for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { @@ -7776,16 +8090,22 @@ void Player::_HandleDeadlyPoison(Unit* Target, WeaponAttackType attType, SpellEn { Item* otherWeapon = GetWeaponForAttack(attType == BASE_ATTACK ? OFF_ATTACK : BASE_ATTACK); if (!otherWeapon) + { return; + } // all poison enchantments are temporary uint32 enchant_id = otherWeapon->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT); if (!enchant_id) + { return; + } SpellItemEnchantmentEntry const* pSecondEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pSecondEnchant) + { return; + } for (int s = 0; s < 3; ++s) { @@ -7803,14 +8123,20 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) { Item* item = GetWeaponForAttack(attType, true, false); if (!item) + { return; + } ItemPrototype const* proto = item->GetProto(); if (!proto) + { return; + } if (!Target || Target == this) + { return; + } for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { @@ -7833,7 +8159,9 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) // not allow proc extra attack spell at extra attack if (m_extraAttacks && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_ADD_EXTRA_ATTACKS)) + { return; + } float chance = (float)spellInfo->GetProcChance(); @@ -8133,16 +8461,22 @@ void Player::_ApplyAmmoBonuses() bool Player::CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const { if (!ammo_proto) + { return false; + } // check ranged weapon Item* weapon = GetWeaponForAttack(RANGED_ATTACK, true, false); if (!weapon) + { return false; + } ItemPrototype const* weapon_proto = weapon->GetProto(); if (!weapon_proto || weapon_proto->Class != ITEM_CLASS_WEAPON) + { return false; + } // check ammo ws. weapon compatibility switch (weapon_proto->SubClass) @@ -8150,11 +8484,15 @@ bool Player::CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const case ITEM_SUBCLASS_WEAPON_BOW: case ITEM_SUBCLASS_WEAPON_CROSSBOW: if (ammo_proto->SubClass != ITEM_SUBCLASS_ARROW) + { return false; + } break; case ITEM_SUBCLASS_WEAPON_GUN: if (ammo_proto->SubClass != ITEM_SUBCLASS_BULLET) + { return false; + } break; default: return false; @@ -8168,7 +8506,9 @@ bool Player::CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const void Player::RemovedInsignia(Player* looterPlr) { if (!GetBattleGroundId()) + { return; + } // If not released spirit, do it ! if (m_deathTimer > 0) @@ -8180,13 +8520,17 @@ void Player::RemovedInsignia(Player* looterPlr) Corpse* corpse = GetCorpse(); if (!corpse) + { return; + } // We have to convert player corpse to bones, not to be able to resurrect there // SpawnCorpseBones isn't handy, 'cos it saves player while he in BG Corpse* bones = sObjectAccessor.ConvertCorpseForPlayer(GetObjectGuid(), true); if (!bones) + { return; + } // Now we must make bones lootable, and send player loot bones->SetFlag(CORPSE_FIELD_DYNAMIC_FLAGS, CORPSE_DYNFLAG_LOOTABLE); @@ -8722,7 +9066,9 @@ void Player::SendPetSkillWipeConfirm() { Pet* pet = GetPet(); if (!pet) + { return; + } WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8 + 4)); data << ObjectGuid(pet->GetObjectGuid()); data << uint32(pet->resetTalentsCost()); @@ -8739,10 +9085,14 @@ void Player::SetVirtualItemSlot(uint8 i, Item* item) if (i < 2 && item) { if (!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) + { return; + } uint32 charges = item->GetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT); if (charges == 0) + { return; + } if (charges > 1) item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT, charges - 1); else if (charges <= 1) @@ -8900,7 +9250,9 @@ uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) { uint8 slots[4]; if (!GetSlotsForInventoryType(proto->InventoryType, slots, proto->SubClass)) + { return NULL_SLOT; + } if (slot != NULL_SLOT) { @@ -8909,7 +9261,9 @@ uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) for (int i = 0; i < 4; ++i) { if (slots[i] == slot) + { return slot; + } } } } @@ -8922,7 +9276,9 @@ uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) { // in case 2hand equipped weapon (without titan grip) offhand slot empty but not free if (slots[i] != EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed()) + { return slots[i]; + } } } @@ -8930,7 +9286,9 @@ uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) for (int i = 0; i < 4; ++i) { if (slots[i] != NULL_SLOT && swap) + { return slots[i]; + } } } @@ -8955,7 +9313,9 @@ InventoryResult Player::CanUnequipItems(uint32 item, uint32 count) const { tempcount += pItem->GetCount(); if (tempcount >= count) + { return EQUIP_ERR_OK; + } } else res = ires; @@ -8968,7 +9328,9 @@ InventoryResult Player::CanUnequipItems(uint32 item, uint32 count) const { tempcount += pItem->GetCount(); if (tempcount >= count) + { return EQUIP_ERR_OK; + } } } @@ -8984,7 +9346,9 @@ InventoryResult Player::CanUnequipItems(uint32 item, uint32 count) const { tempcount += pItem->GetCount(); if (tempcount >= count) + { return EQUIP_ERR_OK; + } } } } @@ -9078,12 +9442,16 @@ Item* Player::GetItemByEntry(uint32 item) const for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetEntry() == item) + { return pItem; + } for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (Item* itemPtr = pBag->GetItemByEntry(item)) + { return itemPtr; + } return NULL; } @@ -9093,12 +9461,16 @@ Item* Player::GetItemByLimitedCategory(uint32 limitedCategory) const for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetProto()->ItemLimitCategory == limitedCategory) + { return pItem; + } for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (Item* itemPtr = pBag->GetItemByLimitedCategory(limitedCategory)) + { return itemPtr; + } return NULL; } @@ -9108,26 +9480,34 @@ Item* Player::GetItemByGuid(ObjectGuid guid) const for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetObjectGuid() == guid) + { return pItem; + } for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (pItem->GetObjectGuid() == guid) + { return pItem; + } for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (pItem->GetObjectGuid() == guid) + { return pItem; + } for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = pBag->GetItemByPos(j)) if (pItem->GetObjectGuid() == guid) + { return pItem; + } return NULL; } @@ -9142,13 +9522,17 @@ Item* Player::GetItemByPos(uint16 pos) const Item* Player::GetItemByPos(uint8 bag, uint8 slot) const { if (bag == INVENTORY_SLOT_BAG_0 && slot < BANK_SLOT_BAG_END) + { return m_items[slot]; + } else if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) || (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END)) { Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (pBag) + { return pBag->GetItemByPos(slot); + } } return NULL; } @@ -9158,7 +9542,9 @@ uint32 Player::GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const const Item* pItem = GetItemByPos(bag, slot); if (!pItem) + { return 0; + } return pItem->GetProto()->DisplayInfoID; } @@ -9176,13 +9562,19 @@ Item* Player::GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bo Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, slot); if (!item || item->GetProto()->Class != ITEM_CLASS_WEAPON) + { return NULL; + } if (useable && !CanUseEquippedWeapon(attackType)) + { return NULL; + } if (nonbroken && item->IsBroken()) + { return NULL; + } return item; } @@ -9191,13 +9583,19 @@ Item* Player::GetShield(bool useable) const { Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (!item || item->GetProto()->Class != ITEM_CLASS_ARMOR) + { return NULL; + } if (!useable) + { return item; + } if (item->IsBroken() || !CanUseEquippedWeapon(OFF_ATTACK)) + { return NULL; + } return item; } @@ -9216,31 +9614,47 @@ uint32 Player::GetAttackBySlot(uint8 slot) bool Player::IsInventoryPos(uint8 bag, uint8 slot) { if (bag == INVENTORY_SLOT_BAG_0 && slot == NULL_SLOT) + { return true; + } if (bag == INVENTORY_SLOT_BAG_0 && (slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END)) + { return true; + } if (bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) + { return true; + } return false; } bool Player::IsEquipmentPos(uint8 bag, uint8 slot) { if (bag == INVENTORY_SLOT_BAG_0 && (slot < EQUIPMENT_SLOT_END)) + { return true; + } if (bag == INVENTORY_SLOT_BAG_0 && (slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END)) + { return true; + } return false; } bool Player::IsBankPos(uint8 bag, uint8 slot) { if (bag == INVENTORY_SLOT_BAG_0 && (slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END)) + { return true; + } if (bag == INVENTORY_SLOT_BAG_0 && (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END)) + { return true; + } if (bag >= BANK_SLOT_BAG_START && bag < BANK_SLOT_BAG_END) + { return true; + } return false; } @@ -9249,9 +9663,13 @@ bool Player::IsBagPos(uint16 pos) uint8 bag = pos >> 8; uint8 slot = pos & 255; if (bag == INVENTORY_SLOT_BAG_0 && (slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END)) + { return true; + } if (bag == INVENTORY_SLOT_BAG_0 && (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END)) + { return true; + } return false; } @@ -9259,33 +9677,47 @@ bool Player::IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const { // post selected if (bag == NULL_BAG && !explicit_pos) + { return true; + } if (bag == INVENTORY_SLOT_BAG_0) { // any post selected if (slot == NULL_SLOT && !explicit_pos) + { return true; + } // equipment if (slot < EQUIPMENT_SLOT_END) + { return true; + } // bag equip slots if (slot >= INVENTORY_SLOT_BAG_START && slot < INVENTORY_SLOT_BAG_END) + { return true; + } // backpack slots if (slot >= INVENTORY_SLOT_ITEM_START && slot < INVENTORY_SLOT_ITEM_END) + { return true; + } // bank main slots if (slot >= BANK_SLOT_ITEM_START && slot < BANK_SLOT_ITEM_END) + { return true; + } // bank bag slots if (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END) + { return true; + } return false; } @@ -9295,11 +9727,15 @@ bool Player::IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const { Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (!pBag) + { return false; + } // any post selected if (slot == NULL_SLOT && !explicit_pos) + { return true; + } return slot < pBag->GetBagSize(); } @@ -9309,11 +9745,15 @@ bool Player::IsValidPos(uint8 bag, uint8 slot, bool explicit_pos) const { Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (!pBag) + { return false; + } // any post selected if (slot == NULL_SLOT && !explicit_pos) + { return true; + } return slot < pBag->GetBagSize(); } @@ -9332,7 +9772,9 @@ bool Player::HasItemCount(uint32 item, uint32 count, bool inBankAlso) const { tempcount += pItem->GetCount(); if (tempcount >= count) + { return true; + } } } for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) @@ -9346,7 +9788,9 @@ bool Player::HasItemCount(uint32 item, uint32 count, bool inBankAlso) const { tempcount += pItem->GetCount(); if (tempcount >= count) + { return true; + } } } } @@ -9361,7 +9805,9 @@ bool Player::HasItemCount(uint32 item, uint32 count, bool inBankAlso) const { tempcount += pItem->GetCount(); if (tempcount >= count) + { return true; + } } } for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) @@ -9375,7 +9821,9 @@ bool Player::HasItemCount(uint32 item, uint32 count, bool inBankAlso) const { tempcount += pItem->GetCount(); if (tempcount >= count) + { return true; + } } } } @@ -9398,7 +9846,9 @@ bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_ { tempcount += pItem->GetCount(); if (tempcount >= count) + { return true; + } } } @@ -9415,7 +9865,9 @@ bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_ { tempcount += pItem->GetGemCountWithID(item); if (tempcount >= count) + { return true; + } } } } @@ -9443,14 +9895,18 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 { tempcount += pItem->GetCount(); if (tempcount >= count) + { return true; + } } if (pProto->Socket[0].Color) { tempcount += pItem->GetGemCountWithLimitCategory(limitCategory); if (tempcount >= count) + { return true; + } } } @@ -9524,23 +9980,33 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, Item { // prevent cheating if ((slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) || slot >= PLAYER_SLOT_END) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } } else { Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (!pBag) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } ItemPrototype const* pBagProto = pBag->GetProto(); if (!pBagProto) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } if (slot >= pBagProto->ContainerSlots) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } if (!ItemCanGoIntoBag(pProto, pBagProto)) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } } // non empty stack with space @@ -9552,7 +10018,9 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, Item // can be merged at least partly InventoryResult res = pItem2->CanBeMergedPartlyWith(pProto); if (res != EQUIP_ERR_OK) + { return res; + } // free stack space or infinity need_space = pProto->GetMaxStackSize() - pItem2->GetCount(); @@ -9574,23 +10042,33 @@ InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, It { // skip specific bag already processed in first called _CanStoreItem_InBag if (bag == skip_bag) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } // skip nonexistent bag or self targeted bag Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); if (!pBag || pBag == pSrcItem) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } ItemPrototype const* pBagProto = pBag->GetProto(); if (!pBagProto) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } // specialized bag mode or non-specilized if (non_specialized != (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER)) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } if (!ItemCanGoIntoBag(pProto, pBagProto)) + { return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; + } for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { @@ -9631,7 +10109,9 @@ InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, It count -= need_space; if (count == 0) + { return EQUIP_ERR_OK; + } } } return EQUIP_ERR_OK; @@ -9678,7 +10158,9 @@ InventoryResult Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 s count -= need_space; if (count == 0) + { return EQUIP_ERR_OK; + } } } return EQUIP_ERR_OK; @@ -9742,7 +10224,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9771,7 +10255,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9795,7 +10281,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9818,7 +10306,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9841,7 +10331,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9866,7 +10358,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9884,7 +10378,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9902,7 +10398,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9923,7 +10421,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9934,7 +10434,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de // Normally it would be impossible to autostore not empty bags if (pItem && pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) + { return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; + } // search free slot res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); @@ -9948,7 +10450,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -9964,7 +10468,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { if (no_similar_count == 0) + { return EQUIP_ERR_OK; + } if (no_space_count) *no_space_count = count + no_similar_count; @@ -10028,15 +10534,21 @@ InventoryResult Player::CanStoreItems(Item** pItems, int count) const // strange item if (!pProto) + { return EQUIP_ERR_ITEM_NOT_FOUND; + } // item used if (pItem->HasTemporaryLoot()) + { return EQUIP_ERR_ALREADY_LOOTED; + } // item it 'bind' if (pItem->IsBindedNotWith(this)) + { return EQUIP_ERR_DONT_OWN_THAT_ITEM; + } Bag* pBag; ItemPrototype const* pBagProto; @@ -10044,7 +10556,9 @@ InventoryResult Player::CanStoreItems(Item** pItems, int count) const // item is 'one item only' InventoryResult res = CanTakeMoreSimilarItems(pItem); if (res != EQUIP_ERR_OK) + { return res; + } // search stack for merge to if (pProto->Stackable != 1) @@ -10153,7 +10667,9 @@ InventoryResult Player::CanStoreItems(Item** pItems, int count) const // no free slot found? if (!b_found) + { return EQUIP_ERR_INVENTORY_FULL; + } } return EQUIP_ERR_OK; @@ -10185,15 +10701,21 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool { // item used if (pItem->HasTemporaryLoot()) + { return EQUIP_ERR_ALREADY_LOOTED; + } if (pItem->IsBindedNotWith(this)) + { return EQUIP_ERR_DONT_OWN_THAT_ITEM; + } // check count of items (skip for auto move for same player from bank) InventoryResult res = CanTakeMoreSimilarItems(pItem); if (res != EQUIP_ERR_OK) + { return res; + } // check this only in game if (direct_action) @@ -10201,7 +10723,9 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool // May be here should be more stronger checks; STUNNED checked // ROOT, CONFUSED, DISTRACTED, FLEEING this needs to be checked. if (hasUnitState(UNIT_STAT_STUNNED)) + { return EQUIP_ERR_YOU_ARE_STUNNED; + } // do not allow equipping gear except weapons, offhands, projectiles, relics in // - combat @@ -10209,42 +10733,60 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool if (!pProto->CanChangeEquipStateInCombat()) { if (IsInCombat()) + { return EQUIP_ERR_NOT_IN_COMBAT; + } if (BattleGround* bg = GetBattleGround()) if (bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS) + { return EQUIP_ERR_NOT_DURING_ARENA_MATCH; + } } // prevent equip item in process logout if (GetSession()->isLogingOut()) + { return EQUIP_ERR_YOU_ARE_STUNNED; + } if (IsInCombat() && pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer != 0) return EQUIP_ERR_CANT_DO_RIGHT_NOW; // maybe exist better err if (IsNonMeleeSpellCasted(false)) + { return EQUIP_ERR_CANT_DO_RIGHT_NOW; + } } ScalingStatDistributionEntry const* ssd = pProto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) : 0; // check allowed level (extend range to upper values if MaxLevel more or equal max player level, this let GM set high level with 1...max range items) if (ssd && ssd->MaxLevel < DEFAULT_MAX_LEVEL && ssd->MaxLevel < getLevel()) + { return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; + } uint8 eslot = FindEquipSlot(pProto, slot, swap); if (eslot == NULL_SLOT) + { return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; + } InventoryResult msg = CanUseItem(pItem , direct_action); if (msg != EQUIP_ERR_OK) + { return msg; + } if (!swap && GetItemByPos(INVENTORY_SLOT_BAG_0, eslot)) + { return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE; + } // if swap ignore item (equipped also) if (InventoryResult res2 = CanEquipUniqueItem(pItem, swap ? eslot : uint8(NULL_SLOT))) + { return res2; + } // check unique-equipped special item classes if (pProto->Class == ITEM_CLASS_QUIVER) @@ -10274,16 +10816,22 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool if (type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND) { if (!CanDualWield()) + { return EQUIP_ERR_CANT_DUAL_WIELD; + } } else if (type == INVTYPE_2HWEAPON) { if (!CanDualWield() || !CanTitanGrip()) + { return EQUIP_ERR_CANT_DUAL_WIELD; + } } if (IsTwoHandUsed()) + { return EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED; + } } // equip two-hand weapon case (with possible unequip 2 items) @@ -10292,10 +10840,14 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool if (eslot == EQUIPMENT_SLOT_OFFHAND) { if (!CanTitanGrip()) + { return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; + } } else if (eslot != EQUIPMENT_SLOT_MAINHAND) + { return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; + } if (!CanTitanGrip()) { @@ -10320,23 +10872,31 @@ InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const { // Applied only to equipped items and bank bags if (!IsEquipmentPos(pos) && !IsBagPos(pos)) + { return EQUIP_ERR_OK; + } Item* pItem = GetItemByPos(pos); // Applied only to existing equipped item if (!pItem) + { return EQUIP_ERR_OK; + } DEBUG_LOG("STORAGE: CanUnequipItem slot = %u, item = %u, count = %u", pos, pItem->GetEntry(), pItem->GetCount()); ItemPrototype const* pProto = pItem->GetProto(); if (!pProto) + { return EQUIP_ERR_ITEM_NOT_FOUND; + } // item used if (pItem->HasTemporaryLoot()) + { return EQUIP_ERR_ALREADY_LOOTED; + } // do not allow unequipping gear except weapons, offhands, projectiles, relics in // - combat @@ -10344,19 +10904,27 @@ InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const if (!pProto->CanChangeEquipStateInCombat()) { if (IsInCombat()) + { return EQUIP_ERR_NOT_IN_COMBAT; + } if (BattleGround* bg = GetBattleGround()) if (bg->isArena() && bg->GetStatus() == STATUS_IN_PROGRESS) + { return EQUIP_ERR_NOT_DURING_ARENA_MATCH; + } } // prevent unequip item in process logout if (GetSession()->isLogingOut()) + { return EQUIP_ERR_YOU_ARE_STUNNED; + } if (!swap && pItem->IsBag() && !((Bag*)pItem)->IsEmpty()) + { return EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS; + } return EQUIP_ERR_OK; } @@ -10364,26 +10932,36 @@ InventoryResult Player::CanUnequipItem(uint16 pos, bool swap) const InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap, bool not_loading) const { if (!pItem) + { return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; + } uint32 count = pItem->GetCount(); DEBUG_LOG("STORAGE: CanBankItem bag = %u, slot = %u, item = %u, count = %u", bag, slot, pItem->GetEntry(), pItem->GetCount()); ItemPrototype const* pProto = pItem->GetProto(); if (!pProto) + { return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; + } // item used if (pItem->HasTemporaryLoot()) + { return EQUIP_ERR_ALREADY_LOOTED; + } if (pItem->IsBindedNotWith(this)) + { return EQUIP_ERR_DONT_OWN_THAT_ITEM; + } // check count of items (skip for auto move for same player from bank) InventoryResult res = CanTakeMoreSimilarItems(pItem); if (res != EQUIP_ERR_OK) + { return res; + } // in specific slot if (bag != NULL_BAG && slot != NULL_SLOT) @@ -10391,22 +10969,32 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest if (slot >= BANK_SLOT_BAG_START && slot < BANK_SLOT_BAG_END) { if (!pItem->IsBag()) + { return EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT; + } if (slot - BANK_SLOT_BAG_START >= GetBankBagSlotCount()) + { return EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT; + } res = CanUseItem(pItem, not_loading); if (res != EQUIP_ERR_OK) + { return res; + } } res = _CanStoreItem_InSpecificSlot(bag, slot, dest, pProto, count, swap, pItem); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } } // not specific slot or have space for partly store only in specific slot @@ -10418,7 +11006,9 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest { Bag* pBag = (Bag*)pItem; if (pBag && !pBag->IsEmpty()) + { return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; + } } // search stack in bag for merge to @@ -10428,10 +11018,14 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest { res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } } else { @@ -10440,10 +11034,14 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest res = _CanStoreItem_InBag(bag, dest, pProto, count, true, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } } } @@ -10452,10 +11050,14 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest { res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } } else { @@ -10464,10 +11066,14 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest res = _CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } } } @@ -10479,10 +11085,14 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest // in slots res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } // in special bags if (pProto->BagFamily) @@ -10494,7 +11104,9 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest continue; if (count == 0) + { return EQUIP_ERR_OK; + } } } @@ -10505,7 +11117,9 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest continue; if (count == 0) + { return EQUIP_ERR_OK; + } } } @@ -10519,17 +11133,23 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest continue; if (count == 0) + { return EQUIP_ERR_OK; + } } } // search free space res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) + { return res; + } if (count == 0) + { return EQUIP_ERR_OK; + } for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { @@ -10538,7 +11158,9 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest continue; if (count == 0) + { return EQUIP_ERR_OK; + } } return EQUIP_ERR_BANK_FULL; } @@ -10550,7 +11172,9 @@ InventoryResult Player::CanUseItem(Item* pItem, bool direct_action) const DEBUG_LOG("STORAGE: CanUseItem item = %u", pItem->GetEntry()); if (!IsAlive() && direct_action) + { return EQUIP_ERR_YOU_ARE_DEAD; + } // if (isStunned()) // return EQUIP_ERR_YOU_ARE_STUNNED; @@ -10559,11 +11183,15 @@ InventoryResult Player::CanUseItem(Item* pItem, bool direct_action) const if (pProto) { if (pItem->IsBindedNotWith(this)) + { return EQUIP_ERR_DONT_OWN_THAT_ITEM; + } InventoryResult msg = CanUseItem(pProto); if (msg != EQUIP_ERR_OK) + { return msg; + } if (uint32 item_use_skill = pItem->GetSkill()) { @@ -10571,11 +11199,15 @@ InventoryResult Player::CanUseItem(Item* pItem, bool direct_action) const { // armor items with scaling stats can downgrade armor skill reqs if related class can learn armor use at some level if (pProto->Class != ITEM_CLASS_ARMOR) + { return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + } ScalingStatDistributionEntry const* ssd = pProto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(pProto->ScalingStatDistribution) : NULL; if (!ssd) + { return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + } bool allowScaleSkill = false; for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i) @@ -10599,12 +11231,16 @@ InventoryResult Player::CanUseItem(Item* pItem, bool direct_action) const } if (!allowScaleSkill) + { return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + } } } if (pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank) + { return EQUIP_ERR_CANT_EQUIP_REPUTATION; + } return EQUIP_ERR_OK; } @@ -10619,32 +11255,48 @@ InventoryResult Player::CanUseItem(ItemPrototype const* pProto) const if (pProto) { if ((pProto->Flags2 & ITEM_FLAG2_HORDE_ONLY) && GetTeam() != HORDE) + { return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; + } if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && GetTeam() != ALLIANCE) + { return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; + } if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0) + { return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM; + } if (pProto->RequiredSkill != 0) { if (GetSkillValue(pProto->RequiredSkill) == 0) + { return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + } else if (GetSkillValue(pProto->RequiredSkill) < pProto->RequiredSkillRank) + { return EQUIP_ERR_CANT_EQUIP_SKILL; + } } if (pProto->RequiredSpell != 0 && !HasSpell(pProto->RequiredSpell)) + { return EQUIP_ERR_NO_REQUIRED_PROFICIENCY; + } if (getLevel() < pProto->RequiredLevel) + { return EQUIP_ERR_CANT_EQUIP_LEVEL_I; + } #ifdef ENABLE_ELUNA InventoryResult eres = sEluna->OnCanUseItem(this, pProto->ItemId); if (eres != EQUIP_ERR_OK) + { return eres; + } #endif return EQUIP_ERR_OK; @@ -10656,18 +11308,24 @@ InventoryResult Player::CanUseAmmo(uint32 item) const { DEBUG_LOG("STORAGE: CanUseAmmo item = %u", item); if (!IsAlive()) + { return EQUIP_ERR_YOU_ARE_DEAD; + } // if( isStunned() ) // return EQUIP_ERR_YOU_ARE_STUNNED; ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); if (pProto) { if (pProto->InventoryType != INVTYPE_AMMO) + { return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE; + } InventoryResult msg = CanUseItem(pProto); if (msg != EQUIP_ERR_OK) + { return msg; + } /*if ( GetReputationMgr().GetReputation() < pProto->RequiredReputation ) return EQUIP_ERR_CANT_EQUIP_REPUTATION; @@ -10675,7 +11333,9 @@ InventoryResult Player::CanUseAmmo(uint32 item) const // Requires No Ammo if (GetDummyAura(46699)) + { return EQUIP_ERR_BAG_FULL6; + } return EQUIP_ERR_OK; } @@ -10737,7 +11397,9 @@ Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update Item* Player::StoreItem(ItemPosCountVec const& dest, Item* pItem, bool update) { if (!pItem) + { return NULL; + } Item* lastItem = pItem; uint32 entry = pItem->GetEntry(); @@ -10766,7 +11428,9 @@ Item* Player::StoreItem(ItemPosCountVec const& dest, Item* pItem, bool update) Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update) { if (!pItem) + { return NULL; + } uint8 bag = pos >> 8; uint8 slot = pos & 255; @@ -10783,7 +11447,9 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool pItem->SetCount(count); if (!pItem) + { return NULL; + } if (pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM || @@ -11038,7 +11704,9 @@ void Player::SetVisibleItemSlot(uint8 slot, Item* pItem) void Player::VisualizeItem(uint8 slot, Item* pItem) { if (!pItem) + { return; + } // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) if (pItem->GetProto()->Bonding == BIND_WHEN_EQUIPPED || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM) @@ -11296,7 +11964,9 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) + { return; + } } else { @@ -11329,7 +11999,9 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ DestroyItem(i, j, update); if (remcount >= count) + { return; + } } else { @@ -11361,7 +12033,9 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) + { return; + } } } else @@ -11390,7 +12064,9 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ DestroyItem(INVENTORY_SLOT_BAG_0, i, update); if (remcount >= count) + { return; + } } else { @@ -11419,7 +12095,9 @@ void Player::DestroyItemCount(uint32 item, uint32 count, bool update, bool unequ DestroyItem(i, j, update); if (remcount >= count) + { return; + } } else { @@ -11492,7 +12170,9 @@ void Player::DestroyConjuredItems(bool update) void Player::DestroyItemCount(Item* pItem, uint32& count, bool update) { if (!pItem) + { return; + } DEBUG_LOG("STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(), pItem->GetEntry(), count); @@ -11632,7 +12312,9 @@ void Player::SwapItem(uint16 src, uint16 dst) Item* pDstItem = GetItemByPos(dstbag, dstslot); if (!pSrcItem) + { return; + } DEBUG_LOG("STORAGE: SwapItem bag = %u, slot = %u, item = %u", dstbag, dstslot, pSrcItem->GetEntry()); @@ -11750,7 +12432,9 @@ void Player::SwapItem(uint16 src, uint16 dst) else if (IsEquipmentPos(dst)) msg = CanEquipItem(dstslot, eDest, pSrcItem, false); else + { return; + } // can be merge/fill if (msg == EQUIP_ERR_OK) @@ -11973,7 +12657,9 @@ Item* Player::GetItemFromBuyBackSlot(uint32 slot) { DEBUG_LOG("STORAGE: GetItemFromBuyBackSlot slot = %u", slot); if (slot >= BUYBACK_SLOT_START && slot < BUYBACK_SLOT_END) + { return m_items[slot]; + } return NULL; } @@ -12092,7 +12778,9 @@ void Player::TradeCancel(bool sendback) void Player::UpdateItemDuration(uint32 time, bool realtimeonly) { if (m_itemDuration.empty()) + { return; + } DEBUG_LOG("Player::UpdateItemDuration(%u,%u)", time, realtimeonly); @@ -12204,10 +12892,14 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) void Player::AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 duration) { if (!item) + { return; + } if (slot >= MAX_ENCHANTMENT_SLOT) + { return; + } for (EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { @@ -12234,16 +12926,24 @@ void Player::ApplyEnchantment(Item* item, bool apply) void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool apply_dur, bool ignore_condition) { if (slot > PRISMATIC_ENCHANTMENT_SLOT && slot < PROP_ENCHANTMENT_SLOT_0) + { return; + } if (!item) + { return; + } if (!item->IsEquipped()) + { return; + } if (slot >= MAX_ENCHANTMENT_SLOT) + { return; + } if (slot == REFORGE_ENCHANTMENT_SLOT) { @@ -12253,14 +12953,20 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool uint32 enchant_id = item->GetEnchantmentId(slot); if (!enchant_id) + { return; + } SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) + { return; + } if (!ignore_condition && pEnchant->EnchantmentCondition && !EnchantmentFitsRequirements(pEnchant->EnchantmentCondition, -1)) + { return; + } if (!item->IsBroken()) { @@ -12546,11 +13252,15 @@ void Player::ApplyReforgeEnchantment(Item* item, bool apply) { if (!item) + { return; + } ItemReforgeEntry const* reforge = sItemReforgeStore.LookupEntry(item->GetEnchantmentId(REFORGE_ENCHANTMENT_SLOT)); if (!reforge) + { return; + } float removeValue = item->GetReforgableStat(ItemModType(reforge->SourceStat)) * reforge->SourceMultiplier; @@ -12795,7 +13505,9 @@ void Player::SendItemDurations() void Player::SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast) { if (!item) // prevent crash + { return; + } // last check 2.0.10 WorldPacket data(SMSG_ITEM_PUSH_RESULT, (8 + 4 + 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4)); @@ -12915,7 +13627,9 @@ void Player::PrepareGossipMenu(WorldObject* pSource, uint32 menuId) break; case GOSSIP_OPTION_TAXIVENDOR: if (GetSession()->SendLearnNewTaxiNode(pCreature)) + { return; + } break; case GOSSIP_OPTION_BATTLEFIELD: if (!pCreature->CanInteractWithBattleMaster(this, false)) @@ -13014,7 +13728,9 @@ void Player::PrepareGossipMenu(WorldObject* pSource, uint32 menuId) void Player::SendPreparedGossip(WorldObject* pSource) { if (!pSource) + { return; + } if (pSource->GetTypeId() == TYPEID_UNIT) { @@ -13051,11 +13767,15 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me GossipMenu& gossipmenu = PlayerTalkClass->GetGossipMenu(); if (gossipListId >= gossipmenu.MenuItemCount()) + { return; + } // if not same, then something funky is going on if (menuId != gossipmenu.GetMenuId()) + { return; + } GossipMenuItem const& menu_item = gossipmenu.GetItem(gossipListId); @@ -13181,17 +13901,23 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me GetMap()->ScriptsStart(DBS_ON_GOSSIP, pMenuData.m_gAction_script, pSource, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); } else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT) - { GetMap()->ScriptsStart(DBS_ON_GOSSIP, pMenuData.m_gAction_script, this, pSource, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET); } + { + GetMap()->ScriptsStart(DBS_ON_GOSSIP, pMenuData.m_gAction_script, this, pSource, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET); + } } } uint32 Player::GetGossipTextId(WorldObject* pSource) { if (!pSource || pSource->GetTypeId() != TYPEID_UNIT) + { return DEFAULT_GOSSIP_MESSAGE; + } if (uint32 pos = sObjectMgr.GetNpcGossip(((Creature*)pSource)->GetGUIDLow())) + { return pos; + } return DEFAULT_GOSSIP_MESSAGE; } @@ -13201,7 +13927,9 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource) uint32 textId = DEFAULT_GOSSIP_MESSAGE; if (!menuId) + { return textId; + } uint32 scriptId = 0; uint32 lastConditionId = 0; @@ -13232,9 +13960,13 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource) uint32 Player::GetDefaultGossipMenuForSource(WorldObject* pSource) { if (pSource->GetTypeId() == TYPEID_UNIT) + { return ((Creature*)pSource)->GetCreatureInfo()->GossipMenuId; + } else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT) + { return ((GameObject*)pSource)->GetGOInfo()->GetGossipMenuId(); + } return 0; } @@ -13267,7 +13999,9 @@ void Player::PrepareQuestMenu(ObjectGuid guid) irbounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(pGameObject->GetEntry()); } else + { return; + } } QuestMenu& qm = PlayerTalkClass->GetQuestMenu(); @@ -13315,7 +14049,9 @@ void Player::SendPreparedQuest(ObjectGuid guid) QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu(); if (questMenu.Empty()) + { return; + } QuestMenuItem const& qmi0 = questMenu.GetItem(0); @@ -13390,7 +14126,9 @@ bool Player::IsCurrentQuest(uint32 quest_id, uint8 completed_or_not) const { QuestStatusMap::const_iterator itr = mQuestStatus.find(quest_id); if (itr == mQuestStatus.end()) + { return false; + } switch (completed_or_not) { @@ -13423,14 +14161,18 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* pQuest) rbounds = sObjectMgr.GetGOQuestRelationsMapBounds(pGameObject->GetEntry()); } else + { return NULL; + } } uint32 nextQuestID = pQuest->GetNextQuestInChain(); for (QuestRelationsMap::const_iterator itr = rbounds.first; itr != rbounds.second; ++itr) { if (itr->second == nextQuestID) + { return sObjectMgr.GetQuestTemplate(nextQuestID); + } } return NULL; @@ -13452,7 +14194,9 @@ bool Player::CanSeeStartQuest(Quest const* pQuest) const { int32 highLevelDiff = sWorld.getConfig(CONFIG_INT32_QUEST_HIGH_LEVEL_HIDE_DIFF); if (highLevelDiff < 0) + { return true; + } return getLevel() + uint32(highLevelDiff) >= pQuest->GetMinLevel(); } @@ -13474,10 +14218,14 @@ bool Player::CanTakeQuest(Quest const* pQuest, bool msg) const bool Player::CanAddQuest(Quest const* pQuest, bool msg) const { if (!SatisfyQuestLog(msg)) + { return false; + } if (!CanGiveQuestSourceItemIfNeed(pQuest)) + { return false; + } return true; } @@ -13485,7 +14233,9 @@ bool Player::CanAddQuest(Quest const* pQuest, bool msg) const bool Player::CanCompleteQuest(uint32 quest_id) const { if (!quest_id) + { return false; + } QuestStatusMap::const_iterator q_itr = mQuestStatus.find(quest_id); @@ -13498,7 +14248,9 @@ bool Player::CanCompleteQuest(uint32 quest_id) const Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id); if (!qInfo) + { return false; + } // only used for "flag" quests and not real in-game quests if (qInfo->HasQuestFlag(QUEST_FLAGS_AUTO_REWARDED)) @@ -13513,10 +14265,14 @@ bool Player::CanCompleteQuest(uint32 quest_id) const // auto complete quest if (qInfo->IsAutoComplete() && CanTakeQuest(qInfo, false)) + { return true; + } if (status != QUEST_STATUS_INCOMPLETE) + { return false; + } // incomplete quest have status data QuestStatusData const& q_status = q_itr->second; @@ -13526,13 +14282,17 @@ bool Player::CanCompleteQuest(uint32 quest_id) const for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { if (qInfo->ReqItemCount[i] != 0 && q_status.m_itemcount[i] < qInfo->ReqItemCount[i]) + { return false; + } } for (int i = 0; i < QUEST_REQUIRED_CURRENCY_COUNT; ++i) { if (qInfo->ReqCurrencyId[i] && !HasCurrencyCount(qInfo->ReqCurrencyId[i], int32(qInfo->ReqCurrencyCount[i] * GetCurrencyPrecision(qInfo->ReqCurrencyId[i])))) + { return false; + } } } @@ -13544,29 +14304,41 @@ bool Player::CanCompleteQuest(uint32 quest_id) const continue; if (qInfo->ReqCreatureOrGOCount[i] != 0 && q_status.m_creatureOrGOcount[i] < qInfo->ReqCreatureOrGOCount[i]) + { return false; + } } } if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT) && !q_status.m_explored) + { return false; + } if (qInfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_TIMED) && q_status.m_timer == 0) + { return false; + } if (qInfo->GetRewOrReqMoney() < 0) { if (GetMoney() < uint64(-qInfo->GetRewOrReqMoney())) + { return false; + } } uint32 repFacId = qInfo->GetRepObjectiveFaction(); if (repFacId && GetReputationMgr().GetReputation(repFacId) < qInfo->GetRepObjectiveValue()) + { return false; + } if (uint32 spell = qInfo->GetReqSpellLearned()) if (!HasSpell(spell)) + { return false; + } return true; } @@ -13577,23 +14349,31 @@ bool Player::CanCompleteRepeatableQuest(Quest const* pQuest) const // if repeatable she must be able to complete event if player don't have it. // Seem that all repeatable quest are DELIVER Flag so, no need to add more. if (!CanTakeQuest(pQuest, false)) + { return false; + } if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) { for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) if (pQuest->ReqItemId[i] && pQuest->ReqItemCount[i] && !HasItemCount(pQuest->ReqItemId[i], pQuest->ReqItemCount[i])) + { return false; + } for (int i = 0; i < QUEST_REQUIRED_CURRENCY_COUNT; ++i) { if (pQuest->ReqCurrencyId[i] && !HasCurrencyCount(pQuest->ReqCurrencyId[i], int32(pQuest->ReqCurrencyCount[i] * GetCurrencyPrecision(pQuest->ReqCurrencyId[i])))) + { return false; + } } } if (!CanRewardQuest(pQuest, false)) + { return false; + } return true; } @@ -13602,15 +14382,21 @@ bool Player::CanRewardQuest(Quest const* pQuest, bool msg) const { // not auto complete quest and not completed quest (only cheating case, then ignore without message) if (!pQuest->IsAutoComplete() && GetQuestStatus(pQuest->GetQuestId()) != QUEST_STATUS_COMPLETE) + { return false; + } // daily quest can't be rewarded (25 daily quest already completed) if (!SatisfyQuestDay(pQuest, true) || !SatisfyQuestWeek(pQuest, true) || !SatisfyQuestMonth(pQuest, true)) + { return false; + } // rewarded and not repeatable quest (only cheating case, then ignore without message) if (GetQuestRewardStatus(pQuest->GetQuestId())) + { return false; + } if (pQuest->HasSpecialFlag(QUEST_SPECIAL_FLAG_DELIVER)) { @@ -13643,11 +14429,15 @@ bool Player::CanRewardQuest(Quest const* pQuest, bool msg) const // prevent receive reward with low money and GetRewOrReqMoney() < 0 if (pQuest->GetRewOrReqMoney() < 0 && GetMoney() < uint64(-pQuest->GetRewOrReqMoney())) + { return false; + } if (uint32 spell = pQuest->GetReqSpellLearned()) if (!HasSpell(spell)) + { return false; + } return true; } @@ -13656,7 +14446,9 @@ bool Player::CanRewardQuest(Quest const* pQuest, uint32 reward, bool msg) const { // prevent receive reward with quest items in bank or for not completed quest if (!CanRewardQuest(pQuest, msg)) + { return false; + } if (pQuest->GetRewChoiceItemsCount() > 0) { @@ -14077,7 +14869,9 @@ bool Player::SatisfyQuestSkill(Quest const* qInfo, bool msg) const // skip 0 case RequiredSkill if (skill == 0) + { return true; + } // check skill value if (GetSkillValue(skill) < qInfo->GetRequiredSkillValue()) @@ -14097,7 +14891,9 @@ bool Player::SatisfyQuestSpell(Quest const* qInfo, bool msg) const // skip 0 case ReqSpellLearned if (spell == 0) + { return true; + } // check spell if (!HasSpell(spell)) @@ -14128,7 +14924,9 @@ bool Player::SatisfyQuestLog(bool msg) const { // exist free slot if (FindQuestSlot(0) < MAX_QUEST_LOG_SIZE) + { return true; + } if (msg) { @@ -14143,7 +14941,9 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const { // No previous quest (might be first quest in a series) if (qInfo->prevQuests.empty()) + { return true; + } for (Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter) { @@ -14159,12 +14959,16 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const { // skip one-from-all exclusive group if (qPrevInfo->GetExclusiveGroup() >= 0) + { return true; + } // each-from-all exclusive group ( < 0) // given a group with 2+ quests, and one of those has a branch that is not restricted by the group, return true if (qInfo->GetPrevQuestId() != 0 && qPrevInfo->GetNextQuestId() != qInfo->GetPrevQuestId()) + { return true; + } // can be start if only all quests in prev quest exclusive group completed and rewarded ExclusiveQuestGroupsMapBounds bounds = sObjectMgr.GetExclusiveQuestGroupsMapBounds(qPrevInfo->GetExclusiveGroup()); @@ -14197,12 +15001,16 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const { // skip one-from-all exclusive group if (qPrevInfo->GetExclusiveGroup() >= 0) + { return true; + } // each-from-all exclusive group ( < 0) // given a group with 2+ quests, and one of those has a branch that is not restricted by the group, return true if (qInfo->GetPrevQuestId() != 0 && qPrevInfo->GetNextQuestId() != abs(qInfo->GetPrevQuestId())) + { return true; + } // each-from-all exclusive group ( < 0) // can be start if only all quests in prev quest exclusive group active @@ -14245,7 +15053,9 @@ bool Player::SatisfyQuestClass(Quest const* qInfo, bool msg) const uint32 reqClass = qInfo->GetRequiredClasses(); if (reqClass == 0) + { return true; + } if ((reqClass & getClassMask()) == 0) { @@ -14263,7 +15073,9 @@ bool Player::SatisfyQuestRace(Quest const* qInfo, bool msg) const uint32 reqraces = qInfo->GetRequiredRaces(); if (reqraces == 0) + { return true; + } if ((reqraces & getRaceMask()) == 0) { @@ -14331,7 +15143,9 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const { // non positive exclusive group, if > 0 then can be start if any other quest in exclusive group already started/completed if (qInfo->GetExclusiveGroup() <= 0) + { return true; + } ExclusiveQuestGroupsMapBounds bounds = sObjectMgr.GetExclusiveQuestGroupsMapBounds(qInfo->GetExclusiveGroup()); @@ -14374,7 +15188,9 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg) const bool Player::SatisfyQuestNextChain(Quest const* qInfo, bool msg) const { if (!qInfo->GetNextQuestInChain()) + { return true; + } // next quest in chain already started or completed QuestStatusMap::const_iterator itr = mQuestStatus.find(qInfo->GetNextQuestInChain()); @@ -14397,7 +15213,9 @@ bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg) const { // No previous quest in chain if (qInfo->prevChainQuests.empty()) + { return true; + } for (Quest::PrevChainQuests::const_iterator iter = qInfo->prevChainQuests.begin(); iter != qInfo->prevChainQuests.end(); ++iter) { @@ -14425,14 +15243,18 @@ bool Player::SatisfyQuestPrevChain(Quest const* qInfo, bool msg) const bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) const { if (!qInfo->IsDaily()) + { return true; + } bool have_slot = false; for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx); if (qInfo->GetQuestId() == id) + { return false; + } if (!id) have_slot = true; @@ -14452,7 +15274,9 @@ bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) const bool Player::SatisfyQuestWeek(Quest const* qInfo, bool /*msg*/) const { if (!qInfo->IsWeekly() || m_weeklyquests.empty()) + { return true; + } // if not found in cooldown list return m_weeklyquests.find(qInfo->GetQuestId()) == m_weeklyquests.end(); @@ -14461,7 +15285,9 @@ bool Player::SatisfyQuestWeek(Quest const* qInfo, bool /*msg*/) const bool Player::SatisfyQuestMonth(Quest const* qInfo, bool /*msg*/) const { if (!qInfo->IsMonthly() || m_monthlyquests.empty()) + { return true; + } // if not found in cooldown list return m_monthlyquests.find(qInfo->GetQuestId()) == m_monthlyquests.end(); @@ -14476,7 +15302,9 @@ bool Player::CanGiveQuestSourceItemIfNeed(Quest const* pQuest, ItemPosCountVec* // player already have max amount required item (including bank), just report success uint32 has_count = GetItemCount(srcitem, true); if (has_count >= count) + { return true; + } count -= has_count; // real need amount @@ -14490,7 +15318,9 @@ bool Player::CanGiveQuestSourceItemIfNeed(Quest const* pQuest, ItemPosCountVec* msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, *dest, srcitem, count); if (msg == EQUIP_ERR_OK) + { return true; + } else SendEquipError(msg, NULL, NULL, srcitem); return false; @@ -14565,7 +15395,9 @@ QuestStatus Player::GetQuestStatus(uint32 quest_id) const if (itr != mQuestStatus.end()) { if (itr->second.m_status == QUEST_STATUS_FORCE_COMPLETE) + { return QUEST_STATUS_COMPLETE; + } return itr->second.m_status; } } @@ -14576,7 +15408,9 @@ bool Player::CanShareQuest(uint32 quest_id) const { if (Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id)) if (qInfo->HasQuestFlag(QUEST_FLAGS_SHARABLE)) + { return IsCurrentQuest(quest_id); + } return false; } @@ -14601,11 +15435,15 @@ uint32 Player::GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry) { Quest const* qInfo = sObjectMgr.GetQuestTemplate(quest_id); if (!qInfo) + { return 0; + } for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) if (qInfo->ReqCreatureOrGOId[j] == entry) + { return mQuestStatus[quest_id].m_creatureOrGOcount[j]; + } return 0; } @@ -14632,7 +15470,9 @@ uint16 Player::FindQuestSlot(uint32 quest_id) const { for (uint16 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) if (GetQuestSlotQuestId(i) == quest_id) + { return i; + } return MAX_QUEST_LOG_SIZE; } @@ -15155,7 +15995,9 @@ bool Player::HasQuestForItem(uint32 itemid) const for (int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { if (itemid == qinfo->ReqItemId[j] && q_status.m_itemcount[j] < qinfo->ReqItemCount[j]) + { return true; + } } // This part - for ReqSource for (int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j) @@ -15167,16 +16009,22 @@ bool Player::HasQuestForItem(uint32 itemid) const // 'unique' item if (pProto->MaxCount && (int32)GetItemCount(itemid, true) < pProto->MaxCount) + { return true; + } // allows custom amount drop when not 0 if (qinfo->ReqSourceCount[j]) { if (GetItemCount(itemid, true) < qinfo->ReqSourceCount[j]) + { return true; + } } else if ((int32)GetItemCount(itemid, true) < pProto->Stackable) + { return true; + } } } } @@ -15396,7 +16244,9 @@ void Player::SendQuestGiverStatusMultiple() void Player::_LoadDeclinedNames(QueryResult* result) { if (!result) + { return; + } delete m_declinedname; m_declinedname = new DeclinedName; @@ -15413,7 +16263,9 @@ void Player::_LoadArenaTeamInfo(QueryResult* result) // arenateamid, played_week, played_season, personal_rating memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32) * MAX_ARENA_SLOT * ARENA_TEAM_END); if (!result) + { return; + } do { @@ -15449,7 +16301,9 @@ void Player::_LoadEquipmentSets(QueryResult* result) { // SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", GUID_LOPART(m_guid)); if (!result) + { return; + } uint32 count = 0; do @@ -15482,7 +16336,9 @@ void Player::_LoadEquipmentSets(QueryResult* result) void Player::_LoadBGData(QueryResult* result) { if (!result) + { return; + } // Expecting only one row Field* fields = result->Fetch(); @@ -15505,7 +16361,9 @@ bool Player::LoadPositionFromDB(ObjectGuid guid, uint32& mapid, float& x, float& { QueryResult* result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'", guid.GetCounter()); if (!result) + { return false; + } Field* fields = result->Fetch(); @@ -15523,12 +16381,16 @@ bool Player::LoadPositionFromDB(ObjectGuid guid, uint32& mapid, float& x, float& void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count) { if (!data) + { return; + } Tokens tokens = StrSplit(data, " "); if (tokens.size() != count) + { return; + } Tokens::iterator iter; uint32 index; @@ -16179,7 +17041,9 @@ bool Player::IsTappedByMeOrMyGroup(Creature* creature) } /* We're not in a group, check to make sure we're the recipient (prevent cheaters) */ else if (recipient == this) - { return true; } + { + return true; + } } else /* Don't know what happened to the recipient, probably disconnected @@ -16193,18 +17057,24 @@ bool Player::isAllowedToLoot(Creature* creature) { // never tapped by any (mob solo kill) if (!creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED)) + { return false; + } if (Player* recipient = creature->GetLootRecipient()) { if (recipient == this) + { return true; + } if (Group* otherGroup = recipient->GetGroup()) { Group* thisGroup = GetGroup(); if (!thisGroup) + { return false; + } return thisGroup == otherGroup; } @@ -16349,7 +17219,9 @@ void Player::_LoadAuras(QueryResult* result, uint32 timediff) void Player::_LoadGlyphs(QueryResult* result) { if (!result) + { return; + } // 0 1 2 // "SELECT spec, slot, glyph FROM character_glyphs WHERE guid='%u'" @@ -16617,7 +17489,9 @@ void Player::_LoadMailedItems(QueryResult* result) // 0 1 2 3 4 // "SELECT data, text, mail_id, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE receiver = '%u'", GUID_LOPART(m_guid) if (!result) + { return; + } do { @@ -16665,7 +17539,9 @@ void Player::_LoadMails(QueryResult* result) // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 //"SELECT id,messageType,sender,receiver,subject,body,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId,has_items FROM mail WHERE receiver = '%u' ORDER BY id DESC", GetGUIDLow() if (!result) + { return; + } do { @@ -17128,13 +18004,19 @@ InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, Difficulty difficulty // some instances only have one difficulty MapDifficultyEntry const* mapDiff = GetMapDifficultyData(mapid, difficulty); if (!mapDiff) + { return NULL; + } BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); if (itr != m_boundInstances[difficulty].end()) + { return &itr->second; + } else + { return NULL; + } } void Player::UnbindInstance(uint32 mapid, Difficulty difficulty, bool unload) @@ -17200,14 +18082,18 @@ InstancePlayerBind* Player::BindToInstance(DungeonPersistentState* state, bool p return &bind; } else + { return NULL; + } } DungeonPersistentState* Player::GetBoundInstanceSaveForSelfOrGroup(uint32 mapid) { MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry) + { return NULL; + } InstancePlayerBind* pBind = GetBoundInstance(mapid, GetDifficulty(mapEntry->IsRaid())); DungeonPersistentState* state = pBind ? pBind->state : NULL; @@ -17285,7 +18171,9 @@ void Player::SendSavedInstances() GetSession()->SendPacket(&data); if (!hasBeenSaved) + { return; + } for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) { @@ -17697,7 +18585,9 @@ void Player::_SaveAuras() SpellAuraHolderMap const& auraHolders = GetSpellAuraHolderMap(); if (auraHolders.empty()) + { return; + } stmt = CharacterDatabase.CreateStatement(insertAuras, "INSERT INTO character_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, " "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " @@ -18030,7 +18920,9 @@ void Player::_SaveQuestStatus() void Player::_SaveDailyQuestStatus() { if (!m_DailyQuestChanged) + { return; + } // we don't need transactions here. static SqlStatementID delQuestStatus ; @@ -18051,7 +18943,9 @@ void Player::_SaveDailyQuestStatus() void Player::_SaveWeeklyQuestStatus() { if (!m_WeeklyQuestChanged || m_weeklyquests.empty()) + { return; + } // we don't need transactions here. static SqlStatementID delQuestStatus ; @@ -18074,7 +18968,9 @@ void Player::_SaveWeeklyQuestStatus() void Player::_SaveMonthlyQuestStatus() { if (!m_MonthlyQuestChanged || m_monthlyquests.empty()) + { return; + } // we don't need transactions here. static SqlStatementID deleteQuest ; @@ -18216,7 +19112,9 @@ void Player::_SaveStats() { // check if stat saving is enabled and if char level is high enough if (!sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_STAT_SAVE) || getLevel() < sWorld.getConfig(CONFIG_UINT32_MIN_LEVEL_STAT_SAVE)) + { return; + } static SqlStatementID delStats ; static SqlStatementID insertStats ; @@ -18281,14 +19179,18 @@ void Player::UpdateSpeakTime() { // ignore chat spam protection for GMs in any mode if (GetSession()->GetSecurity() > SEC_PLAYER) + { return; + } time_t current = time(NULL); if (m_speakTime > current) { uint32 max_count = sWorld.getConfig(CONFIG_UINT32_CHATFLOOD_MESSAGE_COUNT); if (!max_count) + { return; + } ++m_speakCount; if (m_speakCount >= max_count) @@ -18339,7 +19241,9 @@ void Player::SetUInt32ValueInArray(Tokens& tokens, uint16 index, uint32 value) snprintf(buf, 11, "%u", value); if (index >= tokens.size()) + { return; + } tokens[index] = buf; } @@ -18349,7 +19253,9 @@ void Player::Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, ui // 0 QueryResult* result = CharacterDatabase.PQuery("SELECT playerBytes2 FROM characters WHERE guid = '%u'", guid.GetCounter()); if (!result) + { return; + } Field* fields = result->Fetch(); @@ -18506,7 +19412,9 @@ void Player::UpdateAfkReport(time_t currTime) void Player::UpdateContestedPvP(uint32 diff) { if (!m_contestedPvPTimer || IsInCombat()) + { return; + } if (m_contestedPvPTimer <= diff) { ResetContestedPvP(); @@ -18518,9 +19426,13 @@ void Player::UpdateContestedPvP(uint32 diff) void Player::UpdatePvPFlag(time_t currTime) { if (!IsPvP()) + { return; + } if (pvpInfo.endTimer == 0 || currTime < (pvpInfo.endTimer + 300)) + { return; + } UpdatePvP(false); } @@ -18528,7 +19440,9 @@ void Player::UpdatePvPFlag(time_t currTime) void Player::UpdateDuelFlag(time_t currTime) { if (!duel || duel->startTimer == 0 || currTime < duel->startTimer + 3) + { return; + } // Used by Eluna #ifdef ENABLE_ELUNA @@ -18581,7 +19495,9 @@ void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiv // do not send confirmations, afk, dnd or system notifications for addon messages if (language == LANG_ADDON) + { return; + } data.clear(); ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER_INFORM, text.c_str(), Language(language), CHAT_TAG_NONE, rPlayer->GetObjectGuid()); @@ -18608,7 +19524,9 @@ void Player::PetSpellInitialize() Pet* pet = GetPet(); if (!pet) + { return; + } DEBUG_LOG("Pet Spells Groups"); @@ -18675,7 +19593,9 @@ void Player::PetSpellInitialize() void Player::SendPetGUIDs() { if (!GetPetGuid()) + { return; + } // Later this function might get modified for multiple guids WorldPacket data(SMSG_PET_GUIDS, 12); @@ -18689,7 +19609,9 @@ void Player::PossessSpellInitialize() Unit* charm = GetCharm(); if (!charm) + { return; + } CharmInfo* charmInfo = charm->GetCharmInfo(); @@ -18718,7 +19640,9 @@ void Player::CharmSpellInitialize() Unit* charm = GetCharm(); if (!charm) + { return; + } CharmInfo* charmInfo = charm->GetCharmInfo(); if (!charmInfo) @@ -18827,7 +19751,9 @@ template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& bas { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return 0; + } int32 totalpct = 0; int32 totalflat = 0; @@ -18912,7 +19838,9 @@ void Player::LeaveAllArenaTeams(ObjectGuid guid) uint32 lowguid = guid.GetCounter(); QueryResult* result = CharacterDatabase.PQuery("SELECT arena_team_member.arenateamid FROM arena_team_member JOIN arena_team ON arena_team_member.arenateamid = arena_team.arenateamid WHERE guid='%u'", lowguid); if (!result) + { return; + } do { @@ -19000,7 +19928,9 @@ void Player::HandleStealthedUnitsDetection() bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc /*= NULL*/, uint32 spellid /*= 0*/) { if (nodes.size() < 2) + { return false; + } // not let cheating with start flight in time of logout process || if casting not finished || while in combat || if not use Spell's with EffectSendTaxi if (GetSession()->isLogingOut() || IsInCombat()) @@ -19010,7 +19940,9 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc } if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE)) + { return false; + } // taximaster case if (npc) @@ -19171,7 +20103,9 @@ bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 0*/) { TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(taxi_path_id); if (!entry) + { return false; + } std::vector nodes; @@ -19186,7 +20120,9 @@ void Player::ContinueTaxiFlight() { uint32 sourceNode = m_taxi.GetTaxiSource(); if (!sourceNode) + { return; + } DEBUG_LOG("WORLD: Restart character %u taxi flight", GetGUIDLow()); @@ -19372,7 +20308,9 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin if (count < 1) count = 1; if (!IsAlive()) + { return false; + } ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); if (!pProto) @@ -19577,7 +20515,9 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin } if (!pItem) + { return false; + } uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem, totalCount); @@ -19599,14 +20539,20 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, if (count < 1) count = 1; if (!IsAlive()) + { return false; + } CurrencyTypesEntry const* pCurrency = sCurrencyTypesStore.LookupEntry(currencyId); if (!pCurrency) + { return false; + } if (pCurrency->Category == CURRENCY_CATEGORY_META) + { return false; + } Creature* pCreature = GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); if (!pCreature) @@ -19618,20 +20564,28 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, VendorItemData const* vItems = pCreature->GetVendorItems(); VendorItemData const* tItems = pCreature->GetVendorTemplateItems(); if ((!vItems || vItems->Empty()) && (!tItems || tItems->Empty())) + { return false; + } uint32 vCount = vItems ? vItems->GetItemCount() : 0; uint32 tCount = tItems ? tItems->GetItemCount() : 0; if (vendorslot >= vCount + tCount) + { return false; + } VendorItem const* crItem = vendorslot < vCount ? vItems->GetItem(vendorslot) : tItems->GetItem(vendorslot - vCount); if (!crItem) // store diff item (cheating) + { return false; + } if (crItem->item != currencyId) // store diff item (cheating) + { return false; + } if (!crItem->maxcount) { @@ -19875,7 +20829,9 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it // no cooldown after applying spell mods if (rec == 0 && catrec == 0) + { return; + } catrecTime = catrec ? curTime + catrec / IN_MILLISECONDS : 0; recTime = rec ? curTime + rec / IN_MILLISECONDS : catrecTime; @@ -19926,7 +20882,9 @@ void Player::UpdatePotionCooldown(Spell* spell) { // no potion used in combat or still in combat if (!m_lastPotionId || IsInCombat()) + { return; + } // Call not from spell cast, send cooldown event for item spells if no in combat if (!spell) @@ -19949,12 +20907,16 @@ void Player::UpdatePotionCooldown(Spell* spell) bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) { if (!enchantmentcondition) + { return true; + } SpellItemEnchantmentConditionEntry const* Condition = sSpellItemEnchantmentConditionStore.LookupEntry(enchantmentcondition); if (!Condition) + { return true; + } uint8 curcount[4] = {0, 0, 0, 0}; @@ -20187,7 +21149,9 @@ bool Player::CanJoinToBattleground() const { // check Deserter debuff if (GetDummyAura(26013)) + { return false; + } return true; } @@ -20196,7 +21160,9 @@ bool Player::CanReportAfkDueToLimit() { // a player can complain about 15 people per 5 minutes if (m_bgData.bgAfkReportedCount++ >= 15) + { return false; + } return true; } @@ -20206,7 +21172,9 @@ void Player::ReportedAfkBy(Player* reporter) { BattleGround* bg = GetBattleGround(); if (!bg || bg != reporter->GetBattleGround() || GetTeam() != reporter->GetTeam()) + { return; + } // check if player has 'Idle' or 'Inactive' debuff if (m_bgData.bgAfkReporter.find(reporter->GetGUIDLow()) == m_bgData.bgAfkReporter.end() && !HasAura(43680, EFFECT_INDEX_0) && !HasAura(43681, EFFECT_INDEX_0) && reporter->CanReportAfkDueToLimit()) @@ -20226,19 +21194,27 @@ bool Player::IsVisibleInGridForPlayer(Player* pl) const { // gamemaster in GM mode see all, including ghosts if (pl->isGameMaster() && GetSession()->GetSecurity() <= pl->GetSession()->GetSecurity()) + { return true; + } // player see dead player/ghost from own group/raid if (IsInSameRaidWith(pl)) + { return true; + } // Live player see live player or dead player with not realized corpse if (pl->IsAlive() || pl->m_deathTimer > 0) + { return IsAlive() || m_deathTimer > 0; + } // Ghost see other friendly ghosts, that's for sure if (!(IsAlive() || m_deathTimer > 0) && IsFriendlyTo(pl)) + { return true; + } // Dead player see live players near own corpse if (IsAlive()) @@ -20247,7 +21223,9 @@ bool Player::IsVisibleInGridForPlayer(Player* pl) const { // 20 - aggro distance for same level, 25 - max additional distance if player level less that creature level if (corpse->IsWithinDistInMap(this, (20 + 25) * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO))) + { return true; + } } } @@ -20258,23 +21236,33 @@ bool Player::IsVisibleInGridForPlayer(Player* pl) const bool Player::IsVisibleGloballyFor(Player* u) const { if (!u) + { return false; + } // Always can see self if (u == this) + { return true; + } // Visible units, always are visible for all players if (GetVisibility() == VISIBILITY_ON) + { return true; + } // GMs are visible for higher gms (or players are visible for gms) if (u->GetSession()->GetSecurity() > SEC_PLAYER) + { return GetSession()->GetSecurity() <= u->GetSession()->GetSecurity(); + } // non faction visibility non-breakable for non-GMs if (GetVisibility() == VISIBILITY_OFF) + { return false; + } // non-gm stealth/invisibility not hide from global player lists return true; @@ -20411,7 +21399,9 @@ void Player::SendComboPoints() void Player::AddComboPoints(Unit* target, int8 count) { if (!count) + { return; + } // without combo points lost (duration checked in aura) RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); @@ -20441,7 +21431,9 @@ void Player::AddComboPoints(Unit* target, int8 count) void Player::ClearComboPoints() { if (!m_comboTargetGuid) + { return; + } // without combopoints lost (duration checked in aura) RemoveSpellsCausingAura(SPELL_AURA_RETAIN_COMBO_POINTS); @@ -20585,7 +21577,9 @@ void Player::SendInitialPacketsAfterAddToMap() void Player::SendUpdateToOutOfRangeGroupMembers() { if (m_groupUpdateMask == GROUP_UPDATE_FLAG_NONE) + { return; + } if (Group* group = GetGroup()) group->UpdatePlayerOutOfRange(this); @@ -20684,7 +21678,9 @@ void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint3 void Player::ApplyEquipCooldown(Item* pItem) { if (pItem->GetProto()->Flags & ITEM_FLAG_NO_EQUIP_COOLDOWN) + { return; + } for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { @@ -20745,11 +21741,15 @@ void Player::learnQuestRewardedSpells(Quest const* quest) // skip quests without rewarded spell if (!spell_id) + { return; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) + { return; + } // check learned spells state bool found = false; @@ -20767,7 +21767,9 @@ void Player::learnQuestRewardedSpells(Quest const* quest) // skip quests with not teaching spell or already known spell if (!found) + { return; + } // prevent learn non first rank unknown profession and second specialization for same profession) SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(EFFECT_INDEX_0); @@ -20778,11 +21780,15 @@ void Player::learnQuestRewardedSpells(Quest const* quest) // not have first rank learned (unlearned prof?) uint32 first_spell = sSpellMgr.GetFirstSpellInChain(learned_0); if (!HasSpell(first_spell)) + { return; + } SpellEntry const* learnedInfo = sSpellStore.LookupEntry(learned_0); if (!learnedInfo) + { return; + } // specialization SpellEffectEntry const* learnedSpellEffect0 = learnedInfo->GetSpellEffect(EFFECT_INDEX_0); @@ -20797,7 +21803,9 @@ void Player::learnQuestRewardedSpells(Quest const* quest) SpellEntry const* itrInfo = sSpellStore.LookupEntry(itr->first); if (!itrInfo) + { return; + } // compare only specializations SpellEffectEntry const* itrSpellEffect0 = learnedInfo->GetSpellEffect(EFFECT_INDEX_0); @@ -20811,7 +21819,9 @@ void Player::learnQuestRewardedSpells(Quest const* quest) // now we have 2 specialization, learn possible only if found is lesser specialization rank if (!sSpellMgr.IsHighRankOfSpell(learned_0, itr->first)) + { return; + } } } } @@ -20870,7 +21880,9 @@ void Player::SendAurasForTarget(Unit* target) { Unit::VisibleAuraMap const& visibleAuras = target->GetVisibleAuras(); if (visibleAuras.empty()) + { return; + } WorldPacket data(SMSG_AURA_UPDATE_ALL); data << target->GetPackGUID(); @@ -20918,7 +21930,9 @@ void Player::ResetDailyQuestStatus() void Player::ResetWeeklyQuestStatus() { if (m_weeklyquests.empty()) + { return; + } m_weeklyquests.clear(); // DB data deleted in caller @@ -20928,7 +21942,9 @@ void Player::ResetWeeklyQuestStatus() void Player::ResetMonthlyQuestStatus() { if (m_monthlyquests.empty()) + { return; + } m_monthlyquests.clear(); // DB data deleted in caller @@ -20938,7 +21954,9 @@ void Player::ResetMonthlyQuestStatus() BattleGround* Player::GetBattleGround() const { if (GetBattleGroundId() == 0) + { return NULL; + } return sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgData.bgTypeID); } @@ -20947,7 +21965,9 @@ bool Player::InArena() const { BattleGround* bg = GetBattleGround(); if (!bg || !bg->isArena()) + { return false; + } return true; } @@ -20957,7 +21977,9 @@ bool Player::GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const // get a template bg instead of running one BattleGround* bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); if (!bg) + { return false; + } // limit check leel to dbc compatible level range uint32 level = getLevel(); @@ -20965,7 +21987,9 @@ bool Player::GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const level = DEFAULT_MAX_LEVEL; if (level < bg->GetMinLevel() || level > bg->GetMaxLevel()) + { return false; + } return true; } @@ -20974,11 +21998,15 @@ float Player::GetReputationPriceDiscount(Creature const* pCreature) const { FactionTemplateEntry const* vendor_faction = pCreature->getFactionTemplateEntry(); if (!vendor_faction || !vendor_faction->faction) + { return 1.0f; + } ReputationRank rank = GetReputationRank(vendor_faction->faction); if (rank <= REP_NEUTRAL) + { return 1.0f; + } return 1.0f - 0.05f * (rank - REP_NEUTRAL); } @@ -20999,7 +22027,9 @@ bool Player::IsSpellFitByClassAndRace(uint32 spell_id, uint32* pReqlevel /*= NUL SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spell_id); if (bounds.first == bounds.second) + { return true; + } for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) { @@ -21019,7 +22049,9 @@ bool Player::IsSpellFitByClassAndRace(uint32 spell_id, uint32* pReqlevel /*= NUL if ((skillRCEntry->raceMask & racemask) && (skillRCEntry->classMask & classmask)) { if (skillRCEntry->flags & ABILITY_SKILL_NONTRAINABLE) + { return false; + } if (pReqlevel) // show trainers list case { @@ -21032,7 +22064,9 @@ bool Player::IsSpellFitByClassAndRace(uint32 spell_id, uint32* pReqlevel /*= NUL else // check availble case at train { if (skillRCEntry->reqLevel && getLevel() < skillRCEntry->reqLevel) + { return false; + } } } } @@ -21072,7 +22106,9 @@ bool Player::HasQuestForGO(int32 GOId) const continue; if ((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) + { return true; + } } } } @@ -21082,7 +22118,9 @@ bool Player::HasQuestForGO(int32 GOId) const void Player::UpdateForQuestWorldObjects() { if (m_clientGUIDs.empty()) + { return; + } UpdateData udata(GetMapId()); WorldPacket packet; @@ -21128,7 +22166,9 @@ void Player::SummonIfPossible(bool agree) // expire and auto declined if (m_summon_expire < time(NULL)) + { return; + } // stop taxi flight at summon if (IsTaxiFlying()) @@ -21174,7 +22214,9 @@ void Player::AutoUnequipOffhandIfNeed() { Item* offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (!offItem) + { return; + } // need unequip offhand for 2h-weapon without TitanGrip (in any from hands) if ((CanDualWield() || offItem->GetProto()->InventoryType == INVTYPE_SHIELD || offItem->GetProto()->InventoryType == INVTYPE_HOLDABLE) && @@ -21205,7 +22247,9 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons { int32 itemClass = spellInfo->GetEquippedItemClass(); if(itemClass < 0) + { return true; + } // scan other equipped items for same requirements (mostly 2 daggers/etc) // for optimize check 2 used cases only @@ -21216,7 +22260,9 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons for (int i = EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + { return true; + } break; } case ITEM_CLASS_ARMOR: @@ -21225,17 +22271,23 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_MAINHAND; ++i) if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + { return true; + } // shields can be equipped to offhand slot if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + { return true; + } // ranged slot can have some armor subclasses if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + { return true; + } break; } @@ -21251,13 +22303,17 @@ bool Player::CanNoReagentCast(SpellEntry const* spellInfo) const { // don't take reagents for spells with SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP if (spellInfo->HasAttribute(SPELL_ATTR_EX5_NO_REAGENT_WHILE_PREP) && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PREPARATION)) + { return true; + } // Check no reagent use mask uint64 noReagentMask_0_1 = GetUInt64Value(PLAYER_NO_REAGENT_COST_1); uint32 noReagentMask_2 = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 2); if (spellInfo->IsFitToFamilyMask(noReagentMask_0_1, noReagentMask_2)) + { return true; + } return false; } @@ -21347,7 +22403,9 @@ bool Player::isHonorOrXPTarget(Unit* pVictim) const // Victim level less gray level if (v_level <= k_grey) + { return false; + } if (pVictim->GetTypeId() == TYPEID_UNIT) { @@ -21436,14 +22494,20 @@ void Player::RewardPlayerAndGroupAtCast(WorldObject* pRewardSource, uint32 spell bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const { if (pRewardSource->IsWithinDistInMap(this, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE))) + { return true; + } if (IsAlive()) + { return false; + } Corpse* corpse = GetCorpse(); if (!corpse) + { return false; + } return pRewardSource->IsWithinDistInMap(corpse, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE)); } @@ -21598,13 +22662,17 @@ void Player::SendCorpseReclaimDelay(bool load) { Corpse* corpse = GetCorpse(); if (!corpse) + { return; + } uint32 delay; if (load) { if (corpse->GetGhostTime() > m_deathExpireTime) + { return; + } bool pvp = corpse->GetType() == CORPSE_RESURRECTABLE_PVP; @@ -21623,7 +22691,9 @@ void Player::SendCorpseReclaimDelay(bool load) time_t now = time(NULL); if (now >= expected_time) + { return; + } delay = uint32(expected_time - now); } @@ -21640,13 +22710,19 @@ uint32 Player::GetNextResetTalentsCost() const { // The first time reset costs 1 gold if (GetTalentResetCost() < 1 * GOLD) + { return 1 * GOLD; + } // then 5 gold else if (GetTalentResetCost() < 5 * GOLD) + { return 5 * GOLD; + } // After that it increases in increments of 5 gold else if (GetTalentResetCost() < 10 * GOLD) + { return 10 * GOLD; + } else { uint64 months = (sWorld.GetGameTime() - GetTalentResetTime()) / MONTH; @@ -21673,7 +22749,9 @@ Player* Player::GetNextRandomRaidMember(float radius) { Group* pGroup = GetGroup(); if (!pGroup) + { return NULL; + } std::vector nearMembers; nearMembers.reserve(pGroup->GetMembersCount()); @@ -21689,7 +22767,9 @@ Player* Player::GetNextRandomRaidMember(float radius) } if (nearMembers.empty()) + { return NULL; + } uint32 randTarget = urand(0, nearMembers.size() - 1); return nearMembers[randTarget]; @@ -21699,13 +22779,19 @@ PartyResult Player::CanUninviteFromGroup() const { const Group* grp = GetGroup(); if (!grp) + { return ERR_NOT_IN_GROUP; + } if (!grp->IsLeader(GetObjectGuid()) && !grp->IsAssistant(GetObjectGuid())) + { return ERR_NOT_LEADER; + } if (InBattleGround()) + { return ERR_INVITE_RESTRICTED; + } return ERR_PARTY_RESULT_OK; } @@ -21855,7 +22941,9 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z) void Player::SetCanParry(bool value) { if (m_canParry == value) + { return; + } m_canParry = value; UpdateParryPercentage(); @@ -21864,7 +22952,9 @@ void Player::SetCanParry(bool value) void Player::SetCanBlock(bool value) { if (m_canBlock == value) + { return; + } m_canBlock = value; UpdateBlockPercentage(); @@ -21875,7 +22965,9 @@ bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const { for (ItemPosCountVec::const_iterator itr = vec.begin(); itr != vec.end(); ++itr) if (itr->pos == pos) + { return true; + } return false; } @@ -21912,7 +23004,9 @@ uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 n GtBarberShopCostBaseEntry const* bsc = sGtBarberShopCostBaseStore.LookupEntry(level - 1); if (!bsc) // shouldn't happen + { return 0xFFFFFFFF; + } float cost = 0; @@ -21987,7 +23081,9 @@ bool Player::isTotalImmune() { immuneMask |= (*itr)->GetModifier()->m_miscvalue; if (immuneMask & SPELL_SCHOOL_MASK_ALL) // total immunity + { return true; + } } return false; } @@ -21995,7 +23091,9 @@ bool Player::isTotalImmune() bool Player::HasTitle(uint32 bitIndex) const { if (bitIndex > MAX_TITLE_INDEX) + { return false; + } uint32 fieldIndexOffset = bitIndex / 32; uint32 flag = 1 << (bitIndex % 32); @@ -22010,14 +23108,18 @@ void Player::SetTitle(CharTitlesEntry const* title, bool lost) if (lost) { if (!HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag)) + { return; + } RemoveFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } else { if (HasFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag)) + { return; + } SetFlag(PLAYER__FIELD_KNOWN_TITLES + fieldIndexOffset, flag); } @@ -22031,7 +23133,9 @@ void Player::SetTitle(CharTitlesEntry const* title, bool lost) void Player::UpdateRuneRegen(RuneType rune) { if (rune >= RUNE_DEATH) + { return; + } RuneType actualRune = rune; float cooldown = RUNE_BASE_COOLDOWN; @@ -22092,9 +23196,13 @@ uint8 Player::GetRuneCooldownFraction(uint8 index) const { uint16 baseCd = GetBaseRuneCooldown(index); if (!baseCd || !GetRuneCooldown(index)) + { return 255; + } else if (baseCd == GetRuneCooldown(index)) + { return 0; + } return uint8(float(baseCd - GetRuneCooldown(index)) / baseCd * 255); } @@ -22125,21 +23233,29 @@ void Player::RestoreBaseRune(uint8 index) Aura const* aura = m_runes->runes[index].ConvertAura; // If rune was converted by a non-pasive aura that still active we should keep it converted if (aura && !IsPassiveSpell(aura->GetSpellProto())) + { return; + } // Blood of the North if (aura->GetId() == 54637 && HasAura(54637)) + { return; + } ConvertRune(index, GetBaseRune(index)); SetRuneConvertAura(index, NULL); // Don't drop passive talents providing rune convertion if (!aura || aura->GetModifier()->m_auraname != SPELL_AURA_CONVERT_RUNE) + { return; + } for (uint8 i = 0; i < MAX_RUNES; ++i) if (aura == m_runes->runes[i].ConvertAura) + { return; + } if (Unit* target = aura->GetTarget()) target->RemoveSpellAuraHolder(const_cast(aura)->GetHolder()); @@ -22193,7 +23309,9 @@ void Player::AddRunePower(uint8 index) void Player::InitRunes() { if (getClass() != CLASS_DEATH_KNIGHT) + { return; + } m_runes = new Runes; @@ -22215,7 +23333,9 @@ bool Player::IsBaseRuneSlotsOnCooldown(RuneType runeType) const { for (uint32 i = 0; i < MAX_RUNES; ++i) if (GetBaseRune(i) == runeType && GetRuneCooldown(i) == 0) + { return false; + } return true; } @@ -22258,7 +23378,9 @@ Item* Player::ConvertItem(Item* item, uint32 newItemId) Item* pNewItem = Item::CreateItem(newItemId, 1, this); if (!pNewItem) + { return NULL; + } // copy enchantments for (uint8 j = PERM_ENCHANTMENT_SLOT; j <= TEMP_ENCHANTMENT_SLOT; ++j) @@ -22321,21 +23443,29 @@ uint32 Player::CalculateTalentsPoints() const // this dbc file has entries only up to level 100 NumTalentsAtLevelEntry const* count = sNumTalentsAtLevelStore.LookupEntry(std::min(getLevel(), 100)); if (!count) + { return 0; + } float baseForLevel = count->Talents; if (getClass() != CLASS_DEATH_KNIGHT) + { return uint32(baseForLevel * sWorld.getConfig(CONFIG_FLOAT_RATE_TALENT)); + } // Death Knight starting level // hardcoded here - number of quest awarded talents is equal to number of talents any other class would have at level 55 if (getLevel() < 55) + { return 0; + } NumTalentsAtLevelEntry const* dkBase = sNumTalentsAtLevelStore.LookupEntry(55); if (!dkBase) + { return 0; + } float talentPointsForLevel = count->Talents - dkBase->Talents; talentPointsForLevel += float(m_questRewardTalentCount); @@ -22349,7 +23479,9 @@ uint32 Player::CalculateTalentsPoints() const bool Player::CanStartFlyInArea(uint32 mapid, uint32 zone, uint32 area) const { if (isGameMaster()) + { return true; + } // continent checked in SpellMgr::GetSpellAllowedInLocationError at cast and area update uint32 v_map = GetVirtualMapForMapAndZone(mapid, zone); @@ -22526,7 +23658,9 @@ uint32 Player::GetPhaseMaskForSpawn() const // some aura phases include 1 normal map in addition to phase itself if (uint32 n_phase = phase & ~PHASEMASK_NORMAL) + { return n_phase; + } return PHASEMASK_NORMAL; } @@ -22537,7 +23671,9 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi // proto based limitations if (InventoryResult res = CanEquipUniqueItem(pProto, eslot, limit_count)) + { return res; + } // check unique-equipped on gems for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) @@ -22558,7 +23694,9 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1; if (InventoryResult res = CanEquipUniqueItem(pGem, eslot, gem_limit_count)) + { return res; + } } return EQUIP_ERR_OK; @@ -22571,7 +23709,9 @@ InventoryResult Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 { // there is an equip limit on this item if (HasItemOrGemWithIdEquipped(itemProto->ItemId, 1, except_slot)) + { return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; + } } // check unique-equipped limit @@ -22579,16 +23719,22 @@ InventoryResult Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 { ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(itemProto->ItemLimitCategory); if (!limitEntry) + { return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED; + } // NOTE: limitEntry->mode not checked because if item have have-limit then it applied and to equip case if (limit_count > limitEntry->maxCount) + { return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; + } // there is an equip limit on this item if (HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory, limitEntry->maxCount - limit_count + 1, except_slot)) + { return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; + } } return EQUIP_ERR_OK; @@ -22656,17 +23802,25 @@ PlayerTalent const* Player::GetKnownTalentById(int32 talentId) const { PlayerTalentMap::const_iterator itr = m_talents[m_activeSpec].find(talentId); if (itr != m_talents[m_activeSpec].end() && itr->second.state != PLAYERSPELL_REMOVED) + { return &itr->second; + } else + { return NULL; + } } SpellEntry const* Player::GetKnownTalentRankById(int32 talentId) const { if (PlayerTalent const* talent = GetKnownTalentById(talentId)) + { return sSpellStore.LookupEntry(talent->talentEntry->RankID[talent->currentRank]); + } else + { return NULL; + } } bool Player::LearnTalent(uint32 talentId, uint32 talentRank) @@ -22674,24 +23828,34 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank) uint32 CurTalentPoints = GetFreeTalentPoints(); if (CurTalentPoints == 0) + { return false; + } if (talentRank >= MAX_TALENT_RANK) + { return false; + } TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId); if (!talentInfo) + { return false; + } TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); if (!talentTabInfo) + { return false; + } // prevent learn talent for different class (cheating) if ((getClassMask() & talentTabInfo->ClassMask) == 0) + { return false; + } // find current max talent rank uint32 curtalent_maxrank = 0; @@ -22700,11 +23864,15 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank) // we already have same or higher talent rank learned if (curtalent_maxrank >= (talentRank + 1)) + { return false; + } // check if we have enough talent points if (CurTalentPoints < (talentRank - curtalent_maxrank + 1)) + { return false; + } // Check if it requires another talent if (talentInfo->DependsOn > 0) @@ -22721,7 +23889,9 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank) } if (!hasEnoughRank) + { return false; + } } } @@ -22757,11 +23927,15 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank) // not have required min points spent in talent tree if (spentPoints < (talentInfo->Row * MAX_TALENT_RANK)) + { return false; + } // player has not spent 31 talents in main tree before attempting to learn other tree's talents if (!isMainTree && primaryTreeTalents < REQ_PRIMARY_TREE_TALENTS) + { return false; + } // spell not set in talent.dbc uint32 spellid = talentInfo->RankID[talentRank]; @@ -22773,7 +23947,9 @@ bool Player::LearnTalent(uint32 talentId, uint32 talentRank) // already known if (HasSpell(spellid)) + { return false; + } // learn! (other talent ranks will unlearned at learning) learnSpell(spellid, false); @@ -22803,45 +23979,65 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa { Pet* pet = GetPet(); if (!pet) + { return; + } if (petGuid != pet->GetObjectGuid()) + { return; + } uint32 CurTalentPoints = pet->GetFreeTalentPoints(); if (CurTalentPoints == 0) + { return; + } if (talentRank >= MAX_PET_TALENT_RANK) + { return; + } TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId); if (!talentInfo) + { return; + } TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); if (!talentTabInfo) + { return; + } CreatureInfo const* ci = pet->GetCreatureInfo(); if (!ci) + { return; + } CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->Family); if (!pet_family) + { return; + } if (pet_family->petTalentType < 0) // not hunter pet + { return; + } // prevent learn talent for different family (cheating) if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) + { return; + } // find current max talent rank int32 curtalent_maxrank = 0; @@ -22856,11 +24052,15 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa // we already have same or higher talent rank learned if (curtalent_maxrank >= int32(talentRank + 1)) + { return; + } // check if we have enough talent points if (CurTalentPoints < (talentRank - curtalent_maxrank + 1)) + { return; + } // Check if it requires another talent if (talentInfo->DependsOn > 0) @@ -22875,7 +24075,9 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa hasEnoughRank = true; } if (!hasEnoughRank) + { return; + } } } @@ -22911,7 +24113,9 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa // not have required min points spent in talent tree if (spentPoints < (talentInfo->Row * MAX_PET_TALENT_RANK)) + { return; + } // spell not set in talent.dbc uint32 spellid = talentInfo->RankID[talentRank]; @@ -22923,7 +24127,9 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa // already known if (pet->HasSpell(spellid)) + { return; + } // learn! (other talent ranks will unlearned at learning) pet->learnSpell(spellid); @@ -22943,7 +24149,9 @@ void Player::UnsummonPetTemporaryIfAny() { Pet* pet = GetPet(); if (!pet) + { return; + } if (!m_temporaryUnsummonedPetNumber && pet->isControlled() && !pet->isTemporarySummoned()) m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber(); @@ -22955,7 +24163,9 @@ void Player::UnsummonPetIfAny() { Pet* pet = GetPet(); if (!pet) + { return; + } pet->Unsummon(PET_SAVE_NOT_IN_SLOT, this); } @@ -22963,14 +24173,20 @@ void Player::UnsummonPetIfAny() void Player::ResummonPetTemporaryUnSummonedIfAny() { if (!m_temporaryUnsummonedPetNumber) + { return; + } // not resummon in not appropriate state if (IsPetNeedBeTemporaryUnsummoned()) + { return; + } if (GetPetGuid()) + { return; + } Pet* NewPet = new Pet; if (!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true)) @@ -22982,12 +24198,16 @@ void Player::ResummonPetTemporaryUnSummonedIfAny() bool Player::canSeeSpellClickOn(Creature const* c) const { if (!c->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK)) + { return false; + } SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(c->GetEntry()); for (SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) if (itr->second.IsFitToRequirements(this, c)) + { return true; + } return false; } @@ -23058,7 +24278,9 @@ void Player::BuildPetTalentsInfoData(WorldPacket* data) Pet* pet = GetPet(); if (!pet) + { return; + } unspentTalentPoints = pet->GetFreeTalentPoints(); @@ -23066,11 +24288,15 @@ void Player::BuildPetTalentsInfoData(WorldPacket* data) CreatureInfo const* ci = pet->GetCreatureInfo(); if (!ci) + { return; + } CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(ci->Family); if (!pet_family || pet_family->petTalentType < 0) + { return; + } for (uint32 talentTabId = 1; talentTabId < sTalentTabStore.GetNumRows(); ++talentTabId) { @@ -23314,7 +24540,9 @@ void Player::_SaveBGData() { // nothing save if (!m_bgData.m_needSave) + { return; + } static SqlStatementID delBGData ; static SqlStatementID insBGData ; @@ -23363,10 +24591,14 @@ void Player::DeleteEquipmentSet(uint64 setGuid) void Player::ActivateSpec(uint8 specNum) { if (GetActiveSpec() == specNum) + { return; + } if (specNum >= GetSpecsCount()) + { return; + } UnsummonPetTemporaryIfAny(); @@ -23518,7 +24750,9 @@ void Player::UpdateSpecCount(uint8 count) { uint8 curCount = GetSpecsCount(); if (curCount == count) + { return; + } // maybe current spec data must be copied to 0 spec? if (m_activeSpec >= count) @@ -23654,30 +24888,44 @@ Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask) { case HIGHGUID_ITEM: if (typemask & TYPEMASK_ITEM) + { return GetItemByGuid(guid); + } break; case HIGHGUID_PLAYER: if (GetObjectGuid() == guid) + { return this; + } if ((typemask & TYPEMASK_PLAYER) && IsInWorld()) + { return ObjectAccessor::FindPlayer(guid); + } break; case HIGHGUID_GAMEOBJECT: if ((typemask & TYPEMASK_GAMEOBJECT) && IsInWorld()) + { return GetMap()->GetGameObject(guid); + } break; case HIGHGUID_UNIT: case HIGHGUID_VEHICLE: if ((typemask & TYPEMASK_UNIT) && IsInWorld()) + { return GetMap()->GetCreature(guid); + } break; case HIGHGUID_PET: if ((typemask & TYPEMASK_UNIT) && IsInWorld()) + { return GetMap()->GetPet(guid); + } break; case HIGHGUID_DYNAMICOBJECT: if ((typemask & TYPEMASK_DYNAMICOBJECT) && IsInWorld()) + { return GetMap()->GetDynamicObject(guid); + } break; case HIGHGUID_TRANSPORT: case HIGHGUID_CORPSE: @@ -23718,7 +24966,9 @@ void Player::SetRestType(RestType n_r_type, uint32 areaTriggerId /*= 0*/) uint32 Player::GetEquipGearScore(bool withBags, bool withBank) { if (withBags && withBank && m_cachedGS > 0) + { return m_cachedGS; + } GearScoreVec gearScore(EQUIPMENT_SLOT_END); uint32 twoHandScore = 0; @@ -23804,16 +25054,22 @@ uint32 Player::GetEquipGearScore(bool withBags, bool withBank) return res; } else + { return 0; + } } void Player::_fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& twoHandScore) { if (!item) + { return; + } if (CanUseItem(item->GetProto()) != EQUIP_ERR_OK) + { return; + } uint8 type = item->GetProto()->InventoryType; uint32 level = item->GetProto()->ItemLevel; @@ -23952,11 +25208,15 @@ void Player::SendCurrencyWeekCap(uint32 id) const void Player::SendCurrencyWeekCap(CurrencyTypesEntry const * currency) const { if (!currency || !IsInWorld() || GetSession()->PlayerLoading()) + { return; + } uint32 cap = GetCurrencyWeekCap(currency); if (!cap) + { return; + } WorldPacket packet(SMSG_SET_CURRENCY_WEEK_LIMIT, 8); packet << uint32(floor(cap / currency->GetPrecision())); @@ -23992,7 +25252,9 @@ uint32 Player::GetCurrencyWeekCount(uint32 id) const void Player::ModifyCurrencyCount(uint32 id, int32 count, bool modifyWeek, bool modifySeason, bool ignoreMultipliers) { if (!count) + { return; + } if (!ignoreMultipliers && count > 0) count *= GetTotalAuraMultiplierByMiscValue(SPELL_AURA_MOD_CURRENCY_GAIN, id); @@ -24182,7 +25444,9 @@ void Player::SetCurrencyFlags(uint32 currencyId, uint8 flags) { PlayerCurrenciesMap::iterator itr = m_currencies.find(currencyId); if (itr == m_currencies.end()) + { return; + } itr->second.flags = flags; itr->second.state = PLAYERCURRENCY_CHANGED; @@ -24231,17 +25495,23 @@ AreaLockStatus Player::GetAreaTriggerLockStatus(AreaTrigger const* at, Difficult miscRequirement = 0; if (!at) + { return AREA_LOCKSTATUS_UNKNOWN_ERROR; + } MapEntry const* mapEntry = sMapStore.LookupEntry(at->target_mapId); if (!mapEntry) + { return AREA_LOCKSTATUS_UNKNOWN_ERROR; + } bool isRegularTargetMap = !mapEntry->IsDungeon() || GetDifficulty(mapEntry->IsRaid()) == REGULAR_DIFFICULTY; MapDifficultyEntry const* mapDiff = GetMapDifficultyData(at->target_mapId, difficulty); if (mapEntry->IsDungeon() && !mapDiff) + { return AREA_LOCKSTATUS_MISSING_DIFFICULTY; + } // Expansion requirement if (GetSession()->Expansion() < mapEntry->Expansion()) @@ -24252,7 +25522,9 @@ AreaLockStatus Player::GetAreaTriggerLockStatus(AreaTrigger const* at, Difficult // Gamemaster can always enter if (isGameMaster()) + { return AREA_LOCKSTATUS_OK; + } // Level Requirements if (getLevel() < at->requiredLevel && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_LEVEL)) @@ -24269,7 +25541,9 @@ AreaLockStatus Player::GetAreaTriggerLockStatus(AreaTrigger const* at, Difficult // Raid Requirements if (mapEntry->IsRaid() && !sWorld.getConfig(CONFIG_BOOL_INSTANCE_IGNORE_RAID)) if (!GetGroup() || !GetGroup()->isRaidGroup()) + { return AREA_LOCKSTATUS_RAID_LOCKED; + } // Item Requirements: must have requiredItem OR requiredItem2, report the first one that's missing if (at->requiredItem) @@ -24324,18 +25598,26 @@ AreaLockStatus Player::GetAreaTriggerLockStatus(AreaTrigger const* at, Difficult { // cannot enter if the instance is full (player cap), GMs don't count if (((DungeonMap*)map)->GetPlayersCountExceptGMs() >= ((DungeonMap*)map)->GetMaxPlayers()) + { return AREA_LOCKSTATUS_INSTANCE_IS_FULL; + } // In Combat check if (map && map->GetInstanceData() && map->GetInstanceData()->IsEncounterInProgress()) + { return AREA_LOCKSTATUS_ZONE_IN_COMBAT; + } // Bind Checks InstancePlayerBind* pBind = GetBoundInstance(at->target_mapId, GetDifficulty(mapEntry->IsRaid())); if (pBind && pBind->perm && pBind->state != state) + { return AREA_LOCKSTATUS_HAS_BIND; + } if (pBind && pBind->perm && pBind->state != map->GetPersistentState()) + { return AREA_LOCKSTATUS_HAS_BIND; + } } return AREA_LOCKSTATUS_OK; @@ -24392,7 +25674,9 @@ void Player::UpdateArmorSpecializations() uint32 specPassive = armorSpecToClass[getClass()]; // return class has no armor specialization if (!specPassive) + { return; + } for (int i = 0; i < MAX_ARMOR_SPECIALIZATION_SPELLS; ++i) { @@ -24436,7 +25720,9 @@ void Player::UpdateArmorSpecializations() bool Player::FitArmorSpecializationRules(SpellEntry const * spellProto) const { if (!spellProto || !spellProto->HasAttribute(SPELL_ATTR_EX8_ARMOR_SPECIALIZATION)) + { return true; + } int i = 0; for (; i < MAX_ARMOR_SPECIALIZATION_SPELLS; ++i) @@ -24452,10 +25738,14 @@ bool Player::FitArmorSpecializationRules(SpellEntry const * spellProto) const } if (i == MAX_ARMOR_SPECIALIZATION_SPELLS) + { return false; + } if (!HasSpell(armorSpecToClass[getClass()])) + { return false; + } if (SpellEquippedItemsEntry const * itemsEntry = spellProto->GetSpellEquippedItems()) { @@ -24483,13 +25773,19 @@ bool Player::FitArmorSpecializationRules(SpellEntry const * spellProto) const Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i); // item must be present for specialization to work if (!item) + { return false; + } if (item->GetProto()->Class != itemsEntry->EquippedItemClass) + { return false; + } if (((1 << item->GetProto()->SubClass) & itemsEntry->EquippedItemSubClassMask) == 0) + { return false; + } } } } @@ -24525,11 +25821,15 @@ float Player::GetCollisionHeight(bool mounted) const // mounted case CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID)); if (!mountDisplayInfo) + { return GetCollisionHeight(false); + } CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId); if (!mountModelData) + { return GetCollisionHeight(false); + } CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); if (!displayInfo) diff --git a/src/game/Object/Player.h b/src/game/Object/Player.h index 2f9b47933..86d9cb06a 100644 --- a/src/game/Object/Player.h +++ b/src/game/Object/Player.h @@ -246,7 +246,9 @@ struct Glyph void SetId(uint32 newId) { if (newId == id) + { return; + } if (id == 0 && uState == GLYPH_UNCHANGED) // not exist yet in db and already saved { @@ -925,7 +927,9 @@ class PlayerTaxi return true; } else - { return false; } + { + return false; + } } void AppendTaximaskTo(ByteBuffer& data, bool all); @@ -1197,7 +1201,9 @@ class Player : public Unit m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY; } else if (state > 0) - { m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL; } + { + m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL; + } } @@ -2307,7 +2313,9 @@ class Player : public Unit { for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId) + { return m_bgBattleGroundQueueID[i].bgQueueTypeId; + } return BATTLEGROUND_QUEUE_NONE; } uint32 GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId) const diff --git a/src/game/Object/ReactorAI.cpp b/src/game/Object/ReactorAI.cpp index db610981b..f6271f0ab 100644 --- a/src/game/Object/ReactorAI.cpp +++ b/src/game/Object/ReactorAI.cpp @@ -35,7 +35,9 @@ int ReactorAI::Permissible(const Creature* creature) { if (creature->IsCivilian() || creature->IsNeutralToAll()) + { return PERMIT_BASE_REACTIVE; + } return PERMIT_BASE_NO; } @@ -49,7 +51,9 @@ void ReactorAI::AttackStart(Unit* p) { if (!p || !m_creature->CanAttackByItself()) + { return; + } if (m_creature->Attack(p, true)) { @@ -75,7 +79,9 @@ ReactorAI::UpdateAI(const uint32 /*time_diff*/) { // update i_victimGuid if i_creature.getVictim() !=0 and changed if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) + { return; + } i_victimGuid = m_creature->getVictim()->GetObjectGuid(); diff --git a/src/game/Object/ReputationMgr.cpp b/src/game/Object/ReputationMgr.cpp index d5e60a2da..a69e3be2f 100644 --- a/src/game/Object/ReputationMgr.cpp +++ b/src/game/Object/ReputationMgr.cpp @@ -40,7 +40,9 @@ ReputationRank ReputationMgr::ReputationToRank(int32 standing) { limit -= PointsInRank[i]; if (standing >= limit) + { return ReputationRank(i); + } } return MIN_REPUTATION_RANK; } @@ -61,7 +63,9 @@ int32 ReputationMgr::GetReputation(uint32 faction_id) const int32 ReputationMgr::GetBaseReputation(FactionEntry const* factionEntry) const { if (!factionEntry) + { return 0; + } uint32 raceMask = m_player->getRaceMask(); uint32 classMask = m_player->getClassMask(); @@ -75,10 +79,14 @@ int32 ReputationMgr::GetReputation(FactionEntry const* factionEntry) const { // Faction without recorded reputation. Just ignore. if (!factionEntry) + { return 0; + } if (FactionState const* state = GetState(factionEntry)) + { return GetBaseReputation(factionEntry) + state->Standing; + } return 0; } @@ -106,7 +114,9 @@ void ReputationMgr::ApplyForceReaction(uint32 faction_id, ReputationRank rank, b uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) const { if (!factionEntry) + { return 0; + } uint32 raceMask = m_player->getRaceMask(); uint32 classMask = m_player->getClassMask(); @@ -201,7 +211,9 @@ void ReputationMgr::SendInitialReputations() void ReputationMgr::SendVisible(FactionState const* faction) const { if (m_player->GetSession()->PlayerLoading()) + { return; + } // make faction visible in reputation list at client WorldPacket data(SMSG_SET_FACTION_VISIBLE, 4); @@ -361,7 +373,9 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in achievementManager.UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, factionEntry->ID); if (new_rank > old_rank) + { return true; + } } return false; } @@ -369,7 +383,9 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in void ReputationMgr::SetVisible(FactionTemplateEntry const* factionTemplateEntry) { if (!factionTemplateEntry->faction) + { return; + } if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->faction)) SetVisible(factionEntry); @@ -378,11 +394,15 @@ void ReputationMgr::SetVisible(FactionTemplateEntry const* factionTemplateEntry) void ReputationMgr::SetVisible(FactionEntry const* factionEntry) { if (factionEntry->reputationListID < 0) + { return; + } FactionStateList::iterator itr = m_factions.find(factionEntry->reputationListID); if (itr == m_factions.end()) + { return; + } SetVisible(&itr->second); } @@ -391,11 +411,15 @@ void ReputationMgr::SetVisible(FactionState* faction) { // always invisible or hidden faction can't be make visible if (faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN)) + { return; + } // already set if (faction->Flags & FACTION_FLAG_VISIBLE) + { return; + } faction->Flags |= FACTION_FLAG_VISIBLE; faction->needSend = true; @@ -410,11 +434,15 @@ void ReputationMgr::SetAtWar(RepListID repListID, bool on) { FactionStateList::iterator itr = m_factions.find(repListID); if (itr == m_factions.end()) + { return; + } // always invisible or hidden faction can't change war state if (itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN)) + { return; + } SetAtWar(&itr->second, on); } @@ -423,11 +451,15 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) { // not allow declare war to faction unless already hated or less if (atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED) && ReputationToRank(faction->Standing) > REP_HATED) + { return; + } // already set if (((faction->Flags & FACTION_FLAG_AT_WAR) != 0) == atWar) + { return; + } if (atWar) faction->Flags |= FACTION_FLAG_AT_WAR; @@ -442,7 +474,9 @@ void ReputationMgr::SetInactive(RepListID repListID, bool on) { FactionStateList::iterator itr = m_factions.find(repListID); if (itr == m_factions.end()) + { return; + } SetInactive(&itr->second, on); } @@ -451,11 +485,15 @@ void ReputationMgr::SetInactive(FactionState* faction, bool inactive) { // always invisible or hidden faction can't be inactive if (inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE))) + { return; + } // already set if (((faction->Flags & FACTION_FLAG_INACTIVE) != 0) == inactive) + { return; + } if (inactive) faction->Flags |= FACTION_FLAG_INACTIVE; diff --git a/src/game/Object/SocialMgr.cpp b/src/game/Object/SocialMgr.cpp index 632306ba1..ccd1fa6f9 100644 --- a/src/game/Object/SocialMgr.cpp +++ b/src/game/Object/SocialMgr.cpp @@ -60,12 +60,16 @@ bool PlayerSocial::AddToSocialList(ObjectGuid friend_guid, bool ignore) if (ignore) { if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED) >= SOCIALMGR_IGNORE_LIMIT) + { return false; + } } else { if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND) >= SOCIALMGR_FRIEND_LIMIT) + { return false; + } } uint32 flag = SOCIAL_FLAG_FRIEND; @@ -92,7 +96,9 @@ void PlayerSocial::RemoveFromSocialList(ObjectGuid friend_guid, bool ignore) { PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_guid.GetCounter()); if (itr == m_playerSocialMap.end()) // not exist + { return; + } uint32 flag = SOCIAL_FLAG_FRIEND; if (ignore) @@ -114,7 +120,9 @@ void PlayerSocial::SetFriendNote(ObjectGuid friend_guid, std::string note) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter()); if (itr == m_playerSocialMap.end()) // not exist + { return; + } utf8truncate(note, 48); // DB and client size limitation @@ -128,7 +136,9 @@ void PlayerSocial::SendSocialList() { Player* plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid)); if (!plr) + { return; + } uint32 size = m_playerSocialMap.size(); @@ -164,7 +174,9 @@ bool PlayerSocial::HasFriend(ObjectGuid friend_guid) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter()); if (itr != m_playerSocialMap.end()) + { return itr->second.Flags & SOCIAL_FLAG_FRIEND; + } return false; } @@ -172,7 +184,9 @@ bool PlayerSocial::HasIgnore(ObjectGuid ignore_guid) { PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(ignore_guid.GetCounter()); if (itr != m_playerSocialMap.end()) + { return itr->second.Flags & SOCIAL_FLAG_IGNORED; + } return false; } @@ -187,7 +201,9 @@ SocialMgr::~SocialMgr() void SocialMgr::GetFriendInfo(Player* player, uint32 friend_lowguid, FriendInfo& friendInfo) { if (!player) + { return; + } Player* pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid)); @@ -273,7 +289,9 @@ void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGui void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet) { if (!player) + { return; + } Team team = player->GetTeam(); AccountTypes security = player->GetSession()->GetSecurity(); @@ -307,7 +325,9 @@ PlayerSocial* SocialMgr::LoadFromDB(QueryResult* result, ObjectGuid guid) social->SetPlayerGuid(guid); if (!result) + { return social; + } uint32 friend_guid = 0; uint32 flags = 0; diff --git a/src/game/Object/SpellMgr.cpp b/src/game/Object/SpellMgr.cpp index 270c03732..91035aaa3 100644 --- a/src/game/Object/SpellMgr.cpp +++ b/src/game/Object/SpellMgr.cpp @@ -39,10 +39,14 @@ bool IsPrimaryProfessionSkill(uint32 skill) { SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(skill); if (!pSkill) + { return false; + } if (pSkill->categoryId != SKILL_CATEGORY_PROFESSION) + { return false; + } return true; } @@ -64,20 +68,28 @@ SpellMgr& SpellMgr::Instance() int32 GetSpellDuration(SpellEntry const* spellInfo) { if (!spellInfo) + { return 0; + } SpellDurationEntry const* du = sSpellDurationStore.LookupEntry(spellInfo->DurationIndex); if (!du) + { return 0; + } return (du->Duration[0] == -1) ? -1 : abs(du->Duration[0]); } int32 GetSpellMaxDuration(SpellEntry const* spellInfo) { if (!spellInfo) + { return 0; + } SpellDurationEntry const* du = sSpellDurationStore.LookupEntry(spellInfo->DurationIndex); if (!du) + { return 0; + } return (du->Duration[2] == -1) ? -1 : abs(du->Duration[2]); } @@ -110,14 +122,18 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell) { // some triggered spells have data only usable for client if (spell->IsTriggeredSpellWithRedundentCastTime()) + { return 0; + } // spell targeted to non-trading trade slot item instant at trade success apply if (spell->GetCaster()->GetTypeId() == TYPEID_PLAYER) if (TradeData* my_trade = ((Player*)(spell->GetCaster()))->GetTradeData()) if (Item* nonTrade = my_trade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED)) if (nonTrade == spell->m_targets.getItemTarget()) + { return 0; + } } uint32 castTime = 0; @@ -295,7 +311,9 @@ uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo) { int32 DotDuration = GetSpellDuration(spellInfo); if (DotDuration == 0) + { return 1; + } // 200% limit if (DotDuration > 30000) @@ -312,7 +330,9 @@ uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo) spellEffect->EffectApplyAuraName == SPELL_AURA_PERIODIC_LEECH) ) { if (spellEffect->EffectAmplitude != 0) + { return DotDuration / spellEffect->EffectAmplitude; + } break; } } @@ -354,15 +374,21 @@ float CalculateDefaultCoefficient(SpellEntry const* spellProto, DamageEffectType WeaponAttackType GetWeaponAttackType(SpellEntry const* spellInfo) { if (!spellInfo) + { return BASE_ATTACK; + } switch (spellInfo->GetDmgClass()) { case SPELL_DAMAGE_CLASS_MELEE: if (spellInfo->HasAttribute(SPELL_ATTR_EX3_REQ_OFFHAND)) + { return OFF_ATTACK; + } else + { return BASE_ATTACK; + } break; case SPELL_DAMAGE_CLASS_RANGED: return RANGED_ATTACK; @@ -370,9 +396,13 @@ WeaponAttackType GetWeaponAttackType(SpellEntry const* spellInfo) default: // Wands if (spellInfo->HasAttribute(SPELL_ATTR_EX2_AUTOREPEAT_FLAG)) + { return RANGED_ATTACK; + } else + { return BASE_ATTACK; + } break; } } @@ -381,7 +411,9 @@ bool IsPassiveSpell(uint32 spellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return false; + } return IsPassiveSpell(spellInfo); } @@ -437,7 +469,9 @@ int32 CompareAuraRanks(uint32 spellId_1, uint32 spellId_2) { int32 diff = spellEffect_1->EffectBasePoints - spellEffect_2->EffectBasePoints; if (spellInfo_1->CalculateSimpleValue(SpellEffectIndex(i)) < 0 && spellInfo_2->CalculateSimpleValue(SpellEffectIndex(i)) < 0) + { return -diff; + } else return diff; } } @@ -448,7 +482,9 @@ SpellSpecific GetSpellSpecific(uint32 spellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return SPELL_NORMAL; + } SpellClassOptionsEntry const* classOpt = spellInfo->GetSpellClassOptions(); SpellInterruptsEntry const* interrupts = spellInfo->GetSpellInterrupts(); @@ -486,18 +522,26 @@ SpellSpecific GetSpellSpecific(uint32 spellId) } if (food && drink) + { return SPELL_FOOD_AND_DRINK; + } else if (food) + { return SPELL_FOOD; + } else if (drink) + { return SPELL_DRINK; + } } else { // Well Fed buffs (must be exclusive with Food / Drink replenishment effects, or else Well Fed will cause them to be removed) // SpellIcon 2560 is Spell 46687, does not have this flag if (spellInfo->HasAttribute(SPELL_ATTR_EX2_FOOD_BUFF) || spellInfo->SpellIconID == 2560) + { return SPELL_WELL_FED; + } } break; } @@ -505,18 +549,24 @@ SpellSpecific GetSpellSpecific(uint32 spellId) { // family flags 18(Molten), 25(Frost/Ice), 28(Mage) if (classOpt && classOpt->SpellFamilyFlags & UI64LIT(0x12040000)) + { return SPELL_MAGE_ARMOR; + } SpellEffectEntry const* mageSpellEffect = spellInfo->GetSpellEffect(EFFECT_INDEX_0); if (classOpt && (classOpt->SpellFamilyFlags & UI64LIT(0x1000000)) && mageSpellEffect && mageSpellEffect->EffectApplyAuraName == SPELL_AURA_MOD_CONFUSE) + { return SPELL_MAGE_POLYMORPH; + } break; } case SPELLFAMILY_WARRIOR: { if (classOpt && classOpt->SpellFamilyFlags & UI64LIT(0x00008000010000)) + { return SPELL_POSITIVE_SHOUT; + } break; } @@ -524,15 +574,21 @@ SpellSpecific GetSpellSpecific(uint32 spellId) { // only warlock curses have this if (spellInfo->GetDispel() == DISPEL_CURSE) + { return SPELL_CURSE; + } // Warlock (Demon Armor | Demon Skin | Fel Armor) if (spellInfo->IsFitToFamilyMask(UI64LIT(0x2000002000000000), 0x00000010)) + { return SPELL_WARLOCK_ARMOR; + } // Unstable Affliction | Immolate if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000010000000004))) + { return SPELL_UA_IMMOLATE; + } break; } // Need Fix @@ -549,39 +605,55 @@ SpellSpecific GetSpellSpecific(uint32 spellId) { // only hunter stings have this if (spellInfo->GetDispel() == DISPEL_POISON) + { return SPELL_STING; + } // only hunter aspects have this if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0044000000380000), 0x00001010)) + { return SPELL_ASPECT; + } break; } case SPELLFAMILY_PALADIN: { if (IsSealSpell(spellInfo)) + { return SPELL_SEAL; + } if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000011010002))) + { return SPELL_BLESSING; + } if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000000002190))) + { return SPELL_HAND; + } // skip Heart of the Crusader that have also same spell family mask if (spellInfo->IsFitToFamilyMask(UI64LIT(0x00000820180400)) && spellInfo->HasAttribute(SPELL_ATTR_EX3_UNK9) && (spellInfo->SpellIconID != 237)) + { return SPELL_JUDGEMENT; + } // only paladin auras have this (for palaldin class family) if (spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000000000000), 0x00000020)) + { return SPELL_AURA; + } break; } case SPELLFAMILY_SHAMAN: { if (IsElementalShield(spellInfo)) + { return SPELL_ELEMENTAL_SHIELD; + } break; } @@ -591,7 +663,9 @@ SpellSpecific GetSpellSpecific(uint32 spellId) case SPELLFAMILY_DEATHKNIGHT: if (spellInfo->GetCategory() == 47) + { return SPELL_PRESENCE; + } break; } @@ -604,7 +678,9 @@ SpellSpecific GetSpellSpecific(uint32 spellId) // elixirs can have different families, but potion most ofc. if (SpellSpecific sp = sSpellMgr.GetSpellElixirSpecific(spellInfo->Id)) + { return sp; + } return SPELL_NORMAL; } @@ -705,7 +781,9 @@ bool IsPositiveTarget(uint32 targetA, uint32 targetB) break; } if (targetB) + { return IsPositiveTarget(targetB, 0); + } return true; } @@ -843,12 +921,16 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex) case SPELL_AURA_MOD_HEALING_PCT: case SPELL_AURA_MOD_HEALING_DONE: if (spellEffect->CalculateSimpleValue() < 0) + { return false; + } break; case SPELL_AURA_MOD_DAMAGE_TAKEN: // dependent from bas point sign (positive -> negative) case SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN: if (spellEffect->CalculateSimpleValue() < 0) + { return true; + } // let check by target modes (for Amplify Magic cases/etc) break; case SPELL_AURA_MOD_SPELL_CRIT_CHANCE: @@ -892,7 +974,9 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex) // Petrification if (spellproto->Id == 17624) + { return false; + } break; case SPELL_AURA_MOD_PACIFY_SILENCE: switch (spellproto->Id) @@ -919,7 +1003,9 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex) break; case SPELL_AURA_MOD_DECREASE_SPEED: // used in positive spells also if (spellproto->Id == 37830) // Repolarized Magneto Sphere + { return true; + } // part of positive spell if casted at self if ((spellEffect->EffectImplicitTargetA == TARGET_SELF || spellEffect->EffectImplicitTargetA == TARGET_SELF2) && @@ -927,7 +1013,9 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex) return false; // but not this if this first effect (don't found better check) if (spellproto->HasAttribute(SPELL_ATTR_NEGATIVE) && effIndex == EFFECT_INDEX_0) + { return false; + } break; case SPELL_AURA_TRANSFORM: // some spells negative @@ -976,7 +1064,9 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex) { case SPELLMOD_COST: // dependent from bas point sign (negative -> positive) if (spellproto->CalculateSimpleValue(effIndex) > 0) + { return false; + } break; default: break; @@ -1031,11 +1121,15 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex) // non-positive targets if (spellEffect && !IsPositiveTarget(spellEffect->EffectImplicitTargetA,spellEffect->EffectImplicitTargetB)) + { return false; + } // AttributesEx check if (spellproto->HasAttribute(SPELL_ATTR_NEGATIVE)) + { return false; + } // ok, positive return true; @@ -1045,7 +1139,9 @@ bool IsPositiveSpell(uint32 spellId) { SpellEntry const* spellproto = sSpellStore.LookupEntry(spellId); if (!spellproto) + { return false; + } return IsPositiveSpell(spellproto); } @@ -1056,7 +1152,9 @@ bool IsPositiveSpell(SpellEntry const* spellproto) // some self-applied spells have negative effects but in self casting case negative check ignored. for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (spellproto->GetSpellEffectIdByIndex(SpellEffectIndex(i)) && !IsPositiveEffect(spellproto, SpellEffectIndex(i))) + { return false; + } return true; } @@ -1069,7 +1167,9 @@ bool IsSingleTargetSpell(SpellEntry const* spellInfo) // Not real client side single target spell, but it' not triggered until prev. aura expired. // This is allow store it in single target spells list for caster for spell proc checking if (spellInfo->Id == 38324) // Regeneration (triggered by 38299 (HoTs on Heals)) + { return true; + } return false; } @@ -1088,7 +1188,9 @@ bool IsSingleTargetSpells(SpellEntry const* spellInfo1, SpellEntry const* spellI { case SPELL_MAGE_POLYMORPH: if (GetSpellSpecific(spellInfo2->Id) == spec1) + { return true; + } break; default: break; @@ -1110,10 +1212,14 @@ SpellCastResult GetErrorAtShapeshiftedCast(SpellEntry const* spellInfo, uint32 f SpellShapeshiftEntry const* shapeShift = spellInfo->GetSpellShapeshift(); if (shapeShift && stanceMask & shapeShift->StancesNot) // can explicitly not be casted in this stance + { return SPELL_FAILED_NOT_SHAPESHIFT; + } if (shapeShift && stanceMask & shapeShift->Stances) // can explicitly be casted in this stance + { return SPELL_CAST_OK; + } bool actAsShifted = false; if (form > 0) @@ -1130,15 +1236,21 @@ SpellCastResult GetErrorAtShapeshiftedCast(SpellEntry const* spellInfo, uint32 f if (actAsShifted) { if (spellInfo->HasAttribute(SPELL_ATTR_NOT_SHAPESHIFT)) // not while shapeshifted + { return SPELL_FAILED_NOT_SHAPESHIFT; + } else if (shapeShift && shapeShift->Stances != 0) // needs other shapeshift + { return SPELL_FAILED_ONLY_SHAPESHIFT; + } } else { // needs shapeshift if(!(spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && shapeShift && shapeShift->Stances != 0) + { return SPELL_FAILED_ONLY_SHAPESHIFT; + } } return SPELL_CAST_OK; @@ -1253,7 +1365,9 @@ struct SpellRankHelper if (first_id != spell_id) { if (!worker.IsValidCustomRank(entry, spell_id, first_id)) + { return; + } // for later check that first rank also added else { @@ -1544,7 +1658,9 @@ bool IsCastEndProcModifierAura(SpellEntry const* spellInfo, SpellEffectIndex eff { SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(SpellEffectIndex(effecIdx)); if (!spellEffect) + { return false; + } // modifier auras that can proc on cast end switch (AuraType(spellEffect->EffectApplyAuraName)) @@ -1571,7 +1687,9 @@ bool IsCastEndProcModifierAura(SpellEntry const* spellInfo, SpellEffectIndex eff { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (IsEffectHandledOnDelayedSpellLaunch(procSpell, SpellEffectIndex(i))) + { return true; + } return false; } @@ -1762,11 +1880,15 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr // check prockFlags for condition if ((procFlags & EventProcFlag) == 0) + { return false; + } // Always trigger for this if (EventProcFlag & (PROC_FLAG_KILLED | PROC_FLAG_KILL | PROC_FLAG_ON_TRAP_ACTIVATION)) + { return true; + } if (spellProcEvent) // Exist event data { @@ -1778,19 +1900,25 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr { // Check (if set) for school (melee attack have Normal school) if (spellProcEvent->schoolMask && (spellProcEvent->schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) + { return false; + } } else // For spells need check school/spell family/family mask { // Check (if set) for school if (spellProcEvent->schoolMask && (spellProcEvent->schoolMask & procSpell->SchoolMask) == 0) + { return false; + } SpellClassOptionsEntry const* spellClassOptions = procSpell->GetSpellClassOptions(); // Check (if set) for spellFamilyName if (spellProcEvent->spellFamilyName && (!spellClassOptions && spellProcEvent->spellFamilyName != SPELLFAMILY_GENERIC || spellProcEvent->spellFamilyName != spellClassOptions->SpellFamilyName)) + { return false; + } } } @@ -1799,20 +1927,28 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr { // Don't allow proc from periodic heal if no extra requirement is defined if (EventProcFlag & (PROC_FLAG_ON_DO_PERIODIC | PROC_FLAG_ON_TAKE_PERIODIC) && (procExtra & PROC_EX_PERIODIC_POSITIVE)) + { return false; + } // No extra req, so can trigger for (damage/healing present) and cast end/hit/crit if (procExtra & (PROC_EX_CAST_END | PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) + { return true; + } } else // all spells hits here only if resist/reflect/immune/evade { // Exist req for PROC_EX_EX_TRIGGER_ALWAYS if (procEvent_procEx & PROC_EX_EX_TRIGGER_ALWAYS) + { return true; + } // Check Extra Requirement like (hit/crit/miss/resist/parry/dodge/block/immune/reflect/absorb and other) if (procEvent_procEx & procExtra) + { return true; + } } return false; } @@ -1979,14 +2115,22 @@ bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const* spellInfo_1, uint32 spell bool SpellMgr::canStackSpellRanksInSpellBook(SpellEntry const* spellInfo) const { if (IsPassiveSpell(spellInfo)) // ranked passive spell + { return false; + } if (spellInfo->powerType != POWER_MANA && spellInfo->powerType != POWER_HEALTH) + { return false; + } if (IsProfessionOrRidingSpell(spellInfo->Id)) + { return false; + } if (IsSkillBonusSpell(spellInfo->Id)) + { return false; + } // All stance spells. if any better way, change it. for (int i = 0; i < MAX_EFFECT_INDEX; ++i) @@ -2000,11 +2144,15 @@ bool SpellMgr::canStackSpellRanksInSpellBook(SpellEntry const* spellInfo) const { // Paladin aura Spell if (spellEffect->Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID) + { return false; + } // Seal of Righteousness, 2 version of same rank SpellClassOptionsEntry const* classOptions = spellInfo->GetSpellClassOptions(); if (classOptions && (classOptions->SpellFamilyFlags & UI64LIT(0x0000000008000000)) && spellInfo->SpellIconID == 25) + { return false; + } } break; case SPELLFAMILY_DRUID: @@ -2030,18 +2178,24 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons SpellEntry const* spellInfo_2 = sSpellStore.LookupEntry(spellId_2); if (!spellInfo_1 || !spellInfo_2) + { return false; + } SpellClassOptionsEntry const* classOptions1 = spellInfo_1->GetSpellClassOptions(); SpellClassOptionsEntry const* classOptions2 = spellInfo_2->GetSpellClassOptions(); // Resurrection sickness if ((spellInfo_1->Id == SPELL_ID_PASSIVE_RESURRECTION_SICKNESS) != (spellInfo_2->Id == SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) + { return false; + } // Allow stack passive and not passive spells if (spellInfo_1->HasAttribute(SPELL_ATTR_PASSIVE) != spellInfo_2->HasAttribute(SPELL_ATTR_PASSIVE)) + { return false; + } // Specific spell family spells switch(spellInfo_1->GetSpellFamilyName()) @@ -2069,15 +2223,21 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Heart of the Wild, Agility and various Idol Triggers if (spellInfo_1->SpellIconID == 240 && spellInfo_2->SpellIconID == 240) + { return false; + } // Personalized Weather (thunder effect should overwrite rainy aura) if (spellInfo_1->SpellIconID == 2606 && spellInfo_2->SpellIconID == 2606) + { return false; + } // Mirrored Soul (FoS - Devourer) - and other Boss spells if (spellInfo_1->SpellIconID == 3176 && spellInfo_2->SpellIconID == 3176) + { return false; + } // Brood Affliction: Bronze if ((spellInfo_1->Id == 23170 && spellInfo_2->Id == 23171) || @@ -2116,15 +2276,21 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Blood Fury and Rage of the Unraveller if (spellInfo_1->SpellIconID == 1662 && spellInfo_2->SpellIconID == 1662) + { return false; + } // Kindred Spirits if (spellInfo_1->SpellIconID == 3559 && spellInfo_2->SpellIconID == 3559) + { return false; + } // Vigilance and Damage Reduction (Vigilance triggered spell) if (spellInfo_1->SpellIconID == 2834 && spellInfo_2->SpellIconID == 2834) + { return false; + } // Unstable Sphere Timer and Unstable Sphere Passive if ((spellInfo_1->Id == 50758 && spellInfo_2->Id == 50756) || @@ -2248,23 +2414,31 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Halls of Reflection Clone if (spellInfo_1->SpellIconID == 692 && spellInfo_2->SpellIconID == 692) + { return false; + } break; } case SPELLFAMILY_MAGE: // Arcane Intellect and Insight if (spellInfo_2->SpellIconID == 125 && spellInfo_1->Id == 18820) + { return false; + } break; case SPELLFAMILY_WARRIOR: { // Scroll of Protection and Defensive Stance (multi-family check) if (spellInfo_1->SpellIconID == 276 && spellInfo_1->SpellVisual[0] == 196 && spellInfo_2->Id == 71) + { return false; + } // Improved Hamstring -> Hamstring (multi-family check) if (classOptions2 && (classOptions2->SpellFamilyFlags & UI64LIT(0x2)) && spellInfo_1->Id == 23694 ) + { return false; + } break; } @@ -2272,11 +2446,15 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons { // Scroll of Stamina and Leader of the Pack (multi-family check) if (spellInfo_1->SpellIconID == 312 && spellInfo_1->SpellVisual[0] == 216 && spellInfo_2->Id == 24932) + { return false; + } // Dragonmaw Illusion (multi-family check) if (spellId_1 == 40216 && spellId_2 == 42016) + { return false; + } break; } @@ -2284,7 +2462,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons { // Garrote-Silence -> Garrote (multi-family check) if (spellInfo_1->SpellIconID == 498 && spellInfo_1->SpellVisual[0] == 0 && spellInfo_2->SpellIconID == 498) + { return false; + } break; } @@ -2292,33 +2472,45 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons { // Concussive Shot and Imp. Concussive Shot (multi-family check) if (spellInfo_1->Id == 19410 && spellInfo_2->Id == 5116) + { return false; + } // Improved Wing Clip -> Wing Clip (multi-family check) if (classOptions2 && (classOptions2->SpellFamilyFlags & UI64LIT(0x40)) && spellInfo_1->Id == 19229 ) + { return false; + } break; } case SPELLFAMILY_PALADIN: { // Unstable Currents and other -> *Sanctity Aura (multi-family check) if (spellInfo_2->SpellIconID == 502 && spellInfo_1->SpellIconID == 502 && spellInfo_1->SpellVisual[0] == 969) + { return false; + } // *Band of Eternal Champion and Seal of Command(multi-family check) if (spellId_1 == 35081 && spellInfo_2->SpellIconID == 561 && spellInfo_2->SpellVisual[0] == 7992) + { return false; + } // Blessing of Sanctuary (multi-family check, some from 16 spell icon spells) if (spellInfo_1->Id == 67480 && spellInfo_2->Id == 20911) + { return false; + } break; } } // Dragonmaw Illusion, Blood Elf Illusion, Human Illusion, Illidari Agent Illusion, Scarlet Crusade Disguise if (spellInfo_1->SpellIconID == 1691 && spellInfo_2->SpellIconID == 1691) + { return false; + } break; case SPELLFAMILY_MAGE: if (classOptions2 && classOptions2->SpellFamilyName == SPELLFAMILY_MAGE ) @@ -2335,7 +2527,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Fingers of Frost effects if (spellInfo_1->SpellIconID == 2947 && spellInfo_2->SpellIconID == 2947) + { return false; + } // Living Bomb & Ignite (Dots) if (classOptions1 && (classOptions1->SpellFamilyFlags & UI64LIT(0x2000000000000)) && (classOptions2->SpellFamilyFlags & UI64LIT(0x8000000)) || @@ -2349,15 +2543,21 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons } // Detect Invisibility and Mana Shield (multi-family check) if (spellInfo_2->Id == 132 && spellInfo_1->SpellIconID == 209 && spellInfo_1->SpellVisual[0] == 968) + { return false; + } // Combustion and Fire Protection Aura (multi-family check) if (spellInfo_1->Id == 11129 && spellInfo_2->SpellIconID == 33 && spellInfo_2->SpellVisual[0] == 321) + { return false; + } // Arcane Intellect and Insight if (spellInfo_1->SpellIconID == 125 && spellInfo_2->Id == 18820) + { return false; + } break; case SPELLFAMILY_WARLOCK: @@ -2396,11 +2596,15 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Metamorphosis, diff effects if (spellInfo_1->SpellIconID == 3314 && spellInfo_2->SpellIconID == 3314) + { return false; + } } // Detect Invisibility and Mana Shield (multi-family check) if (spellInfo_1->Id == 132 && spellInfo_2->SpellIconID == 209 && spellInfo_2->SpellVisual[0] == 968) + { return false; + } break; case SPELLFAMILY_WARRIOR: if (classOptions2 && classOptions1->SpellFamilyName == SPELLFAMILY_WARRIOR ) @@ -2428,15 +2632,21 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Hamstring -> Improved Hamstring (multi-family check) if (classOptions1 && (classOptions1->SpellFamilyFlags & UI64LIT(0x2)) && spellInfo_2->Id == 23694 ) + { return false; + } // Defensive Stance and Scroll of Protection (multi-family check) if (spellInfo_1->Id == 71 && spellInfo_2->SpellIconID == 276 && spellInfo_2->SpellVisual[0] == 196) + { return false; + } // Bloodlust and Bloodthirst (multi-family check) if (spellInfo_2->Id == 2825 && spellInfo_1->SpellIconID == 38 && spellInfo_1->SpellVisual[0] == 0) + { return false; + } break; case SPELLFAMILY_PRIEST: @@ -2478,7 +2688,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Innervate and Glyph of Innervate and some other spells if (spellInfo_1->SpellIconID == 62 && spellInfo_2->SpellIconID == 62) + { return false; + } // Wrath of Elune and Nature's Grace if ((spellInfo_1->Id == 16886 && spellInfo_2->Id == 46833) || @@ -2502,7 +2714,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Savage Roar and Savage Roar (triggered) if (spellInfo_1->SpellIconID == 2865 && spellInfo_2->SpellIconID == 2865) + { return false; + } // Frenzied Regeneration and Savage Defense if ((spellInfo_1->Id == 22842 && spellInfo_2->Id == 62606) || @@ -2512,11 +2726,15 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Leader of the Pack and Scroll of Stamina (multi-family check) if (spellInfo_1->Id == 24932 && spellInfo_2->SpellIconID == 312 && spellInfo_2->SpellVisual[0] == 216) + { return false; + } // Dragonmaw Illusion (multi-family check) if (spellId_1 == 42016 && spellId_2 == 40216) + { return false; + } break; case SPELLFAMILY_ROGUE: @@ -2536,11 +2754,15 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Overkill if (spellInfo_1->SpellIconID == 2285 && spellInfo_2->SpellIconID == 2285) + { return false; + } // Garrote -> Garrote-Silence (multi-family check) if (spellInfo_1->SpellIconID == 498 && spellInfo_2->SpellIconID == 498 && spellInfo_2->SpellVisual[0] == 0) + { return false; + } break; case SPELLFAMILY_HUNTER: if (classOptions2 && classOptions2->SpellFamilyName == SPELLFAMILY_HUNTER ) @@ -2557,31 +2779,43 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Deterrence if (spellInfo_1->SpellIconID == 83 && spellInfo_2->SpellIconID == 83) + { return false; + } // Bestial Wrath if (spellInfo_1->SpellIconID == 1680 && spellInfo_2->SpellIconID == 1680) + { return false; + } // Aspect of the Viper & Vicious Viper if (spellInfo_1->SpellIconID == 2227 && spellInfo_2->SpellIconID == 2227) + { return false; + } } // Wing Clip -> Improved Wing Clip (multi-family check) if (classOptions1 && (classOptions1->SpellFamilyFlags & UI64LIT(0x40)) && spellInfo_2->Id == 19229 ) + { return false; + } // Concussive Shot and Imp. Concussive Shot (multi-family check) if (spellInfo_2->Id == 19410 && spellInfo_1->Id == 5116) + { return false; + } break; case SPELLFAMILY_PALADIN: if (classOptions2 && classOptions2->SpellFamilyName == SPELLFAMILY_PALADIN ) { // Paladin Seals if (IsSealSpell(spellInfo_1) && IsSealSpell(spellInfo_2)) + { return true; + } // Swift Retribution / Improved Devotion Aura (talents) and Paladin Auras if ((spellInfo_1->IsFitToFamilyMask(UI64LIT(0x0), 0x00000020) && (spellInfo_2->SpellIconID == 291 || spellInfo_2->SpellIconID == 3028)) || @@ -2590,19 +2824,27 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Beacon of Light and Light's Beacon if ((spellInfo_1->SpellIconID == 3032) && (spellInfo_2->SpellIconID == 3032)) + { return false; + } // Concentration Aura and Improved Concentration Aura and Aura Mastery if ((spellInfo_1->SpellIconID == 1487) && (spellInfo_2->SpellIconID == 1487)) + { return false; + } // Seal of Corruption (caster/target parts stacking allow, other stacking checked by spell specs) if (spellInfo_1->SpellIconID == 2292 && spellInfo_2->SpellIconID == 2292) + { return false; + } // Divine Sacrifice and Divine Guardian if (spellInfo_1->SpellIconID == 3837 && spellInfo_2->SpellIconID == 3837) + { return false; + } // Blood Corruption, Holy Vengeance, Righteous Vengeance if ((spellInfo_1->SpellIconID == 2292 && spellInfo_2->SpellIconID == 3025) || @@ -2612,19 +2854,27 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Blessing of Sanctuary (multi-family check, some from 16 spell icon spells) if (spellInfo_2->Id == 67480 && spellInfo_1->Id == 20911) + { return false; + } // Combustion and Fire Protection Aura (multi-family check) if (spellInfo_2->Id == 11129 && spellInfo_1->SpellIconID == 33 && spellInfo_1->SpellVisual[0] == 321) + { return false; + } // *Sanctity Aura -> Unstable Currents and other (multi-family check) if (spellInfo_1->SpellIconID==502 && classOptions2->SpellFamilyName == SPELLFAMILY_GENERIC && spellInfo_2->SpellIconID==502 && spellInfo_2->SpellVisual[0]==969 ) + { return false; + } // *Seal of Command and Band of Eternal Champion (multi-family check) if (spellInfo_1->SpellIconID == 561 && spellInfo_1->SpellVisual[0] == 7992 && spellId_2 == 35081) + { return false; + } break; case SPELLFAMILY_SHAMAN: if (classOptions2 && classOptions2->SpellFamilyName == SPELLFAMILY_SHAMAN ) @@ -2636,34 +2886,48 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons // Ghost Wolf if (spellInfo_1->SpellIconID == 67 && spellInfo_2->SpellIconID == 67) + { return false; + } // Totem of Wrath (positive/negative), ranks checked early if (spellInfo_1->SpellIconID == 2019 && spellInfo_2->SpellIconID == 2019) + { return false; + } } // Bloodlust and Bloodthirst (multi-family check) if (spellInfo_1->Id == 2825 && spellInfo_2->SpellIconID == 38 && spellInfo_2->SpellVisual[0] == 0) + { return false; + } break; case SPELLFAMILY_DEATHKNIGHT: if (classOptions2 && classOptions2->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT) { // Lichborne and Lichborne (triggered) if (spellInfo_1->SpellIconID == 61 && spellInfo_2->SpellIconID == 61) + { return false; + } // Frost Presence and Frost Presence (triggered) if (spellInfo_1->SpellIconID == 2632 && spellInfo_2->SpellIconID == 2632) + { return false; + } // Unholy Presence and Unholy Presence (triggered) if (spellInfo_1->SpellIconID == 2633 && spellInfo_2->SpellIconID == 2633) + { return false; + } // Blood Presence and Blood Presence (triggered) if (spellInfo_1->SpellIconID == 2636 && spellInfo_2->SpellIconID == 2636) + { return false; + } } break; default: @@ -2689,17 +2953,25 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons } if (!isModifier) + { return true; + } } if (IsRankSpellDueToSpell(spellInfo_1, spellId_2)) + { return true; + } if (!classOptions1 || classOptions1->SpellFamilyName == 0 || !classOptions2 || classOptions2->SpellFamilyName == 0) + { return false; + } if (classOptions1->SpellFamilyName != classOptions2->SpellFamilyName) + { return false; + } bool dummy_only = true; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) @@ -2711,7 +2983,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons continue; if (!spellEffect1 || !spellEffect2) + { return false; + } if (spellEffect1->Effect != spellEffect2->Effect || spellEffect1->EffectItemType != spellEffect2->EffectItemType || @@ -2725,7 +2999,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons } if (dummy_only) + { return false; + } return true; } @@ -2736,7 +3012,9 @@ bool SpellMgr::IsSpellCanAffectSpell(SpellEntry const* spellInfo_1, SpellEntry c { ClassFamilyMask mask = spellInfo_1->GetEffectSpellClassMask(SpellEffectIndex(i)); if (spellInfo_2->IsFitToFamilyMask(mask)) + { return true; + } } return false; } @@ -2745,10 +3023,14 @@ bool SpellMgr::IsProfessionOrRidingSpell(uint32 spellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return false; + } if (spellInfo->GetSpellEffectIdByIndex(EFFECT_INDEX_1) != SPELL_EFFECT_SKILL) + { return false; + } uint32 skill = spellInfo->GetEffectMiscValue(EFFECT_INDEX_1); @@ -2759,10 +3041,14 @@ bool SpellMgr::IsProfessionSpell(uint32 spellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return false; + } if (spellInfo->GetSpellEffectIdByIndex(EFFECT_INDEX_1) != SPELL_EFFECT_SKILL) + { return false; + } uint32 skill = spellInfo->GetEffectMiscValue(EFFECT_INDEX_1); @@ -2773,10 +3059,14 @@ bool SpellMgr::IsPrimaryProfessionSpell(uint32 spellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return false; + } if (spellInfo->GetSpellEffectIdByIndex(EFFECT_INDEX_1) != SPELL_EFFECT_SKILL) + { return false; + } uint32 skill = spellInfo->GetEffectMiscValue(EFFECT_INDEX_1); @@ -2800,11 +3090,15 @@ uint32 SpellMgr::GetProfessionSpellMinLevel(uint32 spellId) uint32 rank = GetSpellRank(spellId); if (rank >= 8) + { return 0; + } SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds(spellId); if (bounds.first == bounds.second) + { return 0; + } switch (bounds.first->second->skillId) { @@ -2835,7 +3129,9 @@ bool SpellMgr::IsSkillBonusSpell(uint32 spellId) const continue; if (pAbility->req_skill_value > 0) + { return true; + } } return false; @@ -2845,11 +3141,15 @@ SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo, { // fast case if (level + 10 >= spellInfo->GetSpellLevel()) + { return spellInfo; + } // ignore selection for passive spells if (IsPassiveSpell(spellInfo)) + { return spellInfo; + } bool needRankSelection = false; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) @@ -2872,7 +3172,9 @@ SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo, // not required (rank check more slow so check it here) if (!needRankSelection || GetSpellRank(spellInfo->Id) == 0) + { return spellInfo; + } for (uint32 nextSpellId = spellInfo->Id; nextSpellId != 0; nextSpellId = GetPrevSpellInChain(nextSpellId)) { @@ -2882,7 +3184,9 @@ SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo, // if found appropriate level if (level + 10 >= nextSpellInfo->GetSpellLevel()) + { return nextSpellInfo; + } // one rank less then } @@ -2948,7 +3252,9 @@ static void LoadSpellChains_AbilityHelper(SpellChainMap& chainMap, AbilitySpellP // prev rank must be listed now prev_chain_itr = chainMap.find(prev_id); if (prev_chain_itr == chainMap.end()) + { return; + } SpellChainNode node; node.prev = prev_id; @@ -3751,7 +4057,9 @@ bool SpellMgr::LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefault } } if (!have_spell) + { return false; + } // remove duplicates with levelupSpells if any if (PetLevelupSpellSet const* levelupSpells = cInfo->Family ? GetPetLevelupSpellList(cInfo->Family) : NULL) @@ -3873,7 +4181,9 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) { // not exist if (!spellInfo) + { return false; + } bool need_check_reagents = false; @@ -4202,7 +4512,9 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell } if (!found) + { return SPELL_FAILED_INCORRECT_AREA; + } } // continent limitation (virtual continent), ignore for GM @@ -4211,7 +4523,9 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell uint32 v_map = GetVirtualMapForMapAndZone(map_id, zone_id); MapEntry const* mapEntry = sMapStore.LookupEntry(v_map); if (!mapEntry || mapEntry->addon < 1 || !mapEntry->IsContinent()) + { return SPELL_FAILED_INCORRECT_AREA; + } } // raid instance limitation @@ -4219,7 +4533,9 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry || mapEntry->IsRaid()) + { return SPELL_FAILED_NOT_IN_RAID_INSTANCE; + } } // DB base check (if non empty then must fit at least single for allow) @@ -4229,7 +4545,9 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell for (SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) { if (itr->second.IsFitToRequirements(player, zone_id, area_id)) + { return SPELL_CAST_OK; + } } return SPELL_FAILED_INCORRECT_AREA; } @@ -4242,12 +4560,16 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell if (spellInfo->HasAttribute(SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || (GetSpellRecoveryTime(spellInfo) > 10 * MINUTE * IN_MILLISECONDS && !spellInfo->HasAttribute(SPELL_ATTR_EX4_USABLE_IN_ARENA))) if (player && player->InArena()) + { return SPELL_FAILED_NOT_IN_ARENA; + } // Spell casted only on battleground if (spellInfo->HasAttribute(SPELL_ATTR_EX3_BATTLEGROUND)) if (!player || !player->InBattleGround()) + { return SPELL_FAILED_ONLY_BATTLEGROUNDS; + } switch (spellInfo->Id) { @@ -4256,7 +4578,9 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell case 22563: // recall { if (!player) + { return SPELL_FAILED_REQUIRES_AREA; + } BattleGround* bg = player->GetBattleGround(); return map_id == 30 && bg && bg->GetStatus() != STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_REQUIRES_AREA; @@ -4279,13 +4603,17 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell { MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry) + { return SPELL_FAILED_INCORRECT_AREA; + } return mapEntry->IsBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 44521: // Preparation { if (!player) + { return SPELL_FAILED_REQUIRES_AREA; + } BattleGround* bg = player->GetBattleGround(); return bg && bg->GetStatus() == STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; @@ -4300,9 +4628,13 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell case 32727: // Arena Preparation { if (!player) + { return SPELL_FAILED_REQUIRES_AREA; + } if (!player->InArena()) + { return SPELL_FAILED_REQUIRES_AREA; + } BattleGround* bg = player->GetBattleGround(); return bg && bg->GetStatus() == STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; @@ -4312,7 +4644,9 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell case 74411: // Battleground - Dampening { if (!player) + { return SPELL_FAILED_ONLY_BATTLEGROUNDS; + } BattleGround* bg = player->GetBattleGround(); return bg && !bg->isArena() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; @@ -4641,38 +4975,52 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto case SPELLFAMILY_GENERIC: // some generic arena related spells have by some strange reason MECHANIC_TURN if (spellproto->GetMechanic() == MECHANIC_TURN) + { return DIMINISHING_NONE; + } break; case SPELLFAMILY_MAGE: // Dragon's Breath if (spellproto->SpellIconID == 1548) + { return DIMINISHING_DISORIENT; + } break; case SPELLFAMILY_ROGUE: { // Blind if (classOptions && classOptions->SpellFamilyFlags & UI64LIT(0x00001000000)) + { return DIMINISHING_FEAR_CHARM_BLIND; + } // Cheap Shot else if (classOptions && classOptions->SpellFamilyFlags & UI64LIT(0x00000000400)) + { return DIMINISHING_CHEAPSHOT_POUNCE; + } // Crippling poison - Limit to 10 seconds in PvP (No SpellFamilyFlags) else if (spellproto->SpellIconID == 163) + { return DIMINISHING_LIMITONLY; + } break; } case SPELLFAMILY_HUNTER: { // Freezing Trap & Freezing Arrow & Wyvern Sting if (spellproto->SpellIconID == 180 || spellproto->SpellIconID == 1721) + { return DIMINISHING_DISORIENT; + } break; } case SPELLFAMILY_WARLOCK: { // Curses/etc if (spellproto->IsFitToFamilyMask(UI64LIT(0x00080000000))) + { return DIMINISHING_LIMITONLY; + } break; } case SPELLFAMILY_PALADIN: @@ -4680,41 +5028,55 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto // Judgement of Justice - Limit to 10 seconds in PvP if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000100000))) if (classOptions && classOptions->SpellFamilyFlags & UI64LIT(0x00080000000)) + { return DIMINISHING_LIMITONLY; + } break; } case SPELLFAMILY_DRUID: { // Cyclone if (spellproto->IsFitToFamilyMask(UI64LIT(0x02000000000))) + { return DIMINISHING_CYCLONE; + } // Pounce else if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000020000))) + { return DIMINISHING_CHEAPSHOT_POUNCE; + } // Faerie Fire else if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000000400))) + { return DIMINISHING_LIMITONLY; + } break; } case SPELLFAMILY_WARRIOR: { // Hamstring - limit duration to 10s in PvP if (spellproto->IsFitToFamilyMask(UI64LIT(0x00000000002))) + { return DIMINISHING_LIMITONLY; + } break; } case SPELLFAMILY_PRIEST: { // Shackle Undead if (spellproto->SpellIconID == 27) + { return DIMINISHING_DISORIENT; + } break; } case SPELLFAMILY_DEATHKNIGHT: { // Hungering Cold (no flags) if (spellproto->SpellIconID == 2797) + { return DIMINISHING_DISORIENT; + } break; } default: @@ -4724,26 +5086,46 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto // Get by mechanic uint32 mechanic = GetAllSpellMechanicMask(spellproto); if (!mechanic) + { return DIMINISHING_NONE; + } if (mechanic & ((1 << (MECHANIC_STUN - 1)) | (1 << (MECHANIC_SHACKLE - 1)))) + { return triggered ? DIMINISHING_TRIGGER_STUN : DIMINISHING_CONTROL_STUN; + } if (mechanic & ((1 << (MECHANIC_SLEEP - 1)) | (1 << (MECHANIC_FREEZE - 1)))) + { return DIMINISHING_FREEZE_SLEEP; + } if (mechanic & ((1 << (MECHANIC_KNOCKOUT - 1)) | (1 << (MECHANIC_POLYMORPH - 1)) | (1 << (MECHANIC_SAPPED - 1)))) + { return DIMINISHING_DISORIENT; + } if (mechanic & (1 << (MECHANIC_ROOT - 1))) + { return triggered ? DIMINISHING_TRIGGER_ROOT : DIMINISHING_CONTROL_ROOT; + } if (mechanic & ((1 << (MECHANIC_FEAR - 1)) | (1 << (MECHANIC_CHARM - 1)) | (1 << (MECHANIC_TURN - 1)))) + { return DIMINISHING_FEAR_CHARM_BLIND; + } if (mechanic & ((1 << (MECHANIC_SILENCE - 1)) | (1 << (MECHANIC_INTERRUPT - 1)))) + { return DIMINISHING_SILENCE; + } if (mechanic & (1 << (MECHANIC_DISARM - 1))) + { return DIMINISHING_DISARM; + } if (mechanic & (1 << (MECHANIC_BANISH - 1))) + { return DIMINISHING_BANISH; + } if (mechanic & (1 << (MECHANIC_HORROR - 1))) + { return DIMINISHING_HORROR; + } return DIMINISHING_NONE; } @@ -4751,7 +5133,9 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellEntry const* spellproto) { if (!IsDiminishingReturnsGroupDurationLimited(group)) + { return 0; + } SpellClassOptionsEntry const* classOptions = spellproto->GetSpellClassOptions(); @@ -4762,21 +5146,27 @@ int32 GetDiminishingReturnsLimitDuration(DiminishingGroup group, SpellEntry cons { // Wyvern Sting if (classOptions && classOptions->SpellFamilyFlags & UI64LIT(0x0000100000000000)) + { return 6000; + } break; } case SPELLFAMILY_PALADIN: { // Repentance - limit to 6 seconds in PvP if (classOptions && classOptions->SpellFamilyFlags & UI64LIT(0x00000000004)) + { return 6000; + } break; } case SPELLFAMILY_DRUID: { // Faerie Fire - limit to 40 seconds in PvP (3.1) if (classOptions && classOptions->SpellFamilyFlags & UI64LIT(0x00000000400)) + { return 40000; + } break; } default: @@ -4839,7 +5229,9 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 if (conditionId) { if (!player || !sObjectMgr.IsPlayerMeetToCondition(conditionId, player, player->GetMap(), NULL, CONDITION_FROM_SPELL_AREA)) + { return false; + } } else // This block will be removed { @@ -4847,28 +5239,36 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 { // not in expected gender if (!player || gender != player->getGender()) + { return false; + } } if (raceMask) { // not in expected race if (!player || !(raceMask & player->getRaceMask())) + { return false; + } } if (questStart) { // not in expected required quest state if (!player || (!questStartCanActive || !player->IsActiveQuest(questStart)) && !player->GetQuestRewardStatus(questStart)) + { return false; + } } if (questEnd) { // not in expected forbidden quest state if (!player || player->GetQuestRewardStatus(questEnd)) + { return false; + } } } @@ -4876,14 +5276,18 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 { // not in expected zone if (newZone != areaId && newArea != areaId) + { return false; + } } if (auraSpell) { // not have expected aura if (!player) + { return false; + } if (auraSpell > 0) // have expected aura return player->HasAura(auraSpell); @@ -4913,12 +5317,16 @@ SpellEntry const* GetSpellEntryByDifficulty(uint32 id, Difficulty difficulty, bo SpellDifficultyEntry const* spellDiff = sSpellDifficultyStore.LookupEntry(id); if (!spellDiff) + { return NULL; + } for (Difficulty diff = difficulty; diff >= REGULAR_DIFFICULTY; diff = GetPrevDifficulty(diff, isRaid)) { if (spellDiff->spellId[diff]) + { return sSpellStore.LookupEntry(spellDiff->spellId[diff]); + } } return NULL; @@ -4927,7 +5335,9 @@ SpellEntry const* GetSpellEntryByDifficulty(uint32 id, Difficulty difficulty, bo int32 GetMasteryCoefficient(SpellEntry const * spellProto) { if (!spellProto || !spellProto->HasAttribute(SPELL_ATTR_EX8_MASTERY)) + { return 0; + } // Find mastery scaling coef int32 coef = 0; diff --git a/src/game/Object/SpellMgr.h b/src/game/Object/SpellMgr.h index bb3a0a9e8..ec7fcbe9a 100644 --- a/src/game/Object/SpellMgr.h +++ b/src/game/Object/SpellMgr.h @@ -89,19 +89,25 @@ float CalculateDefaultCoefficient(SpellEntry const* spellProto, DamageEffectType inline float GetSpellMinRange(SpellRangeEntry const* range, bool friendly = false) { if (!range) + { return 0; + } return (friendly ? range->minRangeFriendly : range->minRange); } inline float GetSpellMaxRange(SpellRangeEntry const* range, bool friendly = false) { if (!range) + { return 0; + } return (friendly ? range->maxRangeFriendly : range->maxRange); } inline uint32 GetSpellRecoveryTime(SpellEntry const *spellInfo) { if(SpellCooldownsEntry const* cooldowns = spellInfo->GetSpellCooldowns()) + { return cooldowns->RecoveryTime > cooldowns->CategoryRecoveryTime ? cooldowns->RecoveryTime : cooldowns->CategoryRecoveryTime; + } return 0; } int32 GetSpellDuration(SpellEntry const *spellInfo); @@ -117,7 +123,9 @@ inline bool IsSpellHaveEffect(SpellEntry const* spellInfo, SpellEffects effect) { if(SpellEffectEntry const* effectEntry = spellInfo->GetSpellEffect(SpellEffectIndex(i))) if(SpellEffects(effectEntry->Effect) == effect) + { return true; + } } return false; } @@ -126,7 +134,9 @@ inline bool IsAuraApplyEffect(SpellEntry const* spellInfo, SpellEffectIndex effe { SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(SpellEffectIndex(effecIdx)); if (!spellEffect) + { return false; + } switch (spellEffect->Effect) { @@ -147,7 +157,9 @@ inline bool IsSpellAppliesAura(SpellEntry const* spellInfo, uint32 effectMask = for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (effectMask & (1 << i)) if (IsAuraApplyEffect(spellInfo, SpellEffectIndex(i))) + { return true; + } return false; } @@ -156,7 +168,9 @@ inline bool IsEffectHandledOnDelayedSpellLaunch(SpellEntry const* spellInfo, Spe { SpellEffectEntry const* effectEntry = spellInfo->GetSpellEffect(effecIdx); if(!effectEntry) + { return false; + } switch (effectEntry->Effect) { case SPELL_EFFECT_SCHOOL_DAMAGE: @@ -174,7 +188,9 @@ inline bool IsPeriodicRegenerateEffect(SpellEntry const* spellInfo, SpellEffectI { SpellEffectEntry const* effectEntry = spellInfo->GetSpellEffect(effecIdx); if(!effectEntry) + { return false; + } switch (AuraType(effectEntry->EffectApplyAuraName)) { @@ -195,7 +211,9 @@ inline bool IsSpellHaveAura(SpellEntry const* spellInfo, AuraType aura, uint32 e if (effectMask & (1 << i)) if(SpellEffectEntry const* effectEntry = spellInfo->GetSpellEffect(SpellEffectIndex(i))) if(AuraType(effectEntry->EffectApplyAuraName) == aura) + { return true; + } return false; } @@ -205,7 +223,9 @@ inline bool IsSpellLastAuraEffect(SpellEntry const* spellInfo, SpellEffectIndex { if(SpellEffectEntry const* effectEntry = spellInfo->GetSpellEffect(SpellEffectIndex(i))) if(effectEntry->EffectApplyAuraName) + { return false; + } } return true; @@ -243,7 +263,9 @@ inline bool IsLootCraftingSpell(SpellEntry const* spellInfo) { SpellEffectEntry const* spellEffect0 = spellInfo->GetSpellEffect(EFFECT_INDEX_0); if (!spellEffect0) + { return false; + } SpellTotemsEntry const* totems = spellInfo->GetSpellTotems(); @@ -273,7 +295,9 @@ inline bool IsSpellRemoveAllMovementAndControlLossEffects(SpellEntry const* spel { SpellEffectEntry const* spellEffect0 = spellProto->GetSpellEffect(EFFECT_INDEX_0); if (!spellEffect0) + { return false; + } return spellEffect0->EffectApplyAuraName == SPELL_AURA_MECHANIC_IMMUNITY && spellEffect0->EffectMiscValue == 1 && @@ -351,14 +375,20 @@ inline bool IsSpellWithCasterSourceTargetsOnly(SpellEntry const* spellInfo) uint32 targetA = effectEntry->EffectImplicitTargetA; if(targetA && !IsCasterSourceTarget(targetA)) + { return false; + } uint32 targetB = effectEntry->EffectImplicitTargetB; if(targetB && !IsCasterSourceTarget(targetB)) + { return false; + } if (!targetA && !targetB) + { return false; + } } return true; } @@ -439,13 +469,19 @@ inline bool IsAreaOfEffectSpell(SpellEntry const* spellInfo) { SpellEffectEntry const* effectEntry = spellInfo->GetSpellEffect(EFFECT_INDEX_0); if(effectEntry && (IsAreaEffectTarget(Targets(effectEntry->EffectImplicitTargetA)) || IsAreaEffectTarget(Targets(effectEntry->EffectImplicitTargetB)))) + { return true; + } effectEntry = spellInfo->GetSpellEffect(EFFECT_INDEX_1); if(effectEntry && (IsAreaEffectTarget(Targets(effectEntry->EffectImplicitTargetA)) || IsAreaEffectTarget(Targets(effectEntry->EffectImplicitTargetB)))) + { return true; + } effectEntry = spellInfo->GetSpellEffect(EFFECT_INDEX_2); if(effectEntry && (IsAreaEffectTarget(Targets(effectEntry->EffectImplicitTargetA)) || IsAreaEffectTarget(Targets(effectEntry->EffectImplicitTargetB)))) + { return true; + } return false; } @@ -470,7 +506,9 @@ inline bool HasAreaAuraEffect(SpellEntry const* spellInfo) if(!effectEntry) continue; if (IsAreaAuraEffect(effectEntry->Effect)) + { return true; + } } return false; } @@ -554,11 +592,15 @@ inline bool IsChanneledSpell(SpellEntry const* spellInfo) inline bool IsNeedCastSpellAtFormApply(SpellEntry const* spellInfo, ShapeshiftForm form) { if ((!spellInfo->HasAttribute(SPELL_ATTR_PASSIVE) && !spellInfo->HasAttribute(SPELL_ATTR_UNK7)) || !form) + { return false; + } SpellShapeshiftEntry const* shapeShift = spellInfo->GetSpellShapeshift(); if (!shapeShift) + { return false; + } // passive spells with SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT are already active without shapeshift, do no recast! return (shapeShift->Stances & (1<<(form-1)) && !(spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT)); @@ -623,10 +665,14 @@ inline Mechanics GetEffectMechanic(SpellEntry const* spellInfo, SpellEffectIndex { SpellEffectEntry const* effectEntry = spellInfo->GetSpellEffect(SpellEffectIndex(effect)); if (effectEntry && effectEntry->EffectMechanic) + { return Mechanics(effectEntry->EffectMechanic); + } SpellCategoriesEntry const* spellCategory = spellInfo->GetSpellCategories(); if (spellCategory && spellCategory->Mechanic) + { return Mechanics(spellCategory->Mechanic); + } return MECHANIC_NONE; } @@ -634,9 +680,13 @@ inline uint32 GetDispellMask(DispelType dispel) { // If dispell all if (dispel == DISPEL_ALL) + { return DISPEL_ALL_MASK; + } else + { return (1 << dispel); + } } // Diminishing Returns interaction with spells @@ -850,14 +900,20 @@ class PetAura { std::map::const_iterator itr = auras.find(petEntry); if (itr != auras.end()) + { return itr->second; + } else { std::map::const_iterator itr2 = auras.find(0); if (itr2 != auras.end()) + { return itr2->second; + } else + { return 0; + } } } @@ -996,7 +1052,9 @@ class SpellMgr { SpellElixirMap::const_iterator itr = mSpellElixirs.find(spellid); if (itr == mSpellElixirs.end()) + { return 0x0; + } return itr->second; } @@ -1007,22 +1065,34 @@ class SpellMgr // flasks must have all bits set from ELIXIR_FLASK_MASK if ((mask & ELIXIR_FLASK_MASK) == ELIXIR_FLASK_MASK) + { return SPELL_FLASK_ELIXIR; + } else if (mask & ELIXIR_BATTLE_MASK) + { return SPELL_BATTLE_ELIXIR; + } else if (mask & ELIXIR_GUARDIAN_MASK) + { return SPELL_GUARDIAN_ELIXIR; + } else if (mask & ELIXIR_WELL_FED) + { return SPELL_WELL_FED; + } else + { return SPELL_NORMAL; + } } SpellThreatEntry const* GetSpellThreatEntry(uint32 spellid) const { SpellThreatMap::const_iterator itr = mSpellThreatMap.find(spellid); if (itr != mSpellThreatMap.end()) + { return &itr->second; + } return NULL; } @@ -1030,10 +1100,14 @@ class SpellMgr float GetSpellThreatMultiplier(SpellEntry const* spellInfo) const { if (!spellInfo) + { return 1.0f; + } if (SpellThreatEntry const* entry = GetSpellThreatEntry(spellInfo->Id)) + { return entry->multiplier; + } return 1.0f; } @@ -1043,7 +1117,9 @@ class SpellMgr { SpellProcEventMap::const_iterator itr = mSpellProcEventMap.find(spellId); if (itr != mSpellProcEventMap.end()) + { return &itr->second; + } return NULL; } @@ -1052,7 +1128,9 @@ class SpellMgr { SpellProcItemEnchantMap::const_iterator itr = mSpellProcItemEnchantMap.find(spellid); if (itr == mSpellProcItemEnchantMap.end()) + { return 0.0f; + } return itr->second; } @@ -1065,7 +1143,9 @@ class SpellMgr // Lookup data SpellBonusMap::const_iterator itr = mSpellBonusMap.find(spellId); if (itr != mSpellBonusMap.end()) + { return &itr->second; + } return NULL; } @@ -1075,7 +1155,9 @@ class SpellMgr { SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find(spell_id); if (itr != mSpellTargetPositions.end()) + { return &itr->second; + } return NULL; } @@ -1084,7 +1166,9 @@ class SpellMgr { SpellChainMap::const_iterator itr = mSpellChains.find(spell_id); if (itr == mSpellChains.end()) + { return NULL; + } return &itr->second; } @@ -1092,7 +1176,9 @@ class SpellMgr uint32 GetFirstSpellInChain(uint32 spell_id) const { if (SpellChainNode const* node = GetSpellChainNode(spell_id)) + { return node->first; + } return spell_id; } @@ -1100,7 +1186,9 @@ class SpellMgr uint32 GetPrevSpellInChain(uint32 spell_id) const { if (SpellChainNode const* node = GetSpellChainNode(spell_id)) + { return node->prev; + } return 0; } @@ -1123,7 +1211,9 @@ class SpellMgr uint8 GetSpellRank(uint32 spell_id) const { if (SpellChainNode const* node = GetSpellChainNode(spell_id)) + { return node->rank; + } return 0; } @@ -1136,12 +1226,16 @@ class SpellMgr // not ordered correctly by rank value if (itr == mSpellChains.end() || !rank2 || itr->second.rank <= rank2) + { return false; + } // check present in same rank chain for (; itr != mSpellChains.end(); itr = mSpellChains.find(itr->second.prev)) if (itr->second.prev == spell2) + { return true; + } return false; } @@ -1164,9 +1258,13 @@ class SpellMgr { SpellLearnSkillMap::const_iterator itr = mSpellLearnSkills.find(spell_id); if (itr != mSpellLearnSkills.end()) + { return &itr->second; + } else + { return NULL; + } } bool IsSpellLearnSpell(uint32 spell_id) const @@ -1184,7 +1282,9 @@ class SpellMgr SpellLearnSpellMapBounds bounds = GetSpellLearnSpellMapBounds(spell_id1); for (SpellLearnSpellMap::const_iterator i = bounds.first; i != bounds.second; ++i) if (i->second.spell == spell_id2) + { return true; + } return false; } @@ -1213,18 +1313,26 @@ class SpellMgr { SpellPetAuraMap::const_iterator itr = mSpellPetAuraMap.find((spell_id << 8) + eff); if (itr != mSpellPetAuraMap.end()) + { return &itr->second; + } else + { return NULL; + } } PetLevelupSpellSet const* GetPetLevelupSpellList(uint32 petFamily) const { PetLevelupSpellMap::const_iterator itr = mPetLevelupSpellMap.find(petFamily); if (itr != mPetLevelupSpellMap.end()) + { return &itr->second; + } else + { return NULL; + } } // < 0 for petspelldata id, > 0 for creature_id @@ -1232,7 +1340,9 @@ class SpellMgr { PetDefaultSpellsMap::const_iterator itr = mPetDefaultSpellsMap.find(id); if (itr != mPetDefaultSpellsMap.end()) + { return &itr->second; + } return NULL; } diff --git a/src/game/Object/StatSystem.cpp b/src/game/Object/StatSystem.cpp index e0ad2a2dc..cdc2577a9 100644 --- a/src/game/Object/StatSystem.cpp +++ b/src/game/Object/StatSystem.cpp @@ -169,7 +169,9 @@ void Player::UpdateResistances(uint32 school) pet->UpdateResistances(school); } else - { UpdateArmor(); } + { + UpdateArmor(); + } } void Player::UpdateArmor() @@ -648,7 +650,9 @@ void Player::UpdateAllSpellCritChances() void Player::UpdateExpertise(WeaponAttackType attack) { if (attack == RANGED_ATTACK) + { return; + } int32 expertise = int32(GetRatingBonusValue(CR_EXPERTISE)); @@ -736,7 +740,9 @@ void Player::UpdateMasteryAuras() std::vector const* masterySpells = GetTalentTreeMasterySpells(m_talentsPrimaryTree[m_activeSpec]); if (!masterySpells) + { return; + } for (uint32 i = 0; i < masterySpells->size(); ++i) { @@ -825,7 +831,9 @@ void Creature::UpdateResistances(uint32 school) SetResistance(SpellSchools(school), int32(value)); } else - { UpdateArmor(); } + { + UpdateArmor(); + } } void Creature::UpdateArmor() @@ -983,7 +991,9 @@ void Pet::UpdateResistances(uint32 school) SetResistance(SpellSchools(school), int32(value)); } else - { UpdateArmor(); } + { + UpdateArmor(); + } } void Pet::UpdateArmor() @@ -1051,7 +1061,9 @@ void Pet::UpdateAttackPowerAndDamage(bool ranged) val = GetStat(STAT_STRENGTH) - 10.0f; } else - { val = 2 * GetStat(STAT_STRENGTH) - 20.0f; } + { + val = 2 * GetStat(STAT_STRENGTH) - 20.0f; + } Unit* owner = GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER) diff --git a/src/game/Object/TemporarySummon.cpp b/src/game/Object/TemporarySummon.cpp index a8dd50cb1..03d3340b9 100644 --- a/src/game/Object/TemporarySummon.cpp +++ b/src/game/Object/TemporarySummon.cpp @@ -61,7 +61,9 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff) m_timer -= update_diff; } else if (m_timer != m_lifetime) - { m_timer = m_lifetime; } + { + m_timer = m_lifetime; + } break; } @@ -122,10 +124,14 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff) return; } else - { m_timer -= update_diff; } + { + m_timer -= update_diff; + } } else if (m_timer != m_lifetime) - { m_timer = m_lifetime; } + { + m_timer = m_lifetime; + } break; } case TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN: @@ -145,10 +151,14 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff) return; } else - { m_timer -= update_diff; } + { + m_timer -= update_diff; + } } else if (m_timer != m_lifetime) - { m_timer = m_lifetime; } + { + m_timer = m_lifetime; + } break; } case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN: diff --git a/src/game/Object/Totem.cpp b/src/game/Object/Totem.cpp index be84bf479..01784cb07 100644 --- a/src/game/Object/Totem.cpp +++ b/src/game/Object/Totem.cpp @@ -49,7 +49,9 @@ bool Totem::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* Team team = owner->GetTypeId() == TYPEID_PLAYER ? ((Player*)owner)->GetTeam() : TEAM_NONE; if (!CreateFromProto(guidlow, cinfo, team)) + { return false; + } // special model selection case for totems if (owner->GetTypeId() == TYPEID_PLAYER) @@ -65,7 +67,9 @@ bool Totem::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cPos.m_pos.z = owner->GetPositionZ(); if (!cPos.Relocate(this)) + { return false; + } // Notify the map's instance data. // Only works if you create the object in it, not if it is moves to that map. @@ -111,7 +115,9 @@ void Totem::Summon(Unit* owner) // there are some totems, which exist just for their visual appeareance if (!GetSpell()) + { return; + } switch (m_type) { @@ -174,7 +180,9 @@ void Totem::SetOwner(Unit* owner) Unit* Totem::GetOwner() { if (ObjectGuid ownerGuid = GetOwnerGuid()) + { return ObjectAccessor::GetUnit(*this, ownerGuid); + } return NULL; } @@ -199,7 +207,9 @@ bool Totem::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex // Mana Spring, Healing stream, Mana tide // Flags : 0x00000002000 | 0x00000004000 | 0x00004000000 -> 0x00004006000 if (spellInfo->GetSpellFamilyName() == SPELLFAMILY_SHAMAN && spellInfo->IsFitToFamilyMask(UI64LIT(0x00004006000))) + { return false; + } SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(index); if (spellEffect) { diff --git a/src/game/Object/TotemAI.cpp b/src/game/Object/TotemAI.cpp index 8ce195696..2f80bda07 100644 --- a/src/game/Object/TotemAI.cpp +++ b/src/game/Object/TotemAI.cpp @@ -36,7 +36,9 @@ int TotemAI::Permissible(const Creature* creature) { if (creature->IsTotem()) + { return PERMIT_BASE_PROACTIVE; + } return PERMIT_BASE_NO; } @@ -59,15 +61,21 @@ void TotemAI::UpdateAI(const uint32 /*diff*/) { if (getTotem().GetTotemType() != TOTEM_ACTIVE) + { return; + } if (!m_creature->IsAlive() || m_creature->IsNonMeleeSpellCasted(false)) + { return; + } // Search spell SpellEntry const* spellInfo = sSpellStore.LookupEntry(getTotem().GetSpell()); if (!spellInfo) + { return; + } // Get spell rangy SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 43dfda04d..b8a926cf9 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -645,7 +645,9 @@ void Unit::Update(uint32 update_diff, uint32 p_time) CombatStop(); } else - { m_CombatTimer -= update_diff; } + { + m_CombatTimer -= update_diff; + } } } @@ -748,7 +750,9 @@ bool Unit::UpdateMeleeAttackingState() player->SendAttackSwingNotInRange(); } else if (swingError == 2) - { player->SendAttackSwingBadFacingAttack(); } + { + player->SendAttackSwingBadFacingAttack(); + } player->SwingErrorMsg(swingError); } @@ -867,7 +871,9 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType, ObjectGuid casterGuid) iter = m_modAuras[auraType].begin(); } else - { ++iter; } + { + ++iter; + } } } @@ -1140,7 +1146,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa group_tap->RewardGroupAtKill(pVictim, player_tap); } else if (player_tap) - { player_tap->RewardSinglePlayerAtKill(pVictim); } + { + player_tap->RewardSinglePlayerAtKill(pVictim); + } } // stop combat @@ -1172,7 +1180,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->CastSpell(pVictim, 27827, true, NULL, spiritOfRedemtionTalentReady); } else - { pVictim->SetHealth(0); } + { + pVictim->SetHealth(0); + } // Call KilledUnit for creatures if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) @@ -1264,7 +1274,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa } } else // Killed creature - { JustKilledCreature((Creature*)pVictim, player_tap); } + { + JustKilledCreature((Creature*)pVictim, player_tap); + } } else // if (health <= damage) { @@ -1341,7 +1353,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->InterruptSpell(CurrentSpellTypes(i)); } else - { spell->Delayed(); } + { + spell->Delayed(); + } } } } @@ -1574,7 +1588,9 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castIte sLog.outError("CastSpell: unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); } else - { sLog.outError("CastSpell: unknown spell id %i by caster: %s", spellId, GetGuidStr().c_str()); } + { + sLog.outError("CastSpell: unknown spell id %i by caster: %s", spellId, GetGuidStr().c_str()); + } return; } @@ -1590,7 +1606,9 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, sLog.outError("CastSpell: unknown spell by caster: %s triggered by aura %u (eff %u)", GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); } else - { sLog.outError("CastSpell: unknown spell by caster: %s", GetGuidStr().c_str()); } + { + sLog.outError("CastSpell: unknown spell by caster: %s", GetGuidStr().c_str()); + } return; } @@ -1644,7 +1662,9 @@ void Unit::CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 if (triggeredByAura) sLog.outError("CastCustomSpell: unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); else - { sLog.outError("CastCustomSpell: unknown spell id %i by caster: %s", spellId, GetGuidStr().c_str()); } + { + sLog.outError("CastCustomSpell: unknown spell id %i by caster: %s", spellId, GetGuidStr().c_str()); + } return; } @@ -1802,11 +1822,15 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S } if (!this || !pVictim) + { return; + } // units which are not alive cannot deal damage except for dying creatures if ((!this->IsAlive() || !pVictim->IsAlive()) && (this->GetTypeId() != TYPEID_UNIT || this->getDeathState() != DEAD)) + { return; + } // Check spell crit chance bool crit = IsSpellCrit(pVictim, spellInfo, damageSchoolMask, attackType); @@ -1872,7 +1896,9 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S } } else - { damage = 0; } + { + damage = 0; + } damageInfo->damage = damage; } @@ -1905,7 +1931,9 @@ 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 (!IsAllowedDamageInArea(pVictim)) + { return; + } // Call default DealDamage (send critical in hit info for threat calculation) CleanDamage cleanDamage(0, BASE_ATTACK, damageInfo->HitInfo & SPELL_HIT_TYPE_CRIT ? MELEE_HIT_CRIT : MELEE_HIT_NORMAL); @@ -2127,7 +2155,9 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo lowEnd = 0.01f; } else if (lowEnd > maxLowEnd) // the smaller value of this and 0.6 is kept as the low end - { lowEnd = maxLowEnd; } + { + lowEnd = maxLowEnd; + } if (highEnd < 0.2f) // high end limits { @@ -2192,7 +2222,9 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo } } else // Umpossible get negative result but.... - { damageInfo->damage = 0; } + { + damageInfo->damage = 0; + } } void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) @@ -2216,7 +2248,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* 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 (!IsAllowedDamageInArea(pVictim)) + { return; + } // Hmmmm dont like this emotes client must by self do all animations if (damageInfo->HitInfo & HITINFO_CRITICALHIT) @@ -2348,7 +2382,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) i = vDamageShields.begin(); } else - { ++i; } + { + ++i; + } } } } @@ -2380,7 +2416,9 @@ void Unit::HandleEmote(uint32 emote_id) HandleEmoteState(emote_id); } else - { HandleEmoteCommand(emote_id); } + { + HandleEmoteCommand(emote_id); + } } } @@ -2501,21 +2539,27 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM ++m; } else - { break; } + { + break; + } } if (damagetype == DOT && m == 4) { *resist += uint32(damage - 1); } else - { *resist += uint32(damage * m / 4); } + { + *resist += uint32(damage * m / 4); + } if (*resist > damage) { *resist = damage; } } else - { *resist = 0; } + { + *resist = 0; + } int32 RemainingDamage = damage - *resist; @@ -2828,7 +2872,9 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM i = vSchoolAbsorb.begin(); } else - { ++i; } + { + ++i; + } } } @@ -2857,7 +2903,9 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM currentAbsorb = (*i)->GetModifier()->m_amount; } else - { currentAbsorb = RemainingDamage; } + { + currentAbsorb = RemainingDamage; + } SpellEffectEntry const* spellEffect = (*i)->GetSpellProto()->GetSpellEffect((*i)->GetEffIndex()); @@ -3019,7 +3067,9 @@ void Unit::CalculateAbsorbResistBlock(Unit* pCaster, SpellNonMeleeDamage* damage void Unit::CalculateHealAbsorb(const uint32 heal, uint32* absorb) { if (!IsAlive() || !heal) + { return; + } int32 RemainingHeal = heal; @@ -3079,13 +3129,19 @@ void Unit::CalculateHealAbsorb(const uint32 heal, uint32* absorb) void Unit::AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType, bool extra) { if (hasUnitState(UNIT_STAT_CAN_NOT_REACT) || HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) + { return; + } if (!pVictim->IsAlive()) + { return; + } if (IsNonMeleeSpellCasted(false)) + { return; + } if (attType == RANGED_ATTACK) return; // ignore ranged case @@ -3185,7 +3241,9 @@ 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()) + { return MELEE_HIT_EVADE; + } int32 attackerMaxSkillValueForLevel = GetMaxSkillValueForLevel(pVictim); int32 victimMaxSkillValueForLevel = pVictim->GetMaxSkillValueForLevel(this); @@ -3377,7 +3435,9 @@ float Unit::CalculateLevelPenalty(SpellEntry const* spellProto) const { uint32 spellLevel = spellProto->GetSpellLevel(); if (spellLevel <= 0 || spellLevel > spellProto->GetMaxLevel()) + { return 1.0f; + } float LvlPenalty = 0.0f; @@ -3403,7 +3463,9 @@ void Unit::SendMeleeAttackStart(Unit* pVictim) void Unit::SendMeleeAttackStop(Unit* victim) { if (!victim) + { return; + } WorldPacket data(SMSG_ATTACKSTOP, (4 + 16)); // we guess size data << GetPackGUID(); @@ -3419,13 +3481,17 @@ void Unit::SendMeleeAttackStop(Unit* victim) bool Unit::IsSpellBlocked(Unit* pCaster, SpellEntry const* spellEntry, WeaponAttackType attackType) { if (!HasInArc(M_PI_F, pCaster)) + { return false; + } if (spellEntry) { // Some spells cannot be blocked if (spellEntry->HasAttribute(SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)) + { return false; + } } /* @@ -3436,7 +3502,9 @@ bool Unit::IsSpellBlocked(Unit* pCaster, SpellEntry const* spellEntry, WeaponAtt if (!(*i)->isAffectedOnSpell(spellProto)) continue; if ((*i)->GetModifier()->m_miscvalue == ???) + { return false; + } } */ @@ -3444,7 +3512,9 @@ bool Unit::IsSpellBlocked(Unit* pCaster, SpellEntry const* spellEntry, WeaponAtt if (GetTypeId() == TYPEID_UNIT) { if (((Creature*)this)->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NO_BLOCK) + { return false; + } } float blockChance = GetUnitBlockChance(); @@ -3495,9 +3565,13 @@ float Unit::MeleeSpellMissChance(Unit* pVictim, WeaponAttackType attType, int32 // Limit miss chance from 0 to 60% if (missChance < 0.0f) + { return 0.0f; + } if (missChance > 60.0f) + { return 60.0f; + } return missChance; } @@ -3519,7 +3593,9 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) // Roll miss uint32 tmp = spell->HasAttribute(SPELL_ATTR_EX3_CANT_MISS) ? 0 : missChance; if (roll < tmp) + { return SPELL_MISS_MISS; + } // Chance resist mechanic (select max value from every mechanic spell effect) int32 resist_mech = 0; @@ -3537,14 +3613,18 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) // Roll chance tmp += resist_mech; if (roll < tmp) + { return SPELL_MISS_RESIST; + } bool canDodge = true; bool canParry = true; // Same spells cannot be parry/dodge if (spell->HasAttribute(SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)) + { return SPELL_MISS_NONE; + } bool from_behind = !pVictim->HasInArc(M_PI_F, this); @@ -3561,7 +3641,9 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) tmp += deflect_chance; if (roll < tmp) + { return SPELL_MISS_DEFLECT; + } } return SPELL_MISS_NONE; } @@ -3616,7 +3698,9 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) tmp += dodgeChance; if (roll < tmp) + { return SPELL_MISS_DODGE; + } } if (canParry) @@ -3636,7 +3720,9 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) tmp += parryChance; if (roll < tmp) + { return SPELL_MISS_PARRY; + } } return SPELL_MISS_NONE; @@ -3647,7 +3733,9 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell) { // Can`t miss on dead target (on skinning for example) if (!pVictim->IsAlive()) + { return SPELL_MISS_NONE; + } SpellSchoolMask schoolMask = GetSpellSchoolMask(spell); // PvP - PvE spell misschances per leveldif > 2 @@ -3698,7 +3786,9 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell) int32 rand = irand(0, 10000); if (rand < tmp) + { return SPELL_MISS_MISS; + } bool from_behind = !pVictim->HasInArc(M_PI_F, this); @@ -3712,7 +3802,9 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell) tmp += deflect_chance; if (rand < tmp) + { return SPELL_MISS_DEFLECT; + } } return SPELL_MISS_NONE; @@ -3730,20 +3822,28 @@ SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool { // Return evade for units in evade mode if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + { return SPELL_MISS_EVADE; + } // Check for immune if (pVictim->IsImmuneToSpell(spell, this == pVictim) && !spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY)) + { return SPELL_MISS_IMMUNE; + } // All positive spells can`t miss // TODO: client not show miss log for this spells - so need find info for this in dbc and use it! if (IsPositiveSpell(spell->Id)) + { return SPELL_MISS_NONE; + } // Check for immune if (pVictim->IsImmunedToDamage(GetSpellSchoolMask(spell)) && !spell->HasAttribute(SPELL_ATTR_UNAFFECTED_BY_INVULNERABILITY)) + { return SPELL_MISS_IMMUNE; + } // Try victim reflect spell if (CanReflect) @@ -3777,7 +3877,9 @@ SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool float Unit::MeleeMissChanceCalc(const Unit* pVictim, WeaponAttackType attType) const { if (!pVictim) + { return 0.0f; + } // Base misschance 5% float missChance = 5.0f; @@ -3824,9 +3926,13 @@ float Unit::MeleeMissChanceCalc(const Unit* pVictim, WeaponAttackType attType) c // Limit miss chance from 0 to 60% if (missChance < 0.0f) + { return 0.0f; + } if (missChance > 60.0f) + { return 60.0f; + } return missChance; } @@ -3834,13 +3940,19 @@ float Unit::MeleeMissChanceCalc(const Unit* pVictim, WeaponAttackType attType) c float Unit::GetUnitDodgeChance() const { if (hasUnitState(UNIT_STAT_STUNNED)) + { return 0.0f; + } if (GetTypeId() == TYPEID_PLAYER) + { return GetFloatValue(PLAYER_DODGE_PERCENTAGE); + } else { if (((Creature const*)this)->IsTotem()) + { return 0.0f; + } else { float dodge = 5.0f; @@ -3853,7 +3965,9 @@ float Unit::GetUnitDodgeChance() const float Unit::GetUnitParryChance() const { if (IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) + { return 0.0f; + } float chance = 0.0f; @@ -3885,7 +3999,9 @@ float Unit::GetUnitParryChance() const float Unit::GetUnitBlockChance() const { if (IsNonMeleeSpellCasted(false) || hasUnitState(UNIT_STAT_STUNNED)) + { return 0.0f; + } if (GetTypeId() == TYPEID_PLAYER) { @@ -3894,7 +4010,9 @@ float Unit::GetUnitBlockChance() const { Item* tmpitem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (tmpitem && !tmpitem->IsBroken()) + { return GetFloatValue(PLAYER_BLOCK_PERCENTAGE); + } } // is player but has no block ability or no not broken shield equipped return 0.0f; @@ -3902,7 +4020,9 @@ float Unit::GetUnitBlockChance() const else { if (((Creature const*)this)->IsTotem()) + { return 0.0f; + } else { float block = 5.0f; @@ -4038,7 +4158,9 @@ void Unit::_UpdateAutoRepeatSpell() } // auto shot is delayed by everythihng, except ranged(!) CURRENT_GENERIC_SPELL's -> recheck that else if (!(m_currentSpells[CURRENT_GENERIC_SPELL] && m_currentSpells[CURRENT_GENERIC_SPELL]->IsRangedSpell())) + { return; + } } // castroutine @@ -4163,7 +4285,9 @@ void Unit::FinishSpell(CurrentSpellTypes spellType, bool ok /*= true*/) { Spell* spell = m_currentSpells[spellType]; if (!spell) + { return; + } if (spellType == CURRENT_CHANNELED_SPELL) spell->SendChannelUpdate(0); @@ -4189,7 +4313,9 @@ bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skip // autorepeat spells may be finished or delayed, but they are still considered casted else if (!skipAutorepeat && m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) + { return true; + } return false; } @@ -4213,7 +4339,9 @@ Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const { for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i) if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id == spell_id) + { return m_currentSpells[i]; + } return NULL; } @@ -4233,7 +4361,9 @@ void Unit::SetFacingToObject(WorldObject* pObject) { // never face when already moving if (!IsStopped()) + { return; + } // TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is. SetFacingTo(GetAngle(pObject)); @@ -4242,9 +4372,13 @@ void Unit::SetFacingToObject(WorldObject* pObject) bool Unit::isInAccessablePlaceFor(Creature const* c) const { if (IsInWater()) + { return c->CanSwim(); + } else + { return c->CanWalk() || c->CanFly(); + } } bool Unit::IsInWater() const @@ -4311,7 +4445,9 @@ int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const { if (!misc_mask) + { return 0; + } int32 modifier = 0; @@ -4328,7 +4464,9 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const { if (!misc_mask) + { return 1.0f; + } float multiplier = 1.0f; @@ -4345,7 +4483,9 @@ float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const { if (!misc_mask) + { return 0; + } int32 modifier = 0; @@ -4363,7 +4503,9 @@ int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_ int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const { if (!misc_mask) + { return 0; + } int32 modifier = 0; @@ -4439,7 +4581,9 @@ int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_ float Unit::GetTotalAuraMultiplierByMiscValueForMask(AuraType auratype, uint32 mask) const { if (!mask) + { return 1.0f; + } float multiplier = 1.0f; @@ -4680,7 +4824,9 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder) // if aura deleted before boosts apply ignore // this can be possible it it removed indirectly by triggered spell effect at ApplyModifier if (holder->IsDeleted()) + { return false; + } holder->HandleSpellSpecificBoosts(true); @@ -4697,7 +4843,9 @@ void Unit::RemoveRankAurasDueToSpell(uint32 spellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return; + } SpellAuraHolderMap::const_iterator i, next; for (i = m_spellAuraHolders.begin(); i != m_spellAuraHolders.end(); i = next) { @@ -4722,17 +4870,23 @@ void Unit::RemoveRankAurasDueToSpell(uint32 spellId) bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) { if (!holder) + { return false; + } SpellEntry const* spellProto = holder->GetSpellProto(); if (!spellProto) + { return false; + } uint32 spellId = holder->GetId(); // passive spell special case (only non stackable with ranks) if (IsPassiveSpell(spellProto) && IsPassiveSpellStackableWithRanks(spellProto)) + { return true; + } SpellSpecific spellId_spec = GetSpellSpecific(spellId); @@ -4777,7 +4931,9 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) // cannot remove higher rank if (sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) if (CompareAuraRanks(spellId, i_spellId) < 0) + { return false; + } // Its a parent aura (create this aura in ApplyModifier) if ((*i).second->IsInUse()) @@ -4802,7 +4958,9 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) { // cannot remove higher rank if (CompareAuraRanks(spellId, i_spellId) < 0) + { return false; + } // Its a parent aura (create this aura in ApplyModifier) if ((*i).second->IsInUse()) @@ -5351,7 +5509,9 @@ void Unit::RemoveSingleAuraFromSpellAuraHolder(SpellAuraHolder* holder, SpellEff { Aura* aura = holder->GetAuraByEffectIndex(index); if (!aura) + { return; + } if (aura->IsLastAuraOnHolder()) RemoveSpellAuraHolder(holder, mode); @@ -5519,7 +5679,9 @@ bool Unit::HasAffectedAura(AuraType auraType, SpellEntry const* spellProto) cons for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if ((*itr)->isAffectedOnSpell(spellProto)) + { return true; + } } return false; @@ -5529,7 +5691,9 @@ Aura* Unit::GetAura(uint32 spellId, SpellEffectIndex effindex) { SpellAuraHolderBounds bounds = GetSpellAuraHolderBounds(spellId); if (bounds.first != bounds.second) + { return bounds.first->second->GetAuraByEffectIndex(effindex); + } return NULL; } @@ -5561,7 +5725,9 @@ Aura* Unit::GetTriggeredByClientAura(uint32 spellId) const // NOTE for further development: If there are more spells of this aura type, it might be required to check that this is the effect that applies SPELL_AURA_PERIODIC_TRIGGER_BY_CLIENT if (holder->GetCasterGuid() == GetObjectGuid() && spellEffect->EffectTriggerSpell == spellId) + { return *itr; + } } return NULL; @@ -5572,7 +5738,9 @@ bool Unit::HasAura(uint32 spellId, SpellEffectIndex effIndex) const SpellAuraHolderConstBounds spair = GetSpellAuraHolderBounds(spellId); for (SpellAuraHolderMap::const_iterator i_holder = spair.first; i_holder != spair.second; ++i_holder) if (i_holder->second->GetAuraByEffectIndex(effIndex)) + { return true; + } return false; } @@ -5595,7 +5763,9 @@ void Unit::AddDynObject(DynamicObject* dynObj) void Unit::RemoveDynObject(uint32 spellid) { if (m_dynObjGUIDs.empty()) + { return; + } for (GuidList::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();) { DynamicObject* dynObj = GetMap()->GetDynamicObject(*i); @@ -5635,7 +5805,9 @@ DynamicObject* Unit::GetDynObject(uint32 spellId, SpellEffectIndex effIndex) } if (dynObj->GetSpellId() == spellId && dynObj->GetEffIndex() == effIndex) + { return dynObj; + } ++i; } return NULL; @@ -5653,7 +5825,9 @@ DynamicObject* Unit::GetDynObject(uint32 spellId) } if (dynObj->GetSpellId() == spellId) + { return dynObj; + } ++i; } return NULL; @@ -5663,7 +5837,9 @@ GameObject* Unit::GetGameObject(uint32 spellId) const { for (GameObjectList::const_iterator i = m_gameObj.begin(); i != m_gameObj.end(); ++i) if ((*i)->GetSpellId() == spellId) + { return *i; + } WildGameObjectMap::const_iterator find = m_wildGameObjs.find(spellId); if (find != m_wildGameObjs.end()) @@ -5739,7 +5915,9 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del) void Unit::RemoveGameObject(uint32 spellid, bool del) { if (m_gameObj.empty()) + { return; + } GameObjectList::iterator i, next; for (i = m_gameObj.begin(); i != m_gameObj.end(); i = next) @@ -6063,15 +6241,21 @@ bool Unit::IsHostileTo(Unit const* unit) const { // always non-hostile to self if (unit == this) + { return false; + } // always non-hostile to GM in GM mode if (unit->GetTypeId() == TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) + { return false; + } // always hostile to enemy if (getVictim() == unit || unit->getVictim() == this) + { return true; + } // test pet/charm masters instead pers/charmeds Unit const* testerOwner = GetCharmerOrOwner(); @@ -6079,22 +6263,30 @@ bool Unit::IsHostileTo(Unit const* unit) const // always hostile to owner's enemy if (testerOwner && (testerOwner->getVictim() == unit || unit->getVictim() == testerOwner)) + { return true; + } // always hostile to enemy owner if (targetOwner && (getVictim() == targetOwner || targetOwner->getVictim() == this)) + { return true; + } // always hostile to owner of owner's enemy if (testerOwner && targetOwner && (testerOwner->getVictim() == targetOwner || targetOwner->getVictim() == testerOwner)) + { return true; + } Unit const* tester = testerOwner ? testerOwner : this; Unit const* target = targetOwner ? targetOwner : unit; // always non-hostile to target with common owner, or to owner/pet if (tester == target) + { return false; + } // special cases (Duel, etc) if (tester->GetTypeId() == TYPEID_PLAYER && target->GetTypeId() == TYPEID_PLAYER) @@ -6104,24 +6296,34 @@ bool Unit::IsHostileTo(Unit const* unit) const // Duel if (pTester->IsInDuelWith(pTarget)) + { return true; + } // Group if (pTester->GetGroup() && pTester->GetGroup() == pTarget->GetGroup()) + { return false; + } // Sanctuary if (pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY)) + { return false; + } // PvP FFA state if (pTester->IsFFAPvP() && pTarget->IsFFAPvP()) + { return true; + } //= PvP states // Green/Blue (can't attack) if (pTester->GetTeam() == pTarget->GetTeam()) + { return false; + } // Red (can attack) if true, Blue/Yellow (can't attack) in another case return pTester->IsPvP() && pTarget->IsPvP(); @@ -6131,10 +6333,14 @@ bool Unit::IsHostileTo(Unit const* unit) const FactionTemplateEntry const* tester_faction = tester->getFactionTemplateEntry(); FactionTemplateEntry const* target_faction = target->getFactionTemplateEntry(); if (!tester_faction || !target_faction) + { return false; + } if (target->isAttackingPlayer() && tester->IsContestedGuard()) + { return true; + } // PvC forced reaction and reputation case if (tester->GetTypeId() == TYPEID_PLAYER) @@ -6143,12 +6349,16 @@ bool Unit::IsHostileTo(Unit const* unit) const { // forced reaction if (ReputationRank const* force = ((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction)) + { return *force <= REP_HOSTILE; + } // if faction have reputation then hostile 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)) + { return (factionState->Flags & FACTION_FLAG_AT_WAR); + } } } // CvP forced reaction and reputation case @@ -6158,12 +6368,16 @@ bool Unit::IsHostileTo(Unit const* unit) const { // forced reaction if (ReputationRank const* force = ((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) + { return *force <= REP_HOSTILE; + } // apply reputation state FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction); if (raw_tester_faction && raw_tester_faction->reputationListID >= 0) + { return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE; + } } } @@ -6175,15 +6389,21 @@ bool Unit::IsFriendlyTo(Unit const* unit) const { // always friendly to self if (unit == this) + { return true; + } // always friendly to GM in GM mode if (unit->GetTypeId() == TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) + { return true; + } // always non-friendly to enemy if (getVictim() == unit || unit->getVictim() == this) + { return false; + } // test pet/charm masters instead pers/charmeds Unit const* testerOwner = GetCharmerOrOwner(); @@ -6191,22 +6411,30 @@ bool Unit::IsFriendlyTo(Unit const* unit) const // always non-friendly to owner's enemy if (testerOwner && (testerOwner->getVictim() == unit || unit->getVictim() == testerOwner)) + { return false; + } // always non-friendly to enemy owner if (targetOwner && (getVictim() == targetOwner || targetOwner->getVictim() == this)) + { return false; + } // always non-friendly to owner of owner's enemy if (testerOwner && targetOwner && (testerOwner->getVictim() == targetOwner || targetOwner->getVictim() == testerOwner)) + { return false; + } Unit const* tester = testerOwner ? testerOwner : this; Unit const* target = targetOwner ? targetOwner : unit; // always friendly to target with common owner, or to owner/pet if (tester == target) + { return true; + } // special cases (Duel) if (tester->GetTypeId() == TYPEID_PLAYER && target->GetTypeId() == TYPEID_PLAYER) @@ -6216,24 +6444,34 @@ bool Unit::IsFriendlyTo(Unit const* unit) const // Duel if (pTester->IsInDuelWith(pTarget)) + { return false; + } // Group if (pTester->GetGroup() && pTester->GetGroup() == pTarget->GetGroup()) + { return true; + } // Sanctuary if (pTarget->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY) && pTester->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_SANCTUARY)) + { return true; + } // PvP FFA state if (pTester->IsFFAPvP() && pTarget->IsFFAPvP()) + { return false; + } //= PvP states // Green/Blue (non-attackable) if (pTester->GetTeam() == pTarget->GetTeam()) + { return true; + } // Blue (friendly/non-attackable) if not PVP, or Yellow/Red in another case (attackable) return !pTarget->IsPvP(); @@ -6243,10 +6481,14 @@ bool Unit::IsFriendlyTo(Unit const* unit) const FactionTemplateEntry const* tester_faction = tester->getFactionTemplateEntry(); FactionTemplateEntry const* target_faction = target->getFactionTemplateEntry(); if (!tester_faction || !target_faction) + { return false; + } if (target->isAttackingPlayer() && tester->IsContestedGuard()) + { return false; + } // PvC forced reaction and reputation case if (tester->GetTypeId() == TYPEID_PLAYER) @@ -6255,12 +6497,16 @@ bool Unit::IsFriendlyTo(Unit const* unit) const { // forced reaction 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)) + { return !(factionState->Flags & FACTION_FLAG_AT_WAR); + } } } // CvP forced reaction and reputation case @@ -6270,12 +6516,16 @@ bool Unit::IsFriendlyTo(Unit const* unit) const { // forced reaction 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) + { return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY; + } } } @@ -6287,11 +6537,15 @@ bool Unit::IsHostileToPlayers() const { 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) + { return false; + } return my_faction->IsHostileToPlayers(); } @@ -6300,11 +6554,15 @@ bool Unit::IsNeutralToAll() const { 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) + { return false; + } return my_faction->IsNeutralToAll(); } @@ -6312,26 +6570,36 @@ bool Unit::IsNeutralToAll() const bool Unit::Attack(Unit* victim, bool meleeAttack) { if (!victim || victim == this) + { return false; + } // dead units can neither attack nor be attacked if (!IsAlive() || !victim->IsInWorld() || !victim->IsAlive()) + { return false; + } // player cannot attack in mount state if (GetTypeId() == TYPEID_PLAYER && IsMounted()) + { return false; + } // nobody can attack GM in GM-mode if (victim->GetTypeId() == TYPEID_PLAYER) { if (((Player*)victim)->isGameMaster()) + { return false; + } } else { if (((Creature*)victim)->IsInEvadeMode()) + { return false; + } } // remove SPELL_AURA_MOD_UNATTACKABLE at attack (in case non-interruptible spells stun aura applied also that not let attack) @@ -6400,7 +6668,9 @@ void Unit::AttackedBy(Unit* attacker) // do not pet reaction for self inflicted damage (like environmental) if (attacker == this) + { return; + } // trigger pet AI reaction if (Pet* pet = GetPet()) @@ -6410,7 +6680,9 @@ void Unit::AttackedBy(Unit* attacker) bool Unit::AttackStop(bool targetSwitch /*=false*/) { if (!m_attacking) + { return false; + } Unit* victim = m_attacking; @@ -6482,7 +6754,9 @@ struct IsAttackingPlayerHelper bool Unit::isAttackingPlayer() const { if (hasUnitState(UNIT_STAT_ATTACK_PLAYER)) + { return true; + } return CheckAllControlledUnits(IsAttackingPlayerHelper(), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); } @@ -6490,7 +6764,9 @@ bool Unit::isAttackingPlayer() const bool Unit::CanAttackByItself() const { if (!IsVehicle()) + { return true; + } for (uint8 i = 0; i < MAX_VEHICLE_SEAT; ++i) { @@ -6499,7 +6775,9 @@ bool Unit::CanAttackByItself() const if (VehicleSeatEntry const* seatEntry = sVehicleSeatStore.LookupEntry(seatId)) { if (seatEntry->m_flags & SEAT_FLAG_CAN_CONTROL) + { return false; + } } } } @@ -6523,7 +6801,9 @@ void Unit::RemoveAllAttackers() bool Unit::HasAuraStateForCaster(AuraState flag, ObjectGuid casterGuid) const { if (!HasAuraState(flag)) + { return false; + } // single per-caster aura state if (flag == AURA_STATE_CONFLAGRATE) @@ -6594,21 +6874,27 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) Unit* Unit::GetOwner() const { if (ObjectGuid ownerid = GetOwnerGuid()) + { return ObjectAccessor::GetUnit(*this, ownerid); + } return NULL; } Unit* Unit::GetCharmer() const { if (ObjectGuid charmerid = GetCharmerGuid()) + { return ObjectAccessor::GetUnit(*this, charmerid); + } return NULL; } bool Unit::IsCharmerOrOwnerPlayerOrPlayerItself() const { if (GetTypeId() == TYPEID_PLAYER) + { return true; + } return GetCharmerOrOwnerGuid().IsPlayer(); } @@ -6617,7 +6903,9 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() { ObjectGuid guid = GetCharmerOrOwnerGuid(); if (guid.IsPlayer()) + { return ObjectAccessor::FindPlayer(guid); + } return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL; } @@ -6626,7 +6914,9 @@ Player const* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const { ObjectGuid guid = GetCharmerOrOwnerGuid(); if (guid.IsPlayer()) + { return ObjectAccessor::FindPlayer(guid); + } return GetTypeId() == TYPEID_PLAYER ? (Player const*)this : NULL; } @@ -6636,7 +6926,9 @@ Pet* Unit::GetPet() const if (ObjectGuid pet_guid = GetPetGuid()) { if (Pet* pet = GetMap()->GetPet(pet_guid)) + { return pet; + } sLog.outError("Unit::GetPet: %s not exist.", pet_guid.GetString().c_str()); const_cast(this)->SetPet(0); @@ -6661,7 +6953,9 @@ void Unit::RemoveMiniPet() Pet* Unit::GetMiniPet() const { if (!GetCritterGuid()) + { return NULL; + } return GetMap()->GetPet(GetCritterGuid()); } @@ -6671,7 +6965,9 @@ Unit* Unit::GetCharm() const if (ObjectGuid charm_guid = GetCharmGuid()) { if (Unit* pet = ObjectAccessor::GetUnit(*this, charm_guid)) + { return pet; + } sLog.outError("Unit::GetCharm: Charmed %s not exist.", charm_guid.GetString().c_str()); const_cast(this)->SetCharm(NULL); @@ -6739,7 +7035,9 @@ Pet* Unit::FindGuardianWithEntry(uint32 entry) for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) if (Pet* pet = GetMap()->GetPet(*itr)) if (pet->GetEntry() == entry) + { return pet; + } return NULL; } @@ -6749,7 +7047,9 @@ Pet* Unit::GetProtectorPet() for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end(); ++itr) if (Pet* pet = GetMap()->GetPet(*itr)) if (pet->getPetType() == PROTECTOR_PET) + { return pet; + } return NULL; } @@ -6762,7 +7062,9 @@ Unit* Unit::_GetTotem(TotemSlot slot) const Totem* Unit::GetTotem(TotemSlot slot) const { if (slot >= MAX_TOTEM_SLOT || !IsInWorld() || !m_TotemSlot[slot]) + { return NULL; + } Creature* totem = GetMap()->GetCreature(m_TotemSlot[slot]); return totem && totem->IsTotem() ? (Totem*)totem : NULL; @@ -6772,7 +7074,9 @@ bool Unit::IsAllTotemSlotsUsed() const { for (int i = 0; i < MAX_TOTEM_SLOT; ++i) if (!m_TotemSlot[i]) + { return false; + } return true; } @@ -6840,7 +7144,9 @@ int32 Unit::DealHeal(Unit* pVictim, uint32 addhealth, SpellEntry const* spellPro Unit* Unit::SelectMagnetTarget(Unit* victim, Spell* spell, SpellEffectIndex eff) { if (!victim) + { return NULL; + } // Magic case if (spell && (spell->m_spellInfo->GetDmgClass() == SPELL_DAMAGE_CLASS_NONE || spell->m_spellInfo->GetDmgClass() == SPELL_DAMAGE_CLASS_MAGIC)) @@ -6851,7 +7157,9 @@ Unit* Unit::SelectMagnetTarget(Unit* victim, Spell* spell, SpellEffectIndex eff) if (Unit* magnet = (*itr)->GetCaster()) { if (magnet->IsAlive() && magnet->IsWithinLOSInMap(this) && spell->CheckTarget(magnet, eff)) + { return magnet; + } } } } @@ -6866,7 +7174,9 @@ Unit* Unit::SelectMagnetTarget(Unit* victim, Spell* spell, SpellEffectIndex eff) if (magnet->IsAlive() && magnet->IsWithinLOSInMap(this) && (!spell || spell->CheckTarget(magnet, eff))) { if (roll_chance_i((*i)->GetModifier()->m_amount)) + { return magnet; + } } } } @@ -6976,13 +7286,17 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int3 uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { if (!spellProto || !pVictim || damagetype == DIRECT_DAMAGE || spellProto->HasAttribute(SPELL_ATTR_EX6_NO_DMG_MODS)) + { return pdamage; + } // For totems get damage bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE) { if (Unit* owner = GetOwner()) + { return owner->SpellDamageBonusDone(pVictim, spellProto, pdamage, damagetype); + } } uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); @@ -7314,7 +7628,9 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u uint32 Unit::SpellDamageBonusTaken(Unit* pCaster, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { if (!spellProto || !pCaster || damagetype == DIRECT_DAMAGE) + { return pdamage; + } uint32 schoolMask = spellProto->SchoolMask; @@ -7467,14 +7783,18 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM { // not critting spell if (spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_CRIT)) + { return false; + } // Creatures do not crit with their spells or abilities, unless it is owned by a player (pet, totem, etc) if (GetTypeId() != TYPEID_PLAYER) { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return false; + } } float crit_chance = 0.0f; @@ -7606,7 +7926,9 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM else if (spellProto->GetCategory() == 19) { if (pVictim->GetCreatureTypeMask() & CREATURE_TYPEMASK_DEMON_OR_UNDEAD) + { return true; + } } break; case SPELLFAMILY_SHAMAN: @@ -7615,7 +7937,9 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM { // Flame Shock if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_SHAMAN, UI64LIT(0x0000000010000000), 0, GetObjectGuid())) + { return true; + } } break; } @@ -7641,7 +7965,9 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM crit_chance = crit_chance > 0.0f ? crit_chance : 0.0f; if (roll_chance_f(crit_chance)) + { return true; + } return false; } @@ -7669,7 +7995,9 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const* spellProto, uint32 damag modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); if (!pVictim) + { return damage += crit_bonus; + } int32 critPctDamageMod = 0; if(spellProto->GetDmgClass() >= SPELL_DAMAGE_CLASS_MELEE) @@ -7713,11 +8041,15 @@ uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, // For totems get healing bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE) if (Unit* owner = GetOwner()) + { return owner->SpellHealingBonusDone(pVictim, spellProto, healamount, damagetype, stack); + } // No heal amount for this class spells if (spellProto->GetDmgClass() == SPELL_DAMAGE_CLASS_NONE) + { return healamount < 0 ? 0 : healamount; + } // Healing Done // Done total percent damage auras @@ -7965,13 +8297,17 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; for (SpellImmuneList::const_iterator itr = schoolList.begin(); itr != schoolList.end(); ++itr) 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) + { return true; + } return false; } @@ -7979,7 +8315,9 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) bool Unit::IsImmuneToSpell(SpellEntry const* spellInfo, bool castOnSelf) { if (!spellInfo) + { return false; + } // TODO add spellEffect immunity checks!, player with flag in bg is immune to immunity buffs from other friendly players! // SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_EFFECT]; @@ -7987,7 +8325,9 @@ bool Unit::IsImmuneToSpell(SpellEntry const* spellInfo, bool castOnSelf) SpellImmuneList const& dispelList = m_spellImmune[IMMUNITY_DISPEL]; for (SpellImmuneList::const_iterator itr = dispelList.begin(); itr != dispelList.end(); ++itr) if (itr->type == spellInfo->GetDispel()) + { return true; + } if (!spellInfo->HasAttribute(SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE) && // unaffected by school immunity !spellInfo->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) // can remove immune (by dispell or immune it) @@ -8004,12 +8344,16 @@ bool Unit::IsImmuneToSpell(SpellEntry const* spellInfo, bool castOnSelf) SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) if (itr->type == mechanic) + { return true; + } AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic - 1))) + { return true; + } } return false; @@ -8020,25 +8364,33 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i // If m_immuneToEffect type contain this effect type, IMMUNE effect. SpellEffectEntry const* spellEffect = spellInfo->GetSpellEffect(index); if(!spellEffect) + { return false; + } uint32 effect = spellEffect->Effect; SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT]; for (SpellImmuneList::const_iterator itr = effectList.begin(); itr != effectList.end(); ++itr) if (itr->type == effect) + { return true; + } if(uint32 mechanic = spellEffect->EffectMechanic) { SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC]; for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr) if (itr->type == mechanic) + { return true; + } AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic - 1))) + { return true; + } } if(uint32 aura = spellEffect->EffectApplyAuraName) @@ -8046,7 +8398,9 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i SpellImmuneList const& list = m_spellImmune[IMMUNITY_STATE]; for (SpellImmuneList::const_iterator itr = list.begin(); itr != list.end(); ++itr) if (itr->type == aura) + { return true; + } // Check for immune to application of harmful magical effects AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL); @@ -8058,7 +8412,9 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i SpellSchoolMask schoolMask = GetSpellSchoolMask(spellInfo); for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) if ((*iter)->GetModifier()->m_miscvalue & schoolMask) + { return true; + } } } return false; @@ -8071,7 +8427,9 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage, WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) { if (!pVictim || pdamage == 0 || (spellProto && spellProto->HasAttribute(SPELL_ATTR_EX6_NO_DMG_MODS))) + { return pdamage; + } // differentiate for weapon damage based spells bool isWeaponDamageBasedSpell = !(spellProto && (damagetype == DOT || IsSpellHaveEffect(spellProto, SPELL_EFFECT_SCHOOL_DAMAGE))); @@ -8339,10 +8697,14 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage, WeaponAttackTyp uint32 Unit::MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage, WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) { if (!pCaster) + { return pdamage; + } if (pdamage == 0) + { return pdamage; + } // differentiate for weapon damage based spells bool isWeaponDamageBasedSpell = !(spellProto && (damagetype == DOT || IsSpellHaveEffect(spellProto, SPELL_EFFECT_SCHOOL_DAMAGE))); @@ -8476,9 +8838,13 @@ float Unit::GetWeaponProcChance() const // normalized proc chance for weapon attack speed // (odd formula...) 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); + } return 0.0f; } @@ -8487,14 +8853,18 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM) const { // proc per minute chance calculation if (PPM <= 0.0f) + { return 0.0f; + } return WeaponSpeed * PPM / 600.0f; // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) } void Unit::Mount(uint32 mount, uint32 spellId) { if (!mount) + { return; + } RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNTING); @@ -8533,7 +8903,9 @@ void Unit::Mount(uint32 mount, uint32 spellId) void Unit::Unmount(bool from_aura) { if (!IsMounted()) + { return; + } RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_MOUNTED); @@ -8621,11 +8993,15 @@ bool Unit::IsNearWaypoint(float currentPositionX, float currentPositionY, float MountCapabilityEntry const* Unit::GetMountCapability(uint32 mountType) const { if (!mountType) + { return NULL; + } MountTypeEntry const* mountTypeEntry = sMountTypeStore.LookupEntry(mountType); if (!mountTypeEntry) + { return NULL; + } uint32 zoneId, areaId; GetZoneAndAreaId(zoneId, areaId); @@ -8817,18 +9193,26 @@ void Unit::ClearInCombat() bool Unit::IsTargetableForAttack(bool inverseAlive /*=false*/) const { if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isGameMaster()) + { return false; + } if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) + { return false; + } // to be removed if unit by any reason enter combat if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE)) + { return false; + } // inversealive is needed for some spells which need to be casted at dead targets (aoe) if (IsAlive() == inverseAlive) + { return false; + } return IsInWorld() && !hasUnitState(UNIT_STAT_DIED) && !IsTaxiFlying(); } @@ -8838,7 +9222,9 @@ int32 Unit::ModifyHealth(int32 dVal) int32 gain = 0; if (dVal == 0) + { return 0; + } int32 curHealth = (int32)GetHealth(); @@ -8870,7 +9256,9 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) int32 gain = 0; if (dVal == 0) + { return 0; + } int32 curPower = (int32)GetPower(power); @@ -8900,11 +9288,15 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, bool detect, bool inVisibleList, bool is3dDistance) const { if (!u || !IsInMap(u)) + { return false; + } // Always can see self if (u == this) + { return true; + } // player visible for other player if not logout and at same transport // including case when player is out of world @@ -8916,11 +9308,15 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo // not in world if (!at_same_transport && (!IsInWorld() || !u->IsInWorld())) + { return false; + } // forbidden to seen (while Removing corpse) if (m_Visibility == VISIBILITY_REMOVE_CORPSE) + { return false; + } Map& _map = *u->GetMap(); // Grid dead/alive checks @@ -8928,7 +9324,9 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo { // non visible at grid for any stealth state if (!IsVisibleInGridForPlayer((Player*)u)) + { return false; + } // if player is dead then he can't detect anyone in any cases if (!u->IsAlive()) @@ -8938,7 +9336,9 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo { // all dead creatures/players not visible for any creatures if (!u->IsAlive() || !IsAlive()) + { return false; + } } // different visible distance checks @@ -8946,47 +9346,65 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo { // use object grey distance for all (only see objects any way) if (!IsWithinDistInMap(viewPoint, World::GetMaxVisibleDistanceInFlight() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) + { return false; + } } else if (!at_same_transport) // distance for show player/pet/creature (no transport case) { // Any units far than max visible distance for viewer or not in our map are not visible too if (!IsWithinDistInMap(viewPoint, _map.GetVisibilityDistance() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f), is3dDistance)) + { return false; + } } // always seen by owner if (GetCharmerOrOwnerGuid() == u->GetObjectGuid()) + { return true; + } // isInvisibleForAlive() those units can only be seen by dead or if other // unit is also invisible for alive.. if an isinvisibleforalive unit dies we // should be able to see it too if (u->IsAlive() && IsAlive() && isInvisibleForAlive() != u->isInvisibleForAlive()) if (u->GetTypeId() != TYPEID_PLAYER || !((Player*)u)->isGameMaster()) + { return false; + } // Visible units, always are visible for all units, except for units under invisibility and phases if (m_Visibility == VISIBILITY_ON && u->m_invisibilityMask == 0) + { return true; + } // GMs see any players, not higher GMs and all units in any phase if (u->GetTypeId() == TYPEID_PLAYER && ((Player*)u)->isGameMaster()) { if (GetTypeId() == TYPEID_PLAYER) + { return ((Player*)this)->GetSession()->GetSecurity() <= ((Player*)u)->GetSession()->GetSecurity(); + } else + { return true; + } } // non faction visibility non-breakable for non-GMs if (m_Visibility == VISIBILITY_OFF) + { return false; + } // grouped players should always see stealthed party members if (GetTypeId() == TYPEID_PLAYER && u->GetTypeId() == TYPEID_PLAYER) if (((Player*)this)->IsGroupVisibleFor(((Player*)u)) && u->IsFriendlyTo(this)) + { return true; + } // raw invisibility bool invisible = (m_invisibilityMask != 0 || u->m_invisibilityMask != 0); @@ -9022,21 +9440,29 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo AuraList const& auras = GetAurasByType(SPELL_AURA_MOD_STALKED); for (AuraList::const_iterator iter = auras.begin(); iter != auras.end(); ++iter) if ((*iter)->GetCasterGuid() == u->GetObjectGuid()) + { return true; + } } // none other cases for detect invisibility, so invisible if (invisible) + { return false; + } } // unit got in stealth in this moment and must ignore old detected state if (m_Visibility == VISIBILITY_GROUP_NO_DETECT) + { return false; + } // GM invisibility checks early, invisibility if any detectable, so if not stealth then visible if (m_Visibility != VISIBILITY_GROUP_STEALTH) + { return true; + } // NOW ONLY STEALTH CASE @@ -9044,21 +9470,29 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo // mobs always detect players (detect == true)... return 'false' for those mobs which have (detect == false) // players detect players only in Player::HandleStealthedUnitsDetection() if (!detect) + { return (u->GetTypeId() == TYPEID_PLAYER) ? ((Player*)u)->HaveAtClient(this) : false; + } // Special cases // If is attacked then stealth is lost, some creature can use stealth too if (!getAttackers().empty()) + { return true; + } // If there is collision rogue is seen regardless of level difference if (IsWithinDist(u, 0.24f)) + { return true; + } // If a mob or player is stunned he will not be able to detect stealth if (u->hasUnitState(UNIT_STAT_STUNNED) && (u != this)) + { return false; + } // set max ditance float visibleDistance = (u->GetTypeId() == TYPEID_PLAYER) ? MAX_PLAYER_STEALTH_DETECT_RANGE : ((Creature const*)u)->GetAttackDistance(this); @@ -9066,7 +9500,9 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo // Always invisible from back (when stealth detection is on), also filter max distance cases bool isInFront = viewPoint->IsInFrontInMap(this, visibleDistance); if (!isInFront) + { return false; + } // if doesn't have stealth detection (Shadow Sight), then check how stealthy the unit is, otherwise just check los if (!u->HasAuraType(SPELL_AURA_DETECT_STEALTH)) @@ -9092,7 +9528,9 @@ bool Unit::IsVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo // recheck new distance if (visibleDistance <= 0 || !IsWithinDist(viewPoint, visibleDistance)) + { return false; + } } // Now check is target visible with LoS @@ -9168,7 +9606,9 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const detectLevel = ((Player*)this)->GetDrunkValue(); if (invLevel <= detectLevel) + { return true; + } } } @@ -9611,25 +10051,35 @@ bool Unit::CanHaveThreatList(bool ignoreAliveState/*=false*/) const { // only creatures can have threat list if (GetTypeId() != TYPEID_UNIT) + { return false; + } // only alive units can have threat list if (!IsAlive() && !ignoreAliveState) + { return false; + } Creature const* creature = ((Creature const*)this); // totems can not have threat list if (creature->IsTotem()) + { return false; + } // pets can not have a threat list, unless they are controlled by a creature if (creature->IsPet() && creature->GetOwnerGuid().IsPlayer()) + { return false; + } // charmed units can not have a threat list if charmed by player if (creature->GetCharmerGuid().IsPlayer()) + { return false; + } return true; } @@ -9639,10 +10089,14 @@ bool Unit::CanHaveThreatList(bool ignoreAliveState/*=false*/) const float Unit::ApplyTotalThreatModifier(float threat, SpellSchoolMask schoolMask) { if (!HasAuraType(SPELL_AURA_MOD_THREAT)) + { return threat; + } if (schoolMask == SPELL_SCHOOL_MASK_NONE) + { return threat; + } SpellSchools school = GetFirstSchoolInMask(schoolMask); @@ -9675,15 +10129,21 @@ void Unit::TauntApply(Unit* taunter) MANGOS_ASSERT(GetTypeId() == TYPEID_UNIT); if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) + { return; + } if (!CanHaveThreatList()) + { return; + } Unit* target = getVictim(); if (target && target == taunter) + { return; + } // Only attack taunter if this is a valid target if (!hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_DIED) && !IsSecondChoiceTarget(taunter, true)) @@ -9705,15 +10165,21 @@ void Unit::TauntFadeOut(Unit* taunter) MANGOS_ASSERT(GetTypeId() == TYPEID_UNIT); if (!taunter || (taunter->GetTypeId() == TYPEID_PLAYER && ((Player*)taunter)->isGameMaster())) + { return; + } if (!CanHaveThreatList()) + { return; + } Unit* target = getVictim(); if (!target || target != taunter) + { return; + } if (m_ThreatManager.isThreatListEmpty()) { @@ -9780,11 +10246,15 @@ bool Unit::SelectHostileTarget() MANGOS_ASSERT(GetTypeId() == TYPEID_UNIT); if (!this->IsAlive()) + { return false; + } // This function only useful once AI has been initialized if (!((Creature*)this)->AI()) + { return false; + } Unit* target = NULL; Unit* oldTarget = getVictim(); @@ -9865,7 +10335,9 @@ bool Unit::SelectHostileTarget() // no target but something prevent go to evade mode if (!IsInCombat() || HasAuraType(SPELL_AURA_MOD_TAUNT)) + { return false; + } // last case when creature don't must go to evade mode: // it in combat but attacker not make any damage and not enter to aggro radius to have record in threat list @@ -9876,7 +10348,9 @@ bool Unit::SelectHostileTarget() for (AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) { if ((*itr)->IsInMap(this) && (*itr)->IsTargetableForAttack() && (*itr)->isInAccessablePlaceFor((Creature*)this)) + { return false; + } } } @@ -9901,13 +10375,17 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt { SpellEffectEntry const* spellEffect = spellProto->GetSpellEffect(effect_index); if(!spellEffect) + { return 0; + } switch (spellEffect->EffectApplyAuraName) { case SPELL_AURA_MOUNTED: if (MountCapabilityEntry const* mountCapability = GetMountCapability(uint32(spellEffect->EffectMiscValueB))) + { return int32(mountCapability->Id); + } break; default: break; @@ -9920,7 +10398,9 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt if (unitPlayer && spellProto->HasAttribute(SPELL_ATTR_EX8_MASTERY) && !spellProto->CalculateSimpleValue(effect_index)) { if (int32 masteryCoef = GetMasteryCoefficient(spellProto)) + { return int32(GetFloatValue(PLAYER_MASTERY) * masteryCoef / 100.0f); + } } // calculate basepoints for armor specialization spells @@ -9928,7 +10408,9 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt { // check spells not valid for current talent tree or insufficient equipped items if (!unitPlayer->FitArmorSpecializationRules(spellProto)) + { return 0; + } } uint8 comboPoints = unitPlayer ? unitPlayer->GetComboPoints() : 0; @@ -10037,7 +10519,9 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMask, int32 duration, Unit const* caster, Spell const* spell /*=NULL*/) { if (duration <= 0) + { return duration; + } int32 mechanicMod = 0; uint32 mechanicMask = GetSpellMechanicMask(spellProto, effectMask); @@ -10123,10 +10607,14 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) continue; if (!i->hitCount) + { return DIMINISHING_LEVEL_1; + } if (!i->hitTime) + { return DIMINISHING_LEVEL_1; + } // If last spell was casted more than 15 seconds ago - reset the count. if (i->stack == 0 && WorldTimer::getMSTimeDiff(i->hitTime, WorldTimer::getMSTime()) > 15 * IN_MILLISECONDS) @@ -10160,7 +10648,9 @@ void Unit::IncrDiminishing(DiminishingGroup group) void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, Unit* caster, DiminishingLevels Level, int32 limitduration, bool isReflected) { if (duration == -1 || group == DIMINISHING_NONE || (!isReflected && caster->IsFriendlyTo(this))) + { return; + } // Duration of crowd control abilities on pvp target is limited by 10 sec. (2.2.0) if (limitduration > 0 && duration > limitduration) @@ -10225,7 +10715,9 @@ bool Unit::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bo bool Unit::isInvisibleForAlive() const { if (m_AuraFlags & UNIT_AURAFLAG_ALIVE_INVISIBLE) + { return true; + } // TODO: maybe spiritservices also have just an aura return IsSpiritService(); } @@ -10236,12 +10728,18 @@ uint32 Unit::GetCreatureType() const { SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm()); if (ssEntry && ssEntry->creatureType > 0) + { return ssEntry->creatureType; + } else + { return CREATURE_TYPE_HUMANOID; + } } else + { return ((Creature*)this)->GetCreatureInfo()->CreatureType; + } } /*####################################### @@ -10280,7 +10778,9 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f } if (!CanModifyStats()) + { return false; + } switch (unitMod) { @@ -10330,7 +10830,9 @@ float Unit::GetModifierValue(UnitMods unitMod, UnitModifierType modifierType) co } if (modifierType == TOTAL_PCT && m_auraModifiersGroup[unitMod][modifierType] <= 0.0f) + { return 0.0f; + } return m_auraModifiersGroup[unitMod][modifierType]; } @@ -10340,7 +10842,9 @@ float Unit::GetTotalStatValue(Stats stat) const UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + stat); if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + { return 0.0f; + } // value = ((base_value * base_pct) + total_value) * total_pct float value = m_auraModifiersGroup[unitMod][BASE_VALUE] + GetCreateStat(stat); @@ -10360,7 +10864,9 @@ float Unit::GetTotalAuraModValue(UnitMods unitMod) const } if (m_auraModifiersGroup[unitMod][TOTAL_PCT] <= 0.0f) + { return 0.0f; + } float value = m_auraModifiersGroup[unitMod][BASE_VALUE]; value *= m_auraModifiersGroup[unitMod][BASE_PCT]; @@ -10429,14 +10935,18 @@ float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const { int32 ap = GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MOD_POS); if (ap < 0) + { return 0.0f; + } return ap * (1.0f + GetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER)); } else { int32 ap = GetInt32Value(UNIT_FIELD_ATTACK_POWER) + GetInt32Value(UNIT_FIELD_ATTACK_POWER_MOD_POS); if (ap < 0) + { return 0.0f; + } return ap * (1.0f + GetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER)); } } @@ -10444,7 +10954,9 @@ float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const float Unit::GetWeaponDamageRange(WeaponAttackType attType , WeaponDamageRange type) const { if (attType == OFF_ATTACK && !haveOffhandWeapon()) + { return 0.0f; + } return m_weaponDamage[attType][type]; } @@ -10535,11 +11047,15 @@ Powers Unit::GetPowerTypeByIndex(uint32 index, uint32 classId) uint32 Unit::GetPower(Powers power) const { if (power == POWER_HEALTH) + { return GetHealth(); + } uint32 powerIndex = GetPowerIndex(power); if (powerIndex == INVALID_POWER_INDEX) + { return 0; + } return GetUInt32Value(UNIT_FIELD_POWER1 + powerIndex); } @@ -10554,11 +11070,15 @@ uint32 Unit::GetPowerByIndex(uint32 index) const uint32 Unit::GetMaxPower(Powers power) const { if (power == POWER_HEALTH) + { return GetMaxHealth(); + } uint32 powerIndex = GetPowerIndex(power); if (powerIndex == INVALID_POWER_INDEX) + { return 0; + } return GetUInt32Value(UNIT_FIELD_MAXPOWER1 + powerIndex); } @@ -10573,11 +11093,15 @@ uint32 Unit::GetMaxPowerByIndex(uint32 index) const void Unit::SetPower(Powers power, int32 val) { if (power == POWER_HEALTH) + { return SetHealth(val >= 0 ? val : 0); + } uint32 powerIndex = GetPowerIndex(power); if (powerIndex == INVALID_POWER_INDEX) + { return; + } return SetPowerByIndex(powerIndex, val); } @@ -10592,7 +11116,9 @@ void Unit::SetPowerByIndex(uint32 powerIndex, int32 val) val = 0; if (GetPowerByIndex(powerIndex) == val) + { return; + } MANGOS_ASSERT(powerIndex < MAX_STORED_POWERS); SetInt32Value(UNIT_FIELD_POWER1 + powerIndex, val); @@ -10636,11 +11162,15 @@ void Unit::SetPowerByIndex(uint32 powerIndex, int32 val) void Unit::SetMaxPower(Powers power, int32 val) { if (power == POWER_HEALTH) + { return SetMaxHealth(val >= 0 ? val : 0); + } uint32 powerIndex = GetPowerIndex(power); if (powerIndex == INVALID_POWER_INDEX) + { return; + } return SetMaxPowerByIndex(powerIndex, val); } @@ -10734,7 +11264,9 @@ uint32 Unit::GetCreatePowers(Powers power) const case POWER_RAGE: return POWER_RAGE_DEFAULT; case POWER_FOCUS: if(GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_HUNTER) + { return POWER_FOCUS_DEFAULT; + } return (GetTypeId() == TYPEID_PLAYER || !((Creature const*)this)->IsPet() || ((Pet const*)this)->getPetType() != HUNTER_PET ? 0 : POWER_FOCUS_DEFAULT); case POWER_ENERGY: return POWER_ENERGY_DEFAULT; case POWER_RUNE: return GetTypeId() == TYPEID_PLAYER && ((Player const*)this)->getClass() == CLASS_DEATH_KNIGHT ? POWER_RUNE_DEFAULT : 0; @@ -10845,7 +11377,9 @@ void CharmInfo::InitVehicleCreateSpells() InitEmptyActionBar(); if (m_unit->GetTypeId() == TYPEID_PLAYER) // player vehicles don't have spells, keep the action bar empty + { return; + } for (uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) { @@ -10861,7 +11395,9 @@ void CharmInfo::InitPossessCreateSpells() InitEmptyActionBar(); // charm action bar if (m_unit->GetTypeId() == TYPEID_PLAYER) // possessed players don't have spells, keep the action bar empty + { return; + } SetActionBar(ACTION_BAR_INDEX_START, COMMAND_ATTACK, ACT_COMMAND); @@ -10977,7 +11513,9 @@ bool CharmInfo::RemoveSpellFromActionBar(uint32 spell_id) void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply) { if (IsPassiveSpell(spellid)) + { return; + } for (uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x) if (spellid == m_charmspells[x].GetAction()) @@ -11284,12 +11822,16 @@ SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const Player* Unit::GetSpellModOwner() const { if (GetTypeId() == TYPEID_PLAYER) + { return (Player*)this; + } if (((Creature*)this)->IsPet() || ((Creature*)this)->IsTotem()) { Unit* owner = GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER) + { return (Player*)owner; + } } return NULL; } @@ -11299,7 +11841,9 @@ void Unit::SendPetActionFeedback(uint8 msg) { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return; + } WorldPacket data(SMSG_PET_ACTION_FEEDBACK, 1); data << uint8(msg); @@ -11310,7 +11854,9 @@ void Unit::SendPetTalk(uint32 pettalk) { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return; + } WorldPacket data(SMSG_PET_ACTION_SOUND, 8 + 4); data << GetObjectGuid(); @@ -11322,7 +11868,9 @@ void Unit::SendPetAIReaction() { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return; + } WorldPacket data(SMSG_AI_REACTION, 8 + 4); data << GetObjectGuid(); @@ -11335,13 +11883,17 @@ void Unit::SendPetAIReaction() void Unit::StopMoving(bool forceSendStop /*=false*/) { if (IsStopped() && !forceSendStop) + { return; + } clearUnitState(UNIT_STAT_MOVING); // not need send any packets if not in world if (!IsInWorld()) + { return; + } Movement::MoveSplineInit init(*this); init.Stop(); @@ -11367,7 +11919,9 @@ void Unit::SetFeared(bool apply, ObjectGuid casterGuid, uint32 spellID, uint32 t if (apply) { if (HasAuraType(SPELL_AURA_PREVENTS_FLEEING)) + { return; + } SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FLEEING); @@ -11539,7 +12093,9 @@ void Unit::SetDisplayId(uint32 modelId) { Pet* pet = ((Pet*)this); if (!pet->isControlled()) + { return; + } Unit* owner = GetOwner(); if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && ((Player*)owner)->GetGroup()) ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID); @@ -11654,7 +12210,9 @@ Unit* Unit::SelectRandomUnfriendlyTarget(Unit* except /*= NULL*/, float radius / // no appropriate targets if (targets.empty()) + { return NULL; + } // select random uint32 rIdx = urand(0, targets.size() - 1); @@ -11693,7 +12251,9 @@ Unit* Unit::SelectRandomFriendlyTarget(Unit* except /*= NULL*/, float radius /*= // no appropriate targets if (targets.empty()) + { return NULL; + } // select random uint32 rIdx = urand(0, targets.size() - 1); @@ -11709,7 +12269,9 @@ bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag) for (SpellAuraHolderMap::const_iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end(); ++iter) { if (!iter->second->IsPositive() && iter->second->GetSpellProto()->GetAuraInterruptFlags() & flag) + { return true; + } } return false; } @@ -11765,7 +12327,9 @@ void Unit::UpdateAuraForGroup(uint8 slot) float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) { if (!normalized || GetTypeId() != TYPEID_PLAYER) + { return float(GetAttackTime(attType)) / 1000.0f; + } Item* Weapon = ((Player*)this)->GetWeaponForAttack(attType, true, false); if (!Weapon) @@ -11792,7 +12356,9 @@ Aura* Unit::GetDummyAura(uint32 spell_id) const Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) if ((*itr)->GetId() == spell_id) + { return *itr; + } return NULL; } @@ -11802,7 +12368,9 @@ void Unit::SetContestedPvP(Player* attackedPlayer) Player* player = GetCharmerOrOwnerPlayerOrPlayerItself(); if (!player || (attackedPlayer && (attackedPlayer == player || player->IsInDuelWith(attackedPlayer)))) + { return; + } player->SetContestedPvPTimer(30000); @@ -11872,7 +12440,9 @@ struct SetPhaseMaskHelper void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) { if (newPhaseMask == GetPhaseMask()) + { return; + } // first move to both phase for proper update controlled units WorldObject::SetPhaseMask(GetPhaseMask() | newPhaseMask, false); @@ -12008,13 +12578,17 @@ void Unit::KnockBackWithAngle(float angle, float horizontalSpeed, float vertical float Unit::GetCombatRatingReduction(CombatRating cr) const { if (GetTypeId() == TYPEID_PLAYER) + { return ((Player const*)this)->GetRatingBonusValue(cr); + } else if (((Creature const*)this)->IsPet()) { // Player's pet get 100% resilience from owner if (Unit* owner = GetOwner()) if (owner->GetTypeId() == TYPEID_PLAYER) + { return ((Player*)owner)->GetRatingBonusValue(cr); + } } return 0.0f; @@ -12131,10 +12705,14 @@ bool Unit::IsIgnoreUnitState(SpellEntry const* spell, IgnoreUnitState ignoreStat { // frozen state absent ignored for all spells if (ignoreState == IGNORE_UNIT_TARGET_NON_FROZEN) + { return true; + } if ((*itr)->isAffectedOnSpell(spell)) + { return true; + } } } @@ -12158,7 +12736,9 @@ bool Unit::CheckAndIncreaseCastCounter() uint32 maxCasts = sWorld.getConfig(CONFIG_UINT32_MAX_SPELL_CASTS_IN_CHAIN); if (maxCasts && m_castCounter >= maxCasts) + { return false; + } ++m_castCounter; return true; @@ -12175,7 +12755,9 @@ SpellAuraHolder* Unit::GetSpellAuraHolder(uint32 spellid, ObjectGuid casterGuid) SpellAuraHolderConstBounds bounds = GetSpellAuraHolderBounds(spellid); for (SpellAuraHolderMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) if (iter->second->GetCasterGuid() == casterGuid) + { return iter->second; + } return NULL; } @@ -12184,30 +12766,42 @@ bool Unit::IsAllowedDamageInArea(Unit* pVictim) const { // can damage self anywhere if (pVictim == this) + { return true; + } // can damage own pet anywhere if (pVictim->GetOwnerGuid() == GetObjectGuid()) + { return true; + } // non player controlled unit can damage anywhere Player const* pOwner = GetCharmerOrOwnerPlayerOrPlayerItself(); if (!pOwner) + { return true; + } // can damage non player controlled victim anywhere Player const* vOwner = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself(); if (!vOwner) + { return true; + } // can damage opponent in duel if (pOwner->IsInDuelWith(vOwner)) + { return true; + } // can't damage player controlled unit by player controlled unit in sanctuary AreaTableEntry const* area = GetAreaEntryByAreaID(pVictim->GetAreaId()); if (area && area->flags & AREA_FLAG_SANCTUARY) + { return false; + } return true; } @@ -12310,7 +12904,9 @@ void Unit::UpdateSplineMovement(uint32 t_diff) }; if (movespline->Finalized()) + { return; + } movespline->updateState(t_diff); bool arrived = movespline->Finalized(); @@ -12349,7 +12945,9 @@ bool Unit::IsInWorgenForm(bool inPermanent) const AuraList const& vTransformAuras = GetAurasByType(SPELL_AURA_WORGEN_TRANSFORM); for (AuraList::const_iterator itr = vTransformAuras.begin(); itr != vTransformAuras.end(); ++itr) if (!inPermanent || (*itr)->GetHolder()->IsPermanent()) + { return true; + } return false; } diff --git a/src/game/Object/Unit.h b/src/game/Object/Unit.h index b289d8cc4..fced3a1bc 100644 --- a/src/game/Object/Unit.h +++ b/src/game/Object/Unit.h @@ -1385,7 +1385,9 @@ class Unit : public WorldObject bool CanUseEquippedWeapon(WeaponAttackType attackType) const { if (IsInFeralForm()) + { return false; + } switch (attackType) { @@ -1456,10 +1458,14 @@ class Unit : public WorldObject Unit* getAttackerForHelper() // If someone wants to help, who to give them { if (getVictim() != NULL) + { return getVictim(); + } if (!m_attackers.empty()) + { return *(m_attackers.begin()); + } return NULL; } @@ -1900,7 +1906,9 @@ class Unit : public WorldObject bool IsContestedGuard() const { if (FactionTemplateEntry const* entry = getFactionTemplateEntry()) + { return entry->IsContestedGuardFaction(); + } return false; } @@ -3296,7 +3304,9 @@ class Unit : public WorldObject { VisibleAuraMap::const_iterator itr = m_visibleAuras.find(slot); if (itr != m_visibleAuras.end()) + { return itr->second; + } return NULL; } void SetVisibleAura(uint8 slot, SpellAuraHolder* holder) diff --git a/src/game/Object/Vehicle.cpp b/src/game/Object/Vehicle.cpp index eb864e407..ddba45f6b 100644 --- a/src/game/Object/Vehicle.cpp +++ b/src/game/Object/Vehicle.cpp @@ -189,12 +189,16 @@ void VehicleInfo::Board(Unit* passenger, uint8 seat) // This check is also called in Spell::CheckCast() if (!CanBoard(passenger)) + { return; + } // Use the planned seat only if the seat is valid, possible to choose and empty if (!IsSeatAvailableFor(passenger, seat)) if (!GetUsableSeatFor(passenger, seat)) + { return; + } VehicleSeatEntry const* seatEntry = GetSeatEntry(seat); MANGOS_ASSERT(seatEntry); @@ -259,25 +263,33 @@ void VehicleInfo::SwitchSeat(Unit* passenger, uint8 seat) // Switching seats is not possible if (m_vehicleEntry->m_flags & VEHICLE_FLAG_DISABLE_SWITCH) + { return; + } PassengerMap::const_iterator itr = m_passengers.find(passenger); MANGOS_ASSERT(itr != m_passengers.end()); // We are already boarded to this seat if (itr->second->GetTransportSeat() == seat) + { return; + } // Check if it's a valid seat if (!IsSeatAvailableFor(passenger, seat)) + { return; + } VehicleSeatEntry const* seatEntry = GetSeatEntry(itr->second->GetTransportSeat()); MANGOS_ASSERT(seatEntry); // Switching seats is only allowed if this flag is set if (~seatEntry->m_flags & SEAT_FLAG_CAN_SWITCH) + { return; + } // Remove passenger modifications of the old seat RemoveSeatMods(passenger, seatEntry->m_flags); @@ -379,31 +391,45 @@ void VehicleInfo::UnBoard(Unit* passenger, bool changeVehicle) bool VehicleInfo::CanBoard(Unit* passenger) const { if (!passenger) + { return false; + } // Passenger is this vehicle if (passenger == m_owner) + { return false; + } // Passenger is already on this vehicle (in this case switching seats is required) if (passenger->IsBoarded() && passenger->GetTransportInfo()->GetTransport() == m_owner) + { return false; + } // Prevent circular boarding: passenger (could only be vehicle) must not have m_owner on board if (passenger->IsVehicle() && passenger->GetVehicleInfo()->HasOnBoard(m_owner)) + { return false; + } // Check if we have at least one empty seat if (!GetEmptySeats()) + { return false; + } // Passenger is already boarded if (m_passengers.find(passenger) != m_passengers.end()) + { return false; + } // Check for empty player seats if (passenger->GetTypeId() == TYPEID_PLAYER) + { return GetEmptySeatsMask() & m_playerSeats; + } // Check for empty creature seats return GetEmptySeatsMask() & m_creatureSeats; @@ -413,7 +439,9 @@ Unit* VehicleInfo::GetPassenger(uint8 seat) const { for (PassengerMap::const_iterator itr = m_passengers.begin(); itr != m_passengers.end(); ++itr) if (itr->second->GetTransportSeat() == seat) + { return (Unit*)itr->first; + } return NULL; } @@ -468,14 +496,18 @@ bool VehicleInfo::GetUsableSeatFor(Unit* passenger, uint8& seat) const // No usable seats available if (!possibleSeats) + { return false; + } // Start with 0 seat = 0; for (uint8 i = 1; seat < MAX_VEHICLE_SEAT; i <<= 1, ++seat) if (possibleSeats & i) + { return true; + } return false; } diff --git a/src/game/OutdoorPvP/OutdoorPvP.cpp b/src/game/OutdoorPvP/OutdoorPvP.cpp index 509904fa5..affae5e39 100644 --- a/src/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvP.cpp @@ -164,7 +164,9 @@ void OutdoorPvP::BuffTeam(Team team, uint32 spellId, bool remove /*= false*/) player->RemoveAurasDueToSpell(spellId); } else - { player->CastSpell(player, spellId, true); } + { + player->CastSpell(player, spellId, true); + } } } } @@ -208,6 +210,8 @@ void OutdoorPvP::RespawnGO(const WorldObject* objRef, ObjectGuid goGuid, bool re go->Refresh(); } else if (go->isSpawned()) - { go->SetLootState(GO_JUST_DEACTIVATED); } + { + go->SetLootState(GO_JUST_DEACTIVATED); + } } } diff --git a/src/game/OutdoorPvP/OutdoorPvPEP.cpp b/src/game/OutdoorPvP/OutdoorPvPEP.cpp index 4379317f0..ebbb50f50 100644 --- a/src/game/OutdoorPvP/OutdoorPvPEP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPEP.cpp @@ -142,11 +142,17 @@ void OutdoorPvPEP::HandleGameObjectCreate(GameObject* go) InitBanner(go, TOWER_ID_NORTHPASS); } else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_CROWNGUARD][0], plaguelandsTowerLocations[TOWER_ID_CROWNGUARD][1], 50.0f)) - { InitBanner(go, TOWER_ID_CROWNGUARD); } + { + InitBanner(go, TOWER_ID_CROWNGUARD); + } else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_EASTWALL][0], plaguelandsTowerLocations[TOWER_ID_EASTWALL][1], 50.0f)) - { InitBanner(go, TOWER_ID_EASTWALL); } + { + InitBanner(go, TOWER_ID_EASTWALL); + } else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_PLAGUEWOOD][0], plaguelandsTowerLocations[TOWER_ID_PLAGUEWOOD][1], 50.0f)) - { InitBanner(go, TOWER_ID_PLAGUEWOOD); } + { + InitBanner(go, TOWER_ID_PLAGUEWOOD); + } break; case GO_LORDAERON_SHRINE_ALLIANCE: m_lordaeronShrineAlliance = go->GetObjectGuid(); diff --git a/src/game/OutdoorPvP/OutdoorPvPGH.cpp b/src/game/OutdoorPvP/OutdoorPvPGH.cpp index 01128962b..c65c8e034 100644 --- a/src/game/OutdoorPvP/OutdoorPvPGH.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPGH.cpp @@ -34,7 +34,9 @@ void OutdoorPvPGH::HandleCreatureCreate(Creature* creature) { // only handle summoned creatures if (!creature->IsTemporarySummon()) + { return; + } switch (creature->GetEntry()) { @@ -80,7 +82,9 @@ bool OutdoorPvPGH::HandleEvent(uint32 eventId, GameObject* go) { // If we are not using the lighthouse return if (go->GetEntry() != GO_VENTURE_BAY_LIGHTHOUSE) + { return false; + } bool eventHandled = true; @@ -89,7 +93,9 @@ bool OutdoorPvPGH::HandleEvent(uint32 eventId, GameObject* go) case EVENT_LIGHTHOUSE_WIN_ALLIANCE: // Ignore the event if the zone is already in alliance control if (m_zoneOwner == ALLIANCE) + { return true; + } // Spawn the npcs only when the tower is fully controlled. Also allow the event to handle summons in DB. m_zoneOwner = ALLIANCE; @@ -100,7 +106,9 @@ bool OutdoorPvPGH::HandleEvent(uint32 eventId, GameObject* go) case EVENT_LIGHTHOUSE_WIN_HORDE: // Ignore the event if the zone is already in horde control if (m_zoneOwner == HORDE) + { return true; + } // Spawn the npcs only when the tower is fully controlled. Also allow the event to handle summons in DB. m_zoneOwner = HORDE; diff --git a/src/game/OutdoorPvP/OutdoorPvPNA.cpp b/src/game/OutdoorPvP/OutdoorPvPNA.cpp index af0b3fdb6..9ccb93609 100644 --- a/src/game/OutdoorPvP/OutdoorPvPNA.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPNA.cpp @@ -138,7 +138,9 @@ void OutdoorPvPNA::HandleCreatureCreate(Creature* creature) case NPC_ALLIANCE_HANAANI_GUARD: // prevent updating guard counter on owner take over if (m_guardsLeft == MAX_NA_GUARDS) + { return; + } if (m_guardsLeft == 0) { @@ -159,7 +161,9 @@ void OutdoorPvPNA::HandleCreatureCreate(Creature* creature) void OutdoorPvPNA::HandleCreatureDeath(Creature* creature) { if (creature->GetEntry() != NPC_HORDE_HALAANI_GUARD && creature->GetEntry() != NPC_ALLIANCE_HANAANI_GUARD) + { return; + } // get the location of the dead guard for future respawn float x, y, z, o; @@ -303,7 +307,9 @@ bool OutdoorPvPNA::HandleEvent(uint32 eventId, GameObject* go) { // If we are not using the Halaa banner return if (go->GetEntry() != GO_HALAA_BANNER) + { return false; + } bool eventHandled = true; diff --git a/src/game/OutdoorPvP/OutdoorPvPZM.cpp b/src/game/OutdoorPvP/OutdoorPvPZM.cpp index 577a09f30..2b52415e1 100644 --- a/src/game/OutdoorPvP/OutdoorPvPZM.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPZM.cpp @@ -307,11 +307,15 @@ bool OutdoorPvPZM::HandleGameObjectUse(Player* player, GameObject* go) break; case GO_ZANGA_BANNER_CENTER_ALLIANCE: if (team == ALLIANCE || !player->HasAura(SPELL_BATTLE_STANDARD_HORDE)) + { return false; + } break; case GO_ZANGA_BANNER_CENTER_HORDE: if (team == HORDE || !player->HasAura(SPELL_BATTLE_STANDARD_ALLIANCE)) + { return false; + } break; default: return false; diff --git a/src/game/References/ThreatManager.cpp b/src/game/References/ThreatManager.cpp index 35c35b747..8487ef487 100644 --- a/src/game/References/ThreatManager.cpp +++ b/src/game/References/ThreatManager.cpp @@ -172,7 +172,9 @@ void HostileReference::updateOnlineStatus() { online = true; } // not accessable but stays online } else - { accessible = true; } + { + accessible = true; + } } setAccessibleState(accessible); setOnlineOfflineState(online); @@ -283,7 +285,9 @@ void ThreatContainer::modifyThreatPercent(Unit* pVictim, int32 pPercent) delete ref; } else - { ref->addThreatPercent(pPercent); } + { + ref->addThreatPercent(pPercent); + } } } @@ -527,7 +531,9 @@ Unit* ThreatManager::getHostileTarget() float ThreatManager::getThreat(Unit* pVictim, bool pAlsoSearchOfflineList) { if (!pVictim) + { return 0.0f; + } float threat = 0.0f; @@ -574,7 +580,9 @@ void ThreatManager::setCurrentVictim(HostileReference* pHostileReference) { // including NULL==NULL case if (pHostileReference == iCurrentVictim) + { return; + } if (pHostileReference) iOwner->SendHighestThreatUpdate(pHostileReference); @@ -637,7 +645,9 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat iUpdateNeed = true; } else - { iThreatOfflineContainer.remove(hostileReference); } + { + iThreatOfflineContainer.remove(hostileReference); + } break; } } @@ -645,7 +655,9 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat void ThreatManager::UpdateForClient(uint32 diff) { if (!iUpdateNeed || isThreatListEmpty()) + { return; + } iUpdateTimer.Update(diff); if (iUpdateTimer.Passed()) diff --git a/src/game/Server/DBCStores.cpp b/src/game/Server/DBCStores.cpp index c487a8105..5a8769444 100644 --- a/src/game/Server/DBCStores.cpp +++ b/src/game/Server/DBCStores.cpp @@ -290,7 +290,9 @@ static bool ReadDBCBuildFileText(const std::string& dbc_path, char const* locale return true; } else + { return false; + } } int ReadDBCLocale(const std::string sDataPath) @@ -329,19 +331,25 @@ static uint32 ReadDBCBuild(const std::string& dbc_path, LocaleNameStr const*&loc ReadDBCBuildFileText(dbc_path, localeNameStr->name, text); if (text.empty()) + { return 0; + } size_t pos = text.find("version=\""); size_t pos1 = pos + strlen("version=\""); size_t pos2 = text.find("\"", pos1); if (pos == text.npos || pos2 == text.npos || pos1 >= pos2) + { return 0; + } std::string build_str = text.substr(pos1, pos2 - pos1); int build = atoi(build_str.c_str()); if (build <= 0) + { return 0; + } return build; } @@ -906,17 +914,23 @@ SimpleFactionsList const* GetFactionTeamList(uint32 faction) { FactionTeamMap::const_iterator itr = sFactionTeamMap.find(faction); if (itr == sFactionTeamMap.end()) + { return NULL; + } return &itr->second; } char const* GetPetName(uint32 petfamily, uint32 dbclang) { if (!petfamily) + { return NULL; + } CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(petfamily); if (!pet_family) + { return NULL; + } return pet_family->Name[dbclang] ? pet_family->Name[dbclang] : NULL; } @@ -924,7 +938,9 @@ TalentSpellPos const* GetTalentSpellPos(uint32 spellId) { TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId); if (itr == sTalentSpellPosMap.end()) + { return NULL; + } return &itr->second; } @@ -933,7 +949,9 @@ SpellEffectEntry const* GetSpellEffectEntry(uint32 spellId, SpellEffectIndex eff { SpellEffectMap::const_iterator itr = sSpellEffectMap.find(spellId); if(itr == sSpellEffectMap.end()) + { return NULL; + } return itr->second.effects[effect]; } @@ -941,7 +959,9 @@ SpellEffectEntry const* GetSpellEffectEntry(uint32 spellId, SpellEffectIndex eff uint32 GetTalentSpellCost(TalentSpellPos const* pos) { if (pos) + { return pos->rank + 1; + } return 0; } @@ -955,7 +975,9 @@ int32 GetAreaFlagByAreaID(uint32 area_id) { AreaFlagByAreaID::iterator i = sAreaFlagByAreaID.find(area_id); if (i == sAreaFlagByAreaID.end()) + { return -1; + } return i->second; } @@ -964,7 +986,9 @@ WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid { WMOAreaInfoByTripple::iterator i = sWMOAreaInfoByTripple.find(WMOAreaTableTripple(rootid, adtid, groupid)); if (i == sWMOAreaInfoByTripple.end()) + { return NULL; + } return i->second; } @@ -972,7 +996,9 @@ AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id) { int32 areaflag = GetAreaFlagByAreaID(area_id); if (areaflag < 0) + { return NULL; + } return sAreaStore.LookupEntry(areaflag); } @@ -980,10 +1006,14 @@ AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id) AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id) { if (area_flag) + { return sAreaStore.LookupEntry(area_flag); + } if (MapEntry const* mapEntry = sMapStore.LookupEntry(map_id)) + { return GetAreaEntryByAreaID(mapEntry->linked_zone); + } return NULL; } @@ -992,18 +1022,26 @@ uint32 GetAreaFlagByMapId(uint32 mapid) { AreaFlagByMapID::iterator i = sAreaFlagByMapID.find(mapid); if (i == sAreaFlagByMapID.end()) + { return 0; + } else + { return i->second; + } } uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId) { if (mapid != 530 && mapid != 571 && mapid != 732) // speed for most cases + { return mapid; + } if (WorldMapAreaEntry const* wma = sWorldMapAreaStore.LookupEntry(zoneId)) + { return wma->virtual_map_id >= 0 ? wma->virtual_map_id : wma->map_id; + } return mapid; } @@ -1012,11 +1050,15 @@ ContentLevels GetContentLevelsForMap(uint32 mapid) { MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry) + { return CONTENT_1_60; + } // exceptions for 648 - Goblin Starter area and 654 - Worgen Starter area if (mapid == 648 || mapid == 654) + { return CONTENT_1_60; + } switch (mapEntry->Expansion()) { @@ -1034,7 +1076,9 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id) { ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(i); if (ch && ch->ChannelID == channel_id) + { return ch; + } } return NULL; } @@ -1042,19 +1086,29 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id) bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId) { if (requiredTotemCategoryId == 0) + { return true; + } if (itemTotemCategoryId == 0) + { return false; + } TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId); if (!itemEntry) + { return false; + } TotemCategoryEntry const* reqEntry = sTotemCategoryStore.LookupEntry(requiredTotemCategoryId); if (!reqEntry) + { return false; + } if (itemEntry->categoryType != reqEntry->categoryType) + { return false; + } return (itemEntry->categoryMask & reqEntry->categoryMask) == reqEntry->categoryMask; } @@ -1065,7 +1119,9 @@ bool Zone2MapCoordinates(float& x, float& y, uint32 zone) // if not listed then map coordinates (instance) if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1) + { return false; + } std::swap(x, y); // at client map coords swapped x = x * ((maEntry->x2 - maEntry->x1) / 100) + maEntry->x1; @@ -1080,7 +1136,9 @@ bool Map2ZoneCoordinates(float& x, float& y, uint32 zone) // if not listed then map coordinates (instance) if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1) + { return false; + } x = (x - maEntry->x1) / ((maEntry->x2 - maEntry->x1) / 100); y = (y - maEntry->y1) / ((maEntry->y2 - maEntry->y1) / 100); // client y coord from top to down @@ -1093,7 +1151,9 @@ ContentLevels GetContentLevelsForMapAndZone(uint32 mapId, uint32 zoneId) { MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry) + { return CONTENT_1_60; + } if (mapEntry->rootPhaseMap != -1) mapId = mapEntry->rootPhaseMap; @@ -1146,7 +1206,9 @@ PvPDifficultyEntry const* GetBattlegroundBracketByLevel(uint32 mapid, uint32 lev // exactly fit if (entry->maxLevel >= level) + { return entry; + } // remember for possible out-of-range case (search higher from existed) if (!maxEntry || maxEntry->maxLevel < entry->maxLevel) @@ -1162,7 +1224,9 @@ PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattleGroundB for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i) if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i)) if (entry->mapId == mapid && entry->GetBracketId() == id) + { return entry; + } return NULL; } @@ -1176,7 +1240,9 @@ std::vector const* GetTalentTreeMasterySpells(uint32 talentTree) { TalentTreeSpellsMap::const_iterator itr = sTalentTreeMasterySpellsMap.find(talentTree); if (itr == sTalentTreeMasterySpellsMap.end()) + { return NULL; + } return &itr->second; } @@ -1185,7 +1251,9 @@ std::vector const* GetTalentTreePrimarySpells(uint32 talentTree) { TalentTreeSpellsMap::const_iterator itr = sTalentTreePrimarySpellsMap.find(talentTree); if (itr == sTalentTreePrimarySpellsMap.end()) + { return NULL; + } return &itr->second; } @@ -1194,7 +1262,9 @@ uint32 GetTalentTreeRolesMask(uint32 talentTree) { TalentTreeRolesMap::const_iterator itr = sTalentTreeRolesMap.find(talentTree); if (itr == sTalentTreeRolesMap.end()) + { return 0; + } return itr->second; } @@ -1202,14 +1272,18 @@ uint32 GetTalentTreeRolesMask(uint32 talentTree) bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, float x, float y, float z, float delta) { if (mapid != atEntry->mapid) + { return false; + } if (atEntry->radius > 0) { // if we have radius check it float dist2 = (x - atEntry->x) * (x - atEntry->x) + (y - atEntry->y) * (y - atEntry->y) + (z - atEntry->z) * (z - atEntry->z); if (dist2 > (atEntry->radius + delta) * (atEntry->radius + delta)) + { return false; + } } else { @@ -1248,7 +1322,9 @@ uint32 GetCreatureModelRace(uint32 model_id) { CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(model_id); if (!displayEntry) + { return 0; + } CreatureDisplayInfoExtraEntry const* extraEntry = sCreatureDisplayInfoExtraStore.LookupEntry(displayEntry->ExtendedDisplayInfoID); return extraEntry ? extraEntry->Race : 0; } diff --git a/src/game/Server/DBCStructure.h b/src/game/Server/DBCStructure.h index a46115f53..30fcc78a2 100644 --- a/src/game/Server/DBCStructure.h +++ b/src/game/Server/DBCStructure.h @@ -518,7 +518,9 @@ struct AchievementCriteriaEntry bool IsExplicitlyStartedTimedCriteria() const { if (!timeLimit) + { return false; + } // in case raw.value == timedCriteriaMiscId in timedCriteriaMiscId stored spellid/itemids for cast/use, so repeating aura start at first cast/use until fails return requiredType == ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST || raw.value != timedCriteriaMiscId; @@ -984,10 +986,14 @@ struct FactionTemplateEntry { for (int i = 0; i < 4; ++i) if (enemyFaction[i] == entry.faction) + { return false; + } for (int i = 0; i < 4; ++i) if (friendFaction[i] == entry.faction) + { return true; + } } return (friendlyMask & entry.ourMask) || (ourMask & entry.friendlyMask); } @@ -997,10 +1003,14 @@ struct FactionTemplateEntry { for (int i = 0; i < 4; ++i) if (enemyFaction[i] == entry.faction) + { return true; + } for (int i = 0; i < 4; ++i) if (friendFaction[i] == entry.faction) + { return false; + } } return (hostileMask & entry.ourMask) != 0; } @@ -1009,7 +1019,9 @@ struct FactionTemplateEntry { for (int i = 0; i < 4; ++i) if (enemyFaction[i] != 0) + { return false; + } return hostileMask == 0 && friendlyMask == 0; } bool IsContestedGuardFaction() const { return (factionFlags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) != 0; } @@ -1622,7 +1634,9 @@ struct ScalingStatValuesEntry uint32 getSpellBonus(uint32 mask) const { if (mask & 0x00008000) + { return spellBonus; + } return 0; } }; @@ -1879,7 +1893,9 @@ struct SpellEffectEntry uint32 GetRadiusIndex() const { if (EffectRadiusIndex != 0) + { return EffectRadiusIndex; + } return EffectRadiusMaxIndex; } diff --git a/src/game/Server/WorldSession.cpp b/src/game/Server/WorldSession.cpp index 42c252beb..db800be02 100644 --- a/src/game/Server/WorldSession.cpp +++ b/src/game/Server/WorldSession.cpp @@ -282,7 +282,9 @@ bool WorldSession::Update(PacketFilter& updater) } } else if (_player->IsInWorld()) - { ExecuteOpcode(opHandle, packet); } + { + ExecuteOpcode(opHandle, packet); + } // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer @@ -306,9 +308,13 @@ bool WorldSession::Update(PacketFilter& updater) LogUnexpectedOpcode(packet, "the player has not logged in yet"); } else if (_player->IsInWorld()) - { LogUnexpectedOpcode(packet, "the player is still in world"); } + { + LogUnexpectedOpcode(packet, "the player is still in world"); + } else - { ExecuteOpcode(opHandle, packet); } + { + ExecuteOpcode(opHandle, packet); + } break; case STATUS_AUTHED: // prevent cheating with skip queue wait @@ -471,7 +477,9 @@ void WorldSession::LogoutPlayer(bool Save) } } else if ((*itr)->GetTypeId() == TYPEID_PLAYER) - { aset.insert((Player*)(*itr)); } + { + aset.insert((Player*)(*itr)); + } } _player->SetPvPDeath(!aset.empty()); @@ -758,7 +766,9 @@ void WorldSession::SendSetPhaseShift(uint32 phaseMask, uint16 mapId) void WorldSession::SendSetPhaseShift(std::set const& phaseIds, std::set const& terrainswaps) { if (PlayerLoading()) + { return; + } ObjectGuid guid = _player->GetObjectGuid(); @@ -863,7 +873,9 @@ void WorldSession::LoadAccountData(QueryResult* result, uint32 mask) m_accountData[i] = AccountData(); if (!result) + { return; + } do { @@ -915,7 +927,9 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, const std: { // _player can be NULL and packet received after logout but m_GUID still store correct guid if (!m_GUIDLow) + { return; + } static SqlStatementID delId; static SqlStatementID insId; @@ -1038,12 +1052,16 @@ void WorldSession::SaveTutorialsData() void WorldSession::ReadAddonsInfo(ByteBuffer &data) { if (data.rpos() + 4 > data.size()) + { return; + } uint32 size; data >> size; if (!size) + { return; + } if (size > 0xFFFFF) { @@ -1071,7 +1089,9 @@ void WorldSession::ReadAddonsInfo(ByteBuffer &data) // check next addon data format correctness if (addonInfo.rpos() + 1 > addonInfo.size()) + { return; + } addonInfo >> addonName; @@ -1182,7 +1202,9 @@ void WorldSession::ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* pac { #ifdef ENABLE_ELUNA if (!sEluna->OnPacketReceive(this, *packet)) + { return; + } #endif /* ENABLE_ELUNA */ // need prevent do internal far teleports in handlers because some handlers do lot steps diff --git a/src/game/Server/WorldSocket.cpp b/src/game/Server/WorldSocket.cpp index 07d89b2db..20fe9614d 100644 --- a/src/game/Server/WorldSocket.cpp +++ b/src/game/Server/WorldSocket.cpp @@ -272,7 +272,9 @@ int WorldSocket::open(void* a) data << ServerToClient; if (SendPacket(data) == -1) + { return -1; + } // Send startup packet. WorldPacket packet (SMSG_AUTH_CHALLENGE, 37); @@ -368,7 +370,9 @@ int WorldSocket::handle_output(ACE_HANDLE) const size_t send_len = m_OutBuffer->length(); if (send_len == 0) + { return handle_output_queue(Guard); + } #ifdef MSG_NOSIGNAL ssize_t n = peer().send(m_OutBuffer->rd_ptr(), send_len, MSG_NOSIGNAL); @@ -411,7 +415,9 @@ int WorldSocket::handle_output(ACE_HANDLE) int WorldSocket::handle_output_queue(GuardType& g) { if (msg_queue()->is_empty()) + { return cancel_wakeup_output(g); + } ACE_Message_Block* mblk; @@ -746,7 +752,9 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) #ifdef ENABLE_ELUNA if (!sEluna->OnPacketReceive(m_Session, *new_pct)) + { return 0; + } #endif /* ENABLE_ELUNA */ return HandleAuthSession(*new_pct); case CMSG_KEEP_ALIVE: @@ -795,7 +803,9 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) return -1; } else - { return 0; } + { + return 0; + } } ACE_NOTREACHED(return 0); @@ -1101,7 +1111,9 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket) } } else - { m_OverSpeedPings = 0; } + { + m_OverSpeedPings = 0; + } } // critical section diff --git a/src/game/Server/WorldSocketMgr.cpp b/src/game/Server/WorldSocketMgr.cpp index d68863aea..2131144a8 100644 --- a/src/game/Server/WorldSocketMgr.cpp +++ b/src/game/Server/WorldSocketMgr.cpp @@ -82,7 +82,9 @@ int WorldSocketMgr::svc() sockets_->erase(t); } else - { ++i; } + { + ++i; + } } } @@ -127,7 +129,9 @@ int WorldSocketMgr::StartNetwork(ACE_INET_Addr& addr) } if (activate(THR_NEW_LWP | THR_JOINABLE, num_threads) == -1) - return -1; + { + return -1; + } sLog.outString("Max allowed socket connections: %d", ACE::max_handles()); return 0; diff --git a/src/game/Tools/CharacterDatabaseCleaner.cpp b/src/game/Tools/CharacterDatabaseCleaner.cpp index e1d38e101..370a5a3fb 100644 --- a/src/game/Tools/CharacterDatabaseCleaner.cpp +++ b/src/game/Tools/CharacterDatabaseCleaner.cpp @@ -92,7 +92,9 @@ void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table found = true; } else - { ss << ","; } + { + ss << ","; + } ss << id; } } @@ -140,7 +142,9 @@ bool CharacterDatabaseCleaner::TalentCheck(uint32 talent_id) { TalentEntry const* talentInfo = sTalentStore.LookupEntry(talent_id); if (!talentInfo) + { return false; + } return sTalentTabStore.LookupEntry(talentInfo->TalentTab); } diff --git a/src/game/Tools/PlayerDump.cpp b/src/game/Tools/PlayerDump.cpp index b8952d3c3..b1d260a8e 100644 --- a/src/game/Tools/PlayerDump.cpp +++ b/src/game/Tools/PlayerDump.cpp @@ -161,7 +161,9 @@ bool changenth(std::string& str, int n, const char* with, bool insert = false, b str.replace(s, e - s, with); } else - { str.insert(s, with); } + { + str.insert(s, with); + } return true; } @@ -191,7 +193,9 @@ bool changetoknth(std::string& str, int n, const char* with, bool insert = false str.replace(s, e - s, with); } else - { str.insert(s, with); } + { + str.insert(s, with); + } return true; } @@ -359,7 +363,9 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); } else // not set case, get single guid string - { wherestr = GenerateWhereStr(fieldname, guid); } + { + wherestr = GenerateWhereStr(fieldname, guid); + } QueryResult* result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str()); if (!result) @@ -421,12 +427,16 @@ std::string PlayerDumpWriter::GetDump(uint32 guid) dump += "UPDATE character_db_version SET " + reqName + " = 1 WHERE FALSE;\n\n"; } else - { sLog.outError("Table 'character_db_version' not have revision guard field, revision guard query not added to pdump."); } + { + sLog.outError("Table 'character_db_version' not have revision guard field, revision guard query not added to pdump."); + } delete result; } else - { sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump."); } + { + sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump."); + } for (DumpTable* itr = &dumpTables[0]; itr->isValid(); ++itr) { DumpTableContent(dump, guid, itr->name, itr->name, itr->type); } @@ -491,7 +501,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s } } else - { guid = sObjectMgr.m_CharGuids.GetNextAfterMaxUsed(); } + { + guid = sObjectMgr.m_CharGuids.GetNextAfterMaxUsed(); + } // normalize the name if specified and check if it exists if (!normalizePlayerName(name)) diff --git a/src/game/Warden/Warden.cpp b/src/game/Warden/Warden.cpp index 967ae935b..d02f1dae1 100644 --- a/src/game/Warden/Warden.cpp +++ b/src/game/Warden/Warden.cpp @@ -245,7 +245,9 @@ std::string Warden::Penalty(WardenCheck* check /*= NULL*/) void WorldSession::HandleWardenDataOpcode(WorldPacket& recvData) { if (!_warden || recvData.empty()) + { return; + } _warden->DecryptData(const_cast(recvData.contents()), recvData.size()); uint8 opcode; @@ -290,10 +292,14 @@ void Warden::HandleData(ByteBuffer& /*buff*/) void Warden::LogPositiveToDB(WardenCheck* check) { if (!check || !_session) + { return; + } if (uint32(check->Action) < sWorld.getConfig(CONFIG_UINT32_WARDEN_DB_LOGLEVEL)) + { return; + } static SqlStatementID insWardenPositive; diff --git a/src/game/Warden/WardenCheckMgr.cpp b/src/game/Warden/WardenCheckMgr.cpp index 84030156c..12bcdc050 100644 --- a/src/game/Warden/WardenCheckMgr.cpp +++ b/src/game/Warden/WardenCheckMgr.cpp @@ -287,7 +287,9 @@ WardenCheck* WardenCheckMgr::GetWardenDataById(uint16 build, uint16 Id) { MultiCheckContainer::const_iterator it = MCheckStore.find(ComposeMultiCheckKey(build, Id)); if (it != MCheckStore.end()) + { return it->second; + } } return CheckStore[Id]; } @@ -301,12 +303,16 @@ WardenCheckResult* WardenCheckMgr::GetWardenResultById(uint16 build, uint16 Id) { MultiResultContainer::const_iterator it = MCheckResultStore.find(ComposeMultiCheckKey(build, Id)); if (it != MCheckResultStore.end()) + { return it->second; + } } CheckResultContainer::const_iterator itr = CheckResultStore.find(Id); if (itr != CheckResultStore.end()) + { return itr->second; + } return NULL; } diff --git a/src/game/WorldHandlers/AccountMgr.cpp b/src/game/WorldHandlers/AccountMgr.cpp index f03362aa3..db2c51a2d 100644 --- a/src/game/WorldHandlers/AccountMgr.cpp +++ b/src/game/WorldHandlers/AccountMgr.cpp @@ -230,7 +230,9 @@ uint32 AccountMgr::GetCharactersCount(uint32 acc_id) return charcount; } else - { return 0; } + { + return 0; + } } bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) diff --git a/src/game/WorldHandlers/AchievementMgr.cpp b/src/game/WorldHandlers/AchievementMgr.cpp index 8f0794f3c..e5bd33cc3 100644 --- a/src/game/WorldHandlers/AchievementMgr.cpp +++ b/src/game/WorldHandlers/AchievementMgr.cpp @@ -277,23 +277,35 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE: if (!target || target->GetTypeId() != TYPEID_UNIT) + { return false; + } return target->GetEntry() == creature.id; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE: if (!target || target->GetTypeId() != TYPEID_PLAYER) + { return false; + } if (classRace.class_id && classRace.class_id != ((Player*)target)->getClass()) + { return false; + } if (classRace.race_id && classRace.race_id != ((Player*)target)->getRace()) + { return false; + } return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH: if (!target || target->GetTypeId() != TYPEID_PLAYER) + { return false; + } return target->GetHealth() * 100 <= health.percent * target->GetMaxHealth(); case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD: if (!target || target->GetTypeId() != TYPEID_PLAYER || target->IsAlive() || ((Player*)target)->GetDeathTimer() == 0) + { return false; + } // flag set == must be same team, not set == different team return (((Player*)target)->GetTeam() == source->GetTeam()) == (player_dead.own_team_flag != 0); case ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA: @@ -310,11 +322,15 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou return miscvalue1 >= value.minvalue; case ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL: if (!target) + { return false; + } return target->getLevel() >= level.minlevel; case ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER: if (!target) + { return false; + } return target->getGender() == gender.gender; case ACHIEVEMENT_CRITERIA_REQUIRE_DISABLED: return false; // always fail @@ -324,7 +340,9 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount; case ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM: if (!target || target->GetTypeId() != TYPEID_PLAYER) + { return false; + } return ((Player*)target)->GetTeam() == Team(team.team); case ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK: return (uint32)Player::GetDrunkenstateByValue(source->GetDrunkValue()) >= drunk.state; @@ -334,13 +352,17 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou { BattleGround* bg = source->GetBattleGround(); if (!bg) + { return false; + } return bg->IsTeamScoreInRange(source->GetTeam() == ALLIANCE ? HORDE : ALLIANCE, bg_loss_team_score.min_score, bg_loss_team_score.max_score); } case ACHIEVEMENT_CRITERIA_REQUIRE_INSTANCE_SCRIPT: { if (!source->IsInWorld()) + { return false; + } InstanceData* data = source->GetInstanceData(); if (!data) { @@ -354,7 +376,9 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou { Item* item = source->GetItemByPos(INVENTORY_SLOT_BAG_0, miscvalue1); if (!item) + { return false; + } ItemPrototype const* proto = item->GetProto(); return proto->ItemLevel >= equipped_item.item_level && proto->Quality >= equipped_item.item_quality; } @@ -375,7 +399,9 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou case ACHIEVEMENT_CRITERIA_REQUIRE_KNOWN_TITLE: { if (CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(known_title.title_id)) + { return source && source->HasTitle(titleInfo->bit_index); + } return false; } @@ -387,7 +413,9 @@ bool AchievementCriteriaRequirementSet::Meets(Player const* source, Unit const* { for (Storage::const_iterator itr = storage.begin(); itr != storage.end(); ++itr) if (!itr->Meets(criteria_id, source, target, miscvalue)) + { return false; + } return true; } @@ -430,7 +458,9 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin DETAIL_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::ResetAchievementCriteria(%u, %u, %u)", type, miscvalue1, miscvalue2); if (!sWorld.getConfig(CONFIG_BOOL_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER) + { return; + } AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr.GetAchievementCriteriaByType(type); for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i != achievementCriteriaList.end(); ++i) @@ -614,7 +644,9 @@ void AchievementMgr::LoadFromDB(QueryResult* achievementResult, QueryResult* cri void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) { if (GetPlayer()->GetSession()->PlayerLoading()) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::SendAchievementEarned(%u)", achievement->ID); @@ -705,7 +737,9 @@ void AchievementMgr::StartTimedAchievementCriteria(AchievementCriteriaTypes type DETAIL_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::StartTimedAchievementCriteria(%u, %u)", type, timedRequirementId); if (!sWorld.getConfig(CONFIG_BOOL_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER) + { return; + } AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr.GetAchievementCriteriaByType(type); for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i != achievementCriteriaList.end(); ++i) @@ -766,7 +800,9 @@ void AchievementMgr::StartTimedAchievementCriteria(AchievementCriteriaTypes type void AchievementMgr::DoFailedTimedAchievementCriterias() { if (m_criteriaFailTimes.empty()) + { return; + } time_t now = time(NULL); for (AchievementCriteriaFailTimeMap::iterator iter = m_criteriaFailTimes.begin(); iter != m_criteriaFailTimes.end();) @@ -812,7 +848,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui DETAIL_FILTER_LOG(LOG_FILTER_ACHIEVEMENT_UPDATES, "AchievementMgr::UpdateAchievementCriteria(%u, %u, %u, %u)", type, miscvalue1, miscvalue2, time); if (!sWorld.getConfig(CONFIG_BOOL_GM_ALLOW_ACHIEVEMENT_GAINS) && m_player->GetSession()->GetSecurity() > SEC_PLAYER) + { return; + } AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr.GetAchievementCriteriaByType(type); for (AchievementCriteriaEntryList::const_iterator itr = achievementCriteriaList.begin(); itr != achievementCriteriaList.end(); ++itr) @@ -1043,7 +1081,9 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case ACHIEVEMENT_CRITERIA_TYPE_CURRENCY_EARNED: { if (!miscvalue1 || !miscvalue2 || miscvalue1 != achievementCriteria->currencyEarned.currencyId) + { return; + } change = miscvalue2; progressType = PROGRESS_ACCUMULATE; @@ -1905,18 +1945,24 @@ bool AchievementMgr::IsCompletedCriteria(AchievementCriteriaEntry const* achieve { // counter can never complete if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER) + { return false; + } if (achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_REACH | ACHIEVEMENT_FLAG_REALM_FIRST_KILL)) { // someone on this realm has already completed that achievement if (sAchievementMgr.IsRealmCompleted(achievement)) + { return false; + } } CriteriaProgressMap::const_iterator itr = m_criteriaProgress.find(achievementCriteria->ID); if (itr == m_criteriaProgress.end()) + { return false; + } CriteriaProgress const* progress = &itr->second; @@ -1929,11 +1975,15 @@ void AchievementMgr::CompletedCriteriaFor(AchievementEntry const* achievement) { // counter can never complete if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER) + { return; + } // already completed and stored if (m_completedAchievements.find(achievement->ID) != m_completedAchievements.end()) + { return; + } if (IsCompletedAchievement(achievement)) CompletedAchievement(achievement); @@ -1943,7 +1993,9 @@ bool AchievementMgr::IsCompletedAchievement(AchievementEntry const* entry) { // counter can never complete if (entry->flags & ACHIEVEMENT_FLAG_COUNTER) + { return false; + } // for achievement with referenced achievement criterias get from referenced and counter from self uint32 achievementForTestId = entry->refAchievement ? entry->refAchievement : entry->ID; @@ -1951,7 +2003,9 @@ bool AchievementMgr::IsCompletedAchievement(AchievementEntry const* entry) AchievementCriteriaEntryList const* cList = sAchievementMgr.GetAchievementCriteriaByAchievement(achievementForTestId); if (!cList) + { return false; + } uint32 count = 0; // For SUMM achievements, we have to count the progress of each criteria of the achievement. @@ -1971,7 +2025,9 @@ bool AchievementMgr::IsCompletedAchievement(AchievementEntry const* entry) // for counters, field4 contains the main count requirement if (count >= criteria->raw.count) + { return true; + } } return false; } @@ -1992,12 +2048,16 @@ bool AchievementMgr::IsCompletedAchievement(AchievementEntry const* entry) // completed as have req. count of completed criterias if (achievementForTestCount > 0 && achievementForTestCount <= count) + { return true; + } } // all criterias completed requirement if (completed_all && achievementForTestCount == 0) + { return true; + } return false; } @@ -2021,11 +2081,15 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* criteri { // not create record for 0 counter if (changeValue == 0) + { return; + } // not start manually started timed achievements if (criteria->IsExplicitlyStartedTimedCriteria()) + { return; + } progress = &m_criteriaProgress[criteria->ID]; @@ -2065,7 +2129,9 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* criteri // not update (not mark as changed) if counter will have same value if (progress->counter == newValue) + { return; + } } progress->counter = newValue; @@ -2121,7 +2187,9 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) { DETAIL_LOG("AchievementMgr::CompletedAchievement(%u)", achievement->ID); if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || m_completedAchievements.find(achievement->ID) != m_completedAchievements.end()) + { return; + } SendAchievementEarned(achievement); CompletedAchievementData& ca = m_completedAchievements[achievement->ID]; @@ -2140,7 +2208,9 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) // no rewards if (!reward) + { return; + } // titles if (uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 1 : 0]) @@ -2189,11 +2259,15 @@ void AchievementMgr::IncompletedAchievement(AchievementEntry const* achievement) { DETAIL_LOG("AchievementMgr::IncompletedAchievement(%u)", achievement->ID); if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER) + { return; + } CompletedAchievementMap::iterator itr = m_completedAchievements.find(achievement->ID); if (itr == m_completedAchievements.end()) + { return; + } WorldPacket data(SMSG_ACHIEVEMENT_DELETED, 4); data << uint32(achievement->ID); @@ -2210,7 +2284,9 @@ void AchievementMgr::IncompletedAchievement(AchievementEntry const* achievement) // no rewards if (!reward) + { return; + } // titles if (uint32 titleId = reward->titleId[GetPlayer()->GetTeam() == HORDE ? 0 : 1]) @@ -2394,7 +2470,9 @@ AchievementReward const* AchievementGlobalMgr::GetAchievementReward(AchievementE AchievementRewardsMapBounds bounds = m_achievementRewards.equal_range(achievement->ID); for (AchievementRewardsMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) if (iter->second.gender == GENDER_NONE || uint8(iter->second.gender) == gender) + { return &iter->second; + } return NULL; } @@ -2404,7 +2482,9 @@ AchievementRewardLocale const* AchievementGlobalMgr::GetAchievementRewardLocale( AchievementRewardLocalesMapBounds bounds = m_achievementRewardLocales.equal_range(achievement->ID); for (AchievementRewardLocalesMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) if (iter->second.gender == GENDER_NONE || uint8(iter->second.gender) == gender) + { return &iter->second; + } return NULL; } diff --git a/src/game/WorldHandlers/ArenaTeamHandler.cpp b/src/game/WorldHandlers/ArenaTeamHandler.cpp index 42ec29606..2cbd17f02 100644 --- a/src/game/WorldHandlers/ArenaTeamHandler.cpp +++ b/src/game/WorldHandlers/ArenaTeamHandler.cpp @@ -41,13 +41,19 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket& recv_data) Player* player = sObjectMgr.GetPlayer(guid); if (!player) + { return; + } if (!_player->IsWithinDistInMap(player, INSPECT_DISTANCE, false)) + { return; + } if (_player->IsHostileTo(player)) + { return; + } for (uint8 i = 0; i < MAX_ARENA_SLOT; ++i) { @@ -96,10 +102,14 @@ void WorldSession::HandleArenaTeamCreateOpcode(WorldPacket& recv_data) ArenaType type = ArenaTeam::GetTypeBySlot(slot); if (!IsArenaTypeValid(type)) + { return; + } if (!IsArenaTypeValid(ArenaType(type))) + { return; + } if (_player->GetArenaTeamId(slot)) { @@ -148,7 +158,9 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket& recv_data) if (!Invitedname.empty()) { if (!normalizePlayerName(Invitedname)) + { return; + } player = ObjectAccessor::FindPlayerByName(Invitedname.c_str()); } @@ -180,7 +192,9 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket& recv_data) // OK result but not send invite if (player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) + { return; + } if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam()) { @@ -224,7 +238,9 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/) ArenaTeam* at = sObjectMgr.GetArenaTeamById(_player->GetArenaTeamIdInvited()); if (!at) + { return; + } if (_player->GetArenaTeamId(at->GetSlot())) { @@ -268,7 +284,9 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket& recv_data) ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) + { return; + } if (_player->GetObjectGuid() == at->GetCaptainGuid() && at->GetMembersSize() > 1) { @@ -304,10 +322,14 @@ void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket& recv_data) if (ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId)) { if (at->GetCaptainGuid() != _player->GetObjectGuid()) + { return; + } if (at->IsFighting()) + { return; + } at->Disband(this); delete at; @@ -326,7 +348,9 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket& recv_data) ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) // arena team not found + { return; + } if (at->GetCaptainGuid() != _player->GetObjectGuid()) { @@ -335,7 +359,9 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket& recv_data) } if (!normalizePlayerName(name)) + { return; + } ArenaTeamMember* member = at->GetMember(name); if (!member) // member not found @@ -368,7 +394,9 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recv_data) ArenaTeam* at = sObjectMgr.GetArenaTeamById(ArenaTeamId); if (!at) // arena team not found + { return; + } if (at->GetCaptainGuid() != _player->GetObjectGuid()) { @@ -377,7 +405,9 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recv_data) } if (!normalizePlayerName(name)) + { return; + } ArenaTeamMember* member = at->GetMember(name); if (!member) // member not found @@ -387,7 +417,9 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recv_data) } if (at->GetCaptainGuid() == member->guid) // target player already captain + { return; + } at->SetCaptain(member->guid); diff --git a/src/game/WorldHandlers/AuctionHouseHandler.cpp b/src/game/WorldHandlers/AuctionHouseHandler.cpp index b16148858..313619119 100644 --- a/src/game/WorldHandlers/AuctionHouseHandler.cpp +++ b/src/game/WorldHandlers/AuctionHouseHandler.cpp @@ -274,7 +274,9 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data) AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) + { return; + } // always return pointer AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry); @@ -392,7 +394,9 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recv_data) AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) + { return; + } // always return pointer AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry); @@ -444,7 +448,9 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recv_data) // cheating if (price < auction->startbid) + { return; + } SendAuctionCommandResult(auction, AUCTION_BID_PLACED, AUCTION_OK); @@ -467,7 +473,9 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recv_data) AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) + { return; + } // always return pointer AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry); @@ -494,7 +502,9 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket& recv_data) { uint64 auctionCut = auction->GetAuctionCut(); if (pl->GetMoney() < auctionCut) // player doesn't have enough money, maybe message needed + { return; + } if (auction->bidder) // if auction have real existed bidder send mail SendAuctionCancelledToBidderMail(auction); @@ -547,7 +557,9 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket& recv_data) AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) + { return; + } // always return pointer AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry); @@ -591,7 +603,9 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket& recv_data) AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) + { return; + } // always return pointer AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry); @@ -629,7 +643,9 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recv_data) recv_data >> usable >> isFull >> unk >> sortCount; if (sortCount >= MAX_AUCTION_SORT) + { return; + } uint8 Sort[MAX_AUCTION_SORT]; memset(Sort, MAX_AUCTION_SORT, MAX_AUCTION_SORT); @@ -641,7 +657,9 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recv_data) recv_data >> column; if (column >= MAX_AUCTION_SORT) + { return; + } recv_data >> reversed; Sort[i] = (reversed > 0) ? (column |= AUCTION_SORT_REVERSED) : column; @@ -649,7 +667,9 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recv_data) AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) + { return; + } // always return pointer AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(auctionHouseEntry); @@ -676,7 +696,9 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recv_data) // converting string that we try to find to lower case std::wstring wsearchedname; if (!Utf8toWStr(searchedname, wsearchedname)) + { return; + } wstrToLower(wsearchedname); @@ -700,7 +722,9 @@ void WorldSession::HandleAuctionListPendingSales(WorldPacket& recv_data) AuctionHouseEntry const* auctionHouseEntry = GetCheckedAuctionHouseForAuctioneer(auctioneerGuid); if (!auctionHouseEntry) + { return; + } uint32 count = 0; diff --git a/src/game/WorldHandlers/CalendarHandler.cpp b/src/game/WorldHandlers/CalendarHandler.cpp index 0fd0e2423..f033aa436 100644 --- a/src/game/WorldHandlers/CalendarHandler.cpp +++ b/src/game/WorldHandlers/CalendarHandler.cpp @@ -749,7 +749,9 @@ void CalendarMgr::SendCalendarEventInviteAlert(CalendarInvite const* invite) CalendarEvent const* event = invite->GetCalendarEvent(); if (!event) + { return; + } WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_ALERT); data << uint64(event->EventId); @@ -821,7 +823,9 @@ void CalendarMgr::SendCalendarEventInvite(CalendarInvite const* invite) void CalendarMgr::SendCalendarCommandResult(Player* player, CalendarError err, char const* param /*= NULL*/) { if (!player) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SMSG_CALENDAR_COMMAND_RESULT (%u)", err); WorldPacket data(SMSG_CALENDAR_COMMAND_RESULT, 0); @@ -858,7 +862,9 @@ void CalendarMgr::SendCalendarEventRemovedAlert(CalendarEvent const* event) void CalendarMgr::SendCalendarEvent(Player* player, CalendarEvent const* event, uint32 sendType) { if (!player || !event) + { return; + } std::string timeStr = TimeToTimestampStr(event->EventTime); DEBUG_FILTER_LOG(LOG_FILTER_CALENDAR, "SendCalendarEvent> sendType[%u], CreatorGuid[%s], EventId[" UI64FMTD "], Type[%u], Flags[%u], Title[%s]", @@ -1017,7 +1023,9 @@ void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket packet, CalendarEven void CalendarMgr::SendCalendarRaidLockoutRemove(Player* player, DungeonPersistentState const* save) { if (!save || !player) + { return; + } DEBUG_LOG("SMSG_CALENDAR_RAID_LOCKOUT_REMOVED [%s]", player->GetObjectGuid().GetString().c_str()); time_t currTime = time(NULL); @@ -1034,7 +1042,9 @@ void CalendarMgr::SendCalendarRaidLockoutRemove(Player* player, DungeonPersisten void CalendarMgr::SendCalendarRaidLockoutAdd(Player* player, DungeonPersistentState const* save) { if (!save || !player) + { return; + } DEBUG_LOG("SMSG_CALENDAR_RAID_LOCKOUT_ADDED [%s]", player->GetObjectGuid().GetString().c_str()); time_t currTime = time(NULL); diff --git a/src/game/WorldHandlers/CellImpl.h b/src/game/WorldHandlers/CellImpl.h index 59fb3e96c..126218d57 100644 --- a/src/game/WorldHandlers/CellImpl.h +++ b/src/game/WorldHandlers/CellImpl.h @@ -68,7 +68,9 @@ inline void Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor &visitor, Map& m, float x, float y, float radius) const { if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + { return; + } // no jokes here... Actually placing ASSERT() here was good idea, but // we had some problems with DynamicObjects, which pass radius = 0.0f (DB issue?) @@ -149,7 +151,9 @@ Cell::VisitCircle(TypeContainerVisitor &visitor, Map& m, const Cel // if x_shift == 0 then we have too small cell area, which were already // visited at previous step, so just return from procedure... if (x_shift == 0) + { return; + } uint32 y_start = end_cell.y_coord; uint32 y_end = begin_cell.y_coord; diff --git a/src/game/WorldHandlers/Channel.cpp b/src/game/WorldHandlers/Channel.cpp index edea62e82..402a23c36 100644 --- a/src/game/WorldHandlers/Channel.cpp +++ b/src/game/WorldHandlers/Channel.cpp @@ -94,7 +94,9 @@ void Channel::Join(Player* player, const char* password) } if (player->GetGuildId() && (GetFlags() == 0x38)) + { return; + } // join channel player->JoinedChannel(this); @@ -343,7 +345,9 @@ void Channel::SetMode(Player* player, const char* targetName, bool moderator, bo ObjectGuid targetGuid = target->GetObjectGuid(); if (moderator && guid == m_ownerGuid && targetGuid == m_ownerGuid) + { return; + } if (!IsOn(targetGuid)) { @@ -588,7 +592,9 @@ void Channel::Moderate(Player* player) void Channel::Say(Player* player, const char* text, uint32 lang) { if (!text) + { return; + } ObjectGuid guid = player->GetObjectGuid(); diff --git a/src/game/WorldHandlers/Channel.h b/src/game/WorldHandlers/Channel.h index 92c1dae9e..16207446d 100644 --- a/src/game/WorldHandlers/Channel.h +++ b/src/game/WorldHandlers/Channel.h @@ -239,7 +239,9 @@ private: { PlayerList::const_iterator p_itr = m_players.find(guid); if (p_itr == m_players.end()) + { return 0; + } return p_itr->second.flags; } diff --git a/src/game/WorldHandlers/ChannelHandler.cpp b/src/game/WorldHandlers/ChannelHandler.cpp index 4bea3e394..b55e00ba0 100644 --- a/src/game/WorldHandlers/ChannelHandler.cpp +++ b/src/game/WorldHandlers/ChannelHandler.cpp @@ -42,7 +42,9 @@ void WorldSession::HandleJoinChannelOpcode(WorldPacket& recvPacket) pass = recvPacket.ReadString(passwordLength); if (channelname.empty()) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetJoinChannel(channelname, channel_id)) @@ -60,7 +62,9 @@ void WorldSession::HandleLeaveChannelOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(recvPacket.ReadBits(8)); if (channelname.empty()) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) { @@ -112,7 +116,9 @@ void WorldSession::HandleChannelSetOwnerOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(newp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -143,7 +149,9 @@ void WorldSession::HandleChannelModeratorOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -163,7 +171,9 @@ void WorldSession::HandleChannelUnmoderatorOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -183,7 +193,9 @@ void WorldSession::HandleChannelMuteOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -203,7 +215,9 @@ void WorldSession::HandleChannelUnmuteOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -223,7 +237,9 @@ void WorldSession::HandleChannelInviteOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -243,7 +259,9 @@ void WorldSession::HandleChannelKickOpcode(WorldPacket& recvPacket) otp = recvPacket.ReadString(nameLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -263,7 +281,9 @@ void WorldSession::HandleChannelBanOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) @@ -283,7 +303,9 @@ void WorldSession::HandleChannelUnbanOpcode(WorldPacket& recvPacket) channelname = recvPacket.ReadString(channelLen); if (!normalizePlayerName(otp)) + { return; + } if (ChannelMgr* cMgr = channelMgr(_player->GetTeam())) if (Channel* chn = cMgr->GetChannel(channelname, _player)) diff --git a/src/game/WorldHandlers/CharacterHandler.cpp b/src/game/WorldHandlers/CharacterHandler.cpp index 9b52fb281..1631c9151 100644 --- a/src/game/WorldHandlers/CharacterHandler.cpp +++ b/src/game/WorldHandlers/CharacterHandler.cpp @@ -567,7 +567,9 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recv_data) // can't delete loaded character if (sObjectMgr.GetPlayer(guid)) + { return; + } uint32 accountId = 0; std::string name; @@ -603,7 +605,9 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recv_data) // prevent deleting other players' characters using cheating tools if (accountId != GetAccountId()) + { return; + } std::string IP_str = GetRemoteAddress(); BASIC_LOG("Account: %d (IP: %s) Delete Character:[%s] (guid: %u)", GetAccountId(), IP_str.c_str(), name.c_str(), lowguid); @@ -1198,19 +1202,25 @@ void WorldSession::HandleAlterAppearanceOpcode(WorldPacket& recv_data) { BarberShopStyleEntry const* bs_skinTone = sBarberShopStyleStore.LookupEntry(skinTone); if (!bs_skinTone || bs_skinTone->type != 3 || bs_skinTone->race != _player->getRace() || bs_skinTone->gender != _player->getGender()) + { return; + } skinTone_id = bs_skinTone->hair_id; } BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(Hair); if (!bs_hair || bs_hair->type != 0 || bs_hair->race != _player->getRace() || bs_hair->gender != _player->getGender()) + { return; + } BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(FacialHair); if (!bs_facialHair || bs_facialHair->type != 2 || bs_facialHair->race != _player->getRace() || bs_facialHair->gender != _player->getGender()) + { return; + } uint32 Cost = _player->GetBarberShopCost(bs_hair->hair_id, Color, bs_facialHair->hair_id, skinTone_id); @@ -1371,7 +1381,9 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket& recv_data) recv_data >> iconName; if (index >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount + { return; + } EquipmentSet eqSet; @@ -1397,10 +1409,14 @@ void WorldSession::HandleEquipmentSetSaveOpcode(WorldPacket& recv_data) Item* item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (!item && itemGuid) // cheating check 1 + { return; + } if (item && item->GetObjectGuid() != itemGuid) // cheating check 2 + { return; + } eqSet.Items[i] = itemGuid.GetCounter(); } diff --git a/src/game/WorldHandlers/Chat.cpp b/src/game/WorldHandlers/Chat.cpp index e2bbf4b86..4c60488fe 100644 --- a/src/game/WorldHandlers/Chat.cpp +++ b/src/game/WorldHandlers/Chat.cpp @@ -933,7 +933,9 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac // ignore only for non-players for non strong checks (when allow apply command at least to same sec level) if (GetAccessLevel() > SEC_PLAYER && !strong && !sWorld.getConfig(CONFIG_BOOL_GM_LOWER_SECURITY)) + { return false; + } if (target) target_sec = target->GetSecurity(); @@ -959,16 +961,24 @@ bool ChatHandler::hasStringAbbr(const char* name, const char* part) { // "" part from non-"" command if (!*part) + { return false; + } for (;;) { if (!*part) + { return true; + } else if (!*name) + { return false; + } else if (tolower(*name) != tolower(*part)) + { return false; + } ++name; ++part; } } @@ -1275,7 +1285,9 @@ void ChatHandler::ExecuteCommand(const char* text) { #ifdef ENABLE_ELUNA if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str())) + { return; + } #endif /* ENABLE_ELUNA */ SendSysMessage(LANG_NO_SUBCMD); ShowHelpForCommand(command->ChildCommands, text); @@ -1286,7 +1298,9 @@ void ChatHandler::ExecuteCommand(const char* text) { #ifdef ENABLE_ELUNA if (!sEluna->OnCommand(m_session ? m_session->GetPlayer() : NULL, fullcmd.c_str())) + { return; + } #endif /* ENABLE_ELUNA */ SendSysMessage(LANG_NO_CMD); SetSentErrorMessage(true); @@ -1356,19 +1370,27 @@ bool ChatHandler::ParseCommands(const char* text) if (m_session) { if (m_session->GetSecurity() == SEC_PLAYER && !sWorld.getConfig(CONFIG_BOOL_PLAYER_COMMANDS)) + { return false; + } if (text[0] != '!' && text[0] != '.') + { return false; + } /// ignore single . and ! in line if (strlen(text) < 2) + { return false; + } } /// ignore messages staring from many dots. if ((text[0] == '.' && text[1] == '.') || (text[0] == '!' && text[1] == '!')) + { return false; + } /// skip first . or ! (in console allowed use command with . and ! and without its) if (text[0] == '!' || text[0] == '.') @@ -1400,7 +1422,9 @@ bool ChatHandler::ShowHelpForSubCommands(ChatCommand* table, char const* cmd) } if (list.empty()) + { return false; + } if (table == getCommandTable()) { @@ -1458,7 +1482,9 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand* table, const char* cmd) if (childCommands) if (ShowHelpForSubCommands(childCommands, showCommand ? showCommand->Name : "")) + { return true; + } if (command && command->Help.empty()) SendSysMessage(LANG_NO_HELP_CMD); @@ -1486,7 +1512,9 @@ bool ChatHandler::isValidChatMessage(const char* message) */ if (strlen(message) > 255) + { return false; + } const char validSequence[6] = "cHhhr"; const char* validSequenceIterator = validSequence; @@ -1502,12 +1530,16 @@ bool ChatHandler::isValidChatMessage(const char* message) message = strchr(message, '|'); if (!message) + { return true; + } ++message; char commandChar = *message; if (validCommands.find(commandChar) == std::string::npos) + { return false; + } ++message; // validate sequence @@ -1521,7 +1553,9 @@ bool ChatHandler::isValidChatMessage(const char* message) ++validSequenceIterator; } else if (commandChar != '|') + { return false; + } } } return true; @@ -1632,12 +1666,16 @@ bool ChatHandler::isValidChatMessage(const char* message) // read chars up to colon = link type reader.getline(buffer, 256, ':'); if (reader.eof()) // : must be + { return false; + } if (strcmp(buffer, "currency") == 0) { if (color != CHAT_LINK_COLOR_CURRENCY) + { return false; + } uint32 currencyEntry = 0; // read currency entry @@ -1651,14 +1689,18 @@ bool ChatHandler::isValidChatMessage(const char* message) } linkedCurrency = sCurrencyTypesStore.LookupEntry(currencyEntry); if (!linkedCurrency) + { return false; + } } else if (strcmp(buffer, "item") == 0) { // read item entry reader.getline(buffer, 256, ':'); if (reader.eof()) // : must be + { return false; + } linkedItem = ObjectMgr::GetItemPrototype(atoi(buffer)); if (!linkedItem) @@ -1696,7 +1738,9 @@ bool ChatHandler::isValidChatMessage(const char* message) else if (c == '-') negativeNumber = true; else + { return false; + } } } if (negativeNumber) @@ -1706,13 +1750,17 @@ bool ChatHandler::isValidChatMessage(const char* message) { itemProperty = sItemRandomPropertiesStore.LookupEntry(propertyId); if (!itemProperty) + { return false; + } } else if (propertyId < 0) { itemSuffix = sItemRandomSuffixStore.LookupEntry(-propertyId); if (!itemSuffix) + { return false; + } } // ignore other integers @@ -1777,16 +1825,22 @@ bool ChatHandler::isValidChatMessage(const char* message) else if (strcmp(buffer, "trade") == 0) { if (color != CHAT_LINK_COLOR_TRADE) + { return false; + } // read spell entry reader.getline(buffer, 256, ':'); if (reader.eof()) // : must be + { return false; + } linkedSpell = sSpellStore.LookupEntry(atoi(buffer)); if (!linkedSpell) + { return false; + } char c = reader.peek(); // base64 encoded stuff @@ -1800,20 +1854,28 @@ bool ChatHandler::isValidChatMessage(const char* message) { // talent links are always supposed to be blue if (color != CHAT_LINK_COLOR_TALENT) + { return false; + } // read talent entry reader.getline(buffer, 256, ':'); if (reader.eof()) // : must be + { return false; + } TalentEntry const* talentInfo = sTalentStore.LookupEntry(atoi(buffer)); if (!talentInfo) + { return false; + } linkedSpell = sSpellStore.LookupEntry(talentInfo->RankID[0]); if (!linkedSpell) + { return false; + } char c = reader.peek(); // skillpoints? whatever, drop it @@ -1826,7 +1888,9 @@ bool ChatHandler::isValidChatMessage(const char* message) else if (strcmp(buffer, "spell") == 0) { if (color != CHAT_LINK_COLOR_SPELL) + { return false; + } uint32 spellid = 0; // read spell entry @@ -1840,12 +1904,16 @@ bool ChatHandler::isValidChatMessage(const char* message) } linkedSpell = sSpellStore.LookupEntry(spellid); if (!linkedSpell) + { return false; + } } else if (strcmp(buffer, "enchant") == 0) { if (color != CHAT_LINK_COLOR_ENCHANT) + { return false; + } uint32 spellid = 0; // read spell entry @@ -1859,22 +1927,30 @@ bool ChatHandler::isValidChatMessage(const char* message) } linkedSpell = sSpellStore.LookupEntry(spellid); if (!linkedSpell) + { return false; + } } else if (strcmp(buffer, "achievement") == 0) { if (color != CHAT_LINK_COLOR_ACHIEVEMENT) + { return false; + } reader.getline(buffer, 256, ':'); if (reader.eof()) // : must be + { return false; + } uint32 achievementId = atoi(buffer); linkedAchievement = sAchievementStore.LookupEntry(achievementId); if (!linkedAchievement) + { return false; + } char c = reader.peek(); // skip progress @@ -1887,12 +1963,16 @@ bool ChatHandler::isValidChatMessage(const char* message) else if (strcmp(buffer, "glyph") == 0) { if (color != CHAT_LINK_COLOR_GLYPH) + { return false; + } // first id is slot, drop it reader.getline(buffer, 256, ':'); if (reader.eof()) // : must be + { return false; + } uint32 glyphId = 0; char c = reader.peek(); @@ -1905,12 +1985,16 @@ bool ChatHandler::isValidChatMessage(const char* message) } GlyphPropertiesEntry const* glyph = sGlyphPropertiesStore.LookupEntry(glyphId); if (!glyph) + { return false; + } linkedSpell = sSpellStore.LookupEntry(glyph->SpellId); if (!linkedSpell) + { return false; + } } else { @@ -1930,13 +2014,17 @@ bool ChatHandler::isValidChatMessage(const char* message) } reader.getline(buffer, 256, ']'); if (reader.eof()) // ] must be + { return false; + } // verify the link name if (linkedCurrency) { if (linkedCurrency->Category == CURRENCY_CATEGORY_META) + { return false; + } bool foundName = false; for (uint8 i = 0; i < MAX_LOCALE; ++i) @@ -1948,7 +2036,9 @@ bool ChatHandler::isValidChatMessage(const char* message) } } if (!foundName) + { return false; + } } else if (linkedSpell) { @@ -1997,7 +2087,9 @@ bool ChatHandler::isValidChatMessage(const char* message) } } if (!foundName) + { return false; + } } else if (linkedQuest) { @@ -2081,12 +2173,16 @@ bool ChatHandler::isValidChatMessage(const char* message) } } if (!foundName) + { return false; + } } // that place should never be reached - if nothing linked has been set in |H // it will return false before else + { return false; + } } break; case 'r': @@ -2109,12 +2205,16 @@ bool ChatHandler::isValidChatMessage(const char* message) Player* ChatHandler::getSelectedPlayer() { if (!m_session) + { return NULL; + } ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); if (!guid) + { return m_session->GetPlayer(); + } return sObjectMgr.GetPlayer(guid); } @@ -2122,12 +2222,16 @@ Player* ChatHandler::getSelectedPlayer() Unit* ChatHandler::getSelectedUnit() { if (!m_session) + { return NULL; + } ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); if (!guid) + { return m_session->GetPlayer(); + } // can be selected player at another map return ObjectAccessor::GetUnit(*m_session->GetPlayer(), guid); @@ -2136,7 +2240,9 @@ Unit* ChatHandler::getSelectedUnit() Creature* ChatHandler::getSelectedCreature() { if (!m_session) + { return NULL; + } return m_session->GetPlayer()->GetMap()->GetAnyTypeCreature(m_session->GetPlayer()->GetSelectionGuid()); } @@ -2150,7 +2256,9 @@ Creature* ChatHandler::getSelectedCreature() void ChatHandler::SkipWhiteSpaces(char** args) { if (!*args) + { return; + } while (isWhiteSpace(**args)) ++(*args); @@ -2166,7 +2274,9 @@ void ChatHandler::SkipWhiteSpaces(char** args) bool ChatHandler::ExtractInt32(char** args, int32& val) { if (!*args || !** args) + { return false; + } char* tail = *args; @@ -2178,7 +2288,9 @@ bool ChatHandler::ExtractInt32(char** args, int32& val) return false; // args not modified and can be re-parsed if (valRaw < std::numeric_limits::min() || valRaw > std::numeric_limits::max()) + { return false; + } // value successfully extracted val = int32(valRaw); @@ -2216,7 +2328,9 @@ bool ChatHandler::ExtractOptInt32(char** args, int32& val, int32 defVal) bool ChatHandler::ExtractUInt32Base(char** args, uint32& val, uint32 base) { if (!*args || !** args) + { return false; + } char* tail = *args; @@ -2228,7 +2342,9 @@ bool ChatHandler::ExtractUInt32Base(char** args, uint32& val, uint32 base) return false; // args not modified and can be re-parsed if (valRaw > std::numeric_limits::max()) + { return false; + } // value successfully extracted val = uint32(valRaw); @@ -2248,7 +2364,9 @@ bool ChatHandler::ExtractUInt32Base(char** args, uint32& val, uint32 base) bool ChatHandler::ExtractUInt64(char** args, uint64& val) { if (!*args || !** args) + { return false; + } char* tail = *args; @@ -2260,7 +2378,9 @@ bool ChatHandler::ExtractUInt64(char** args, uint64& val) return false; // args not modified and can be re-parsed if (valRaw > std::numeric_limits::max()) + { return false; + } // value successfully extracted val = uint64(valRaw); @@ -2280,7 +2400,9 @@ bool ChatHandler::ExtractUInt64(char** args, uint64& val) bool ChatHandler::ExtractInt64(char** args, int64& val) { if (!*args || !** args) + { return false; + } char* tail = *args; @@ -2292,7 +2414,9 @@ bool ChatHandler::ExtractInt64(char** args, int64& val) return false; // args not modified and can be re-parsed if (valRaw < std::numeric_limits::min() || valRaw > std::numeric_limits::max()) + { return false; + } // value successfully extracted val = int64(valRaw); @@ -2329,7 +2453,9 @@ bool ChatHandler::ExtractOptUInt32(char** args, uint32& val, uint32 defVal) bool ChatHandler::ExtractFloat(char** args, float& val) { if (!*args || !** args) + { return false; + } char* tail = *args; @@ -2378,7 +2504,9 @@ bool ChatHandler::ExtractOptFloat(char** args, float& val, float defVal) char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/) { if (!*args || !** args) + { return NULL; + } char* head = *args; @@ -2392,7 +2520,9 @@ char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/) case '|': // client replace all | by || in raw text if (head[1] != '|') + { return NULL; + } ++head; // skip one | break; default: break; @@ -2412,10 +2542,14 @@ char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/) int diff = strncmp(head, lit, l); if (diff != 0) + { return NULL; + } if (head[l] && !isWhiteSpace(head[l])) + { return NULL; + } char* arg = head; @@ -2455,10 +2589,14 @@ char* ChatHandler::ExtractLiteralArg(char** args, char const* lit /*= NULL*/) char* ChatHandler::ExtractQuotedArg(char** args, bool asis /*= false*/) { if (!*args || !** args) + { return NULL; + } if (**args != '\'' &&** args != '"' &&** args != '[') + { return NULL; + } char guard = (*args)[0]; @@ -2472,7 +2610,9 @@ char* ChatHandler::ExtractQuotedArg(char** args, bool asis /*= false*/) ++tail; if (!*tail || (tail[1] && !isWhiteSpace(tail[1]))) // fail + { return NULL; + } if (!tail[1]) // quote is last char in string { @@ -2520,14 +2660,18 @@ bool ChatHandler::ExtractOnOff(char** args, bool& value) { char* arg = ExtractLiteralArg(args); if (!arg) + { return false; + } if (strncmp(arg, "on", 3) == 0) value = true; else if (strncmp(arg, "off", 4) == 0) value = false; else + { return false; + } return true; } @@ -2552,11 +2696,15 @@ bool ChatHandler::ExtractOnOff(char** args, bool& value) char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= NULL*/, int* foundIdx /*= NULL*/, char** keyPair /*= NULL*/, char** somethingPair /*= NULL*/) { if (!*args || !** args) + { return NULL; + } // skip if not linked started or encoded single | (doubled by client) if ((*args)[0] != '|' || (*args)[1] == '|') + { return NULL; + } // |color|Hlinktype:key:data...|h[name]|h|r @@ -2578,7 +2726,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= ++tail; if (!*tail) + { return NULL; + } // |Hlinktype:key:data...|h[name]|h|r @@ -2588,7 +2738,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= // Hlinktype:key:data...|h[name]|h|r if (*tail != 'H') + { return NULL; + } int linktype_idx = 0; @@ -2606,14 +2758,18 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= // is search fail? if (!linkTypes[linktype_idx]) // NULL terminator in last element + { return NULL; + } tail += strlen(linkTypes[linktype_idx]); // skip linktype string // :key:data...|h[name]|h|r if (*tail != ':') + { return NULL; + } } else { @@ -2621,7 +2777,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= ++tail; if (!*tail) + { return NULL; + } } ++tail; @@ -2634,7 +2792,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= ++tail; if (!*tail) + { return NULL; + } keyEnd = tail; // remember key end for truncate @@ -2654,7 +2814,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= ++tail; if (!*tail) + { return NULL; + } somethingEnd = tail; // remember data end for truncate } @@ -2665,7 +2827,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= ++tail; if (!*tail) + { return NULL; + } // |h[name]|h|r @@ -2673,7 +2837,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= // [name]|h|r if (!*tail || *tail != '[') + { return NULL; + } while (*tail && (*tail != ']' || *(tail + 1) != '|')) // skip name part ++tail; @@ -2682,13 +2848,17 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= // h|r if (!*tail || *tail != 'h' || *(tail + 1) != '|') + { return NULL; + } tail += 2; // skip h| // r if (!*tail || *tail != 'r' || (*(tail + 1) && !isWhiteSpace(*(tail + 1)))) + { return NULL; + } ++tail; // skip r @@ -2729,7 +2899,9 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= char* ChatHandler::ExtractArg(char** args, bool asis /*= false*/) { if (!*args || !** args) + { return NULL; + } char* arg = ExtractQuotedOrLiteralArg(args, asis); if (!arg) @@ -2751,7 +2923,9 @@ char* ChatHandler::ExtractOptNotLastArg(char** args) // have more data if (*args &&** args) + { return arg; + } // optional name not found *args = arg ? arg : (char*)""; // *args don't must be NULL @@ -2805,7 +2979,9 @@ char* ChatHandler::ExtractKeyFromLink(char** text, char const* const* linkTypes, { // skip empty if (!*text || !** text) + { return NULL; + } // return non link case char* arg = ExtractQuotedOrLiteralArg(text); @@ -2822,7 +2998,9 @@ char* ChatHandler::ExtractKeyFromLink(char** text, char const* const* linkTypes, arg = ExtractLinkArg(text, linkTypes, found_idx, keyPair, something1 ? somethingPair : NULL); if (!arg) + { return NULL; + } *keyPair[1] = '\0'; // truncate key string @@ -2852,7 +3030,9 @@ bool ChatHandler::ExtractUint32KeyFromLink(char** text, char const* linkType, ui { char* arg = ExtractKeyFromLink(text, linkType); if (!arg) + { return false; + } return ExtractUInt32(&arg, value); } @@ -2860,7 +3040,9 @@ bool ChatHandler::ExtractUint32KeyFromLink(char** text, char const* linkType, ui GameObject* ChatHandler::GetGameObjectWithGuid(uint32 lowguid, uint32 entry) { if (!m_session) + { return NULL; + } Player* pl = m_session->GetPlayer(); @@ -2898,11 +3080,15 @@ uint32 ChatHandler::ExtractSpellIdFromLink(char** text) char* param1_str = NULL; char* idS = ExtractKeyFromLink(text, spellKeys, &type, ¶m1_str); if (!idS) + { return 0; + } uint32 id; if (!ExtractUInt32(&idS, id)) + { return 0; + } switch (type) { @@ -2916,11 +3102,15 @@ uint32 ChatHandler::ExtractSpellIdFromLink(char** text) // talent TalentEntry const* talentEntry = sTalentStore.LookupEntry(id); if (!talentEntry) + { return 0; + } int32 rank; if (!ExtractInt32(¶m1_str, rank)) + { return 0; + } if (rank < 0) // unlearned talent have in shift-link field -1 as rank rank = 0; @@ -2932,7 +3122,9 @@ uint32 ChatHandler::ExtractSpellIdFromLink(char** text) uint32 glyph_prop_id; if (!ExtractUInt32(¶m1_str, glyph_prop_id)) + { return 0; + } GlyphPropertiesEntry const* glyphPropEntry = sGlyphPropertiesStore.LookupEntry(glyph_prop_id); return glyphPropEntry ? glyphPropEntry->SpellId : 0; @@ -2948,14 +3140,20 @@ GameTele const* ChatHandler::ExtractGameTeleFromLink(char** text) // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r char* cId = ExtractKeyFromLink(text, "Htele"); if (!cId) + { return NULL; + } // id case (explicit or from shift link) uint32 id; if (ExtractUInt32(&cId, id)) + { return sObjectMgr.GetGameTele(id); + } else + { return sObjectMgr.GetGameTele(cId); + } } enum GuidLinkType @@ -2983,7 +3181,9 @@ ObjectGuid ChatHandler::ExtractGuidFromLink(char** text) // |color|Hplayer:name|h[name]|h|r char* idS = ExtractKeyFromLink(text, guidKeys, &type); if (!idS) + { return ObjectGuid(); + } switch (type) { @@ -2992,10 +3192,14 @@ ObjectGuid ChatHandler::ExtractGuidFromLink(char** text) { std::string name = idS; if (!normalizePlayerName(name)) + { return ObjectGuid(); + } if (Player* player = sObjectMgr.GetPlayer(name.c_str())) + { return player->GetObjectGuid(); + } return sObjectMgr.GetPlayerGuidByName(name); } @@ -3003,23 +3207,35 @@ ObjectGuid ChatHandler::ExtractGuidFromLink(char** text) { uint32 lowguid; if (!ExtractUInt32(&idS, lowguid)) + { return ObjectGuid(); + } if (CreatureData const* data = sObjectMgr.GetCreatureData(lowguid)) + { return data->GetObjectGuid(lowguid); + } else + { return ObjectGuid(); + } } case GUID_LINK_GAMEOBJECT: { uint32 lowguid; if (!ExtractUInt32(&idS, lowguid)) + { return ObjectGuid(); + } if (GameObjectData const* data = sObjectMgr.GetGOData(lowguid)) + { return ObjectGuid(HIGHGUID_GAMEOBJECT, data->id, lowguid); + } else + { return ObjectGuid(); + } } } @@ -3070,7 +3286,9 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, // |color|Hareatrigger_target:id|h[name]|h|r char* idS = ExtractKeyFromLink(text, locationKeys, &type); if (!idS) + { return false; + } switch (type) { @@ -3079,7 +3297,9 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, { std::string name = idS; if (!normalizePlayerName(name)) + { return false; + } if (Player* player = sObjectMgr.GetPlayer(name.c_str())) { @@ -3104,11 +3324,15 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, { uint32 id; if (!ExtractUInt32(&idS, id)) + { return false; + } GameTele const* tele = sObjectMgr.GetGameTele(id); if (!tele) + { return false; + } mapid = tele->mapId; x = tele->position_x; y = tele->position_y; @@ -3119,11 +3343,15 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, { uint32 id; if (!ExtractUInt32(&idS, id)) + { return false; + } TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); if (!node) + { return false; + } mapid = node->map_id; x = node->x; y = node->y; @@ -3134,7 +3362,9 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, { uint32 lowguid; if (!ExtractUInt32(&idS, lowguid)) + { return false; + } if (CreatureData const* data = sObjectMgr.GetCreatureData(lowguid)) { @@ -3145,13 +3375,17 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, return true; } else + { return false; + } } case LOCATION_LINK_GAMEOBJECT: { uint32 lowguid; if (!ExtractUInt32(&idS, lowguid)) + { return false; + } if (GameObjectData const* data = sObjectMgr.GetGOData(lowguid)) { @@ -3162,13 +3396,17 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, return true; } else + { return false; + } } case LOCATION_LINK_CREATURE_ENTRY: { uint32 id; if (!ExtractUInt32(&idS, id)) + { return false; + } if (ObjectMgr::GetCreatureTemplate(id)) { @@ -3185,16 +3423,22 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, return true; } else + { return false; + } } else + { return false; + } } case LOCATION_LINK_GAMEOBJECT_ENTRY: { uint32 id; if (!ExtractUInt32(&idS, id)) + { return false; + } if (ObjectMgr::GetGameObjectInfo(id)) { @@ -3211,16 +3455,22 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, return true; } else + { return false; + } } else + { return false; + } } case LOCATION_LINK_AREATRIGGER: { uint32 id; if (!ExtractUInt32(&idS, id)) + { return false; + } AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id); if (!atEntry) @@ -3240,7 +3490,9 @@ bool ChatHandler::ExtractLocationFromLink(char** text, uint32& mapid, float& x, { uint32 id; if (!ExtractUInt32(&idS, id)) + { return false; + } if (!sAreaTriggerStore.LookupEntry(id)) { @@ -3274,11 +3526,15 @@ std::string ChatHandler::ExtractPlayerNameFromLink(char** text) // |color|Hplayer:name|h[name]|h|r char* name_str = ExtractKeyFromLink(text, "Hplayer"); if (!name_str) + { return ""; + } std::string name = name_str; if (!normalizePlayerName(name)) + { return ""; + } return name; } @@ -3359,12 +3615,16 @@ uint32 ChatHandler::ExtractAccountId(char** args, std::string* accountName /*= N if (!account_str) { if (!targetIfNullArg) + { return 0; + } /// only target player different from self allowed (if targetPlayer!=NULL then not console) Player* targetPlayer = getSelectedPlayer(); if (!targetPlayer) + { return 0; + } account_id = targetPlayer->GetSession()->GetAccountId(); @@ -3467,7 +3727,9 @@ bool ChatHandler::ExtractRaceMask(char** text, uint32& raceMask, char const** ma } if (!raceMask) + { return false; + } } return true; @@ -3513,7 +3775,9 @@ bool CliHandler::isAvailable(ChatCommand const& cmd) const { // skip non-console commands in console case if (!cmd.AllowConsole) + { return false; + } // normal case return GetAccessLevel() >= (AccountTypes)cmd.SecurityLevel; diff --git a/src/game/WorldHandlers/ChatHandler.cpp b/src/game/WorldHandlers/ChatHandler.cpp index 50e122303..ab619a8d5 100644 --- a/src/game/WorldHandlers/ChatHandler.cpp +++ b/src/game/WorldHandlers/ChatHandler.cpp @@ -128,7 +128,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) { // Disabled addon channel? if (!sWorld.getConfig(CONFIG_BOOL_ADDON_CHANNEL)) + { return; + } } // LANG_ADDON should not be changed nor be affected by flood control else @@ -203,7 +205,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -212,7 +216,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) { #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + { return; + } #endif /* ENABLE_ELUNA */ GetPlayer()->Say(msg, lang); } @@ -220,7 +226,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) { #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, LANG_UNIVERSAL, msg)) + { return; + } #endif /* ENABLE_ELUNA */ GetPlayer()->TextEmote(msg); } @@ -228,7 +236,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) { #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + { return; + } #endif /* ENABLE_ELUNA */ GetPlayer()->Yell(msg, lang); } @@ -284,7 +294,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, player)) + { return; + } #endif /* ENABLE_ELUNA */ GetPlayer()->Whisper(msg, lang, player->GetObjectGuid()); } break; @@ -302,7 +314,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -313,15 +327,21 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) { group = _player->GetGroup(); if (!group || group->isBGGroup()) + { return; + } } if ((type == CHAT_MSG_PARTY_LEADER) && !group->IsLeader(_player->GetObjectGuid())) + { return; + } // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + { return; + } #endif /* ENABLE_ELUNA */ WorldPacket data; @@ -342,7 +362,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -353,7 +375,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild)) + { return; + } #endif /* ENABLE_ELUNA */ guild->BroadcastToGuild(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); @@ -373,7 +397,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -384,7 +410,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, guild)) + { return; + } #endif /* ENABLE_ELUNA */ guild->BroadcastToOfficers(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL); @@ -404,7 +432,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -415,13 +445,17 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) { group = GetPlayer()->GetGroup(); if (!group || group->isBGGroup() || !group->isRaidGroup()) + { return; + } } // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + { return; + } #endif /* ENABLE_ELUNA */ WorldPacket data; @@ -440,7 +474,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) break; if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -451,13 +487,17 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) { group = GetPlayer()->GetGroup(); if (!group || group->isBGGroup() || !group->isRaidGroup() || !group->IsLeader(_player->GetObjectGuid())) + { return; + } } // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + { return; + } #endif /* ENABLE_ELUNA */ WorldPacket data; @@ -471,7 +511,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) msg = recv_data.ReadString(recv_data.ReadBits(9)); if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -484,7 +526,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + { return; + } #endif /* ENABLE_ELUNA */ WorldPacket data; @@ -499,7 +543,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) msg = recv_data.ReadString(recv_data.ReadBits(9)); if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -507,12 +553,16 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // battleground raid is always in Player->GetGroup(), never in GetOriginalGroup() Group* group = GetPlayer()->GetGroup(); if (!group || !group->isBGGroup()) + { return; + } // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + { return; + } #endif /* ENABLE_ELUNA */ WorldPacket data; @@ -526,7 +576,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) msg = recv_data.ReadString(recv_data.ReadBits(9)); if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -534,12 +586,16 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // battleground raid is always in Player->GetGroup(), never in GetOriginalGroup() Group* group = GetPlayer()->GetGroup(); if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetObjectGuid())) + { return; + } // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, group)) + { return; + } #endif /* ENABLE_ELUNA */ WorldPacket data; @@ -556,7 +612,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) channel = recv_data.ReadString(channelLength); if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) + { return; + } if (msg.empty()) break; @@ -568,7 +626,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg, chn)) + { return; + } #endif /* ENABLE_ELUNA */ chn->Say(_player, msg.c_str(), lang); } @@ -602,7 +662,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + { return; + } #endif /* ENABLE_ELUNA */ } break; @@ -631,7 +693,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnChat(GetPlayer(), type, lang, msg)) + { return; + } #endif /* ENABLE_ELUNA */ break; @@ -663,7 +727,9 @@ void WorldSession::HandleAddonMessagechatOpcode(WorldPacket& recv_data) // Disabled addon channel? if (!sWorld.getConfig(CONFIG_BOOL_ADDON_CHANNEL)) + { return; + } switch (type) { @@ -676,7 +742,9 @@ void WorldSession::HandleAddonMessagechatOpcode(WorldPacket& recv_data) Group* group = _player->GetGroup(); if (!group || !group->isBGGroup()) + { return; + } WorldPacket data; ChatHandler::BuildChatPacket(data, type, msg.c_str(), LANG_ADDON); @@ -758,7 +826,9 @@ void WorldSession::HandleAddonMessagechatOpcode(WorldPacket& recv_data) void WorldSession::HandleEmoteOpcode(WorldPacket& recv_data) { if (!GetPlayer()->IsAlive() || GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + { return; + } uint32 emote; recv_data >> emote; @@ -808,7 +878,9 @@ namespace MaNGOS void WorldSession::HandleTextEmoteOpcode(WorldPacket& recv_data) { if (!GetPlayer()->IsAlive()) + { return; + } if (!GetPlayer()->CanSpeak()) { @@ -831,7 +903,9 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recv_data) EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(text_emote); if (!em) + { return; + } uint32 emote_id = em->textid; @@ -882,7 +956,9 @@ void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data) Player* player = sObjectMgr.GetPlayer(iguid); if (!player || !player->GetSession()) + { return; + } WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_IGNORED, _player->GetName(), LANG_UNIVERSAL, CHAT_TAG_NONE, _player->GetObjectGuid()); diff --git a/src/game/WorldHandlers/CreatureLinkingMgr.cpp b/src/game/WorldHandlers/CreatureLinkingMgr.cpp index 544837f5b..fd9d35b07 100644 --- a/src/game/WorldHandlers/CreatureLinkingMgr.cpp +++ b/src/game/WorldHandlers/CreatureLinkingMgr.cpp @@ -284,15 +284,21 @@ bool CreatureLinkingMgr::IsLinkedEventTrigger(Creature* pCreature) const { // Entry case if (m_eventTriggers.find(pCreature->GetEntry()) != m_eventTriggers.end()) + { return true; + } // Guid case if (m_eventGuidTriggers.find(pCreature->GetGUIDLow()) != m_eventGuidTriggers.end()) + { return true; + } // Also return true for npcs that trigger reverse actions, or for followers(needed in respawn) if (CreatureLinkingInfo const* pInfo = GetLinkedTriggerInformation(pCreature)) + { return pInfo->linkingFlag & EVENT_MASK_TRIGGER_TO; + } return false; } @@ -332,7 +338,9 @@ CreatureLinkingInfo const* CreatureLinkingMgr::GetLinkedTriggerInformation(uint3 for (CreatureLinkingMap::const_iterator iter = bounds.first; iter != bounds.second; ++iter) { if (iter->second.mapId == mapId) + { return &(iter->second); + } } return NULL; @@ -343,7 +351,9 @@ void CreatureLinkingHolder::AddSlaveToHolder(Creature* pCreature) { CreatureLinkingInfo const* pInfo = sCreatureLinkingMgr.GetLinkedTriggerInformation(pCreature); if (!pInfo) + { return; + } if (pInfo->mapId == INVALID_MAP_ID) // Guid case, store master->slaves for fast access { @@ -397,11 +407,15 @@ void CreatureLinkingHolder::AddSlaveToHolder(Creature* pCreature) void CreatureLinkingHolder::AddMasterToHolder(Creature* pCreature) { if (pCreature->IsPet()) + { return; + } // Only add master NPCs (by entry) if (!sCreatureLinkingMgr.IsLinkedMaster(pCreature)) + { return; + } // Check, if already stored BossGuidMapBounds bounds = m_masterGuid.equal_range(pCreature->GetEntry()); @@ -417,14 +431,20 @@ void CreatureLinkingHolder::DoCreatureLinkingEvent(CreatureLinkingEvent eventTyp { // This check will be needed in reload case if (!sCreatureLinkingMgr.IsLinkedEventTrigger(pSource)) + { return; + } // Ignore atypic behaviour if (pSource->IsControlledByPlayer()) + { return; + } if (eventType == LINKING_EVENT_AGGRO && !pEnemy) + { return; + } uint32 eventFlagFilter = 0; uint32 reverseEventFlagFilter = 0; @@ -477,7 +497,9 @@ void CreatureLinkingHolder::DoCreatureLinkingEvent(CreatureLinkingEvent eventTyp { case LINKING_EVENT_AGGRO: if (pMaster->IsControlledByPlayer()) + { return; + } if (pMaster->IsInCombat()) pMaster->SetInCombatWith(pEnemy); @@ -505,7 +527,9 @@ void CreatureLinkingHolder::DoCreatureLinkingEvent(CreatureLinkingEvent eventTyp void CreatureLinkingHolder::ProcessSlaveGuidList(CreatureLinkingEvent eventType, Creature* pSource, uint32 flag, uint16 searchRange, GuidList& slaveGuidList, Unit* pEnemy) { if (!flag) + { return; + } for (GuidList::iterator slave_itr = slaveGuidList.begin(); slave_itr != slaveGuidList.end();) { @@ -538,7 +562,9 @@ void CreatureLinkingHolder::ProcessSlave(CreatureLinkingEvent eventType, Creatur if (flag & FLAG_AGGRO_ON_AGGRO) { if (pSlave->IsControlledByPlayer()) + { return; + } if (pSlave->IsInCombat()) pSlave->SetInCombatWith(pEnemy); @@ -619,7 +645,9 @@ bool CreatureLinkingHolder::IsSlaveInRangeOfBoss(Creature const* pSlave, Creatur bool CreatureLinkingHolder::IsSlaveInRangeOfBoss(Creature const* pBoss, float sX, float sY, uint16 searchRange) const { if (!searchRange) + { return true; + } // Do some calculations float mX, mY, mZ, dx, dy; @@ -643,7 +671,9 @@ bool CreatureLinkingHolder::CanSpawn(Creature* pCreature) const { CreatureLinkingInfo const* pInfo = sCreatureLinkingMgr.GetLinkedTriggerInformation(pCreature); if (!pInfo) + { return true; + } float sx, sy, sz; pCreature->GetRespawnCoord(sx, sy, sz); @@ -666,13 +696,19 @@ bool CreatureLinkingHolder::CanSpawn(uint32 lowGuid, Map* _map, CreatureLinkingI { CreatureData const* data = sObjectMgr.GetCreatureData(lowGuid); if (!data) + { return true; + } pInfo = sCreatureLinkingMgr.GetLinkedTriggerInformation(data->id, lowGuid, data->mapid); if (!pInfo) + { return true; + } // Has lowGuid npc actually spawning linked? if (!sCreatureLinkingMgr.IsSpawnedByLinkedMob(pInfo)) + { return true; + } sx = data->posX; // Fill position data sy = data->posY; @@ -684,11 +720,17 @@ bool CreatureLinkingHolder::CanSpawn(uint32 lowGuid, Map* _map, CreatureLinkingI return false; // This should never happen if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_DEAD) + { return IsRespawnReady(pInfo->masterDBGuid, _map); + } else if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_ALIVE) + { return !IsRespawnReady(pInfo->masterDBGuid, _map); + } else + { return true; + } } // Search for nearby master @@ -699,11 +741,17 @@ bool CreatureLinkingHolder::CanSpawn(uint32 lowGuid, Map* _map, CreatureLinkingI if (pMaster && IsSlaveInRangeOfBoss(pMaster, sx, sy, pInfo->searchRange)) { if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_DEAD) + { return pMaster->IsAlive(); + } else if (pInfo->linkingFlag & FLAG_CANT_SPAWN_IF_BOSS_ALIVE) + { return !pMaster->IsAlive(); + } else + { return true; + } } } @@ -715,7 +763,9 @@ bool CreatureLinkingHolder::TryFollowMaster(Creature* pCreature) { CreatureLinkingInfo const* pInfo = sCreatureLinkingMgr.GetLinkedTriggerInformation(pCreature); if (!pInfo || !(pInfo->linkingFlag & FLAG_FOLLOW)) + { return false; + } Creature* pMaster = NULL; if (pInfo->mapId != INVALID_MAP_ID) // entry case diff --git a/src/game/WorldHandlers/DisableMgr.cpp b/src/game/WorldHandlers/DisableMgr.cpp index 34974e69f..1e41f8121 100644 --- a/src/game/WorldHandlers/DisableMgr.cpp +++ b/src/game/WorldHandlers/DisableMgr.cpp @@ -282,11 +282,15 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags { MANGOS_ASSERT(type < MAX_DISABLE_TYPES); if (m_DisableMap[type].empty()) + { return false; + } DisableTypeMap::iterator itr = m_DisableMap[type].find(entry); if (itr == m_DisableMap[type].end()) // not disabled + { return false; + } switch (type) { @@ -324,9 +328,13 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags return false; } else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast + { return true; + } else if (flags & SPELL_DISABLE_LOS) + { return (spellFlags & SPELL_DISABLE_LOS) != 0; + } break; } @@ -358,9 +366,13 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags return false; case DISABLE_TYPE_QUEST: if (!unit) + { return true; + } if (Player const* player = unit->ToPlayer()) + { return !player->isGameMaster(); + } return true; case DISABLE_TYPE_BATTLEGROUND: case DISABLE_TYPE_OUTDOORPVP: diff --git a/src/game/WorldHandlers/DuelHandler.cpp b/src/game/WorldHandlers/DuelHandler.cpp index c3156da80..f1ff8ed25 100644 --- a/src/game/WorldHandlers/DuelHandler.cpp +++ b/src/game/WorldHandlers/DuelHandler.cpp @@ -36,13 +36,17 @@ void WorldSession::HandleDuelAcceptedOpcode(WorldPacket& recvPacket) recvPacket >> guid; if (!GetPlayer()->duel) // ignore accept from duel-sender + { return; + } Player* pl = GetPlayer(); Player* plTarget = pl->duel->opponent; if (pl == pl->duel->initiator || !plTarget || pl == plTarget || pl->duel->startTime != 0 || plTarget->duel->startTime != 0) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "WORLD: received CMSG_DUEL_ACCEPTED"); DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "Player 1 is: %u (%s)", pl->GetGUIDLow(), pl->GetName()); @@ -62,7 +66,9 @@ void WorldSession::HandleDuelCancelledOpcode(WorldPacket& recvPacket) // no duel requested if (!GetPlayer()->duel) + { return; + } // player surrendered in a duel using /forfeit if (GetPlayer()->duel->startTime != 0) diff --git a/src/game/WorldHandlers/GameEventMgr.cpp b/src/game/WorldHandlers/GameEventMgr.cpp index 39cae638e..85b1c83ec 100644 --- a/src/game/WorldHandlers/GameEventMgr.cpp +++ b/src/game/WorldHandlers/GameEventMgr.cpp @@ -49,7 +49,9 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry, time_t currenttime) const ((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE)) < (mGameEvent[entry].length * MINUTE)) return true; else + { return false; + } } uint32 GameEventMgr::NextCheck(uint16 entry) const @@ -58,11 +60,15 @@ uint32 GameEventMgr::NextCheck(uint16 entry) const // outdated event: we return max if (currenttime > mGameEvent[entry].end) + { return max_ge_check_delay; + } // never started event, we return delay before start if (mGameEvent[entry].start > currenttime) + { return uint32(mGameEvent[entry].start - currenttime); + } uint32 delay; // in event, we return the end of it @@ -73,9 +79,13 @@ uint32 GameEventMgr::NextCheck(uint16 entry) const delay = (mGameEvent[entry].occurence * MINUTE) - ((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE)); // In case the end is before next check if (mGameEvent[entry].end < time_t(currenttime + delay)) + { return uint32(mGameEvent[entry].end - currenttime); + } else + { return delay; + } } void GameEventMgr::StartEvent(uint16 event_id, bool overwrite /*=false*/, bool resume /*=false*/) @@ -884,11 +894,15 @@ GameEventCreatureData const* GameEventMgr::GetCreatureUpdateDataForActiveEvent(u } if (!event_id) + { return NULL; + } for (GameEventCreatureDataList::const_iterator itr = mGameEventCreatureData[event_id].begin(); itr != mGameEventCreatureData[event_id].end(); ++itr) if (itr->first == lowguid) + { return &itr->second; + } return NULL; } @@ -1020,7 +1034,9 @@ int16 GameEventMgr::GetGameEventId(uint32 guid_or_poolid) for (uint16 i = 0; i < mGameEventSpawnPoolIds.size(); ++i) for (IdList::const_iterator itr = mGameEventSpawnPoolIds[i].begin(); itr != mGameEventSpawnPoolIds[i].end(); ++itr) if (*itr == guid_or_poolid) + { return i; + } return 0; } @@ -1032,11 +1048,15 @@ GameEventMgr::GameEventMgr() bool GameEventMgr::IsActiveHoliday(HolidayIds id) { if (id == HOLIDAY_NONE) + { return false; + } for (GameEventMgr::ActiveEvents::const_iterator itr = m_ActiveEvents.begin(); itr != m_ActiveEvents.end(); ++itr) if (mGameEvent[*itr].holiday_id == id) + { return true; + } return false; } diff --git a/src/game/WorldHandlers/GossipDef.cpp b/src/game/WorldHandlers/GossipDef.cpp index cc1b9b29e..d20455c46 100644 --- a/src/game/WorldHandlers/GossipDef.cpp +++ b/src/game/WorldHandlers/GossipDef.cpp @@ -97,7 +97,9 @@ void GossipMenu::AddMenuItem(uint8 Icon, int32 itemText, uint32 dtSender, uint32 uint32 GossipMenu::MenuItemSender(unsigned int ItemId) { if (ItemId >= m_gItems.size()) + { return 0; + } return m_gItems[ ItemId ].m_gSender; } @@ -105,7 +107,9 @@ uint32 GossipMenu::MenuItemSender(unsigned int ItemId) uint32 GossipMenu::MenuItemAction(unsigned int ItemId) { if (ItemId >= m_gItems.size()) + { return 0; + } return m_gItems[ ItemId ].m_gOptionId; } @@ -113,7 +117,9 @@ uint32 GossipMenu::MenuItemAction(unsigned int ItemId) bool GossipMenu::MenuItemCoded(unsigned int ItemId) { if (ItemId >= m_gItems.size()) + { return 0; + } return m_gItems[ ItemId ].m_gCoded; } @@ -356,7 +362,9 @@ void QuestMenu::AddMenuItem(uint32 QuestId, uint8 Icon) { Quest const* qinfo = sObjectMgr.GetQuestTemplate(QuestId); if (!qinfo) + { return; + } MANGOS_ASSERT(m_qItems.size() <= GOSSIP_MAX_MENU_ITEMS); @@ -372,7 +380,9 @@ bool QuestMenu::HasItem(uint32 questid) { for (QuestMenuItemList::const_iterator i = m_qItems.begin(); i != m_qItems.end(); ++i) if (i->m_qId == questid) + { return true; + } return false; } diff --git a/src/game/WorldHandlers/GridDefines.h b/src/game/WorldHandlers/GridDefines.h index 5df852373..91338f771 100644 --- a/src/game/WorldHandlers/GridDefines.h +++ b/src/game/WorldHandlers/GridDefines.h @@ -101,7 +101,9 @@ struct CoordPair x_coord -= val; } else - { x_coord = 0; } + { + x_coord = 0; + } } void operator>>(const uint32 val) @@ -111,7 +113,9 @@ struct CoordPair x_coord += val; } else - { x_coord = LIMIT - 1; } + { + x_coord = LIMIT - 1; + } } void operator-=(const uint32 val) @@ -121,7 +125,9 @@ struct CoordPair y_coord -= val; } else - { y_coord = 0; } + { + y_coord = 0; + } } void operator+=(const uint32 val) @@ -131,7 +137,9 @@ struct CoordPair y_coord += val; } else - { y_coord = LIMIT - 1; } + { + y_coord = LIMIT - 1; + } } CoordPair& normalize() @@ -179,7 +187,9 @@ namespace MaNGOS c = MAP_HALFSIZE - 0.5; } else if (c < -(MAP_HALFSIZE - 0.5)) - { c = -(MAP_HALFSIZE - 0.5); } + { + c = -(MAP_HALFSIZE - 0.5); + } } inline bool IsValidMapCoord(float c) diff --git a/src/game/WorldHandlers/GridMap.cpp b/src/game/WorldHandlers/GridMap.cpp index c6ff60b6b..254908ae7 100644 --- a/src/game/WorldHandlers/GridMap.cpp +++ b/src/game/WorldHandlers/GridMap.cpp @@ -88,7 +88,9 @@ bool GridMap::loadData(char* filename) // Not return error if file not found FILE* in = fopen(filename, "rb"); if (!in) + { return true; + } fread(&header, sizeof(header), 1, in); if (header.mapMagic == *((uint32 const*)(MAP_MAGIC)) && @@ -152,7 +154,9 @@ bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/) fseek(in, offset, SEEK_SET); fread(&header, sizeof(header), 1, in); if (header.fourcc != *((uint32 const*)(MAP_AREA_MAGIC))) + { return false; + } m_gridArea = header.gridArea; if (!(header.flags & MAP_AREA_NO_AREA)) @@ -170,7 +174,9 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/) fseek(in, offset, SEEK_SET); fread(&header, sizeof(header), 1, in); if (header.fourcc != *((uint32 const*)(MAP_HEIGHT_MAGIC))) + { return false; + } m_gridHeight = header.gridHeight; if (!(header.flags & MAP_HEIGHT_NO_HEIGHT)) @@ -211,10 +217,14 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/) bool GridMap::loadHolesData(FILE* in, uint32 offset, uint32 size) { if (fseek(in, offset, SEEK_SET) != 0) + { return false; + } if (fread(&m_holes, sizeof(m_holes), 1, in) != 1) + { return false; + } return true; } @@ -224,7 +234,9 @@ bool GridMap::loadGridMapLiquidData(FILE* in, uint32 offset, uint32 /*size*/) fseek(in, offset, SEEK_SET); fread(&header, sizeof(header), 1, in); if (header.fourcc != *((uint32 const*)(MAP_LIQUID_MAGIC))) + { return false; + } m_liquidType = header.liquidType; m_liquid_offX = header.offsetX; @@ -254,7 +266,9 @@ bool GridMap::loadGridMapLiquidData(FILE* in, uint32 offset, uint32 /*size*/) uint16 GridMap::getArea(float x, float y) { if (!m_area_map) + { return m_gridArea; + } x = 16 * (32 - x / SIZE_OF_GRIDS); y = 16 * (32 - y / SIZE_OF_GRIDS); @@ -283,7 +297,9 @@ bool GridMap::isHole(int row, int col) const float GridMap::getHeightFromFloat(float x, float y) const { if (!m_V8 || !m_V9) + { return INVALID_HEIGHT_VALUE; + } x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); @@ -296,7 +312,9 @@ float GridMap::getHeightFromFloat(float x, float y) const y_int &= (MAP_RESOLUTION - 1); if (isHole(x_int, y_int)) + { return INVALID_HEIGHT_VALUE; + } // Height stored as: h5 - its v8 grid, h1-h4 - its v9 grid // +--------------> X @@ -368,7 +386,9 @@ float GridMap::getHeightFromFloat(float x, float y) const float GridMap::getHeightFromUint8(float x, float y) const { if (!m_uint8_V8 || !m_uint8_V9) + { return m_gridHeight; + } x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); @@ -436,7 +456,9 @@ float GridMap::getHeightFromUint8(float x, float y) const float GridMap::getHeightFromUint16(float x, float y) const { if (!m_uint16_V8 || !m_uint16_V9) + { return m_gridHeight; + } x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); @@ -504,7 +526,9 @@ float GridMap::getHeightFromUint16(float x, float y) const float GridMap::getLiquidLevel(float x, float y) { if (!m_liquid_map) + { return m_liquidLevel; + } x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); @@ -513,10 +537,14 @@ float GridMap::getLiquidLevel(float x, float y) int cy_int = ((int)y & (MAP_RESOLUTION - 1)) - m_liquid_offX; if (cx_int < 0 || cx_int >= m_liquid_height) + { return INVALID_HEIGHT_VALUE; + } if (cy_int < 0 || cy_int >= m_liquid_width) + { return INVALID_HEIGHT_VALUE; + } return m_liquid_map[cx_int * m_liquid_width + cy_int]; } @@ -524,7 +552,9 @@ float GridMap::getLiquidLevel(float x, float y) uint8 GridMap::getTerrainType(float x, float y) { if (!m_liquidFlags) + { return (uint8)m_liquidType; + } x = 16 * (32 - x / SIZE_OF_GRIDS); y = 16 * (32 - y / SIZE_OF_GRIDS); @@ -538,7 +568,9 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re { // Check water type (if no water return) if (!m_liquidFlags && !m_liquidType) + { return LIQUID_MAP_NO_WATER; + } // Get cell float cx = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); @@ -585,21 +617,29 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re } if (type == 0) + { return LIQUID_MAP_NO_WATER; + } // Check req liquid type mask if (ReqLiquidType && !(ReqLiquidType & type)) + { return LIQUID_MAP_NO_WATER; + } // Check water level: // Check water height map int lx_int = x_int - m_liquid_offY; if (lx_int < 0 || lx_int >= m_liquid_height) + { return LIQUID_MAP_NO_WATER; + } int ly_int = y_int - m_liquid_offX; if (ly_int < 0 || ly_int >= m_liquid_width) + { return LIQUID_MAP_NO_WATER; + } // Get water level float liquid_level = m_liquid_map ? m_liquid_map[lx_int * m_liquid_width + ly_int] : m_liquidLevel; @@ -609,7 +649,9 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re // Check water level and ground level if (liquid_level < ground_level || z < ground_level - 2) + { return LIQUID_MAP_NO_WATER; + } // All ok in water -> store data if (data) @@ -625,13 +667,19 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re // Get position delta if (delta > 20) // Under water + { return LIQUID_MAP_UNDER_WATER; + } if (delta > 0) // In water + { return LIQUID_MAP_IN_WATER; + } if (delta > -1) // Walk on water + { return LIQUID_MAP_WATER_WALK; + } // Above water return LIQUID_MAP_ABOVE_WATER; } @@ -756,7 +804,9 @@ void TerrainInfo::CleanUpGrids(const uint32 diff) { i_timer.Update(diff); if (!i_timer.Passed()) + { return; + } for (int y = 0; y < MAX_NUMBER_OF_GRIDS; ++y) { @@ -803,7 +853,9 @@ int TerrainInfo::UnrefGrid(const uint32& x, const uint32& y) LOCK_GUARD _lock(m_refMutex); if (iRef > 0) + { return (iRef -= 1); + } return 0; } @@ -853,7 +905,9 @@ float TerrainInfo::GetHeightStatic(float x, float y, float z, bool useVmaps/*=tr // we are already under the surface or vmap height above map heigt if (z < mapHeight || vmapHeight > mapHeight) + { return vmapHeight; + } else return mapHeight; // better use .map surface height } @@ -872,9 +926,13 @@ inline bool IsOutdoorWMO(uint32 mogpFlags, int32 adtId, int32 rootId, int32 grou if (wmoEntry && atEntry) { if (atEntry->flags & AREA_FLAG_OUTSIDE) + { return true; + } if (atEntry->flags & AREA_FLAG_INSIDE) + { return false; + } } outdoor = mogpFlags & 0x8; @@ -882,7 +940,9 @@ inline bool IsOutdoorWMO(uint32 mogpFlags, int32 adtId, int32 rootId, int32 grou if (wmoEntry) { if (wmoEntry->Flags & 4) + { return true; + } if ((wmoEntry->Flags & 2) != 0) outdoor = false; @@ -897,7 +957,9 @@ bool TerrainInfo::IsOutdoors(float x, float y, float z) const // no wmo found? -> outside by default if (!GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId)) + { return true; + } AreaTableEntry const* atEntry = 0; WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); @@ -923,7 +985,9 @@ bool TerrainInfo::GetAreaInfo(float x, float y, float z, uint32& flags, int32& a float _mapheight = gmap->getHeight(x, y); // z + 2.0f condition taken from GetHeightStatic(), not sure if it's such a great choice... if (z + 2.0f > _mapheight && _mapheight > vmap_z) + { return false; + } } return true; } @@ -971,9 +1035,13 @@ uint16 TerrainInfo::GetAreaFlag(float x, float y, float z, bool* isOutdoors) con uint8 TerrainInfo::GetTerrainType(float x, float y) const { if (GridMap* gmap = const_cast(this)->GetGrid(x, y)) + { return gmap->getTerrainType(x, y); + } else + { return 0; + } } uint32 TerrainInfo::GetAreaId(float x, float y, float z) const @@ -1048,11 +1116,17 @@ GridMapLiquidStatus TerrainInfo::getLiquidStatus(float x, float y, float z, uint // Get position delta if (delta > 20) // Under water + { return LIQUID_MAP_UNDER_WATER; + } if (delta > 0) // In water + { return LIQUID_MAP_IN_WATER; + } if (delta > -1) // Walk on water + { return LIQUID_MAP_WATER_WALK; + } result = LIQUID_MAP_ABOVE_WATER; } } @@ -1103,7 +1177,9 @@ bool TerrainInfo::IsSwimmable(float x, float y, float pZ, float radius /*= 1.5f* if (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr)) { if (liquid_ptr->level - liquid_ptr->depth_level > radius) // is unit have enough space to swim - return true; + { + return true; + } } } return false; @@ -1114,7 +1190,9 @@ bool TerrainInfo::IsUnderWater(float x, float y, float z) const if (const_cast(this)->GetGrid(x, y)) { if (getLiquidStatus(x, y, z, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)&LIQUID_MAP_UNDER_WATER) + { return true; + } } return false; } @@ -1228,7 +1306,9 @@ float TerrainInfo::GetWaterLevel(float x, float y, float z, float* pGround /*= N GridMapLiquidStatus res = getLiquidStatus(x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status); if (!res) + { return VMAP_INVALID_HEIGHT_VALUE; + } return liquid_status.level; } @@ -1272,7 +1352,9 @@ TerrainInfo* TerrainManager::LoadTerrain(const uint32 mapId) void TerrainManager::UnloadTerrain(const uint32 mapId) { if (sWorld.getConfig(CONFIG_BOOL_GRID_UNLOAD) == 0) + { return; + } Guard _guard(*this); @@ -1309,9 +1391,13 @@ uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag, uint32 map_id) AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id); if (entry) + { return entry->ID; + } else + { return 0; + } } uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag, uint32 map_id) @@ -1319,9 +1405,13 @@ uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag, uint32 map_id) AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id); if (entry) + { return (entry->zone != 0) ? entry->zone : entry->ID; + } else + { return 0; + } } void TerrainManager::GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag, uint32 map_id) diff --git a/src/game/WorldHandlers/GridNotifiers.cpp b/src/game/WorldHandlers/GridNotifiers.cpp index 1e694807c..e4c530493 100644 --- a/src/game/WorldHandlers/GridNotifiers.cpp +++ b/src/game/WorldHandlers/GridNotifiers.cpp @@ -193,15 +193,21 @@ bool CannibalizeObjectCheck::operator()(Corpse* u) { // ignore bones if (u->GetType() == CORPSE_BONES) + { return false; + } Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGuid()); if (!owner || i_fobj->IsFriendlyTo(owner)) + { return false; + } if (i_fobj->IsWithinDistInMap(u, i_range)) + { return true; + } return false; } @@ -214,7 +220,9 @@ void MaNGOS::RespawnDo::operator()(Creature* u) const { BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(u->GetGUIDLow()); if (!((BattleGroundMap*)map)->GetBG()->IsActiveEvent(eventId.event1, eventId.event2)) + { return; + } } u->Respawn(); @@ -228,7 +236,9 @@ void MaNGOS::RespawnDo::operator()(GameObject* u) const { BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(u->GetGUIDLow()); if (!((BattleGroundMap*)map)->GetBG()->IsActiveEvent(eventId.event1, eventId.event2)) + { return; + } } u->Respawn(); @@ -237,18 +247,26 @@ void MaNGOS::RespawnDo::operator()(GameObject* u) const void MaNGOS::CallOfHelpCreatureInRangeDo::operator()(Creature* u) { if (u == i_funit) + { return; + } if (!u->CanAssistTo(i_funit, i_enemy, false)) + { return; + } // too far if (!i_funit->IsWithinDistInMap(u, i_range)) + { return; + } // only if see assisted creature if (!i_funit->IsWithinLOSInMap(u)) + { return; + } if (u->AI()) u->AI()->AttackStart(i_enemy); @@ -257,18 +275,26 @@ void MaNGOS::CallOfHelpCreatureInRangeDo::operator()(Creature* u) bool MaNGOS::AnyAssistCreatureInRangeCheck::operator()(Creature* u) { if (u == i_funit) + { return false; + } if (!u->CanAssistTo(i_funit, i_enemy)) + { return false; + } // too far if (!i_funit->IsWithinDistInMap(u, i_range)) + { return false; + } // only if see assisted creature if (!i_funit->IsWithinLOSInMap(u)) + { return false; + } return true; } diff --git a/src/game/WorldHandlers/GridNotifiers.h b/src/game/WorldHandlers/GridNotifiers.h index af19fbacc..1cf80b96f 100644 --- a/src/game/WorldHandlers/GridNotifiers.h +++ b/src/game/WorldHandlers/GridNotifiers.h @@ -641,7 +641,9 @@ namespace MaNGOS bool operator()(Player* u) { if (i_fobj->IsFriendlyTo(u) || u->IsAlive() || u->IsTaxiFlying()) + { return false; + } return i_fobj->IsWithinDistInMap(u, i_range); } @@ -683,10 +685,14 @@ namespace MaNGOS { GameObjectInfo const* goInfo = go->GetGOInfo(); if (goInfo->type != GAMEOBJECT_TYPE_SPELL_FOCUS) + { return false; + } if (goInfo->spellFocus.focusId != i_focusId) + { return false; + } float dist = (float)goInfo->spellFocus.dist; @@ -791,7 +797,9 @@ namespace MaNGOS bool operator()(GameObject* go) { if (go->GetEntry() == i_entry && go->IsWithinDist3d(i_x, i_y, i_z, i_range)) + { return true; + } return false; } @@ -915,7 +923,9 @@ namespace MaNGOS && i_obj->IsWithinDistInMap(u, i_range)) return true; else + { return false; + } } private: WorldObject const* i_obj; @@ -950,9 +960,13 @@ namespace MaNGOS bool operator()(Unit* u) { if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_obj->IsFriendlyTo(u)) + { return true; + } else + { return false; + } } private: WorldObject const* i_obj; @@ -967,7 +981,9 @@ namespace MaNGOS bool operator()(Unit* u) { if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range)) + { return true; + } return false; } @@ -1016,18 +1032,26 @@ namespace MaNGOS { // Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems if (!u->IsTargetableForAttack()) + { return false; + } // ignore totems as AoE targets if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsTotem()) + { return false; + } // check visibility only for unit-like original casters if (i_targetForUnit && !u->IsVisibleForOrDetect((Unit const*)i_originalCaster, i_originalCaster, false)) + { return false; + } if ((i_targetForPlayer ? !i_originalCaster->IsFriendlyTo(u) : i_originalCaster->IsHostileTo(u)) && i_obj->IsWithinDistInMap(u, i_range)) + { return true; + } return false; } @@ -1052,13 +1076,19 @@ namespace MaNGOS { // 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()) + { return false; + } if ((i_targetForPlayer ? !i_obj->IsFriendlyTo(u) : i_obj->IsHostileTo(u)) && i_obj->IsWithinDistInMap(u, i_range)) + { return true; + } return false; } @@ -1114,7 +1144,9 @@ namespace MaNGOS bool operator()(Creature* u) { if (u->IsAlive() && u->IsHostileTo(i_funit) && i_funit->IsWithinDistInMap(u, u->GetAttackDistance(i_funit))) + { return true; + } return false; } @@ -1147,15 +1179,23 @@ namespace MaNGOS bool operator()(Creature* u) { if (u == i_obj) + { return false; + } if (!u->CanAssistTo(i_obj, i_enemy)) + { return false; + } if (!i_obj->IsWithinDistInMap(u, i_range)) + { return false; + } if (!i_obj->IsWithinLOSInMap(u)) + { return false; + } i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check return true; @@ -1208,7 +1248,9 @@ namespace MaNGOS bool operator()(Unit* pUnit) { if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit, m_fRange, false)) + { return true; + } return false; } @@ -1232,7 +1274,9 @@ namespace MaNGOS bool operator()(Player* u) { if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range)) + { return true; + } return false; } diff --git a/src/game/WorldHandlers/GridNotifiersImpl.h b/src/game/WorldHandlers/GridNotifiersImpl.h index ea5bea67c..5ca08bba6 100644 --- a/src/game/WorldHandlers/GridNotifiersImpl.h +++ b/src/game/WorldHandlers/GridNotifiersImpl.h @@ -82,7 +82,9 @@ inline void CreatureCreatureRelocationWorker(Creature* c1, Creature* c2) inline void MaNGOS::PlayerRelocationNotifier::Visit(CreatureMapType& m) { if (!i_player.IsAlive() || i_player.IsTaxiFlying()) + { return; + } for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { @@ -96,7 +98,9 @@ template<> inline void MaNGOS::CreatureRelocationNotifier::Visit(PlayerMapType& m) { if (!i_creature.IsAlive()) + { return; + } for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { @@ -110,7 +114,9 @@ template<> inline void MaNGOS::CreatureRelocationNotifier::Visit(CreatureMapType& m) { if (!i_creature.IsAlive()) + { return; + } for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { @@ -123,47 +129,67 @@ inline void MaNGOS::CreatureRelocationNotifier::Visit(CreatureMapType& m) inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) { if (!target->IsAlive() || target->IsTaxiFlying()) + { return; + } if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->IsTotem()) + { return; + } if (!i_dynobject.IsWithinDistInMap(target, i_dynobject.GetRadius())) + { return; + } // Check targets for not_selectable unit flag and remove if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_OOC_NOT_ATTACKABLE)) + { return; + } // Evade target 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) if (target->GetTypeId() == TYPEID_PLAYER && target != i_check && (((Player*)target)->isGameMaster() || ((Player*)target)->GetVisibility() == VISIBILITY_OFF)) + { return; + } // for player casts use less strict negative and more stricted positive targeting if (i_check->GetTypeId() == TYPEID_PLAYER) { if (i_check->IsFriendlyTo(target) != i_positive) + { return; + } } else { if (i_check->IsHostileTo(target) == i_positive) + { return; + } } if (i_dynobject.IsAffecting(target)) + { return; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId()); SpellEffectIndex eff_index = i_dynobject.GetEffIndex(); // Check target immune to spell or aura if (target->IsImmuneToSpell(spellInfo, false) || target->IsImmuneToSpellEffect(spellInfo, eff_index, false)) + { return; + } // Apply PersistentAreaAura on target // in case 2 dynobject overlap areas for same spell, same holder is selected, so dynobjects share holder @@ -220,7 +246,9 @@ void MaNGOS::WorldObjectSearcher::Visit(GameObjectMapType& m) { // already found if (i_object) + { return; + } for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -240,7 +268,9 @@ void MaNGOS::WorldObjectSearcher::Visit(PlayerMapType& m) { // already found if (i_object) + { return; + } for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -260,7 +290,9 @@ void MaNGOS::WorldObjectSearcher::Visit(CreatureMapType& m) { // already found if (i_object) + { return; + } for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -280,7 +312,9 @@ void MaNGOS::WorldObjectSearcher::Visit(CorpseMapType& m) { // already found if (i_object) + { return; + } for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -300,7 +334,9 @@ void MaNGOS::WorldObjectSearcher::Visit(DynamicObjectMapType& m) { // already found if (i_object) + { return; + } for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -448,7 +484,9 @@ void MaNGOS::GameObjectSearcher::Visit(GameObjectMapType& m) { // already found if (i_object) + { return; + } for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -492,7 +530,9 @@ void MaNGOS::UnitSearcher::Visit(CreatureMapType& m) { // already found if (i_object) + { return; + } for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -512,7 +552,9 @@ void MaNGOS::UnitSearcher::Visit(PlayerMapType& m) { // already found if (i_object) + { return; + } for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -578,7 +620,9 @@ void MaNGOS::CreatureSearcher::Visit(CreatureMapType& m) { // already found if (i_object) + { return; + } for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -620,7 +664,9 @@ void MaNGOS::PlayerSearcher::Visit(PlayerMapType& m) { // already found if (i_object) + { return; + } for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { diff --git a/src/game/WorldHandlers/Group.cpp b/src/game/WorldHandlers/Group.cpp index 047ac9088..1389ae75e 100644 --- a/src/game/WorldHandlers/Group.cpp +++ b/src/game/WorldHandlers/Group.cpp @@ -74,9 +74,13 @@ RollVoteMask Roll::GetVoteMaskFor(Player* player) const // In NEED_BEFORE_GREED need disabled for non-usable item for player if (m_method != NEED_BEFORE_GREED || player->CanUseItem(itemProto) == EQUIP_ERR_OK) + { return m_commonVoteMask; + } else + { return RollVoteMask(m_commonVoteMask & ~ROLL_VOTE_MASK_NEED); + } } //=================================================== @@ -169,7 +173,9 @@ bool Group::Create(ObjectGuid guid, const char* name) } if (!AddMember(guid, name)) + { return false; + } if (!isBGGroup()) CharacterDatabase.CommitTransaction(); @@ -194,7 +200,9 @@ bool Group::LoadGroupFromDB(Field* fields) // group leader not exist if (!sObjectMgr.GetPlayerNameByGUID(m_leaderGuid, m_leaderName)) + { return false; + } m_groupType = GroupType(fields[13].GetUInt8()); @@ -230,7 +238,9 @@ bool Group::LoadMemberFromDB(uint32 guidLow, uint8 subgroup, bool assistant) // skip nonexistent member if (!sObjectMgr.GetPlayerNameByGUID(member.guid, member.name)) + { return false; + } member.group = subgroup; member.assistant = assistant; @@ -260,12 +270,16 @@ void Group::ConvertToRaid() bool Group::AddInvite(Player* player) { if (!player || player->GetGroupInvite()) + { return false; + } Group* group = player->GetGroup(); if (group && group->isBGGroup()) group = player->GetOriginalGroup(); if (group) + { return false; + } RemoveInvite(player); @@ -284,7 +298,9 @@ bool Group::AddInvite(Player* player) bool Group::AddLeaderInvite(Player* player) { if (!AddInvite(player)) + { return false; + } _updateLeaderFlag(true); m_leaderGuid = player->GetObjectGuid(); @@ -313,7 +329,9 @@ Player* Group::GetInvited(ObjectGuid guid) const { for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) if ((*itr)->GetObjectGuid() == guid) + { return (*itr); + } return NULL; } @@ -323,7 +341,9 @@ Player* Group::GetInvited(const std::string& name) const for (InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) { if ((*itr)->GetName() == name) + { return (*itr); + } } return NULL; } @@ -331,7 +351,9 @@ Player* Group::GetInvited(const std::string& name) const bool Group::AddMember(ObjectGuid guid, const char* name) { if (!_addMember(guid, name)) + { return false; + } SendUpdate(); @@ -436,7 +458,9 @@ void Group::ChangeLeader(ObjectGuid guid) { member_citerator slot = _getMemberCSlot(guid); if (slot == m_memberSlots.end()) + { return; + } // Used by Eluna #ifdef ENABLE_ELUNA @@ -732,12 +756,16 @@ bool Group::CountRollVote(Player* player, ObjectGuid const& lootedTarget, uint32 break; if (rollI == RollId.end()) + { return false; + } // possible cheating RollVoteMask voteMask = (*rollI)->GetVoteMaskFor(player); if ((voteMask & (1 << vote)) == 0) + { return false; + } CountRollVote(player->GetObjectGuid(), rollI, vote); // result not related this function result meaning, ignore return true; @@ -754,7 +782,9 @@ bool Group::CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& rollI, if (roll->getLoot()) if (roll->getLoot()->items.empty()) + { return false; + } switch (vote) { @@ -802,11 +832,15 @@ bool Group::CountRollVote(ObjectGuid const& playerGUID, Rolls::iterator& rollI, void Group::StartLootRoll(WorldObject* lootTarget, LootMethod method, Loot* loot, uint8 itemSlot, uint32 maxEnchantingSkill) { if (itemSlot >= loot->items.size()) + { return; + } LootItem const& lootItem = loot->items[itemSlot]; if (lootItem.currency) + { return; + } Roll* r = new Roll(lootTarget->GetObjectGuid(), method, lootItem); @@ -1002,7 +1036,9 @@ void Group::CountTheRoll(Rolls::iterator& rollI) void Group::SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid) { if (id >= TARGET_ICON_COUNT) + { return; + } // clean other icons if (targetGuid) @@ -1064,7 +1100,9 @@ void Group::GetDataForXPAtKill(Unit const* victim, uint32& count, uint32& sum_le void Group::SendTargetIconList(WorldSession* session) { if (!session) + { return; + } WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + TARGET_ICON_COUNT * 9)); data << uint8(1); // list targets @@ -1136,10 +1174,14 @@ void Group::SendUpdate() void Group::UpdatePlayerOutOfRange(Player* pPlayer) { if (!pPlayer || !pPlayer->IsInWorld()) + { return; + } if (pPlayer->GetGroupUpdateFlag() == GROUP_UPDATE_FLAG_NONE) + { return; + } WorldPacket data; pPlayer->GetSession()->BuildPartyMemberStatsChangedPacket(pPlayer, &data); @@ -1206,7 +1248,9 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant) } // We are raid group and no one slot is free if (!groupFound) + { return false; + } } return _addMember(guid, name, isAssistant, groupid); @@ -1215,10 +1259,14 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant) bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint8 group) { if (IsFull()) + { return false; + } if (!guid) + { return false; + } Player* player = sObjectMgr.GetPlayer(guid, false); @@ -1321,7 +1369,9 @@ void Group::_setLeader(ObjectGuid guid) { member_citerator slot = _getMemberCSlot(guid); if (slot == m_memberSlots.end()) + { return; + } if (!isBGGroup()) { @@ -1417,7 +1467,9 @@ bool Group::_setMembersGroup(ObjectGuid guid, uint8 group) { member_witerator slot = _getMemberWSlot(guid); if (slot == m_memberSlots.end()) + { return false; + } slot->group = group; @@ -1433,7 +1485,9 @@ bool Group::_setAssistantFlag(ObjectGuid guid, const bool& state) { member_witerator slot = _getMemberWSlot(guid); if (slot == m_memberSlots.end()) + { return false; + } slot->assistant = state; if (!isBGGroup()) @@ -1444,13 +1498,17 @@ bool Group::_setAssistantFlag(ObjectGuid guid, const bool& state) bool Group::_setMainTank(ObjectGuid guid) { if (m_mainTankGuid == guid) + { return false; + } if (guid) { member_citerator slot = _getMemberCSlot(guid); if (slot == m_memberSlots.end()) + { return false; + } if (m_mainAssistantGuid == guid) _setMainAssistant(ObjectGuid()); @@ -1467,13 +1525,17 @@ bool Group::_setMainTank(ObjectGuid guid) bool Group::_setMainAssistant(ObjectGuid guid) { if (m_mainAssistantGuid == guid) + { return false; + } if (guid) { member_witerator slot = _getMemberWSlot(guid); if (slot == m_memberSlots.end()) + { return false; + } if (m_mainTankGuid == guid) _setMainTank(ObjectGuid()); @@ -1491,18 +1553,26 @@ bool Group::_setMainAssistant(ObjectGuid guid) bool Group::SameSubGroup(Player const* member1, Player const* member2) const { if (!member1 || !member2) + { return false; + } if (member1->GetGroup() != this || member2->GetGroup() != this) + { return false; + } else + { return member1->GetSubGroup() == member2->GetSubGroup(); + } } // allows setting subgroup for offline members void Group::ChangeMembersGroup(ObjectGuid guid, uint8 group) { if (!isRaidGroup()) + { return; + } Player* player = sObjectMgr.GetPlayer(guid); @@ -1510,7 +1580,9 @@ void Group::ChangeMembersGroup(ObjectGuid guid, uint8 group) { uint8 prevSubGroup = GetMemberGroup(guid); if (prevSubGroup == group) + { return; + } if (_setMembersGroup(guid, group)) { @@ -1527,11 +1599,15 @@ void Group::ChangeMembersGroup(ObjectGuid guid, uint8 group) void Group::ChangeMembersGroup(Player* player, uint8 group) { if (!player || !isRaidGroup()) + { return; + } uint8 prevSubGroup = player->GetSubGroup(); if (prevSubGroup == group) + { return; + } if (_setMembersGroup(player->GetObjectGuid(), group)) { @@ -1588,7 +1664,9 @@ void Group::UpdateLooterGuid(WorldObject* pSource, bool ifneed) // not update if only update if need and ok Player* looter = ObjectAccessor::FindPlayer(guid_itr->guid); if (looter && looter->IsWithinDist(pSource, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false)) + { return; + } } ++guid_itr; } @@ -1651,7 +1729,9 @@ GroupJoinBattlegroundResult Group::CanJoinBattleGroundQueue(BattleGround const* // only check for MinPlayerCount since MinPlayerCount == MaxPlayerCount for arenas... if (bgOrTemplate->isArena() && memberscount != MinPlayerCount) + { return ERR_ARENA_TEAM_PARTY_SIZE; + } if (memberscount > bgEntry->maxGroupSize) // no MinPlayerCount for battlegrounds return ERR_BATTLEGROUND_NONE; // ERR_GROUP_JOIN_BATTLEGROUND_TOO_MANY handled on client side @@ -1660,11 +1740,15 @@ GroupJoinBattlegroundResult Group::CanJoinBattleGroundQueue(BattleGround const* Player* reference = GetFirstMember()->getSource(); // no reference found, can't join this way if (!reference) + { return ERR_BATTLEGROUND_JOIN_FAILED; + } PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgOrTemplate->GetMapId(), reference->getLevel()); if (!bracketEntry) + { return ERR_BATTLEGROUND_JOIN_FAILED; + } uint32 arenaTeamId = reference->GetArenaTeamId(arenaSlot); Team team = reference->GetTeam(); @@ -1675,23 +1759,33 @@ GroupJoinBattlegroundResult Group::CanJoinBattleGroundQueue(BattleGround const* Player* member = itr->getSource(); // offline member? don't let join if (!member) + { return ERR_BATTLEGROUND_JOIN_FAILED; + } // don't allow cross-faction join as group if (member->GetTeam() != team) + { return ERR_BATTLEGROUND_JOIN_TIMED_OUT; + } // not in the same battleground level bracket, don't let join PvPDifficultyEntry const* memberBracketEntry = GetBattlegroundBracketByLevel(bracketEntry->mapId, member->getLevel()); if (memberBracketEntry != bracketEntry) + { return ERR_BATTLEGROUND_JOIN_RANGE_INDEX; + } // don't let join rated matches if the arena team id doesn't match if (isRated && member->GetArenaTeamId(arenaSlot) != arenaTeamId) + { return ERR_BATTLEGROUND_JOIN_FAILED; + } // don't let join if someone from the group is already in that bg queue if (member->InBattleGroundQueueForBattleGroundQueueType(bgQueueTypeId)) return ERR_BATTLEGROUND_JOIN_FAILED; // not blizz-like // check for deserter debuff in case not arena queue if (bgOrTemplate->GetTypeID() != BATTLEGROUND_AA && !member->CanJoinToBattleground()) + { return ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS; + } // check if member can join any more battleground queues if (!member->HasFreeBattleGroundQueueId()) return ERR_BATTLEGROUND_TOO_MANY_QUEUES; // not blizz-like @@ -1737,7 +1831,9 @@ bool Group::InCombatToInstance(uint32 instanceId) { Player* pPlayer = itr->getSource(); if (pPlayer->getAttackers().size() && pPlayer->GetInstanceId() == instanceId) + { return true; + } } return false; } @@ -1757,7 +1853,9 @@ bool Group::SetPlayerMap(ObjectGuid guid, uint32 mapid) void Group::ResetInstances(InstanceResetMethod method, bool isRaid, Player* SendMsgTo) { if (isBGGroup()) + { return; + } // method can be INSTANCE_RESET_ALL, INSTANCE_RESET_CHANGE_DIFFICULTY, INSTANCE_RESET_GROUP_DISBAND @@ -1839,7 +1937,9 @@ InstanceGroupBind* Group::GetBoundInstance(uint32 mapid, Player* player) { MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry) + { return NULL; + } Difficulty difficulty = player->GetDifficulty(mapEntry->IsRaid()); @@ -1850,9 +1950,13 @@ InstanceGroupBind* Group::GetBoundInstance(uint32 mapid, Player* player) BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); if (itr != m_boundInstances[difficulty].end()) + { return &itr->second; + } else + { return NULL; + } } InstanceGroupBind* Group::GetBoundInstance(Map* aMap, Difficulty difficulty) @@ -1860,13 +1964,19 @@ InstanceGroupBind* Group::GetBoundInstance(Map* aMap, Difficulty difficulty) // some instances only have one difficulty MapDifficultyEntry const* mapDiff = GetMapDifficultyData(aMap->GetId(), difficulty); if (!mapDiff) + { return NULL; + } BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(aMap->GetId()); if (itr != m_boundInstances[difficulty].end()) + { return &itr->second; + } else + { return NULL; + } } InstanceGroupBind* Group::BindToInstance(DungeonPersistentState* state, bool permanent, bool load) @@ -1901,7 +2011,9 @@ InstanceGroupBind* Group::BindToInstance(DungeonPersistentState* state, bool per return &bind; } else + { return NULL; + } } void Group::UnbindInstance(uint32 mapid, uint8 difficulty, bool unload) diff --git a/src/game/WorldHandlers/Group.h b/src/game/WorldHandlers/Group.h index a9e853497..4d58e0197 100644 --- a/src/game/WorldHandlers/Group.h +++ b/src/game/WorldHandlers/Group.h @@ -280,7 +280,9 @@ class Group { for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) if (itr->name == name) + { return itr->guid; + } return ObjectGuid(); } @@ -288,7 +290,9 @@ class Group { member_citerator mslot = _getMemberCSlot(guid); if (mslot == m_memberSlots.end()) + { return false; + } return mslot->assistant; } @@ -311,7 +315,9 @@ class Group { member_citerator mslot = _getMemberCSlot(guid); if (mslot == m_memberSlots.end()) + { return MAX_RAID_SUBGROUPS + 1; + } return mslot->group; } @@ -331,14 +337,18 @@ class Group void SetAssistant(ObjectGuid guid, bool state) { if (!isRaidGroup()) + { return; + } if (_setAssistantFlag(guid, state)) SendUpdate(); } void SetMainTank(ObjectGuid guid) { if (!isRaidGroup()) + { return; + } if (_setMainTank(guid)) SendUpdate(); @@ -346,7 +356,9 @@ class Group void SetMainAssistant(ObjectGuid guid) { if (!isRaidGroup()) + { return; + } if (_setMainAssistant(guid)) SendUpdate(); @@ -432,7 +444,9 @@ class Group { for (member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) if (itr->guid == guid) + { return itr; + } return m_memberSlots.end(); } @@ -441,7 +455,9 @@ class Group { for (member_witerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr) if (itr->guid == guid) + { return itr; + } return m_memberSlots.end(); } diff --git a/src/game/WorldHandlers/GroupHandler.cpp b/src/game/WorldHandlers/GroupHandler.cpp index ec2fac370..3371f0747 100644 --- a/src/game/WorldHandlers/GroupHandler.cpp +++ b/src/game/WorldHandlers/GroupHandler.cpp @@ -235,7 +235,9 @@ void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroupInvite(); if (!group) + { return; + } if (accepted) { @@ -269,12 +271,16 @@ void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recv_data) if (group->Create(group->GetLeaderGuid(), group->GetLeaderName())) sObjectMgr.AddGroup(group); else + { return; + } } // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!! if (!group->AddMember(GetPlayer()->GetObjectGuid(), GetPlayer()->GetName())) + { return; + } } else { @@ -284,7 +290,9 @@ void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recv_data) // remember leader if online Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid()); if (!leader || !leader->GetSession()) + { return; + } // report WorldPacket data(SMSG_GROUP_DECLINE, 10); // guess size @@ -315,7 +323,9 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket& recv_data) Group* grp = GetPlayer()->GetGroup(); if (!grp) + { return; + } if (grp->IsMember(guid)) { @@ -339,7 +349,9 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recv_data) // player not found if (!normalizePlayerName(membername)) + { return; + } // can't uninvite yourself if (GetPlayer()->GetName() == membername) @@ -357,7 +369,9 @@ void WorldSession::HandleGroupUninviteOpcode(WorldPacket& recv_data) Group* grp = GetPlayer()->GetGroup(); if (!grp) + { return; + } if (ObjectGuid guid = grp->GetMemberGuid(membername)) { @@ -381,13 +395,17 @@ void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } Player* player = sObjectMgr.GetPlayer(guid); /** error handling **/ if (!player || !group->IsLeader(GetPlayer()->GetObjectGuid()) || player->GetGroup() != group) + { return; + } /********************/ // everything is fine, do it @@ -397,7 +415,9 @@ void WorldSession::HandleGroupSetLeaderOpcode(WorldPacket& recv_data) void WorldSession::HandleGroupDisbandOpcode(WorldPacket& /*recv_data*/) { if (!GetPlayer()->GetGroup()) + { return; + } if (_player->InBattleGround()) { @@ -423,11 +443,15 @@ void WorldSession::HandleLootMethodOpcode(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } /** error handling **/ if (!group->IsLeader(GetPlayer()->GetObjectGuid())) + { return; + } /********************/ // everything is fine, do it @@ -450,14 +474,20 @@ void WorldSession::HandleLootRoll(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } if (rollType >= MAX_ROLL_FROM_CLIENT) + { return; + } // everything is fine, do it, if false then some cheating problem found if (!group->CountRollVote(GetPlayer(), lootedTarget, itemSlot, RollVote(rollType))) + { return; + } switch (rollType) { @@ -478,7 +508,9 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) recv_data >> y; if (!GetPlayer()->GetGroup()) + { return; + } // DEBUG_LOG("Received opcode MSG_MINIMAP_PING X: %f, Y: %f", x, y); @@ -501,7 +533,9 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) /** error handling **/ if (minimum > maximum || maximum > 10000) // < 32768 for urand call + { return; + } /********************/ // everything is fine, do it @@ -527,7 +561,9 @@ void WorldSession::HandleRaidTargetUpdateOpcode(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } /** error handling **/ /********************/ @@ -554,14 +590,20 @@ void WorldSession::HandleGroupRaidConvertOpcode(WorldPacket& /*recv_data*/) { Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } if (_player->InBattleGround()) + { return; + } /** error handling **/ if (!group->IsLeader(GetPlayer()->GetObjectGuid()) || group->GetMembersCount() < 2) + { return; + } /********************/ // everything is fine, do it (is it 0 (PARTY_OP_INVITE) correct code) @@ -578,12 +620,16 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recv_data) recv_data >> groupNr; if (groupNr >= MAX_RAID_SUBGROUPS) + { return; + } // we will get correct pointer for group here, so we don't have to check if group is BG raid Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } /** error handling **/ if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && @@ -591,7 +637,9 @@ void WorldSession::HandleGroupChangeSubGroupOpcode(WorldPacket& recv_data) return; if (!group->HasFreeSlotSubGroup(groupNr)) + { return; + } /********************/ // everything is fine, do it @@ -613,11 +661,15 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } /** error handling **/ if (!group->IsLeader(GetPlayer()->GetObjectGuid())) + { return; + } /********************/ // everything is fine, do it @@ -636,11 +688,15 @@ void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } /** error handling **/ if (!group->IsLeader(GetPlayer()->GetObjectGuid())) + { return; + } /********************/ // everything is fine, do it @@ -668,7 +724,9 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recv_data) { Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } /** error handling **/ if (!group->IsLeader(GetPlayer()->GetObjectGuid()) && @@ -690,7 +748,9 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recv_data) Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } // everything is fine, do it WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9); @@ -791,7 +851,9 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke *data << int32(aura->GetModifier()->m_amount); } else - { *data << int32(0); } + { + *data << int32(0); + } } } } @@ -890,7 +952,9 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke *data << int32(aura->GetModifier()->m_amount); } else - { *data << int32(0); } + { + *data << int32(0); + } } } } @@ -1026,7 +1090,9 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data) data << int32(aura->GetModifier()->m_amount); } else - { data << int32(0); } + { + data << int32(0); + } } } } @@ -1067,7 +1133,9 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data) data << int32(aura->GetModifier()->m_amount); } else - { data << int32(0); } + { + data << int32(0); + } } } } @@ -1131,7 +1199,9 @@ void WorldSession::HandleGroupRequestJoinUpdates(WorldPacket& recv_data) { Group* group = GetPlayer()->GetGroup(); if (!group) + { return; + } WorldPacket data(SMSG_REAL_GROUP_UPDATE, 1 + 4 + 8); data << uint8(group->GetGroupType()); diff --git a/src/game/WorldHandlers/GuildHandler.cpp b/src/game/WorldHandlers/GuildHandler.cpp index d07592a8b..0009d658a 100644 --- a/src/game/WorldHandlers/GuildHandler.cpp +++ b/src/game/WorldHandlers/GuildHandler.cpp @@ -65,7 +65,9 @@ void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket) recvPacket >> gname; if (GetPlayer()->GetGuildId()) // already in guild + { return; + } Guild* guild = new Guild; if (!guild->Create(GetPlayer(), gname)) @@ -115,7 +117,9 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) // OK result but not send invite if (player->GetSocial()->HasIgnore(GetPlayer()->GetObjectGuid())) + { return; + } // not let enemies sign guild charter if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != GetPlayer()->GetTeam()) @@ -222,7 +226,9 @@ void WorldSession::HandleGuildRemoveOpcode(WorldPacket& recvPacket) } if (!sObjectMgr.GetPlayerNameByGUID(targetGuid, plName)) + { return; + } MemberSlot* slot = guild->GetMemberSlot(targetGuid); if (!slot) @@ -274,14 +280,20 @@ void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/) guild = sGuildMgr.GetGuildById(player->GetGuildIdInvited()); if (!guild || player->GetGuildId()) + { return; + } // not let enemies sign guild charter if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(guild->GetLeaderGuid())) + { return; + } if (!guild->AddMember(GetPlayer()->GetObjectGuid(), guild->GetLowestRank())) + { return; + } // Put record into guild log guild->LogGuildEvent(GUILD_EVENT_LOG_JOIN_GUILD, GetPlayer()->GetObjectGuid()); @@ -376,7 +388,9 @@ void WorldSession::HandleGuildPromoteOpcode(WorldPacket& recvPacket) } if (!sObjectMgr.GetPlayerNameByGUID(targetGuid, plName)) + { return; + } MemberSlot* slot = guild->GetMemberSlot(targetGuid); if (!slot) @@ -433,7 +447,9 @@ void WorldSession::HandleGuildDemoteOpcode(WorldPacket& recvPacket) } if (!sObjectMgr.GetPlayerNameByGUID(targetGuid, plName)) + { return; + } MemberSlot* slot = guild->GetMemberSlot(targetGuid); if (!slot) @@ -507,7 +523,9 @@ void WorldSession::HandleGuildSetRankOpcode(WorldPacket& recvPacket) } if (!sObjectMgr.GetPlayerNameByGUID(targetGuid, plName)) + { return; + } MemberSlot* slot = guild->GetMemberSlot(targetGuid); if (!slot) @@ -523,7 +541,9 @@ void WorldSession::HandleGuildSetRankOpcode(WorldPacket& recvPacket) } if (slot->RankId == newRankId || newRankId >= guild->GetRanksSize()) + { return; + } bool promote = newRankId < slot->RankId; if (!guild->HasRankRight(GetPlayer()->GetRank(), promote ? GR_RIGHT_PROMOTE : GR_RIGHT_DEMOTE)) @@ -676,7 +696,9 @@ void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket) Player* oldLeader = GetPlayer(); if (!normalizePlayerName(name)) + { return; + } Guild* guild = sGuildMgr.GetGuildById(oldLeader->GetGuildId()); @@ -707,7 +729,9 @@ void WorldSession::HandleGuildLeaderOpcode(WorldPacket& recvPacket) } if (slot->guid == oldLeader->GetObjectGuid()) + { return; + } guild->SetLeader(slot->guid); // NOTE: GR_OFFICER might not actually be officer rank @@ -772,7 +796,9 @@ void WorldSession::HandleGuildSetNoteOpcode(WorldPacket& recvPacket) } if (!sObjectMgr.GetPlayerNameByGUID(targetGuid, name)) + { return; + } MemberSlot* slot = guild->GetMemberSlot(targetGuid); if (!slot) @@ -866,7 +892,9 @@ void WorldSession::HandleGuildAddRankOpcode(WorldPacket& recvPacket) } if (guild->GetRanksSize() >= GUILD_RANKS_MAX_COUNT) // client not let create more 10 than ranks + { return; + } guild->CreateRank(rankname, GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); @@ -1053,7 +1081,9 @@ void WorldSession::HandleGuildBankerActivate(WorldPacket& recv_data) recv_data >> goGuid >> unk; if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + { return; + } if (uint32 GuildId = GetPlayer()->GetGuildId()) { @@ -1077,18 +1107,26 @@ void WorldSession::HandleGuildBankQueryTab(WorldPacket& recv_data) DEBUG_LOG("WORLD: Received (CMSG_GUILD_BANK_QUERY_TAB) TabId %u", TabId); if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + { return; + } uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } if (TabId >= pGuild->GetPurchasedTabs()) + { return; + } pGuild->DisplayGuildBankContent(this, TabId); } @@ -1102,21 +1140,31 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recv_data) recv_data >> goGuid >> money; if (!money) + { return; + } if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + { return; + } if (GetPlayer()->GetMoney() < money) + { return; + } uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } CharacterDatabase.BeginTransaction(); @@ -1150,24 +1198,36 @@ void WorldSession::HandleGuildBankWithdrawMoney(WorldPacket& recv_data) recv_data >> goGuid >> money; if (!money) + { return; + } if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + { return; + } uint32 GuildId = GetPlayer()->GetGuildId(); if (GuildId == 0) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } if (pGuild->GetGuildBankMoney() < money) // not enough money in bank + { return; + } if (!pGuild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_WITHDRAW_GOLD)) + { return; + } CharacterDatabase.BeginTransaction(); @@ -1272,7 +1332,9 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket& recv_data) } if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + { return; + } // Bank <-> Bank if (BankToBank) @@ -1308,27 +1370,39 @@ void WorldSession::HandleGuildBankBuyTab(WorldPacket& recv_data) recv_data >> TabId; if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + { return; + } uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } // m_PurchasedTabs = 0 when buying Tab 0, that is why this check can be made // also don't allow buy tabs that are obtained through guild perks if (TabId != pGuild->GetPurchasedTabs() || TabId >= GUILD_BANK_MAX_BOUGHT_TABS) + { return; + } uint64 TabCost = GetGuildBankTabPrice(TabId) * GOLD; if (!TabCost) + { return; + } if (GetPlayer()->GetMoney() < TabCost) // Should not happen, this is checked by client + { return; + } // Go on with creating tab pGuild->CreateNewBankTab(); @@ -1353,27 +1427,41 @@ void WorldSession::HandleGuildBankUpdateTab(WorldPacket& recv_data) recv_data >> IconIndex; if (Name.empty()) + { return; + } if (IconIndex.empty()) + { return; + } if (!GetPlayer()->GetGameObjectIfCanInteractWith(goGuid, GAMEOBJECT_TYPE_GUILD_BANK)) + { return; + } uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } if (TabId >= pGuild->GetPurchasedTabs()) + { return; + } if (!pGuild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_MODIFY_BANK_TABS)) + { return; + } pGuild->SetGuildBankTabInfo(TabId, Name, IconIndex); pGuild->DisplayGuildBankTabsInfo(this); @@ -1389,15 +1477,21 @@ void WorldSession::HandleGuildBankLogQuery(WorldPacket& recv_data) uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } // GUILD_BANK_MAX_TABS send by client for money log if (TabId >= pGuild->GetPurchasedTabs() && TabId != GUILD_BANK_MAX_TABS) + { return; + } pGuild->DisplayGuildBankLogs(this, TabId); } @@ -1411,14 +1505,20 @@ void WorldSession::HandleQueryGuildBankTabText(WorldPacket& recv_data) uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } if (TabId >= pGuild->GetPurchasedTabs()) + { return; + } pGuild->SendGuildBankTabText(this, TabId); } @@ -1435,14 +1535,20 @@ void WorldSession::HandleSetGuildBankTabText(WorldPacket& recv_data) uint32 GuildId = GetPlayer()->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } if (TabId >= pGuild->GetPurchasedTabs()) + { return; + } pGuild->SetGuildBankTabText(TabId, Text); } diff --git a/src/game/WorldHandlers/GuildMgr.cpp b/src/game/WorldHandlers/GuildMgr.cpp index bdb289c39..77173b6b0 100644 --- a/src/game/WorldHandlers/GuildMgr.cpp +++ b/src/game/WorldHandlers/GuildMgr.cpp @@ -56,7 +56,9 @@ void GuildMgr::RemoveGuild(uint32 guildId) void GuildMgr::RemoveGuild(ObjectGuid guildGuid) { if (!guildGuid.IsGuild()) + { return; + } RemoveGuild(guildGuid.GetCounter()); } @@ -65,7 +67,9 @@ Guild* GuildMgr::GetGuildById(uint32 guildId) const { GuildMap::const_iterator itr = m_GuildMap.find(guildId); if (itr != m_GuildMap.end()) + { return itr->second; + } return NULL; } @@ -73,7 +77,9 @@ Guild* GuildMgr::GetGuildById(uint32 guildId) const Guild* GuildMgr::GetGuildByGuid(ObjectGuid guildGuid) const { if (!guildGuid.IsGuild()) + { return NULL; + } return GetGuildById(guildGuid.GetCounter()); } @@ -82,7 +88,9 @@ Guild* GuildMgr::GetGuildByName(std::string const& name) const { for (GuildMap::const_iterator itr = m_GuildMap.begin(); itr != m_GuildMap.end(); ++itr) if (itr->second->GetName() == name) + { return itr->second; + } return NULL; } @@ -91,7 +99,9 @@ Guild* GuildMgr::GetGuildByLeader(ObjectGuid const& guid) const { for (GuildMap::const_iterator itr = m_GuildMap.begin(); itr != m_GuildMap.end(); ++itr) if (itr->second->GetLeaderGuid() == guid) + { return itr->second; + } return NULL; } @@ -100,7 +110,9 @@ std::string GuildMgr::GetGuildNameById(uint32 guildId) const { GuildMap::const_iterator itr = m_GuildMap.find(guildId); if (itr != m_GuildMap.end()) + { return itr->second->GetName(); + } return ""; } @@ -108,7 +120,9 @@ std::string GuildMgr::GetGuildNameById(uint32 guildId) const std::string GuildMgr::GetGuildNameByGuid(ObjectGuid guildGuid) const { if (!guildGuid.IsGuild()) + { return ""; + } return GetGuildNameById(guildGuid.GetCounter()); } diff --git a/src/game/WorldHandlers/InstanceData.cpp b/src/game/WorldHandlers/InstanceData.cpp index fff46bc5e..271de1bc9 100644 --- a/src/game/WorldHandlers/InstanceData.cpp +++ b/src/game/WorldHandlers/InstanceData.cpp @@ -49,7 +49,9 @@ void InstanceData::SaveToDB() const CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%u'", data.c_str(), instance->GetInstanceId()); } else - { CharacterDatabase.PExecute("UPDATE world SET data = '%s' WHERE map = '%u'", data.c_str(), instance->GetId()); } + { + CharacterDatabase.PExecute("UPDATE world SET data = '%s' WHERE map = '%u'", data.c_str(), instance->GetId()); + } } bool InstanceData::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= NULL*/, uint32 /*miscvalue1*/ /*= 0*/) const diff --git a/src/game/WorldHandlers/ItemHandler.cpp b/src/game/WorldHandlers/ItemHandler.cpp index 113fc59db..285d4005c 100644 --- a/src/game/WorldHandlers/ItemHandler.cpp +++ b/src/game/WorldHandlers/ItemHandler.cpp @@ -46,7 +46,9 @@ void WorldSession::HandleSplitItemOpcode(WorldPacket& recv_data) uint16 dst = ((dstbag << 8) | dstslot); if (src == dst) + { return; + } if (count == 0) return; // check count - if zero it's fake packet @@ -76,7 +78,9 @@ void WorldSession::HandleSwapInvItemOpcode(WorldPacket& recv_data) // prevent attempt swap same item to current position generated by client at special cheating sequence if (srcslot == dstslot) + { return; + } if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot, true)) { @@ -104,13 +108,17 @@ void WorldSession::HandleAutoEquipItemSlotOpcode(WorldPacket& recv_data) // cheating attempt, client should never send opcode in that case if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, dstslot)) + { return; + } Item* item = _player->GetItemByGuid(itemGuid); uint16 dstpos = dstslot | (INVENTORY_SLOT_BAG_0 << 8); if (!item || item->GetPos() == dstpos) + { return; + } _player->SwapItem(item->GetPos(), dstpos); } @@ -128,7 +136,9 @@ void WorldSession::HandleSwapItem(WorldPacket& recv_data) // prevent attempt swap same item to current position generated by client at special cheating sequence if (src == dst) + { return; + } if (!_player->IsValidPos(srcbag, srcslot, true)) { @@ -167,7 +177,9 @@ void WorldSession::HandleAutoEquipItemOpcode(WorldPacket& recv_data) uint16 src = pSrcItem->GetPos(); if (dest == src) // prevent equip in same slot, only at cheat + { return; + } Item* pDstItem = _player->GetItemByPos(dest); if (!pDstItem) // empty slot, simple case @@ -341,7 +353,9 @@ void WorldSession::HandleSellItemOpcode(WorldPacket& recv_data) recv_data >> count; if (!itemGuid) + { return; + } Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR); if (!pCreature) @@ -541,7 +555,9 @@ void WorldSession::HandleListInventoryOpcode(WorldPacket& recv_data) recv_data >> guid; if (!GetPlayer()->IsAlive()) + { return; + } DEBUG_LOG("WORLD: Received opcode CMSG_LIST_INVENTORY"); @@ -705,7 +721,9 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket& recv_data) Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) + { return; + } if (!_player->IsValidPos(dstbag, NULL_SLOT, false)) // can be autostore pos { @@ -779,7 +797,9 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) recvPacket >> guid; if (!CheckBanker(guid)) + { return; + } uint32 slot = _player->GetBankBagSlotCount(); @@ -791,12 +811,16 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) BankBagSlotPricesEntry const* slotEntry = sBankBagSlotPricesStore.LookupEntry(slot); if (!slotEntry) + { return; + } uint64 price = slotEntry->price; if (_player->GetMoney() < price) + { return; + } _player->SetBankBagSlotCount(slot); _player->ModifyMoney(-int64(price)); @@ -814,7 +838,9 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) + { return; + } ItemPosCountVec dest; InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, pItem, false); @@ -846,7 +872,9 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket) Item* pItem = _player->GetItemByPos(srcbag, srcslot); if (!pItem) + { return; + } if (_player->IsBankPos(srcbag, srcslot)) // moving from bank to inventory { @@ -1031,7 +1059,9 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) recv_data >> itemGuid; if (!itemGuid.IsItem()) + { return; + } for (int i = 0; i < MAX_GEM_SOCKETS; ++i) recv_data >> gemGuids[i]; @@ -1044,20 +1074,28 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) continue; if (!gemGuid.IsItem()) + { return; + } for (int j = i + 1; j < MAX_GEM_SOCKETS; ++j) if (gemGuids[j] == gemGuid) + { return; + } } Item* itemTarget = _player->GetItemByGuid(itemGuid); if (!itemTarget) // missing item to socket + { return; + } ItemPrototype const* itemProto = itemTarget->GetProto(); if (!itemProto) + { return; + } // this slot is excepted when applying / removing meta gem bonus uint8 slot = itemTarget->IsEquipped() ? itemTarget->GetSlot() : uint8(NULL_SLOT); @@ -1080,22 +1118,30 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) { // no prismatic socket if (!itemTarget->GetEnchantmentId(PRISMATIC_ENCHANTMENT_SLOT)) + { return; + } // not first not-colored (not normally used) socket if (i != 0 && !itemProto->Socket[i - 1].Color && (i + 1 >= MAX_GEM_SOCKETS || itemProto->Socket[i + 1].Color)) + { return; + } // ok, this is first not colored socket for item with prismatic socket } // tried to put normal gem in meta socket if (itemProto->Socket[i].Color == SOCKET_COLOR_META && GemProps[i]->color != SOCKET_COLOR_META) + { return; + } // tried to put meta gem in normal socket if (itemProto->Socket[i].Color != SOCKET_COLOR_META && GemProps[i]->color == SOCKET_COLOR_META) + { return; + } } uint32 GemEnchants[MAX_GEM_SOCKETS]; @@ -1246,15 +1292,21 @@ void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data) // apply only to equipped item if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, eslot)) + { return; + } Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, eslot); if (!item) + { return; + } if (!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) + { return; + } GetPlayer()->ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, false); item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT); diff --git a/src/game/WorldHandlers/LFGMgr.cpp b/src/game/WorldHandlers/LFGMgr.cpp index 3aa1f8d2a..bd7b4f8f5 100644 --- a/src/game/WorldHandlers/LFGMgr.cpp +++ b/src/game/WorldHandlers/LFGMgr.cpp @@ -446,18 +446,26 @@ LFGPlayers* LFGMgr::GetPlayerOrPartyData(ObjectGuid guid) { playerData::iterator it = m_playerData.find(guid); if (it != m_playerData.end()) + { return &(it->second); + } else + { return NULL; + } } LFGProposal* LFGMgr::GetProposalData(uint32 proposalID) { proposalMap::iterator it = m_proposalMap.find(proposalID); if (it != m_proposalMap.end()) + { return &(it->second); + } else + { return NULL; + } } LfgJoinResult LFGMgr::GetJoinResult(Player* plr) @@ -597,16 +605,24 @@ DungeonTypes LFGMgr::GetDungeonType(uint32 dungeonId) case 1: { if (dungeon->difficulty == DUNGEON_DIFFICULTY_NORMAL) + { return DUNGEON_TBC; + } else if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC) + { return DUNGEON_TBC_HEROIC; + } } case 2: { if (dungeon->difficulty == DUNGEON_DIFFICULTY_NORMAL) + { return DUNGEON_WOTLK; + } else if (dungeon->difficulty == DUNGEON_DIFFICULTY_HEROIC) + { return DUNGEON_WOTLK_HEROIC; + } } default: return DUNGEON_UNKNOWN; @@ -797,7 +813,9 @@ void LFGMgr::AddToQueue(ObjectGuid guid) { LFGPlayers* information = GetPlayerOrPartyData(guid); if (!information) + { return; + } // This will be necessary for finding matches in the queue UpdateNeededRoles(guid, information); @@ -951,16 +969,24 @@ bool LFGMgr::RoleMapsAreCompatible(LFGPlayers* groupOne, LFGPlayers* groupTwo) // When this is called we already know that the dungeons match, so just focus on roles // compare: neededX(role) from each struct and the amount of people per role in the roleMap if ((groupOne->currentRoles.size() + groupTwo->currentRoles.size()) > NORMAL_TOTAL_ROLE_COUNT) + { return false; + } else { // make sure we don't have too many players of a certain role here if (((NORMAL_DAMAGE_COUNT - groupOne->neededDps) + (NORMAL_DAMAGE_COUNT - groupTwo->neededDps)) > NORMAL_DAMAGE_COUNT) + { return false; + } else if (((NORMAL_TANK_OR_HEALER_COUNT - groupOne->neededHealers) + (NORMAL_TANK_OR_HEALER_COUNT - groupTwo->neededHealers)) > NORMAL_TANK_OR_HEALER_COUNT) + { return false; + } else if (((NORMAL_TANK_OR_HEALER_COUNT - groupOne->neededTanks) + (NORMAL_TANK_OR_HEALER_COUNT - groupTwo->neededTanks)) > NORMAL_TANK_OR_HEALER_COUNT) + { return false; + } else return true; // the player/role counts line up! } @@ -980,7 +1006,9 @@ bool LFGMgr::MatchesAreOfSameTeam(LFGPlayers* groupOne, LFGPlayers* groupTwo) // todo: disable this if a config option is set if (pPlayer1->GetTeamId() == pPlayer2->GetTeamId()) + { return true; + } return false; } @@ -993,7 +1021,9 @@ void LFGMgr::MergeGroups(ObjectGuid guidOne, ObjectGuid guidTwo, std::setdungeonList.clear(); @@ -1078,9 +1108,13 @@ uint32 LFGMgr::GetDungeonEntry(uint32 ID) { LfgDungeonsEntry const* dungeon = sLfgDungeonsStore.LookupEntry(ID); if (dungeon) + { return dungeon->Entry(); + } else + { return 0; + } } // called each time a player selects their role @@ -1184,7 +1218,9 @@ void LFGMgr::PerformRoleCheck(Player* pPlayer, Group* pGroup, uint8 roles) bool LFGMgr::ValidateGroupRoles(roleMap groupMap) { if (groupMap.empty()) // sanity check + { return false; + } uint8 tankCount = 0, dpsCount = 0, healCount = 0; @@ -1320,7 +1356,9 @@ void LFGMgr::ProposalUpdate(uint32 proposalID, ObjectGuid plrGuid, bool accepted LFGProposal* proposal = GetProposalData(proposalID); if (!proposal) + { return; + } bool allOkay = true; // true if everyone answered LFG_ANSWER_AGREE @@ -1407,7 +1445,9 @@ bool LFGMgr::HasLeaderFlag(roleMap const& roles) for (roleMap::const_iterator it = roles.begin(); it != roles.end(); ++it) { if (it->second & PLAYER_ROLE_LEADER) + { return true; + } } return false; } @@ -1415,7 +1455,9 @@ bool LFGMgr::HasLeaderFlag(roleMap const& roles) void LFGMgr::CreateDungeonGroup(LFGProposal* proposal) { if (!proposal) + { return; + } Group* pGroup; @@ -1478,7 +1520,9 @@ void LFGMgr::CreateDungeonGroup(LFGProposal* proposal) // set dungeon difficulty for group LfgDungeonsEntry const* dungeon = sLfgDungeonsStore.LookupEntry(proposal->dungeonID); if (!dungeon) + { return; + } pGroup->SetDungeonDifficulty(Difficulty(dungeon->difficulty)); //todo: check for raids and if so call setraiddifficulty @@ -1499,7 +1543,9 @@ void LFGMgr::TeleportToDungeon(uint32 dungeonID, Group* pGroup) // if nobody is in the dungeon, teleport all to beginning of dungeon (sObjectMgr.GetMapEntranceTrigger(mapid [not dungeonid])) LfgDungeonsEntry const* dungeon = sLfgDungeonsStore.LookupEntry(dungeonID); if (!dungeon || !pGroup) + { return; + } uint32 mapID = (uint32)dungeon->mapID; float x, y, z, o; @@ -1591,9 +1637,13 @@ LFGGroupStatus* LFGMgr::GetGroupStatus(ObjectGuid guid) { groupStatusMap::iterator it = m_groupStatusMap.find(guid); if (it != m_groupStatusMap.end()) + { return &(it->second); + } else + { return NULL; + } } void LFGMgr::ProposalDeclined(ObjectGuid guid, LFGProposal* proposal) @@ -1601,7 +1651,9 @@ void LFGMgr::ProposalDeclined(ObjectGuid guid, LFGProposal* proposal) Player* pPlayer = ObjectAccessor::FindPlayer(guid); if (!pPlayer) + { return; + } bool leaveGroupLFG = false; @@ -1650,7 +1702,9 @@ void LFGMgr::ProposalDeclined(ObjectGuid guid, LFGProposal* proposal) void LFGMgr::UpdateWaitMap(LFGRoles role, uint32 dungeonID, time_t waitTime) { if (!role || !dungeonID || !waitTime) + { return; + } switch (role) { @@ -1726,7 +1780,9 @@ void LFGMgr::HandleBossKilled(Player* pPlayer) LFGGroupStatus* status = GetGroupStatus(groupGuid); if (!pGroup || !status) + { return; + } // set each player's lfgstate to LFG_STATE_FINISHED_DUNGEON // fetch reward info, and if it's the first dungeon of the day (per player), @@ -1792,7 +1848,9 @@ void LFGMgr::AttemptToKickPlayer(Group* pGroup, ObjectGuid guid, ObjectGuid kick bootStatusMap::iterator bIt = m_bootStatusMap.find(groupGuid); if (!status) + { return; + } status->state = LFG_STATE_BOOT; m_groupStatusMap[groupGuid] = *status; @@ -1832,7 +1890,9 @@ void LFGMgr::AttemptToKickPlayer(Group* pGroup, ObjectGuid guid, ObjectGuid kick void LFGMgr::CastVote(Player* pPlayer, bool vote) { if (!pPlayer) + { return; + } Group* pGroup = pPlayer->GetGroup(); ObjectGuid groupGuid = pGroup->GetObjectGuid(); @@ -1840,11 +1900,15 @@ void LFGMgr::CastVote(Player* pPlayer, bool vote) LFGGroupStatus* status = GetGroupStatus(groupGuid); if (!status || status->state != LFG_STATE_BOOT) + { return; + } bootStatusMap::iterator it = m_bootStatusMap.find(groupGuid); if (it == m_bootStatusMap.end()) + { return; + } LFGBoot boot = it->second; boot.answers[pPlayer->GetObjectGuid()] = LFGProposalAnswer(vote); diff --git a/src/game/WorldHandlers/LootHandler.cpp b/src/game/WorldHandlers/LootHandler.cpp index 870199613..67581b3e1 100644 --- a/src/game/WorldHandlers/LootHandler.cpp +++ b/src/game/WorldHandlers/LootHandler.cpp @@ -203,7 +203,9 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/) Player* player = GetPlayer(); ObjectGuid guid = player->GetLootGuid(); if (!guid) + { return; + } Loot* pLoot = NULL; Item* pItem = NULL; @@ -233,7 +235,9 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket & /*recv_data*/) { pItem = GetPlayer()->GetItemByGuid(guid); if (!pItem || !pItem->HasGeneratedLoot()) + { return; + } pLoot = &pItem->loot; break; @@ -318,7 +322,9 @@ void WorldSession::HandleLootOpcode(WorldPacket& recv_data) // Check possible cheat if (!_player->IsAlive()) + { return; + } GetPlayer()->SendLoot(guid, LOOT_CORPSE); } @@ -346,7 +352,9 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); if (!player->IsInWorld()) + { return; + } switch (lguid.GetHigh()) { @@ -356,7 +364,9 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE))) + { return; + } loot = &go->loot; @@ -436,7 +446,9 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) { Corpse* corpse = _player->GetMap()->GetCorpse(lguid); if (!corpse || !corpse->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) + { return; + } loot = &corpse->loot; @@ -451,7 +463,9 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) { Item* pItem = player->GetItemByGuid(lguid); if (!pItem) + { return; + } switch (pItem->loot.loot_type) { @@ -503,7 +517,9 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) bool ok_loot = pCreature && pCreature->IsAlive() == (player->getClass() == CLASS_ROGUE && pCreature->lootForPickPocketed); if (!ok_loot || !pCreature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) + { return; + } loot = &pCreature->loot; @@ -547,12 +563,16 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data) Player* target = ObjectAccessor::FindPlayer(target_playerguid); if (!target) + { return; + } DEBUG_LOG("WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = %s [%s].", target_playerguid.GetString().c_str(), target->GetName()); if (_player->GetLootGuid() != lootguid) + { return; + } Loot* pLoot = NULL; @@ -560,7 +580,9 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data) { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lootguid); if (!pCreature) + { return; + } pLoot = &pCreature->loot; } @@ -568,12 +590,16 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data) { GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid); if (!pGO) + { return; + } pLoot = &pGO->loot; } else + { return; + } if (slotid > pLoot->items.size()) { diff --git a/src/game/WorldHandlers/Mail.cpp b/src/game/WorldHandlers/Mail.cpp index d48c1a725..3cfd763fe 100644 --- a/src/game/WorldHandlers/Mail.cpp +++ b/src/game/WorldHandlers/Mail.cpp @@ -127,7 +127,9 @@ MailDraft& MailDraft::AddItem(Item* item) bool MailDraft::prepareItems(Player* receiver) { if (!m_mailTemplateId || !m_mailTemplateItemsNeed) + { return false; + } m_mailTemplateItemsNeed = false; @@ -357,7 +359,9 @@ void MailDraft::SendMailTo(MailReceiver const& receiver, MailSender const& sende void Mail::prepareTemplateItems(Player* receiver) { if (!mailTemplateId || !items.empty()) + { return; + } has_items = true; diff --git a/src/game/WorldHandlers/MailHandler.cpp b/src/game/WorldHandlers/MailHandler.cpp index 21baffaf0..9c854dba9 100644 --- a/src/game/WorldHandlers/MailHandler.cpp +++ b/src/game/WorldHandlers/MailHandler.cpp @@ -88,7 +88,9 @@ bool WorldSession::CheckMailBox(ObjectGuid guid) } } else + { return false; + } return true; } @@ -172,10 +174,14 @@ void WorldSession::HandleSendMail(WorldPacket& recv_data) // packet read complete, now do check if (!CheckMailBox(mailboxGuid)) + { return; + } if (receiver.empty()) + { return; + } Player* pl = _player; @@ -372,7 +378,9 @@ void WorldSession::HandleMailMarkAsRead(WorldPacket& recv_data) recv_data >> mailId; if (!CheckMailBox(mailboxGuid)) + { return; + } Player* pl = _player; @@ -403,7 +411,9 @@ void WorldSession::HandleMailDelete(WorldPacket& recv_data) recv_data.read_skip(); // mailTemplateId if (!CheckMailBox(mailboxGuid)) + { return; + } Player* pl = _player; pl->m_mailsUpdated = true; @@ -439,7 +449,9 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recv_data) recv_data.read_skip(); // original sender GUID for return to, not used if (!CheckMailBox(mailboxGuid)) + { return; + } Player* pl = _player; Mail* m = pl->GetMail(mailId); @@ -498,7 +510,9 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recv_data) recv_data >> itemId; // item guid low if (!CheckMailBox(mailboxGuid)) + { return; + } Player* pl = _player; @@ -595,7 +609,9 @@ void WorldSession::HandleMailTakeMoney(WorldPacket& recv_data) recv_data >> money; if (!CheckMailBox(mailboxGuid)) + { return; + } Player* pl = _player; @@ -630,7 +646,9 @@ void WorldSession::HandleGetMailList(WorldPacket& recv_data) recv_data >> mailboxGuid; if (!CheckMailBox(mailboxGuid)) + { return; + } // client can't work with packets > max int16 value const uint32 maxPacketSize = 32767; @@ -759,7 +777,9 @@ void WorldSession::HandleMailCreateTextItem(WorldPacket& recv_data) recv_data >> mailId; if (!CheckMailBox(mailboxGuid)) + { return; + } Player* pl = _player; diff --git a/src/game/WorldHandlers/Map.cpp b/src/game/WorldHandlers/Map.cpp index 6804df48a..724e5547b 100644 --- a/src/game/WorldHandlers/Map.cpp +++ b/src/game/WorldHandlers/Map.cpp @@ -281,7 +281,9 @@ Map::EnsureGridLoadedAtEnter(const Cell& cell, Player* player) grid->SetGridState(GRID_STATE_ACTIVE); } else - { grid = getNGrid(cell.GridX(), cell.GridY()); } + { + grid = getNGrid(cell.GridX(), cell.GridY()); + } if (player) { @@ -377,7 +379,9 @@ Map::Add(T* obj) EnsureGridLoadedAtEnter(cell); } else - { EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); } + { + EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); + } NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); MANGOS_ASSERT(grid != NULL); @@ -660,7 +664,9 @@ void Map::Remove(Player* player, bool remove) player->CleanupsBeforeDelete(); } else - { player->RemoveFromWorld(); } + { + player->RemoveFromWorld(); + } // this may be called during Map::Update // after decrement+unlink, ++m_mapRefIter will continue correctly @@ -741,7 +747,9 @@ Map::Remove(T* obj, bool remove) obj->CleanupsBeforeDelete(); } else - { obj->RemoveFromWorld(); } + { + obj->RemoveFromWorld(); + } UpdateObjectVisibility(obj, cell, p); // i think will be better to call this function while object still in grid, this changes nothing but logically is better(as for me) RemoveFromGrid(obj, grid, cell); @@ -784,7 +792,9 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie AddToGrid(player, oldGrid, new_cell); } else - { EnsureGridLoadedAtEnter(new_cell, player); } + { + EnsureGridLoadedAtEnter(new_cell, player); + } NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); player->GetViewPoint().Event_GridChanged(&(*newGrid)(new_cell.CellX(), new_cell.CellY())); @@ -872,7 +882,9 @@ bool Map::CreatureRespawnRelocation(Creature* c) return true; } else - { return false; } + { + return false; + } } bool Map::UnloadGrid(const uint32& x, const uint32& y, bool pForce) @@ -939,7 +951,9 @@ uint32 Map::GetMaxPlayers() const if (MapDifficultyEntry const* mapDiff = GetMapDifficulty()) { if (mapDiff->maxPlayers || IsRegularDifficulty()) // Normal case (expect that regular difficulty always have correct maxplayers) + { return mapDiff->maxPlayers; + } else // DBC have 0 maxplayers for heroic instances with expansion < 2 { // The heroic entry exists, so we don't have to check anything, simply return normal max players @@ -948,7 +962,9 @@ uint32 Map::GetMaxPlayers() const } } else // I'd rather ASSERT(false); + { return 0; + } } uint32 Map::GetMaxResetDelay() const @@ -1047,7 +1063,9 @@ void Map::SendInitTransports(Player* player) // Prevent sending transport maps in player update object if (packet.ReadUInt16() != player->GetMapId()) + { return; + } player->GetSession()->SendPacket(&packet); } @@ -1079,7 +1097,9 @@ void Map::SendRemoveTransports(Player* player) // Prevent sending transport maps in player update object if (packet.ReadUInt16() != player->GetMapId()) + { return; + } player->GetSession()->SendPacket(&packet); } @@ -1135,7 +1155,9 @@ void Map::RemoveAllObjectsInRemoveList() sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); } else - { Remove(corpse, true); } + { + Remove(corpse, true); + } break; } case TYPEID_DYNAMICOBJECT: @@ -1273,7 +1295,9 @@ void Map::RemoveFromActive(WorldObject* obj) } } else - { m_activeNonPlayers.erase(obj); } + { + m_activeNonPlayers.erase(obj); + } // also allow unloading spawn grid if (obj->GetTypeId() == TYPEID_UNIT) @@ -1367,7 +1391,9 @@ void Map::CreateInstanceData(bool load) void Map::CreateInstanceData(bool load) { if (i_data != NULL) + { return; + } if (Instanceable()) { @@ -1381,11 +1407,15 @@ void Map::CreateInstanceData(bool load) } if (!i_script_id) + { return; + } i_data = sScriptMgr.CreateInstanceData(this); if (!i_data) + { return; + } if (load) { @@ -1579,7 +1609,9 @@ bool DungeonMap::Add(Player* player) sLog.outError("GroupBind save players: %d, group count: %d", groupBind->state->GetPlayerCount(), groupBind->state->GetGroupCount()); } else - { sLog.outError("GroupBind save NULL"); } + { + sLog.outError("GroupBind save NULL"); + } MANGOS_ASSERT(false); } // if the group/leader is permanently bound to the instance @@ -1935,7 +1967,9 @@ void Map::ScriptsProcess() sScriptMgr.DecreaseScheduledScriptCount(); } else - { ++rmItr; } + { + ++rmItr; + } } } else @@ -2307,7 +2341,9 @@ bool Map::GetHeightInRange(uint32 phasemask, float x, float y, float& z, float m height = mapHeight; } else + { return false; + } } z = std::max(height, m_dyn_tree.getHeight(x, y, height + 1.0f, maxSearchDist, phasemask)); @@ -2360,7 +2396,9 @@ bool Map::GetRandomPointUnderWater(uint32 phaseMask, float& x, float& y, float& // if not enough space to fit the creature better is to return from here if (min_z > liquidLevel) + { return false; + } float max_z = std::max(z + 0.7f * radius, min_z); max_z = std::min(max_z, liquidLevel); diff --git a/src/game/WorldHandlers/MapManager.cpp b/src/game/WorldHandlers/MapManager.cpp index aa9a504fb..566acda0b 100644 --- a/src/game/WorldHandlers/MapManager.cpp +++ b/src/game/WorldHandlers/MapManager.cpp @@ -101,7 +101,9 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj) const MapEntry* entry = sMapStore.LookupEntry(id); if (!entry) + { return NULL; + } if (entry->Instanceable()) { @@ -143,7 +145,9 @@ Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const MapMapType::const_iterator iter = i_maps.find(MapID(mapid, instanceId)); if (iter == i_maps.end()) + { return NULL; + } // this is a small workaround for transports if (instanceId == 0 && iter->second->Instanceable()) @@ -177,7 +181,9 @@ void MapManager::Update(uint32 diff) { i_timer.Update(diff); if (!i_timer.Passed()) + { return; + } for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter) iter->second->Update((uint32)i_timer.GetCurrent()); diff --git a/src/game/WorldHandlers/MapManager.h b/src/game/WorldHandlers/MapManager.h index 61962beb4..409e5ad53 100644 --- a/src/game/WorldHandlers/MapManager.h +++ b/src/game/WorldHandlers/MapManager.h @@ -43,7 +43,9 @@ struct MapID bool operator<(const MapID& val) const { if (nMapId == val.nMapId) + { return nInstanceId < val.nInstanceId; + } return nMapId < val.nMapId; } diff --git a/src/game/WorldHandlers/MapPersistentStateMgr.cpp b/src/game/WorldHandlers/MapPersistentStateMgr.cpp index e795d2255..8bddb4c34 100644 --- a/src/game/WorldHandlers/MapPersistentStateMgr.cpp +++ b/src/game/WorldHandlers/MapPersistentStateMgr.cpp @@ -74,7 +74,9 @@ bool MapPersistentState::UnloadIfEmpty() return false; } else + { return true; + } } void MapPersistentState::SaveCreatureRespawnTime(uint32 loguid, time_t t) @@ -83,7 +85,9 @@ void MapPersistentState::SaveCreatureRespawnTime(uint32 loguid, time_t t) // BGs/Arenas always reset at server restart/unload, so no reason store in DB if (GetMapEntry()->IsBattleGroundOrArena()) + { return; + } CharacterDatabase.BeginTransaction(); @@ -108,7 +112,9 @@ void MapPersistentState::SaveGORespawnTime(uint32 loguid, time_t t) // BGs/Arenas always reset at server restart/unload, so no reason store in DB if (GetMapEntry()->IsBattleGroundOrArena()) + { return; + } CharacterDatabase.BeginTransaction(); @@ -293,9 +299,13 @@ time_t DungeonPersistentState::GetResetTimeForDB() const // only state the reset time for normal instances const MapEntry* entry = sMapStore.LookupEntry(GetMapId()); if (!entry || entry->map_type == MAP_RAID || GetDifficulty() == DUNGEON_DIFFICULTY_HEROIC) + { return 0; + } else + { return GetResetTime(); + } } void DungeonPersistentState::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry) @@ -337,7 +347,9 @@ bool BattleGroundPersistentState::CanBeUnload() const uint32 DungeonResetScheduler::GetMaxResetTimeFor(MapDifficultyEntry const* mapDiff) { if (!mapDiff || !mapDiff->resetTime) + { return 0; + } uint32 delay = uint32(mapDiff->resetTime / DAY * sWorld.getConfig(CONFIG_FLOAT_RATE_INSTANCE_RESET_TIME)) * DAY; @@ -644,7 +656,9 @@ MapPersistentStateManager::~MapPersistentStateManager() MapPersistentState* MapPersistentStateManager::AddPersistentState(MapEntry const* mapEntry, uint32 instanceId, Difficulty difficulty, time_t resetTime, bool canReset, bool load /*=false*/, bool initPools /*= true*/, uint32 completedEncountersMask /*= 0*/) { if (MapPersistentState* old_save = GetPersistentState(mapEntry->MapID, instanceId)) + { return old_save; + } if (mapEntry->IsDungeon()) { @@ -721,7 +735,9 @@ void MapPersistentStateManager::DeleteInstanceFromDB(uint32 instanceid) void MapPersistentStateManager::RemovePersistentState(uint32 mapId, uint32 instanceId) { if (lock_instLists) + { return; + } if (instanceId) { @@ -919,7 +935,9 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu // global reset for all instances of the given map MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry->IsDungeon()) + { return; + } time_t now = time(NULL); diff --git a/src/game/WorldHandlers/MapPersistentStateMgr.h b/src/game/WorldHandlers/MapPersistentStateMgr.h index 1bba2f6be..e778be7f3 100644 --- a/src/game/WorldHandlers/MapPersistentStateMgr.h +++ b/src/game/WorldHandlers/MapPersistentStateMgr.h @@ -406,7 +406,9 @@ inline void MapPersistentStateManager::DoForAllStatesWithMapId(uint32 mapId, Do& { MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry) + { return; + } if (mapEntry->Instanceable()) { diff --git a/src/game/WorldHandlers/MassMailMgr.cpp b/src/game/WorldHandlers/MassMailMgr.cpp index ad0cd9f2e..cc21a97ca 100644 --- a/src/game/WorldHandlers/MassMailMgr.cpp +++ b/src/game/WorldHandlers/MassMailMgr.cpp @@ -59,7 +59,9 @@ struct MassMailerQueryHandler void HandleQueryCallback(QueryResult* result, MailDraft* mailProto, MailSender sender) { if (!result) + { return; + } MassMailMgr::ReceiversList& recievers = sMassMailMgr.AddMassMailTask(mailProto, sender); @@ -81,7 +83,9 @@ void MassMailMgr::AddMassMailTask(MailDraft* mailProto, const MailSender& sender void MassMailMgr::Update(bool sendall /*= false*/) { if (m_massMails.empty()) + { return; + } uint32 maxcount = sWorld.getConfig(CONFIG_UINT32_MASS_MAILER_SEND_PER_TICK); diff --git a/src/game/WorldHandlers/MiscHandler.cpp b/src/game/WorldHandlers/MiscHandler.cpp index 0b8f43487..5f066ba20 100644 --- a/src/game/WorldHandlers/MiscHandler.cpp +++ b/src/game/WorldHandlers/MiscHandler.cpp @@ -60,10 +60,14 @@ void WorldSession::HandleRepopRequestOpcode(WorldPacket& recv_data) recv_data.read_skip(); if (GetPlayer()->IsAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + { return; + } if (GetPlayer()->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION)) + { return; + } // the world update order is sessions, players, creatures // the netcode runs in parallel with all of these @@ -141,7 +145,9 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recv_data) std::wstring wplayer_name; std::wstring wguild_name; if (!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name))) + { return; + } wstrToLower(wplayer_name); wstrToLower(wguild_name); @@ -412,7 +418,9 @@ void WorldSession::HandleSetTargetOpcode(WorldPacket& recv_data) // update reputation list if need Unit* unit = ObjectAccessor::GetUnit(*_player, guid); // can select group members at diff maps if (!unit) + { return; + } if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction())) _player->GetReputationMgr().SetVisible(factionTemplateEntry); @@ -428,7 +436,9 @@ void WorldSession::HandleSetSelectionOpcode(WorldPacket& recv_data) // update reputation list if need Unit* unit = ObjectAccessor::GetUnit(*_player, guid); // can select group members at diff maps if (!unit) + { return; + } if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction())) _player->GetReputationMgr().SetVisible(factionTemplateEntry); @@ -464,7 +474,9 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recv_data) recv_data >> friendNote; if (!normalizePlayerName(friendName)) + { return; + } CharacterDatabase.escape_string(friendName); // prevent SQL injection - normal name don't must changed by this call @@ -477,7 +489,9 @@ void WorldSession::HandleAddFriendOpcode(WorldPacket& recv_data) void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult* result, uint32 accountId, std::string friendNote) { if (!result) + { return; + } uint32 friendLowGuid = (*result)[0].GetUInt32(); ObjectGuid friendGuid = ObjectGuid(HIGHGUID_PLAYER, friendLowGuid); @@ -487,7 +501,9 @@ void WorldSession::HandleAddFriendOpcodeCallBack(QueryResult* result, uint32 acc WorldSession* session = sWorld.FindSession(accountId); if (!session || !session->GetPlayer()) + { return; + } FriendsResult friendResult = FRIEND_NOT_FOUND; if (friendGuid) @@ -545,7 +561,9 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recv_data) recv_data >> IgnoreName; if (!normalizePlayerName(IgnoreName)) + { return; + } CharacterDatabase.escape_string(IgnoreName); // prevent SQL injection - normal name don't must changed by this call @@ -558,7 +576,9 @@ void WorldSession::HandleAddIgnoreOpcode(WorldPacket& recv_data) void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult* result, uint32 accountId) { if (!result) + { return; + } uint32 ignoreLowGuid = (*result)[0].GetUInt32(); ObjectGuid ignoreGuid = ObjectGuid(HIGHGUID_PLAYER, ignoreLowGuid); @@ -567,7 +587,9 @@ void WorldSession::HandleAddIgnoreOpcodeCallBack(QueryResult* result, uint32 acc WorldSession* session = sWorld.FindSession(accountId); if (!session || !session->GetPlayer()) + { return; + } FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND; if (ignoreGuid) @@ -645,27 +667,39 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket& recv_data) recv_data >> guid; if (GetPlayer()->IsAlive()) + { return; + } // do not allow corpse reclaim in arena if (GetPlayer()->InArena()) + { return; + } // body not released yet if (!GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + { return; + } Corpse* corpse = GetPlayer()->GetCorpse(); if (!corpse) + { return; + } // prevent resurrect before 30-sec delay after body release not finished if (corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP) > time(NULL)) + { return; + } if (!corpse->IsWithinDistInMap(GetPlayer(), CORPSE_RECLAIM_RADIUS, true)) + { return; + } // resurrect GetPlayer()->ResurrectPlayer(GetPlayer()->InBattleGround() ? 1.0f : 0.5f); @@ -684,7 +718,9 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recv_data) recv_data >> status; if (GetPlayer()->IsAlive()) + { return; + } if (status == 0) { @@ -693,7 +729,9 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recv_data) } if (!GetPlayer()->isRessurectRequestedBy(guid)) + { return; + } GetPlayer()->ResurectUsingRequestData(); // will call spawncorpsebones } @@ -702,7 +740,9 @@ void WorldSession::HandleReturnToGraveyard(WorldPacket& /*recvPacket*/) { Player* pPlayer = GetPlayer(); if (pPlayer->IsAlive() || !pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + { return; + } WorldSafeLocsEntry const* ClosestGrave = NULL; @@ -767,7 +807,9 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) } if (sScriptMgr.OnAreaTrigger(player, atEntry)) + { return; + } uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(Trigger_ID); if (quest_id && player->IsAlive() && player->IsActiveQuest(quest_id)) @@ -792,22 +834,30 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) if (BattleGround* bg = player->GetBattleGround()) { if (bg->HandleAreaTrigger(player, Trigger_ID)) - return; + { + return; + } } else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId())) { if (outdoorPvP->HandleAreaTrigger(player, Trigger_ID)) + { return; + } } // NULL if all values default (non teleport trigger) AreaTrigger const* at = sObjectMgr.GetAreaTrigger(Trigger_ID); if (!at) + { return; + } MapEntry const* targetMapEntry = sMapStore.LookupEntry(at->target_mapId); if (!targetMapEntry) + { return; + } // ghost resurrected at enter attempt to dungeon with corpse (including fail enter cases) if (!player->IsAlive() && targetMapEntry->IsDungeon()) @@ -845,7 +895,9 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) at = corpseAt; targetMapEntry = sMapStore.LookupEntry(at->target_mapId); if (!targetMapEntry) + { return; + } } } @@ -868,7 +920,9 @@ void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data) DEBUG_LOG("UAD: type %u, time %u, decompressedSize %u", type, timestamp, decompressedSize); if (type > NUM_ACCOUNT_DATA_TYPES) + { return; + } if (decompressedSize == 0) // erase { @@ -923,7 +977,9 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) DEBUG_LOG("RAD: type %u", type); if (type > NUM_ACCOUNT_DATA_TYPES) + { return; + } AccountData* adata = GetAccountData(AccountDataType(type)); @@ -1096,13 +1152,19 @@ void WorldSession::HandleInspectOpcode(WorldPacket& recv_data) Player* plr = sObjectMgr.GetPlayer(guid); if (!plr) // wrong player + { return; + } if (!_player->IsWithinDistInMap(plr, INSPECT_DISTANCE, false)) + { return; + } if (_player->IsHostileTo(plr)) + { return; + } WorldPacket data(SMSG_INSPECT_RESULTS, 50); data << plr->GetObjectGuid(); @@ -1142,10 +1204,14 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) } if (!_player->IsWithinDistInMap(player, INSPECT_DISTANCE, false)) + { return; + } if (_player->IsHostileTo(player)) + { return; + } WorldPacket data(SMSG_INSPECT_HONOR_STATS, 18); data.WriteGuidMask<4, 3, 6, 2, 5, 0, 7, 1>(player->GetObjectGuid()); @@ -1325,7 +1391,9 @@ void WorldSession::HandleFarSightOpcode(WorldPacket& recv_data) WorldObject* obj = _player->GetMap()->GetWorldObject(_player->GetFarSightGuid()); if (!obj) + { return; + } switch (op) { @@ -1351,7 +1419,9 @@ void WorldSession::HandleSetTitleOpcode(WorldPacket& recv_data) if (title > 0 && title < MAX_TITLE_INDEX) { if (!GetPlayer()->HasTitle(title)) + { return; + } } else title = 0; @@ -1404,7 +1474,9 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data) } if (Difficulty(mode) == _player->GetDungeonDifficulty()) + { return; + } // cannot reset while in an instance Map* map = _player->GetMap(); @@ -1416,7 +1488,9 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data) // Exception to set mode to normal for low-level players if (_player->getLevel() < LEVELREQUIREMENT_HEROIC && mode > REGULAR_DIFFICULTY) + { return; + } if (Group* pGroup = _player->GetGroup()) { @@ -1449,7 +1523,9 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data) } if (Difficulty(mode) == _player->GetRaidDifficulty()) + { return; + } // cannot reset while in an instance Map* map = _player->GetMap(); @@ -1461,7 +1537,9 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data) // Exception to set mode to normal for low-level players if (_player->getLevel() < LEVELREQUIREMENT_HEROIC && mode > REGULAR_DIFFICULTY) + { return; + } if (Group* pGroup = _player->GetGroup()) { @@ -1543,13 +1621,19 @@ void WorldSession::HandleQueryInspectAchievementsOpcode(WorldPacket& recv_data) Player* player = sObjectMgr.GetPlayer(guid); if (!player) + { return; + } if (!_player->IsWithinDistInMap(player, INSPECT_DISTANCE, false)) + { return; + } if (_player->IsHostileTo(player)) + { return; + } player->GetAchievementMgr().SendRespondInspectAchievements(_player); } @@ -1578,11 +1662,15 @@ void WorldSession::HandleHearthandResurrect(WorldPacket& /*recv_data*/) AreaTableEntry const* atEntry = sAreaStore.LookupEntry(_player->GetAreaId()); if (!atEntry || !(atEntry->flags & AREA_FLAG_CAN_HEARTH_AND_RES)) + { return; + } // Can't use in flight if (_player->IsTaxiFlying()) + { return; + } // Send Everytime _player->BuildPlayerRepop(); diff --git a/src/game/WorldHandlers/MoveMap.cpp b/src/game/WorldHandlers/MoveMap.cpp index a5b938c58..8b9d77fe6 100644 --- a/src/game/WorldHandlers/MoveMap.cpp +++ b/src/game/WorldHandlers/MoveMap.cpp @@ -73,19 +73,27 @@ namespace MMAP bool MMapFactory::IsPathfindingEnabled(uint32 mapId, const Unit* unit = NULL) { if (!sWorld.getConfig(CONFIG_BOOL_MMAP_ENABLED)) + { return false; + } if (unit) { // always use mmaps for players if (unit->GetTypeId() == TYPEID_PLAYER) + { return true; + } if (IsPathfindingForceDisabled(unit)) + { return false; + } if (IsPathfindingForceEnabled(unit)) + { return true; + } // always use mmaps for pets of players (can still be disabled by extra-flag for pet creature) if (unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->IsPet() && unit->GetOwner() && @@ -112,7 +120,9 @@ namespace MMAP if (const CreatureInfo* pInfo = pCreature->GetCreatureInfo()) { if (pInfo->ExtraFlags & CREATURE_EXTRA_FLAG_MMAP_FORCE_ENABLE) + { return true; + } } } @@ -126,7 +136,9 @@ namespace MMAP if (const CreatureInfo* pInfo = pCreature->GetCreatureInfo()) { if (pInfo->ExtraFlags & CREATURE_EXTRA_FLAG_MMAP_FORCE_DISABLE) + { return true; + } } } @@ -384,7 +396,9 @@ namespace MMAP dtNavMesh const* MMapManager::GetNavMesh(uint32 mapId) { if (loadedMMaps.find(mapId) == loadedMMaps.end()) + { return NULL; + } return loadedMMaps[mapId]->navMesh; } @@ -392,7 +406,9 @@ namespace MMAP dtNavMeshQuery const* MMapManager::GetNavMeshQuery(uint32 mapId, uint32 instanceId) { if (loadedMMaps.find(mapId) == loadedMMaps.end()) + { return NULL; + } MMapData* mmap = loadedMMaps[mapId]; if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end()) diff --git a/src/game/WorldHandlers/MovementHandler.cpp b/src/game/WorldHandlers/MovementHandler.cpp index 1ac6ad68c..39783c574 100644 --- a/src/game/WorldHandlers/MovementHandler.cpp +++ b/src/game/WorldHandlers/MovementHandler.cpp @@ -50,7 +50,9 @@ void WorldSession::HandleMoveWorldportAckOpcode() { // ignore unexpected far teleports if (!GetPlayer()->IsBeingTeleportedFar()) + { return; + } // get start teleport coordinates (will used later in fail case) WorldLocation old_loc; @@ -277,10 +279,14 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data) Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; if (!plMover || !plMover->IsBeingTeleportedNear()) + { return; + } if (guid != plMover->GetObjectGuid()) + { return; + } plMover->SetSemaphoreTeleportNear(false); @@ -334,7 +340,9 @@ void WorldSession::HandleMovementOpcodes(WorldPacket& recv_data) /*----------------*/ if (!VerifyMovementInfo(movementInfo, movementInfo.GetGuid())) + { return; + } // fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map). if (opcode == CMSG_MOVE_FALL_LAND && plMover && !plMover->IsTaxiFlying()) @@ -407,7 +415,9 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket& recv_data) { --_player->m_forced_speed_changes[force_move_type]; if (_player->m_forced_speed_changes[force_move_type] > 0) + { return; + } } if (!_player->GetTransport() && fabs(_player->GetSpeed(move_type) - newspeed) > 0.01f) @@ -498,7 +508,9 @@ void WorldSession::HandleMoveKnockBackAck(WorldPacket& recv_data) recv_data >> movementInfo; if (!VerifyMovementInfo(movementInfo, movementInfo.GetGuid())) + { return; + } HandleMoverRelocation(movementInfo); @@ -559,7 +571,9 @@ void WorldSession::HandleMoveWaterWalkAck(WorldPacket& recv_data) void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data) { if (!_player->IsAlive() || _player->IsInCombat()) + { return; + } ObjectGuid summonerGuid; bool agree; @@ -573,17 +587,23 @@ bool WorldSession::VerifyMovementInfo(MovementInfo const& movementInfo, ObjectGu { // ignore wrong guid (player attempt cheating own session for not own guid possible...) if (guid != _player->GetMover()->GetObjectGuid()) + { return false; + } if (!MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x, movementInfo.GetPos()->y, movementInfo.GetPos()->z, movementInfo.GetPos()->o)) + { return false; + } if (movementInfo.GetTransportGuid()) { // transports size limited // (also received at zeppelin/lift leave by some reason with t_* as absolute in continent coordinates, can be safely skipped) if (movementInfo.GetTransportPos()->x > 50 || movementInfo.GetTransportPos()->y > 50 || movementInfo.GetTransportPos()->z > 100) + { return false; + } if (!MaNGOS::IsValidMapCoord(movementInfo.GetPos()->x + movementInfo.GetTransportPos()->x, movementInfo.GetPos()->y + movementInfo.GetTransportPos()->y, movementInfo.GetPos()->z + movementInfo.GetTransportPos()->z, movementInfo.GetPos()->o + movementInfo.GetTransportPos()->o)) diff --git a/src/game/WorldHandlers/NPCHandler.cpp b/src/game/WorldHandlers/NPCHandler.cpp index 74a1bdd8d..0c50d59f5 100644 --- a/src/game/WorldHandlers/NPCHandler.cpp +++ b/src/game/WorldHandlers/NPCHandler.cpp @@ -87,7 +87,9 @@ void WorldSession::HandleBankerActivateOpcode(WorldPacket& recv_data) recv_data >> guid; if (!CheckBanker(guid)) + { return; + } SendShowBank(guid); } @@ -153,11 +155,15 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) // trainer list loaded at check; if (!unit->IsTrainerOf(_player, true)) + { return; + } CreatureInfo const* ci = unit->GetCreatureInfo(); if (!ci) + { return; + } TrainerSpellData const* cSpells = unit->GetTrainerSpells(); TrainerSpellData const* tSpells = unit->GetTrainerTemplateSpells(); @@ -456,12 +462,16 @@ void WorldSession::HandleReturnToGraveyardOpcode(WorldPacket& recv_data) { Corpse* corpse = _player->GetCorpse(); if (!corpse) + { return; + } WorldSafeLocsEntry const* corpseGrave = sObjectMgr.GetClosestGraveYard(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam()); if (!corpseGrave) + { return; + } _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation()); } @@ -472,7 +482,9 @@ void WorldSession::HandleBinderActivateOpcode(WorldPacket& recv_data) recv_data >> npcGuid; if (!GetPlayer()->IsInWorld() || !GetPlayer()->IsAlive()) + { return; + } Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_INNKEEPER); if (!unit) @@ -488,7 +500,9 @@ void WorldSession::SendBindPoint(Creature* npc) { // prevent set homebind to instances in any case if (GetPlayer()->GetMap()->Instanceable()) + { return; + } // send spell for bind 3286 bind magic npc->CastSpell(_player, 3286, true); // Bind @@ -859,10 +873,14 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recv_data) { uint32 GuildId = _player->GetGuildId(); if (!GuildId) + { return; + } Guild* pGuild = sGuildMgr.GetGuildById(GuildId); if (!pGuild) + { return; + } pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost); pGuild->SendMoneyInfo(this, _player->GetGUIDLow()); } diff --git a/src/game/WorldHandlers/ObjectGridLoader.cpp b/src/game/WorldHandlers/ObjectGridLoader.cpp index 239209680..748c9faa3 100644 --- a/src/game/WorldHandlers/ObjectGridLoader.cpp +++ b/src/game/WorldHandlers/ObjectGridLoader.cpp @@ -149,7 +149,9 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair& cell, GridRefManager& void LoadHelper(CellCorpseSet const& cell_corpses, CellPair& cell, CorpseMapType& /*m*/, uint32& count, Map* map, GridType& grid) { if (cell_corpses.empty()) + { return; + } for (CellCorpseSet::const_iterator itr = cell_corpses.begin(); itr != cell_corpses.end(); ++itr) { diff --git a/src/game/WorldHandlers/PetHandler.cpp b/src/game/WorldHandlers/PetHandler.cpp index fbaf8fa35..0658ef849 100644 --- a/src/game/WorldHandlers/PetHandler.cpp +++ b/src/game/WorldHandlers/PetHandler.cpp @@ -67,19 +67,25 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) } if (!pet->IsAlive()) + { return; + } if (pet->GetTypeId() == TYPEID_PLAYER) { // controller player can only do melee attack if (!(flag == ACT_COMMAND && spellid == COMMAND_ATTACK)) + { return; + } } else if (((Creature*)pet)->IsPet()) { // pet can have action bar disabled if (((Pet*)pet)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) + { return; + } } CharmInfo* charmInfo = pet->GetCharmInfo(); @@ -212,7 +218,9 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) } if (pet->GetCharmInfo() && pet->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) + { return; + } for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { @@ -228,7 +236,9 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) // do not cast not learned spells if (!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo)) + { return; + } _player->SetInCombatState(true, unit_target); @@ -336,7 +346,9 @@ void WorldSession::HandlePetStopAttack(WorldPacket& recv_data) } if (!pet->IsAlive()) + { return; + } pet->AttackStop(); } @@ -413,7 +425,9 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) // pet can have action bar disabled if (pet->IsPet() && ((Pet*)pet)->GetModeFlags() & PET_MODE_DISABLE_ACTIONS) + { return; + } CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) @@ -437,7 +451,9 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) // ignore invalid position if (position[i] >= MAX_UNIT_ACTION_BAR_INDEX) + { return; + } // in the normal case, command and reaction buttons can only be moved, not removed // at moving count ==2, at removing count == 1 @@ -445,7 +461,9 @@ void WorldSession::HandlePetSetAction(WorldPacket& recv_data) if (act_state == ACT_COMMAND || act_state == ACT_REACTION) { if (count == 1) + { return; + } move_command = true; } @@ -589,7 +607,9 @@ void WorldSession::HandlePetAbandon(WorldPacket& recv_data) DETAIL_LOG("HandlePetAbandon. CMSG_PET_ABANDON pet guid is %s", guid.GetString().c_str()); if (!_player->IsInWorld()) + { return; + } // pet/charmed if (Creature* pet = _player->GetMap()->GetAnyTypeCreature(guid)) @@ -619,7 +639,9 @@ void WorldSession::HandlePetUnlearnOpcode(WorldPacket& recvPacket) } if (pet->getPetType() != HUNTER_PET || pet->m_usedTalentCount == 0) + { return; + } CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) @@ -649,7 +671,9 @@ void WorldSession::HandlePetSpellAutocastOpcode(WorldPacket& recvPacket) // do not add not learned spells/ passive spells if (!pet->HasSpell(spellid) || IsPassiveSpell(spellid)) + { return; + } CharmInfo* charmInfo = pet->GetCharmInfo(); if (!charmInfo) @@ -696,13 +720,17 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) } if (pet->GetCharmInfo() && pet->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) + { return; + } Aura* triggeredByAura = pet->GetTriggeredByClientAura(spellid); // do not cast not learned spells if ((!triggeredByAura && !pet->HasSpell(spellid)) || IsPassiveSpell(spellInfo)) + { return; + } SpellCastTargets targets; diff --git a/src/game/WorldHandlers/PetitionsHandler.cpp b/src/game/WorldHandlers/PetitionsHandler.cpp index 3db269ad9..04d425a96 100644 --- a/src/game/WorldHandlers/PetitionsHandler.cpp +++ b/src/game/WorldHandlers/PetitionsHandler.cpp @@ -130,7 +130,9 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recv_data) _player->ModifyMoney(-(int64)GUILD_CHARTER_COST); Item* charter = _player->StoreNewItem(dest, GUILD_CHARTER, true); if (!charter) + { return; + } charter->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, charter->GetGUIDLow()); // ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id @@ -192,7 +194,9 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data) // if has guild => error, return; if (_player->GetGuildId()) + { return; + } result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionguid_low); @@ -302,7 +306,9 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recv_data) Item* item = _player->GetItemByGuid(petitionGuid); if (!item) + { return; + } QueryResult* result = CharacterDatabase.PQuery("SELECT 1 FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter()); if (!result) @@ -368,7 +374,9 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recv_data) delete result; if (ownerGuid == _player->GetObjectGuid()) + { return; + } // not let enemies sign guild charter if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && @@ -456,7 +464,9 @@ void WorldSession::HandlePetitionDeclineOpcode(WorldPacket& recv_data) QueryResult* result = CharacterDatabase.PQuery("SELECT ownerguid FROM petition WHERE petitionguid = '%u'", petitionLowGuid); if (!result) + { return; + } Field* fields = result->Fetch(); ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); @@ -484,12 +494,16 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recv_data) Player* player = ObjectAccessor::FindPlayer(playerGuid); if (!player) + { return; + } /// Get petition type and check QueryResult* result = CharacterDatabase.PQuery("SELECT 1 FROM petition WHERE petitionguid = '%u'", petitionGuid.GetCounter()); if (!result) + { return; + } delete result; DEBUG_LOG("OFFER PETITION: petition %s to %s", petitionGuid.GetString().c_str(), playerGuid.GetString().c_str()); @@ -578,7 +592,9 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recv_data) } if (_player->GetObjectGuid() != ownerGuid) + { return; + } // signs result = CharacterDatabase.PQuery("SELECT playerguid FROM petition_sign WHERE petitionguid = '%u'", petitionGuid.GetCounter()); diff --git a/src/game/WorldHandlers/PoolManager.cpp b/src/game/WorldHandlers/PoolManager.cpp index e2afa6112..cf6653002 100644 --- a/src/game/WorldHandlers/PoolManager.cpp +++ b/src/game/WorldHandlers/PoolManager.cpp @@ -160,7 +160,9 @@ bool PoolGroup::CheckPool() const for (uint32 i = 0; i < ExplicitlyChanced.size(); ++i) chance += ExplicitlyChanced[i].chance; if (chance != 100 && chance != 0) + { return false; + } } return true; } @@ -212,7 +214,9 @@ PoolObject* PoolGroup::RollOne(SpawnedPoolData& spawns, uint32 triggerFrom) // Triggering object is marked as spawned at this time and can be also rolled (respawn case) // so this need explicit check for this case if (roll < 0 && !ExplicitlyChanced[i].exclude && (ExplicitlyChanced[i].guid == triggerFrom || !spawns.IsSpawnedObject(ExplicitlyChanced[i].guid))) + { return &ExplicitlyChanced[i]; + } } } @@ -222,7 +226,9 @@ PoolObject* PoolGroup::RollOne(SpawnedPoolData& spawns, uint32 triggerFrom) // Triggering object is marked as spawned at this time and can be also rolled (respawn case) // so this need explicit check for this case if (!EqualChanced[index].exclude && (EqualChanced[index].guid == triggerFrom || !spawns.IsSpawnedObject(EqualChanced[index].guid))) + { return &EqualChanced[index]; + } } return NULL; @@ -532,7 +538,9 @@ struct PoolMapChecker { MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry) + { return false; + } MapEntry const* poolMapEntry = m_poolTemplates[pool_id].mapEntry; @@ -545,7 +553,9 @@ struct PoolMapChecker // if at same map, then all ok if (poolMapEntry == mapEntry) + { return true; + } // pool spawns must be at single instanceable map if (mapEntry->Instanceable()) @@ -1160,7 +1170,9 @@ void PoolManager::SpawnPoolInMaps(uint16 pool_id, bool instantly) // pool no have spawns (base at loading algo if (!poolTemplate.mapEntry) + { return; + } SpawnPoolInMapsWorker worker(*this, pool_id, instantly); sMapPersistentStateMgr.DoForAllStatesWithMapId(poolTemplate.mapEntry->MapID, worker); @@ -1187,7 +1199,9 @@ void PoolManager::DespawnPoolInMaps(uint16 pool_id) // pool no have spawns (base at loading algo if (!poolTemplate.mapEntry) + { return; + } DespawnPoolInMapsWorker worker(*this, pool_id); sMapPersistentStateMgr.DoForAllStatesWithMapId(poolTemplate.mapEntry->MapID, worker); @@ -1223,7 +1237,9 @@ void PoolManager::UpdatePoolInMaps(uint16 pool_id, uint32 db_guid_or_pool_id) // pool no have spawns (base at loading algo if (!poolTemplate.mapEntry) + { return; + } UpdatePoolInMapsWorker worker(*this, pool_id, db_guid_or_pool_id); sMapPersistentStateMgr.DoForAllStatesWithMapId(poolTemplate.mapEntry->MapID, worker); diff --git a/src/game/WorldHandlers/QueryHandler.cpp b/src/game/WorldHandlers/QueryHandler.cpp index 7935d4527..b4aef1eda 100644 --- a/src/game/WorldHandlers/QueryHandler.cpp +++ b/src/game/WorldHandlers/QueryHandler.cpp @@ -43,7 +43,9 @@ void WorldSession::SendNameQueryOpcode(Player* p) { if (!p) + { return; + } // guess size WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 1 + 1 + 1 + 1 + 10)); @@ -87,7 +89,9 @@ void WorldSession::SendNameQueryOpcodeFromDB(ObjectGuid guid) void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult* result, uint32 accountId) { if (!result) + { return; + } WorldSession* session = sWorld.FindSession(accountId); if (!session) diff --git a/src/game/WorldHandlers/QuestDef.cpp b/src/game/WorldHandlers/QuestDef.cpp index 1b7d717b1..d4a356f94 100644 --- a/src/game/WorldHandlers/QuestDef.cpp +++ b/src/game/WorldHandlers/QuestDef.cpp @@ -301,7 +301,9 @@ uint32 Quest::XPValue(Player* pPlayer) const int32 Quest::GetRewOrReqMoney() const { if (RewOrReqMoney <= 0) + { return RewOrReqMoney; + } return int32(RewOrReqMoney * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); } @@ -309,7 +311,9 @@ int32 Quest::GetRewOrReqMoney() const bool Quest::IsAllowedInRaid() const { if (Type == QUEST_TYPE_RAID || Type == QUEST_TYPE_RAID_10 || Type == QUEST_TYPE_RAID_25) + { return true; + } return sWorld.getConfig(CONFIG_BOOL_QUEST_IGNORE_RAID); } @@ -327,7 +331,9 @@ uint32 Quest::CalculateRewardHonor(uint32 level) const /* not exist in 4.x TeamContributionPoints const* tc = sTeamContributionPoints.LookupEntry(level-1); if(!tc) + { return 0; + } */ uint32 i_honor = uint32(/*tc->Value*/1.0f * GetRewHonorMultiplier() * 0.1f); honor = i_honor + GetRewHonorAddition(); diff --git a/src/game/WorldHandlers/QuestHandler.cpp b/src/game/WorldHandlers/QuestHandler.cpp index 5b7b9c8e4..1e66b9f91 100644 --- a/src/game/WorldHandlers/QuestHandler.cpp +++ b/src/game/WorldHandlers/QuestHandler.cpp @@ -107,7 +107,9 @@ void WorldSession::HandleQuestgiverHelloOpcode(WorldPacket& recv_data) pCreature->StopMoving(); if (sScriptMgr.OnGossipHello(_player, pCreature)) + { return; + } _player->PrepareGossipMenu(pCreature, pCreature->GetCreatureInfo()->GossipMenuId); _player->SendPreparedGossip(pCreature); @@ -121,7 +123,9 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recv_data) recv_data >> guid >> quest >> unk1; if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_ACCEPT_QUEST")) + { return; + } DEBUG_LOG("WORLD: Received opcode CMSG_QUESTGIVER_ACCEPT_QUEST - for %s to %s, quest = %u, unk1 = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, unk1); @@ -247,16 +251,22 @@ void WorldSession::HandleQuestgiverChooseRewardOpcode(WorldPacket& recv_data) } if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_CHOOSE_REWARD")) + { return; + } DEBUG_LOG("WORLD: Received opcode CMSG_QUESTGIVER_CHOOSE_REWARD - for %s to %s, quest = %u, reward = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, reward); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); if (!pObject) + { return; + } if (!pObject->HasInvolvedQuest(quest)) + { return; + } Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest); if (pQuest) @@ -281,19 +291,25 @@ void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket& recv_data) recv_data >> guid >> quest; if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_REQUEST_REWARD")) + { return; + } DEBUG_LOG("WORLD: Received opcode CMSG_QUESTGIVER_REQUEST_REWARD - for %s to %s, quest = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); if (!pObject || !pObject->HasInvolvedQuest(quest)) + { return; + } if (_player->CanCompleteQuest(quest)) _player->CompleteQuest(quest); if (_player->GetQuestStatus(quest) != QUEST_STATUS_COMPLETE) + { return; + } if (Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest)) _player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true); @@ -312,7 +328,9 @@ void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data) recv_data >> slot1 >> slot2; if (slot1 == slot2 || slot1 >= MAX_QUEST_LOG_SIZE || slot2 >= MAX_QUEST_LOG_SIZE) + { return; + } DEBUG_LOG("WORLD: Received opcode CMSG_QUESTLOG_SWAP_QUEST slot 1 = %u, slot 2 = %u", slot1, slot2); @@ -373,22 +391,30 @@ void WorldSession::HandleQuestConfirmAccept(WorldPacket& recv_data) if (const Quest* pQuest = sObjectMgr.GetQuestTemplate(quest)) { if (!pQuest->HasQuestFlag(QUEST_FLAGS_PARTY_ACCEPT)) + { return; + } Player* pOriginalPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid()); if (!pOriginalPlayer) + { return; + } if (pQuest->IsAllowedInRaid()) { if (!_player->IsInSameRaidWith(pOriginalPlayer)) + { return; + } } else { if (!_player->IsInSameGroupWith(pOriginalPlayer)) + { return; + } } if (_player->CanAddQuest(pQuest, true)) @@ -406,7 +432,9 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) recv_data >> guid >> quest >> unk; if (!CanInteractWithQuestGiver(guid, "CMSG_QUESTGIVER_COMPLETE_QUEST")) + { return; + } // All ok, continue DEBUG_LOG("WORLD: Received opcode CMSG_QUESTGIVER_COMPLETE_QUEST - for %s to %s, quest = %u, unk = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest, unk); diff --git a/src/game/WorldHandlers/ScriptMgr.cpp b/src/game/WorldHandlers/ScriptMgr.cpp index 3c334dc7c..a31203393 100644 --- a/src/game/WorldHandlers/ScriptMgr.cpp +++ b/src/game/WorldHandlers/ScriptMgr.cpp @@ -76,7 +76,9 @@ uint8 GetSpellStartDBScriptPriority(SpellEntry const* spellinfo, SpellEffectInde #if defined (CATA) SpellEffectEntry const* spellEffect = spellinfo->GetSpellEffect(effIdx); if (!spellEffect) + { return 0; + } #endif #if defined (CATA) if (spellEffect->Effect == SPELL_EFFECT_SCRIPT_EFFECT) @@ -1357,7 +1359,9 @@ bool ScriptAction::HandleScriptStep() pWorldObject = pSource; } else if (pTarget && pTarget->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT)) - { pWorldObject = pTarget; } + { + pWorldObject = pTarget; + } // if we have a distance, we must have a worldobject if (m_script->questExplored.distance != 0 && !pWorldObject) @@ -1373,7 +1377,9 @@ bool ScriptAction::HandleScriptStep() failQuest = true; } else if (m_script->questExplored.distance != 0 && !pWorldObject->IsWithinDistInMap(pPlayer, float(m_script->questExplored.distance))) - { failQuest = true; } + { + failQuest = true; + } // quest id and flags checked at script loading if (!failQuest) @@ -1381,7 +1387,9 @@ bool ScriptAction::HandleScriptStep() pPlayer->AreaExploredOrEventHappens(m_script->questExplored.questId); } else - { pPlayer->FailQuest(m_script->questExplored.questId); } + { + pPlayer->FailQuest(m_script->questExplored.questId); + } break; } @@ -1420,7 +1428,9 @@ bool ScriptAction::HandleScriptStep() pPlayer->RewardPlayerAndGroupAtEvent(creatureEntry, pSearcher); } else - { pPlayer->KilledMonsterCredit(creatureEntry, pRewardSource ? pRewardSource->GetObjectGuid() : ObjectGuid()); } + { + pPlayer->KilledMonsterCredit(creatureEntry, pRewardSource ? pRewardSource->GetObjectGuid() : ObjectGuid()); + } break; } @@ -1626,9 +1636,13 @@ bool ScriptAction::HandleScriptStep() pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget); } else if (m_script->playSound.flags & (4 | 8)) - { m_map->PlayDirectSoundToMap(m_script->playSound.soundId, (m_script->playSound.flags & 8) ? pSource->GetZoneId() : 0); } + { + m_map->PlayDirectSoundToMap(m_script->playSound.soundId, (m_script->playSound.flags & 8) ? pSource->GetZoneId() : 0); + } else - { pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget); } + { + pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget); + } } break; } @@ -1732,7 +1746,9 @@ bool ScriptAction::HandleScriptStep() ((Creature*)pSource)->SetFactionTemporary(m_script->faction.factionId, m_script->faction.flags); } else - { ((Creature*)pSource)->ClearTemporaryFaction(); } + { + ((Creature*)pSource)->ClearTemporaryFaction(); + } break; } @@ -1748,7 +1764,9 @@ bool ScriptAction::HandleScriptStep() ((Creature*)pSource)->DeMorph(); } else if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) - { ((Creature*)pSource)->SetDisplayId(m_script->morph.creatureOrModelEntry); } + { + ((Creature*)pSource)->SetDisplayId(m_script->morph.creatureOrModelEntry); + } else { CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_script->morph.creatureOrModelEntry); @@ -1771,7 +1789,9 @@ bool ScriptAction::HandleScriptStep() ((Creature*)pSource)->Unmount(); } else if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) - { ((Creature*)pSource)->Mount(m_script->mount.creatureOrModelEntry); } + { + ((Creature*)pSource)->Mount(m_script->mount.creatureOrModelEntry); + } else { CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(m_script->mount.creatureOrModelEntry); @@ -1839,14 +1859,18 @@ bool ScriptAction::HandleScriptStep() pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); } else if (m_script->goLockState.lockState & 0x02) - { pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); } + { + pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); + } // Set Non Interactable or Set Interactable if (m_script->goLockState.lockState & 0x04) { pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT); } else if (m_script->goLockState.lockState & 0x08) - { pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT); } + { + pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT); + } break; } @@ -1875,7 +1899,9 @@ bool ScriptAction::HandleScriptStep() } // Remove Flags else if (m_script->npcFlag.change_flag & 0x02) - { pSource->RemoveFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); } + { + pSource->RemoveFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); + } // Toggle Flags else { @@ -1884,7 +1910,9 @@ bool ScriptAction::HandleScriptStep() pSource->RemoveFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); } else - { pSource->SetFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); } + { + pSource->SetFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); + } } break; @@ -1929,7 +1957,9 @@ bool ScriptAction::HandleScriptStep() } } else - { result = true; } + { + result = true; + } if (result) // Terminate further steps of this script { @@ -1958,7 +1988,9 @@ bool ScriptAction::HandleScriptStep() ((Creature*)pSource)->addUnitState(UNIT_STAT_WAYPOINT_PAUSED); } else - { ((Creature*)pSource)->clearUnitState(UNIT_STAT_WAYPOINT_PAUSED); } + { + ((Creature*)pSource)->clearUnitState(UNIT_STAT_WAYPOINT_PAUSED); + } break; } case SCRIPT_COMMAND_XP_USER: // 33 @@ -1995,7 +2027,9 @@ bool ScriptAction::HandleScriptStep() terminateResult = !sObjectMgr.IsPlayerMeetToCondition(m_script->terminateCond.conditionId, player, m_map, second, CONDITION_FROM_DBSCRIPTS); } else - { terminateResult = sObjectMgr.IsPlayerMeetToCondition(m_script->terminateCond.conditionId, player, m_map, second, CONDITION_FROM_DBSCRIPTS); } + { + terminateResult = sObjectMgr.IsPlayerMeetToCondition(m_script->terminateCond.conditionId, player, m_map, second, CONDITION_FROM_DBSCRIPTS); + } if (terminateResult && m_script->terminateCond.failQuest && player) { @@ -2023,7 +2057,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_SEND_AI_EVENT_AROUND: // 35 { if (LogIfNotCreature(pSource)) + { return false; + } if (LogIfNotUnit(pTarget)) break; @@ -2048,9 +2084,13 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_MOVE_DYNAMIC: // 37 { if (LogIfNotCreature(pSource)) + { return false; + } if (LogIfNotUnit(pTarget)) + { return false; + } float x, y, z; if (m_script->moveDynamic.maxDist == 0) // Move to pTarget @@ -2081,9 +2121,13 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_SEND_MAIL: // 38 { if (LogIfNotPlayer(pTarget)) + { return false; + } if (!m_script->sendMail.altSender && LogIfNotCreature(pSource)) + { return false; + } MailSender sender; if (m_script->sendMail.altSender) @@ -2132,7 +2176,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_SET_EQUIPMENT_SLOTS: // 42 { if (LogIfNotCreature(pSource)) + { return false; + } Creature* pCSource = static_cast(pSource); // reset default @@ -2176,7 +2222,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_UPDATE_TEMPLATE: // 44 { if (LogIfNotCreature(pSource)) + { return false; + } Creature* pCSource = static_cast(pSource); @@ -2425,7 +2473,9 @@ CreatureAI* ScriptMgr::GetCreatureAI(Creature* pCreature) // Used by Eluna #ifdef ENABLE_ELUNA if (CreatureAI* luaAI = sEluna->GetAI(pCreature)) + { return luaAI; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2449,7 +2499,9 @@ bool ScriptMgr::OnGossipHello(Player* pPlayer, Creature* pCreature) // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnGossipHello(pPlayer, pCreature)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2464,7 +2516,9 @@ bool ScriptMgr::OnGossipHello(Player* pPlayer, GameObject* pGameObject) // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnGossipHello(pPlayer, pGameObject)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2481,13 +2535,17 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 send { // Used by Eluna if (sEluna->OnGossipSelectCode(pPlayer, pCreature, sender, action, code)) + { return true; + } } else { // Used by Eluna if (sEluna->OnGossipSelect(pPlayer, pCreature, sender, action)) + { return true; + } } #endif /* ENABLE_ELUNA */ @@ -2497,7 +2555,9 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 send return SD3::GossipSelectWithCode(pPlayer, pCreature, sender, action, code); } else - { return SD3::GossipSelect(pPlayer, pCreature, sender, action); } + { + return SD3::GossipSelect(pPlayer, pCreature, sender, action); + } #else return false; #endif @@ -2510,12 +2570,16 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 if (code) { if (sEluna->OnGossipSelectCode(pPlayer, pGameObject, sender, action, code)) + { return true; + } } else { if (sEluna->OnGossipSelect(pPlayer, pGameObject, sender, action)) + { return true; + } } #endif /* ENABLE_ELUNA */ @@ -2525,7 +2589,9 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 return SD3::GOGossipSelectWithCode(pPlayer, pGameObject, sender, action, code); } else - { return SD3::GOGossipSelect(pPlayer, pGameObject, sender, action); } + { + return SD3::GOGossipSelect(pPlayer, pGameObject, sender, action); + } #else return false; #endif @@ -2536,7 +2602,9 @@ bool ScriptMgr::OnQuestAccept(Player* pPlayer, Creature* pCreature, Quest const* // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnQuestAccept(pPlayer, pCreature, pQuest)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2551,7 +2619,9 @@ bool ScriptMgr::OnQuestAccept(Player* pPlayer, GameObject* pGameObject, Quest co // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnQuestAccept(pPlayer, pGameObject, pQuest)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2566,7 +2636,9 @@ bool ScriptMgr::OnQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest) // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnQuestAccept(pPlayer, pItem, pQuest)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2581,7 +2653,9 @@ bool ScriptMgr::OnQuestRewarded(Player* pPlayer, Creature* pCreature, Quest cons // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnQuestReward(pPlayer, pCreature, pQuest, reward)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2596,7 +2670,9 @@ bool ScriptMgr::OnQuestRewarded(Player* pPlayer, GameObject* pGameObject, Quest // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnQuestReward(pPlayer, pGameObject, pQuest, reward)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2611,7 +2687,9 @@ uint32 ScriptMgr::GetDialogStatus(Player* pPlayer, Creature* pCreature) // Used by Eluna #ifdef ENABLE_ELUNA if (uint32 dialogId = sEluna->GetDialogStatus(pPlayer, pCreature)) + { return dialogId; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2626,7 +2704,9 @@ uint32 ScriptMgr::GetDialogStatus(Player* pPlayer, GameObject* pGameObject) // Used by Eluna #ifdef ENABLE_ELUNA if (uint32 dialogId = sEluna->GetDialogStatus(pPlayer, pGameObject)) + { return dialogId; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2640,7 +2720,9 @@ bool ScriptMgr::OnGameObjectUse(Player* pPlayer, GameObject* pGameObject) { #ifdef ENABLE_ELUNA if (sEluna->OnGameObjectUse(pPlayer, pGameObject)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2655,7 +2737,9 @@ bool ScriptMgr::OnItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& // Used by Eluna #ifdef ENABLE_ELUNA if (!sEluna->OnUse(pPlayer, pItem, targets)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2670,7 +2754,9 @@ bool ScriptMgr::OnAreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry) // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnAreaTrigger(pPlayer, atEntry)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2704,7 +2790,9 @@ bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex ef #ifdef ENABLE_ELUNA if (pTarget->ToCreature()) if (sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget->ToCreature())) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2719,7 +2807,9 @@ bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex ef // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2734,7 +2824,9 @@ bool ScriptMgr::OnEffectDummy(Unit* pCaster, uint32 spellId, SpellEffectIndex ef // Used by Eluna #ifdef ENABLE_ELUNA if (sEluna->OnDummyEffect(pCaster, spellId, effIndex, pTarget)) + { return true; + } #endif /* ENABLE_ELUNA */ #ifdef ENABLE_SD3 @@ -2903,7 +2995,9 @@ bool StartEvents_Event(Map* map, uint32 id, Object* source, Object* target, bool #endif { bg = ((BattleGroundMap*)map)->GetBG(); } else // Use the go, because GOs don't move - { opvp = sOutdoorPvPMgr.GetScript(((GameObject*)source)->GetZoneId()); } + { + opvp = sOutdoorPvPMgr.GetScript(((GameObject*)source)->GetZoneId()); + } } if (bg && bg->HandleEvent(id, static_cast(source))) @@ -2923,7 +3017,9 @@ bool StartEvents_Event(Map* map, uint32 id, Object* source, Object* target, bool execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE; } else if (target && target->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT)) - { execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET; } + { + execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET; + } return map->ScriptsStart(DBS_ON_EVENT, id, source, target, execParam); } diff --git a/src/game/WorldHandlers/SkillDiscovery.cpp b/src/game/WorldHandlers/SkillDiscovery.cpp index 6cf266476..a720f6cf9 100644 --- a/src/game/WorldHandlers/SkillDiscovery.cpp +++ b/src/game/WorldHandlers/SkillDiscovery.cpp @@ -173,7 +173,9 @@ uint32 GetExplicitDiscoverySpell(uint32 spellId, Player* player) // in this case we have both skill and spell SkillDiscoveryMap::const_iterator tab = SkillDiscoveryStore.find(spellId); if (tab == SkillDiscoveryStore.end()) + { return 0; + } SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spellId); uint32 skillvalue = bounds.first != bounds.second ? player->GetSkillValue(bounds.first->second->skillId) : 0; @@ -196,7 +198,9 @@ uint32 GetExplicitDiscoverySpell(uint32 spellId, Player* player) continue; if (item_iter->chance > roll) + { return item_iter->spellId; + } roll -= item_iter->chance; } @@ -225,7 +229,9 @@ uint32 GetSkillDiscoverySpell(uint32 skillId, uint32 spellId, Player* player) } if (!skillId) + { return 0; + } // check skill line case tab = SkillDiscoveryStore.find(-(int32)skillId); diff --git a/src/game/WorldHandlers/SkillHandler.cpp b/src/game/WorldHandlers/SkillHandler.cpp index ce921ee53..a66fdb3d7 100644 --- a/src/game/WorldHandlers/SkillHandler.cpp +++ b/src/game/WorldHandlers/SkillHandler.cpp @@ -108,7 +108,9 @@ void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket& recv_data) } if (!unit->CanTrainAndResetTalentsOf(_player)) + { return; + } if (!(_player->resetTalents())) { diff --git a/src/game/WorldHandlers/Spell.cpp b/src/game/WorldHandlers/Spell.cpp index 3cd29d24e..d3675e814 100644 --- a/src/game/WorldHandlers/Spell.cpp +++ b/src/game/WorldHandlers/Spell.cpp @@ -115,7 +115,9 @@ bool IsQuestTameSpell(uint32 spellId) { SpellEntry const* spellproto = sSpellStore.LookupEntry(spellId); if (!spellproto) + { return false; + } SpellEffectEntry const* spellEffect0 = spellproto->GetSpellEffect(EFFECT_INDEX_0); SpellEffectEntry const* spellEffect1 = spellproto->GetSpellEffect(EFFECT_INDEX_1); @@ -146,7 +148,9 @@ SpellCastTargets::~SpellCastTargets() void SpellCastTargets::setUnitTarget(Unit* target) { if (!target) + { return; + } m_destX = target->GetPositionX(); m_destY = target->GetPositionY(); @@ -182,7 +186,9 @@ void SpellCastTargets::setGOTarget(GameObject* target) void SpellCastTargets::setItemTarget(Item* item) { if (!item) + { return; + } m_itemTarget = item; m_itemTargetGUID = item->GetObjectGuid(); @@ -912,7 +918,9 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex) { SpellEffectEntry const *spellEffect = m_spellInfo->GetSpellEffect(effIndex); if (!spellEffect || spellEffect->Effect == 0) + { return; + } // Check for effect immune skip if immuned bool immuned = pVictim->IsImmuneToSpellEffect(m_spellInfo, effIndex, pVictim == m_caster); @@ -1014,7 +1022,9 @@ void Spell::AddGOTarget(GameObject* pVictim, SpellEffectIndex effIndex) { SpellEffectEntry const* spellEffect = m_spellInfo->GetSpellEffect(effIndex); if (!spellEffect || spellEffect->Effect == 0) + { return; + } ObjectGuid targetGUID = pVictim->GetObjectGuid(); @@ -1067,7 +1077,9 @@ void Spell::AddItemTarget(Item* pitem, SpellEffectIndex effIndex) { SpellEffectEntry const* spellEffect = m_spellInfo->GetSpellEffect(effIndex); if (!spellEffect || spellEffect->Effect == 0) + { return; + } // Lookup target in already in list for (ItemTargetList::iterator ihit = m_UniqueItemInfo.begin(); ihit != m_UniqueItemInfo.end(); ++ihit) @@ -1090,7 +1102,9 @@ void Spell::AddItemTarget(Item* pitem, SpellEffectIndex effIndex) void Spell::DoAllEffectOnTarget(TargetInfo* target) { if (target->processed) // Check target + { return; + } target->processed = true; // Target checked in apply effects procedure // Get mask of effects for target @@ -1098,7 +1112,9 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) Unit* unit = m_caster->GetObjectGuid() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); if (!unit) + { return; + } // Get original caster (if exist) and calculate damage/healing from him data Unit* real_caster = GetAffectiveCaster(); @@ -1298,7 +1314,9 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) void Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) { if (!unit || !effectMask) + { return; + } Unit* realCaster = GetAffectiveCaster(); @@ -1476,16 +1494,22 @@ void Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) void Spell::DoAllEffectOnTarget(GOTargetInfo* target) { if (target->processed) // Check target + { return; + } target->processed = true; // Target checked in apply effects procedure uint32 effectMask = target->effectMask; if (!effectMask) + { return; + } GameObject* go = m_caster->GetMap()->GetGameObject(target->targetGUID); if (!go) + { return; + } for (int effectNumber = 0; effectNumber < MAX_EFFECT_INDEX; ++effectNumber) if (effectMask & (1 << effectNumber)) @@ -1504,7 +1528,9 @@ void Spell::DoAllEffectOnTarget(ItemTargetInfo* target) { uint32 effectMask = target->effectMask; if (!target->item || !effectMask) + { return; + } for (int effectNumber = 0; effectNumber < MAX_EFFECT_INDEX; ++effectNumber) if (effectMask & (1 << effectNumber)) @@ -1518,7 +1544,9 @@ void Spell::HandleDelayedSpellLaunch(TargetInfo* target) Unit* unit = m_caster->GetObjectGuid() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); if (!unit) + { return; + } // Get original caster (if exist) and calculate damage/healing from him data Unit* real_caster = GetAffectiveCaster(); @@ -1593,7 +1621,9 @@ bool Spell::IsAliveUnitPresentInTargetList() { // Not need check return true if (m_needAliveTargetMask == 0) + { return true; + } uint8 needAliveTargetMask = m_needAliveTargetMask; @@ -1629,17 +1659,25 @@ struct ChainHealingOrder : public std::binary_functionGetTypeId() == TYPEID_PLAYER && MainTarget->GetTypeId() == TYPEID_PLAYER && ((Player const*)Target)->IsInSameRaidWith((Player const*)MainTarget)) { if (Target->GetHealth() == Target->GetMaxHealth()) + { return 40000; + } else + { return 20000 - Target->GetMaxHealth() + Target->GetHealth(); + } } else + { return 40000 - Target->GetMaxHealth() + Target->GetHealth(); + } } }; @@ -1686,7 +1724,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& SpellEffectEntry const* spellEffect = m_spellInfo->GetSpellEffect(effIndex); SpellClassOptionsEntry const* classOpt = m_spellInfo->GetSpellClassOptions(); if (!spellEffect) + { return; + } uint32 EffectChainTarget = spellEffect ? spellEffect->EffectChainTarget : 0; uint32 unMaxTargets = m_spellInfo->GetMaxAffectedTargets(); @@ -2251,7 +2291,9 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& { WorldObject* caster = GetAffectiveCasterObject(); if (!caster) + { return; + } if (caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->IsTemporarySummon()) targetUnitMap.push_back(((TemporarySummon*)(Creature*)caster)->GetSummoner()); @@ -3093,7 +3135,9 @@ SpellCastResult Spell::PreCastCheck(Aura* triggeredByAura /*= NULL*/) { // Prevent casting at cast another spell (ServerSide check) if (m_caster->IsNonMeleeSpellCasted(false, true, true) && m_cast_count && !m_spellInfo->HasAttribute(SPELL_ATTR_EX4_CAN_CAST_WHILE_CASTING)) + { return SPELL_FAILED_SPELL_IN_PROGRESS; + } SpellCastResult result = CheckCast(true); if (result != SPELL_CAST_OK && !IsAutoRepeat()) // always cast autorepeat dummy for triggering @@ -3201,7 +3245,9 @@ void Spell::Prepare() void Spell::cancel() { if (m_spellState == SPELL_STATE_FINISHED) + { return; + } // channeled spells don't display interrupted message even if they are interrupted, possible other cases with no "Interrupted" message bool sendInterrupt = IsChanneledSpell(m_spellInfo) ? false : true; @@ -3600,7 +3646,9 @@ void Spell::TakeAmmo() // wands don't have ammo if (!pItem || pItem->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_WAND) + { return; + } if (pItem->GetProto()->InventoryType == INVTYPE_THROWN) { @@ -3754,7 +3802,9 @@ void Spell::_handle_finish_phase() void Spell::SendSpellCooldown() { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* _player = (Player*)m_caster; @@ -3768,7 +3818,9 @@ void Spell::SendSpellCooldown() // (1) have infinity cooldown but set at aura apply, (2) passive cooldown at triggering if (m_spellInfo->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE) || m_spellInfo->HasAttribute(SPELL_ATTR_PASSIVE)) + { return; + } _player->AddSpellAndCategoryCooldowns(m_spellInfo, m_CastItem ? m_CastItem->GetEntry() : 0, this); } @@ -3908,16 +3960,22 @@ void Spell::update(uint32 difftime) void Spell::finish(bool ok) { if (!m_caster) + { return; + } if (m_spellState == SPELL_STATE_FINISHED) + { return; + } m_spellState = SPELL_STATE_FINISHED; // other code related only to successfully finished spells if (!ok) + { return; + } // handle SPELL_AURA_ADD_TARGET_TRIGGER auras Unit::AuraList const& targetTriggers = m_caster->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); @@ -4005,13 +4063,19 @@ void Spell::finish(bool ok) void Spell::SendCastResult(SpellCastResult result) { if (result == SPELL_CAST_OK) + { return; + } if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (((Player*)m_caster)->GetSession()->PlayerLoading()) // don't send cast results at loading time + { return; + } SendCastResult((Player*)m_caster, m_spellInfo, m_cast_count, result); } @@ -4019,7 +4083,9 @@ void Spell::SendCastResult(SpellCastResult result) void Spell::SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 cast_count, SpellCastResult result, bool isPetCastResult /*=false*/) { if (result == SPELL_CAST_OK) + { return; + } WorldPacket data(isPetCastResult ? SMSG_PET_CAST_FAILED : SMSG_CAST_FAILED, (4 + 1 + 2)); data << uint8(cast_count); // single cast or multi 2.3 (0/1) @@ -4123,7 +4189,9 @@ void Spell::SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 ca void Spell::SendSpellStart() { if (!IsNeedSendToClient()) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Sending SMSG_SPELL_START id=%u", m_spellInfo->Id); @@ -4218,7 +4286,9 @@ void Spell::SendSpellGo() { // not send invisible spell casting if (!IsNeedSendToClient()) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Sending SMSG_SPELL_GO id=%u", m_spellInfo->Id); @@ -4593,7 +4663,9 @@ void Spell::SendChannelUpdate(uint32 time) // Only finish channeling when latest channeled spell finishes if (m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != m_spellInfo->Id) + { return; + } m_caster->SetChannelObjectGuid(ObjectGuid()); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); @@ -4690,7 +4762,9 @@ void Spell::SendResurrectRequest(Player* target) void Spell::SendPlaySpellVisual(uint32 SpellID) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } WorldPacket data; m_caster->BuildSendPlayVisualPacket(&data, SpellID, false); @@ -4701,11 +4775,15 @@ void Spell::SendPlaySpellVisual(uint32 SpellID) void Spell::TakeCastItem() { if (!m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // not remove cast item at triggered spell (equipping, weapon damage, etc) if (m_IsTriggeredSpell && !(m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM)) + { return; + } ItemPrototype const* proto = m_CastItem->GetProto(); @@ -4760,7 +4838,9 @@ void Spell::TakeCastItem() void Spell::TakePower() { if (m_CastItem || m_triggeredByAuraSpell) + { return; + } bool hit = true; if (m_caster->GetTypeId() == TYPEID_PLAYER) @@ -4820,7 +4900,9 @@ void Spell::TakePower() // Zealotry - does not take power if (m_spellInfo->Id == 85696) + { return; + } m_caster->ModifyPower(powerType, -(int32)m_usedHolyPower); return; @@ -4838,20 +4920,28 @@ void Spell::TakePower() SpellCastResult Spell::CheckRunePower() { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_CAST_OK; + } Player* plr = (Player*)m_caster; if (plr->getClass() != CLASS_DEATH_KNIGHT) + { return SPELL_CAST_OK; + } SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID); if (!src) + { return SPELL_CAST_OK; + } if (src->NoRuneCost()) + { return SPELL_CAST_OK; + } // at this moment for rune cost exist only no cost mods, and no percent mods int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death @@ -4884,20 +4974,28 @@ SpellCastResult Spell::CheckRunePower() void Spell::TakeRunePower(bool hit) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* plr = (Player*)m_caster; if (plr->getClass() != CLASS_DEATH_KNIGHT) + { return; + } SpellRuneCostEntry const* src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID); if (!src) + { return; + } if (src->NoRuneCost() && src->NoRunicPowerGain()) + { return; + } m_runesState = plr->GetRunesState(); // store previous state @@ -4972,14 +5070,20 @@ void Spell::TakeRunePower(bool hit) void Spell::TakeReagents() { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (IgnoreItemRequirements()) // reagents used in triggered spell removed by original spell or don't must be removed. + { return; + } Player* p_caster = (Player*)m_caster; if (p_caster->CanNoReagentCast(m_spellInfo)) + { return; + } SpellReagentsEntry const* spellReagents = m_spellInfo->GetSpellReagents(); @@ -5025,12 +5129,16 @@ void Spell::TakeReagents() void Spell::HandleThreatSpells() { if (m_UniqueTargetInfo.empty()) + { return; + } SpellThreatEntry const* threatEntry = sSpellMgr.GetSpellThreatEntry(m_spellInfo->Id); if (!threatEntry || (!threatEntry->threat && threatEntry->ap_bonus == 0.0f)) + { return; + } float threat = threatEntry->threat; if (threatEntry->ap_bonus != 0.0f) @@ -5163,7 +5271,9 @@ Unit* Spell::GetPrefilledUnitTargetOrUnitTarget(SpellEffectIndex effIndex) const { for (TargetList::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) if (itr->effectMask & (1 << effIndex)) + { return m_caster->GetMap()->GetUnit(itr->targetGUID); + } return m_targets.getUnitTarget(); } @@ -5175,20 +5285,28 @@ SpellCastResult Spell::CheckCast(bool strict) ((Player*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) { if (m_triggeredByAuraSpell) + { return SPELL_FAILED_DONT_REPORT; + } else + { return SPELL_FAILED_NOT_READY; + } } // check global cooldown if (strict && !m_IsTriggeredSpell && HasGlobalCooldown()) + { return SPELL_FAILED_NOT_READY; + } // only allow triggered spells if at an ended battleground if (!m_IsTriggeredSpell && m_caster->GetTypeId() == TYPEID_PLAYER) if (BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) if (bg->GetStatus() == STATUS_WAIT_LEAVE) + { return SPELL_FAILED_DONT_REPORT; + } if (!m_IsTriggeredSpell && IsNonCombatSpell(m_spellInfo) && m_caster->IsInCombat() && !m_caster->IsIgnoreUnitState(m_spellInfo, IGNORE_UNIT_COMBAT_STATE)) @@ -5216,10 +5334,14 @@ SpellCastResult Spell::CheckCast(bool strict) // Cannot be used in this stance/form SpellCastResult shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->GetShapeshiftForm()); if (shapeError != SPELL_CAST_OK) + { return shapeError; + } if (m_spellInfo->HasAttribute(SPELL_ATTR_ONLY_STEALTHED) && !(m_caster->HasStealthAura())) + { return SPELL_FAILED_ONLY_STEALTHED; + } } } @@ -5227,13 +5349,19 @@ SpellCastResult Spell::CheckCast(bool strict) // caster state requirements if(auraRestrictions && auraRestrictions->CasterAuraState && !m_caster->HasAuraState(AuraState(auraRestrictions->CasterAuraState))) + { return SPELL_FAILED_CASTER_AURASTATE; + } if(auraRestrictions && auraRestrictions->CasterAuraStateNot && m_caster->HasAuraState(AuraState(auraRestrictions->CasterAuraStateNot))) + { return SPELL_FAILED_CASTER_AURASTATE; + } // Caster aura req check if need if(auraRestrictions && auraRestrictions->casterAuraSpell && !m_caster->HasAura(auraRestrictions->casterAuraSpell)) + { return SPELL_FAILED_CASTER_AURASTATE; + } if(auraRestrictions && auraRestrictions->excludeCasterAuraSpell) { // Special cases of non existing auras handling @@ -5241,10 +5369,14 @@ SpellCastResult Spell::CheckCast(bool strict) { // Avenging Wrath Marker if (m_caster->HasAura(61987)) + { return SPELL_FAILED_CASTER_AURASTATE; + } } else if(m_caster->HasAura(auraRestrictions->excludeCasterAuraSpell)) + { return SPELL_FAILED_CASTER_AURASTATE; + } } if (m_caster->GetTypeId() == TYPEID_PLAYER) @@ -5268,7 +5400,9 @@ SpellCastResult Spell::CheckCast(bool strict) // Spells like Disengage are allowed only in combat if (!m_caster->IsInCombat() && m_spellInfo->HasAttribute(SPELL_ATTR_STOP_ATTACK_TARGET) && m_spellInfo->HasAttribute(SPELL_ATTR_EX2_UNK26)) + { return SPELL_FAILED_CASTER_AURASTATE; + } SpellClassOptionsEntry const* classOptions = m_spellInfo->GetSpellClassOptions(); @@ -5276,14 +5410,20 @@ SpellCastResult Spell::CheckCast(bool strict) { // target state requirements (not allowed state), apply to self also if(auraRestrictions && auraRestrictions->TargetAuraStateNot && target->HasAuraState(AuraState(auraRestrictions->TargetAuraStateNot))) + { return SPELL_FAILED_TARGET_AURASTATE; + } if (!m_IsTriggeredSpell && IsDeathOnlySpell(m_spellInfo) && target->IsAlive()) + { return SPELL_FAILED_TARGET_NOT_DEAD; + } // Target aura req check if need if(auraRestrictions && auraRestrictions->targetAuraSpell && !target->HasAura(auraRestrictions->targetAuraSpell)) + { return SPELL_FAILED_CASTER_AURASTATE; + } if(auraRestrictions && auraRestrictions->excludeTargetAuraSpell) { @@ -5292,10 +5432,14 @@ SpellCastResult Spell::CheckCast(bool strict) { // Avenging Wrath Marker if (target->HasAura(61987)) + { return SPELL_FAILED_CASTER_AURASTATE; + } } else if (target->HasAura(auraRestrictions->excludeTargetAuraSpell)) + { return SPELL_FAILED_CASTER_AURASTATE; + } } // totem immunity for channeled spells(needs to be before spell cast) @@ -5341,11 +5485,15 @@ SpellCastResult Spell::CheckCast(bool strict) { // spell expected to be auto-downranking in cast handle, so must be same if (m_spellInfo != sSpellMgr.SelectAuraRankForLevel(m_spellInfo, target->getLevel())) + { return SPELL_FAILED_LOWLEVEL; + } } if (strict && m_spellInfo->HasAttribute(SPELL_ATTR_EX3_TARGET_ONLY_PLAYER) && target->GetTypeId() != TYPEID_PLAYER && !IsAreaOfEffectSpell(m_spellInfo)) + { return SPELL_FAILED_BAD_TARGETS; + } } else if (m_caster == target) { @@ -5359,7 +5507,9 @@ SpellCastResult Spell::CheckCast(bool strict) { target = m_caster->GetMap()->GetUnit(((Player*)m_caster)->GetSelectionGuid()); if (!target) + { return SPELL_FAILED_BAD_TARGETS; + } m_targets.setUnitTarget(target); } @@ -5374,16 +5524,22 @@ SpellCastResult Spell::CheckCast(bool strict) // Focus Magic (main spell) if (m_spellInfo->Id == 54646) + { return SPELL_FAILED_BAD_TARGETS; + } // Lay on Hands (self cast) if (classOptions && classOptions->SpellFamilyName == SPELLFAMILY_PALADIN && classOptions->SpellFamilyFlags & UI64LIT(0x0000000000008000)) { if (target->HasAura(25771)) // Forbearance + { return SPELL_FAILED_CASTER_AURASTATE; + } if (target->HasAura(61987)) // Avenging Wrath Marker + { return SPELL_FAILED_CASTER_AURASTATE; + } } } @@ -5400,12 +5556,18 @@ SpellCastResult Spell::CheckCast(bool strict) if (!pet) { if (m_triggeredByAuraSpell) // not report pet not existence for triggered spells + { return SPELL_FAILED_DONT_REPORT; + } else + { return SPELL_FAILED_NO_PET; + } } else if (!pet->IsAlive()) + { return SPELL_FAILED_TARGETS_DEAD; + } break; } } @@ -5417,9 +5579,13 @@ SpellCastResult Spell::CheckCast(bool strict) if (!CheckTargetCreatureType(target)) { if (target->GetTypeId() == TYPEID_PLAYER) + { return SPELL_FAILED_TARGET_IS_PLAYER; + } else + { return SPELL_FAILED_BAD_TARGETS; + } } // simple cases @@ -5442,7 +5608,9 @@ SpellCastResult Spell::CheckCast(bool strict) } if (target_hostile) + { return SPELL_FAILED_BAD_TARGETS; + } explicit_target_mode = true; } @@ -5455,7 +5623,9 @@ SpellCastResult Spell::CheckCast(bool strict) } if (target_friendly) + { return SPELL_FAILED_BAD_TARGETS; + } explicit_target_mode = true; } @@ -5474,7 +5644,9 @@ SpellCastResult Spell::CheckCast(bool strict) } if (target_hostile) + { return SPELL_FAILED_BAD_TARGETS; + } } else { @@ -5485,14 +5657,18 @@ SpellCastResult Spell::CheckCast(bool strict) } if (target_friendly) + { return SPELL_FAILED_BAD_TARGETS; + } } } } if (IsPositiveSpell(m_spellInfo->Id)) if (target->IsImmuneToSpell(m_spellInfo, target == m_caster)) + { return SPELL_FAILED_TARGET_AURASTATE; + } // Must be behind the target. if (m_spellInfo->AttributesEx2 == SPELL_ATTR_EX2_UNK20 && m_spellInfo->HasAttribute(SPELL_ATTR_EX_UNK9) && target->HasInArc(M_PI_F, m_caster)) @@ -5518,7 +5694,9 @@ SpellCastResult Spell::CheckCast(bool strict) // check if target is in combat if (non_caster_target && m_spellInfo->HasAttribute(SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->IsInCombat()) + { return SPELL_FAILED_TARGET_AFFECTING_COMBAT; + } } // zone check uint32 zone, area; @@ -5527,16 +5705,22 @@ SpellCastResult Spell::CheckCast(bool strict) SpellCastResult locRes = sSpellMgr.GetSpellAllowedInLocationError(m_spellInfo, m_caster->GetMapId(), zone, area, m_caster->GetCharmerOrOwnerPlayerOrPlayerItself()); if (locRes != SPELL_CAST_OK) + { return locRes; + } // not let players cast spells at mount (and let do it to creatures) if (m_caster->IsMounted() && m_caster->GetTypeId() == TYPEID_PLAYER && !m_IsTriggeredSpell && !IsPassiveSpell(m_spellInfo) && !m_spellInfo->HasAttribute(SPELL_ATTR_CASTABLE_WHILE_MOUNTED)) { if (m_caster->IsTaxiFlying()) + { return SPELL_FAILED_NOT_ON_TAXI; + } else + { return SPELL_FAILED_NOT_MOUNTED; + } } // always (except passive spells) check items @@ -5544,7 +5728,9 @@ SpellCastResult Spell::CheckCast(bool strict) { SpellCastResult castResult = CheckItems(); if (castResult != SPELL_CAST_OK) + { return castResult; + } } // check spell focus object @@ -5556,7 +5742,9 @@ SpellCastResult Spell::CheckCast(bool strict) Cell::VisitGridObjects(m_caster, checker, m_caster->GetMap()->GetVisibilityDistance()); if (!ok) + { return SPELL_FAILED_REQUIRES_SPELL_FOCUS; + } focusObject = ok; // game object found in range } @@ -5739,9 +5927,13 @@ SpellCastResult Spell::CheckCast(bool strict) { // not report target not existence for triggered spells if (m_triggeredByAuraSpell || m_IsTriggeredSpell) + { return SPELL_FAILED_DONT_REPORT; + } else + { return SPELL_FAILED_BAD_TARGETS; + } } } } @@ -5752,20 +5944,26 @@ SpellCastResult Spell::CheckCast(bool strict) { SpellCastResult castResult = CheckRange(strict); if (castResult != SPELL_CAST_OK) + { return castResult; + } } { SpellCastResult castResult = CheckPower(); if (castResult != SPELL_CAST_OK) + { return castResult; + } } if (!m_IsTriggeredSpell) // triggered spell not affected by stun/etc { SpellCastResult castResult = CheckCasterAuras(); if (castResult != SPELL_CAST_OK) + { return castResult; + } } for (int i = 0; i < MAX_EFFECT_INDEX; ++i) @@ -5781,25 +5979,37 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_spellInfo->Id == 48743) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_FAILED_ERROR; + } if (!((Player*)m_caster)->GetSelectionGuid()) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } Pet* target = m_caster->GetMap()->GetPet(((Player*)m_caster)->GetSelectionGuid()); // alive if (!target || target->IsDead()) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } // undead if (target->GetCreatureType() != CREATURE_TYPE_UNDEAD) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } // owned if (target->GetOwnerGuid() != m_caster->GetObjectGuid()) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } float dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellEffect->GetRadiusIndex())); if (!target->IsWithinDistInMap(m_caster,dist)) + { return SPELL_FAILED_OUT_OF_RANGE; + } // will set in target selection code } @@ -5809,7 +6019,9 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_spellInfo->Id == 51582) // Rocket Boots Engaged { if (m_caster->IsInWater()) + { return SPELL_FAILED_ONLY_ABOVEWATER; + } } else if (m_spellInfo->Id == 51690) // Killing Spree { @@ -5822,26 +6034,34 @@ SpellCastResult Spell::CheckCast(bool strict) Cell::VisitAllObjects(m_caster, checker, radius); if (targets.empty()) + { return SPELL_FAILED_OUT_OF_RANGE; + } } else if (m_spellInfo->Id == 68996) // Two forms { if (m_caster->IsInCombat()) + { return SPELL_FAILED_AFFECTING_COMBAT; + } } else if (m_spellInfo->SpellIconID == 156) // Holy Shock { // spell different for friends and enemies // hart version required facing if (m_targets.getUnitTarget() && !m_caster->IsFriendlyTo(m_targets.getUnitTarget()) && !m_caster->HasInArc(M_PI_F, m_targets.getUnitTarget())) + { return SPELL_FAILED_UNIT_NOT_INFRONT; + } } // Fire Nova if (m_spellInfo->GetSpellFamilyName() == SPELLFAMILY_SHAMAN && m_spellInfo->SpellIconID == 33) { // fire totems slot if (!m_caster->GetTotemGuid(TOTEM_SLOT_FIRE)) + { return SPELL_FAILED_TOTEMS; + } } break; } @@ -5859,7 +6079,9 @@ SpellCastResult Spell::CheckCast(bool strict) for (UnitList::iterator itr = targetsCombat.begin(); itr != targetsCombat.end(); ++itr) if ((*itr)->IsInCombat()) + { return SPELL_FAILED_TARGET_IN_COMBAT; + } } break; } @@ -5869,10 +6091,14 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_spellInfo->SpellVisual[0] == 7250) { if (!m_targets.getUnitTarget()) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } if (m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth() * 0.2) + { return SPELL_FAILED_BAD_TARGETS; + } } break; } @@ -5943,15 +6169,21 @@ SpellCastResult Spell::CheckCast(bool strict) Pet* pet = m_caster->GetPet(); if (!pet) + { return SPELL_FAILED_NO_PET; + } SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(spellEffect->EffectTriggerSpell); if (!learn_spellproto) + { return SPELL_FAILED_NOT_KNOWN; + } if(m_spellInfo->GetSpellLevel() > pet->getLevel()) + { return SPELL_FAILED_LOWLEVEL; + } break; } @@ -5960,14 +6192,20 @@ SpellCastResult Spell::CheckCast(bool strict) Pet* pet = m_caster->GetPet(); if (!pet) + { return SPELL_FAILED_NO_PET; + } SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(spellEffect->EffectTriggerSpell); if (!learn_spellproto) + { return SPELL_FAILED_NOT_KNOWN; + } if(m_spellInfo->GetSpellLevel() > pet->getLevel()) + { return SPELL_FAILED_LOWLEVEL; + } break; } @@ -5976,31 +6214,45 @@ SpellCastResult Spell::CheckCast(bool strict) uint32 glyphId = spellEffect->EffectMiscValue; if(GlyphPropertiesEntry const *gp = sGlyphPropertiesStore.LookupEntry(glyphId)) if(m_caster->HasAura(gp->SpellId)) + { return SPELL_FAILED_UNIQUE_GLYPH; + } break; } case SPELL_EFFECT_FEED_PET: { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_FAILED_BAD_TARGETS; + } Item* foodItem = m_targets.getItemTarget(); if (!foodItem) + { return SPELL_FAILED_BAD_TARGETS; + } Pet* pet = m_caster->GetPet(); if (!pet) + { return SPELL_FAILED_NO_PET; + } if (!pet->HaveInDiet(foodItem->GetProto())) + { return SPELL_FAILED_WRONG_PET_FOOD; + } if (!pet->GetCurrentFoodBenefitLevel(foodItem->GetProto()->ItemLevel)) + { return SPELL_FAILED_FOOD_LOWLEVEL; + } if (pet->IsInCombat()) + { return SPELL_FAILED_AFFECTING_COMBAT; + } break; } @@ -6011,23 +6263,31 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->GetTypeId() == TYPEID_PLAYER) if (Unit* target = m_targets.getUnitTarget()) if (target != m_caster && int32(target->GetPowerType()) != spellEffect->EffectMiscValue) + { return SPELL_FAILED_BAD_TARGETS; + } break; } case SPELL_EFFECT_CHARGE: { if (m_caster->hasUnitState(UNIT_STAT_ROOT)) + { return SPELL_FAILED_ROOTED; + } break; } case SPELL_EFFECT_SKINNING: { if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_targets.getUnitTarget() || m_targets.getUnitTarget()->GetTypeId() != TYPEID_UNIT) + { return SPELL_FAILED_BAD_TARGETS; + } if (!m_targets.getUnitTarget()->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE)) + { return SPELL_FAILED_TARGET_UNSKINNABLE; + } Creature* creature = (Creature*)m_targets.getUnitTarget(); if (creature->GetCreatureType() != CREATURE_TYPE_CRITTER && (!creature->lootForBody || creature->lootForSkin || !creature->loot.empty())) @@ -6041,20 +6301,26 @@ SpellCastResult Spell::CheckCast(bool strict) int32 TargetLevel = m_targets.getUnitTarget()->getLevel(); int32 ReqValue = (skillValue < 100 ? (TargetLevel - 10) * 10 : TargetLevel * 5); if (ReqValue > skillValue) + { return SPELL_FAILED_LOW_CASTLEVEL; + } break; } case SPELL_EFFECT_OPEN_LOCK: { if (m_caster->GetTypeId() != TYPEID_PLAYER) // only players can open locks, gather etc. + { return SPELL_FAILED_BAD_TARGETS; + } // we need a go target in case of TARGET_GAMEOBJECT (for other targets acceptable GO and items) if (spellEffect->EffectImplicitTargetA == TARGET_GAMEOBJECT) { if (!m_targets.getGOTarget()) + { return SPELL_FAILED_BAD_TARGETS; + } } // get the lock entry @@ -6068,22 +6334,30 @@ SpellCastResult Spell::CheckCast(bool strict) lockId = go->GetGOInfo()->GetLockId(); if (!lockId) + { return SPELL_FAILED_ALREADY_OPEN; + } } else if (Item* item = m_targets.getItemTarget()) { // not own (trade?) if (item->GetOwner() != m_caster) + { return SPELL_FAILED_ITEM_GONE; + } lockId = item->GetProto()->LockID; // if already unlocked if (!lockId || item->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_UNLOCKED)) + { return SPELL_FAILED_ALREADY_OPEN; + } } else + { return SPELL_FAILED_BAD_TARGETS; + } SkillType skillId = SKILL_NONE; int32 reqSkillValue = 0; @@ -6092,7 +6366,9 @@ SpellCastResult Spell::CheckCast(bool strict) // check lock compatibility SpellCastResult res = CanOpenLock(SpellEffectIndex(i), lockId, skillId, reqSkillValue, skillValue); if (res != SPELL_CAST_OK) + { return res; + } // Failing gathering attempt for mining and herbalism was removed in patch 3.1.0: http://wowwiki.wikia.com/wiki/Patch_3.1.0 // chance for fail at orange LockPicking gathering attempt @@ -6103,7 +6379,9 @@ SpellCastResult Spell::CheckCast(bool strict) // chance for failure in orange gather / lockpick (gathering skill can't fail at maxskill) if ((canFailAtMax || skillValue < sWorld.GetConfigMaxSkillValue()) && reqSkillValue > irand(skillValue - 25, skillValue + 37)) + { return SPELL_FAILED_TRY_AGAIN; + } } break; } @@ -6111,10 +6389,14 @@ SpellCastResult Spell::CheckCast(bool strict) { Creature* pet = m_caster->GetPet(); if (!pet) + { return SPELL_FAILED_NO_PET; + } if (pet->IsAlive()) + { return SPELL_FAILED_ALREADY_HAVE_SUMMON; + } break; } @@ -6126,10 +6408,14 @@ SpellCastResult Spell::CheckCast(bool strict) if (summon_prop->Group == SUMMON_PROP_GROUP_PETS) { if (m_caster->GetPetGuid()) + { return SPELL_FAILED_ALREADY_HAVE_SUMMON; + } if (m_caster->GetCharmGuid()) + { return SPELL_FAILED_ALREADY_HAVE_CHARM; + } } } @@ -6138,7 +6424,9 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_EFFECT_SUMMON_PET: { if (m_caster->GetCharmGuid()) + { return SPELL_FAILED_ALREADY_HAVE_CHARM; + } uint32 plClass = m_caster->getClass(); if (plClass == CLASS_HUNTER) @@ -6146,9 +6434,13 @@ SpellCastResult Spell::CheckCast(bool strict) if (Creature* pet = m_caster->GetPet()) { if (!pet->IsAlive() || pet->IsDead()) // this one will not play along; tried and retried countless times.... + { return SPELL_FAILED_TARGETS_DEAD; + } else + { return SPELL_FAILED_ALREADY_HAVE_SUMMON; + } } else { @@ -6171,7 +6463,9 @@ SpellCastResult Spell::CheckCast(bool strict) pet->CastSpell(pet, 32752, true, NULL, NULL, pet->GetObjectGuid()); } else + { return SPELL_FAILED_ALREADY_HAVE_SUMMON; + } } break; @@ -6179,24 +6473,36 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_EFFECT_SUMMON_PLAYER: { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_FAILED_BAD_TARGETS; + } if (!((Player*)m_caster)->GetSelectionGuid()) + { return SPELL_FAILED_BAD_TARGETS; + } Player* target = sObjectMgr.GetPlayer(((Player*)m_caster)->GetSelectionGuid()); if (!target || ((Player*)m_caster) == target || !target->IsInSameRaidWith((Player*)m_caster)) + { return SPELL_FAILED_BAD_TARGETS; + } // check if our map is dungeon if (sMapStore.LookupEntry(m_caster->GetMapId())->IsDungeon()) { InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(m_caster->GetMapId()); if (!instance) + { return SPELL_FAILED_TARGET_NOT_IN_INSTANCE; + } if (instance->levelMin > target->getLevel()) + { return SPELL_FAILED_LOWLEVEL; + } if (instance->levelMax && instance->levelMax < target->getLevel()) + { return SPELL_FAILED_HIGHLEVEL; + } } break; } @@ -6210,29 +6516,41 @@ SpellCastResult Spell::CheckCast(bool strict) if (Player* owner = ObjectAccessor::FindPlayer(corpse->GetOwnerGuid())) { if (owner->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION)) + { return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED; + } } else + { return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED; + } } else + { return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED; + } } else if (m_targets.m_targetMask & TARGET_FLAG_UNIT) { Unit* target = m_targets.getUnitTarget(); if (!target || target->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION)) + { return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED; + } } else + { return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED; + } break; } case SPELL_EFFECT_SELF_RESURRECT: { if (m_caster->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION)) + { return SPELL_FAILED_TARGET_CANNOT_BE_RESURRECTED; + } break; } @@ -6240,7 +6558,9 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER: { if (!m_caster || m_caster->IsTaxiFlying()) + { return SPELL_FAILED_NOT_ON_TAXI; + } // Blink has leap first and then removing of auras with root effect // need further research with this @@ -6251,7 +6571,9 @@ SpellCastResult Spell::CheckCast(bool strict) if (spellEffect->Effect != SPELL_EFFECT_LEAP) { if (m_caster->hasUnitState(UNIT_STAT_ROOT)) + { return SPELL_FAILED_ROOTED; + } } if (m_caster->GetTypeId() == TYPEID_PLAYER) @@ -6259,7 +6581,9 @@ SpellCastResult Spell::CheckCast(bool strict) // not allow use this effect at battleground until battleground start if (BattleGround const* bg = ((Player*)m_caster)->GetBattleGround()) if (bg->GetStatus() != STATUS_IN_PROGRESS) + { return SPELL_FAILED_TRY_AGAIN; + } } break; @@ -6267,7 +6591,9 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_EFFECT_STEAL_BENEFICIAL_BUFF: { if (m_targets.getUnitTarget() == m_caster) + { return SPELL_FAILED_BAD_TARGETS; + } break; } default: break; @@ -6296,11 +6622,15 @@ SpellCastResult Spell::CheckCast(bool strict) { case 34026: // Kill Command if (!m_caster->GetPet()) + { return SPELL_FAILED_NO_PET; + } break; case 61336: // Survival Instincts if (m_caster->GetTypeId() != TYPEID_PLAYER || !((Player*)m_caster)->IsInFeralForm()) + { return SPELL_FAILED_ONLY_SHAPESHIFT; + } break; default: break; @@ -6310,73 +6640,113 @@ SpellCastResult Spell::CheckCast(bool strict) case SPELL_AURA_MOD_POSSESS: { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_FAILED_UNKNOWN; + } if (expectedTarget == m_caster) + { return SPELL_FAILED_BAD_TARGETS; + } if (m_caster->GetPetGuid()) + { return SPELL_FAILED_ALREADY_HAVE_SUMMON; + } if (m_caster->GetCharmGuid()) + { return SPELL_FAILED_ALREADY_HAVE_CHARM; + } if (m_caster->GetCharmerGuid()) + { return SPELL_FAILED_CHARMED; + } if (!expectedTarget) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } if (expectedTarget->GetCharmerGuid()) + { return SPELL_FAILED_CHARMED; + } if (int32(expectedTarget->getLevel()) > CalculateDamage(SpellEffectIndex(i), expectedTarget)) + { return SPELL_FAILED_HIGHLEVEL; + } break; } case SPELL_AURA_MOD_CHARM: { if (expectedTarget == m_caster) + { return SPELL_FAILED_BAD_TARGETS; + } if (m_caster->GetPetGuid()) + { return SPELL_FAILED_ALREADY_HAVE_SUMMON; + } if (m_caster->GetCharmGuid()) + { return SPELL_FAILED_ALREADY_HAVE_CHARM; + } if (m_caster->GetCharmerGuid()) + { return SPELL_FAILED_CHARMED; + } if (!expectedTarget) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } if (expectedTarget->GetCharmerGuid()) + { return SPELL_FAILED_CHARMED; + } if (int32(expectedTarget->getLevel()) > CalculateDamage(SpellEffectIndex(i), expectedTarget)) + { return SPELL_FAILED_HIGHLEVEL; + } break; } case SPELL_AURA_MOD_POSSESS_PET: { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_FAILED_UNKNOWN; + } if (m_caster->GetCharmGuid()) + { return SPELL_FAILED_ALREADY_HAVE_CHARM; + } if (m_caster->GetCharmerGuid()) + { return SPELL_FAILED_CHARMED; + } Pet* pet = m_caster->GetPet(); if (!pet) + { return SPELL_FAILED_NO_PET; + } if (pet->GetCharmerGuid()) + { return SPELL_FAILED_CHARMED; + } break; } @@ -6384,28 +6754,40 @@ SpellCastResult Spell::CheckCast(bool strict) { if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->GetTransport()) + { return SPELL_FAILED_NO_MOUNTS_ALLOWED; + } if (spellEffect->EffectMiscValueB && !m_caster->GetMountCapability(spellEffect->EffectMiscValueB)) + { return SPELL_FAILED_NOT_HERE; + } // Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells if (m_caster->GetTypeId() == TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->GetAreaGroupId()) + { return SPELL_FAILED_NO_MOUNTS_ALLOWED; + } if (m_caster->IsInDisallowedMountForm()) + { return SPELL_FAILED_NOT_SHAPESHIFT; + } break; } case SPELL_AURA_RANGED_ATTACK_POWER_ATTACKER_BONUS: { if (!expectedTarget) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } // can be casted at non-friendly unit or own pet/charm if (m_caster->IsFriendlyTo(expectedTarget)) + { return SPELL_FAILED_TARGET_FRIENDLY; + } break; } @@ -6417,30 +6799,40 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_caster->GetTypeId() == TYPEID_PLAYER && m_caster->IsAlive()) { if (!((Player*)m_caster)->CanStartFlyInArea(m_caster->GetMapId(), zone, area)) + { return m_IsTriggeredSpell ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_NOT_HERE; + } } break; } case SPELL_AURA_PERIODIC_MANA_LEECH: { if (!expectedTarget) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } if (m_caster->GetTypeId() != TYPEID_PLAYER || m_CastItem) break; if (expectedTarget->GetPowerType() != POWER_MANA) + { return SPELL_FAILED_BAD_TARGETS; + } break; } case SPELL_AURA_CONTROL_VEHICLE: { if (m_caster->HasAuraType(SPELL_AURA_MOUNTED)) + { return SPELL_FAILED_NOT_MOUNTED; + } if (!expectedTarget || !expectedTarget->IsVehicle()) + { return SPELL_FAILED_BAD_TARGETS; + } // It is possible to change between vehicles that are boarded on each other if (m_caster->IsBoarded() && m_caster->GetTransportInfo()->IsOnVehicle()) @@ -6452,36 +6844,50 @@ SpellCastResult Spell::CheckCast(bool strict) boardedOnEachOther = expectedTarget->GetVehicleInfo()->HasOnBoard(m_caster); if (!boardedOnEachOther) + { return SPELL_FAILED_NOT_ON_TRANSPORT; + } } if (!expectedTarget->GetVehicleInfo()->CanBoard(m_caster)) + { return SPELL_FAILED_BAD_TARGETS; + } break; } case SPELL_AURA_MIRROR_IMAGE: { if (!expectedTarget) + { return SPELL_FAILED_BAD_TARGETS; + } // Target must be creature. TODO: Check if target can also be player if (expectedTarget->GetTypeId() != TYPEID_UNIT) + { return SPELL_FAILED_BAD_TARGETS; + } if (expectedTarget == m_caster) // Clone self can't be accepted + { return SPELL_FAILED_BAD_TARGETS; + } // It is assumed that target can not be cloned if already cloned by same or other clone auras if (expectedTarget->HasAuraType(SPELL_AURA_MIRROR_IMAGE)) + { return SPELL_FAILED_BAD_TARGETS; + } break; } case SPELL_AURA_WORGEN_TRANSFORM: { if (!m_caster->HasWorgenForm()) + { return m_IsTriggeredSpell ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + } break; } default: @@ -6493,17 +6899,23 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_targets.m_targetMask & TARGET_FLAG_TRADE_ITEM) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_FAILED_NOT_TRADING; + } Player* pCaster = ((Player*)m_caster); TradeData* my_trade = pCaster->GetTradeData(); if (!my_trade) + { return SPELL_FAILED_NOT_TRADING; + } TradeSlots slot = TradeSlots(m_targets.getItemTargetGuid().GetRawValue()); if (slot != TRADE_SLOT_NONTRADED) + { return SPELL_FAILED_ITEM_NOT_READY; + } // if trade not complete then remember it in trade data if (!my_trade->IsInAcceptProcess()) @@ -6521,12 +6933,18 @@ SpellCastResult Spell::CheckCast(bool strict) SpellCastResult Spell::CheckPetCast(Unit* target) { if (!m_caster->IsAlive()) + { return SPELL_FAILED_CASTER_DEAD; + } if (m_caster->IsNonMeleeSpellCasted(false) && !m_spellInfo->HasAttribute(SPELL_ATTR_EX4_CAN_CAST_WHILE_CASTING)) // prevent spellcast interruption by another spellcast + { return SPELL_FAILED_SPELL_IN_PROGRESS; + } if (m_caster->IsInCombat() && IsNonCombatSpell(m_spellInfo)) + { return SPELL_FAILED_AFFECTING_COMBAT; + } if (m_caster->GetTypeId() == TYPEID_UNIT && (((Creature*)m_caster)->IsPet() || m_caster->IsCharmed())) { @@ -6536,7 +6954,9 @@ SpellCastResult Spell::CheckPetCast(Unit* target) { Player* pCharmer = charmer->GetTypeId() == TYPEID_PLAYER ? static_cast(charmer) : NULL; if (!charmer->IsAlive() && (!pCharmer || !pCharmer->IsGhouled())) + { return SPELL_FAILED_CASTER_DEAD; + } } if (!target && m_targets.getUnitTarget()) @@ -6559,7 +6979,9 @@ SpellCastResult Spell::CheckPetCast(Unit* target) { need = true; if (!target) + { return SPELL_FAILED_BAD_IMPLICIT_TARGETS; + } break; } else if (spellEffect->EffectImplicitTargetA == TARGET_SCRIPT_COORDINATES) @@ -6571,7 +6993,9 @@ SpellCastResult Spell::CheckPetCast(Unit* target) if (need) m_targets.setUnitTarget(target); else if (script == true) + { return CheckCast(true); + } Unit* _target = m_targets.getUnitTarget(); @@ -6584,7 +7008,9 @@ SpellCastResult Spell::CheckPetCast(Unit* target) if (IsPositiveSpell(m_spellInfo->Id)) { if (m_caster->IsHostileTo(_target)) + { return SPELL_FAILED_BAD_TARGETS; + } } else { @@ -6602,7 +7028,9 @@ SpellCastResult Spell::CheckPetCast(Unit* target) } // cooldown if (((Creature*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) + { return SPELL_FAILED_NOT_READY; + } } return CheckCast(true); @@ -6730,23 +7158,33 @@ SpellCastResult Spell::CheckCasterAuras() const { case SPELL_AURA_MOD_STUN: if (!spellUsableWhileStunned || !aura->HasMechanic(MECHANIC_STUN)) + { return SPELL_FAILED_STUNNED; + } break; case SPELL_AURA_MOD_CONFUSE: if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED)) + { return SPELL_FAILED_CONFUSED; + } break; case SPELL_AURA_MOD_FEAR: if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX5_USABLE_WHILE_FEARED)) + { return SPELL_FAILED_FLEEING; + } break; case SPELL_AURA_MOD_SILENCE: case SPELL_AURA_MOD_PACIFY: case SPELL_AURA_MOD_PACIFY_SILENCE: if( m_spellInfo->GetPreventionType() == SPELL_PREVENTION_TYPE_PACIFY) + { return SPELL_FAILED_PACIFIED; + } else if ( m_spellInfo->GetPreventionType() == SPELL_PREVENTION_TYPE_SILENCE) + { return SPELL_FAILED_SILENCED; + } break; default: break; } @@ -6755,7 +7193,9 @@ SpellCastResult Spell::CheckCasterAuras() const } // You are prevented from casting and the spell casted does not grant immunity. Return a failed error. else + { return prevented_reason; + } } return SPELL_CAST_OK; } @@ -6774,19 +7214,25 @@ bool Spell::CanAutoCast(Unit* target) if( m_spellInfo->GetStackAmount() <= 1) { if (target->HasAura(m_spellInfo->Id, SpellEffectIndex(j))) + { return false; + } } else { if(Aura* aura = target->GetAura(m_spellInfo->Id, SpellEffectIndex(j))) if(aura->GetStackAmount() >= m_spellInfo->GetStackAmount()) + { return false; + } } } else if ( IsAreaAuraEffect( spellEffect->Effect )) { if (target->HasAura(m_spellInfo->Id, SpellEffectIndex(j))) + { return false; + } } } @@ -6798,7 +7244,9 @@ bool Spell::CanAutoCast(Unit* target) // check if among target units, our WANTED target is as well (->only self cast spells return false) for (TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) if (ihit->targetGUID == targetguid) + { return true; + } } return false; // target invalid } @@ -6821,7 +7269,9 @@ SpellCastResult Spell::CheckRange(bool strict) if (target) { if (target == m_caster) + { return SPELL_CAST_OK; + } float range_mod = strict ? 0.0f : 5.0f; if (Player* modOwner = m_caster->GetSpellModOwner()) @@ -6854,9 +7304,13 @@ SpellCastResult Spell::CheckRange(bool strict) float dist = m_caster->GetCombatDistance(target, m_spellInfo->rangeIndex == SPELL_RANGE_IDX_COMBAT); if (dist > max_range) + { return SPELL_FAILED_OUT_OF_RANGE; + } if (min_range && dist < min_range) + { return SPELL_FAILED_TOO_CLOSE; + } if( m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->GetFacingCasterFlags() & SPELL_FACING_FLAG_INFRONT) && !m_caster->HasInArc( M_PI_F, target ) ) return SPELL_FAILED_UNIT_NOT_INFRONT; @@ -6866,9 +7320,13 @@ SpellCastResult Spell::CheckRange(bool strict) if (m_targets.m_targetMask == TARGET_FLAG_DEST_LOCATION && m_targets.m_destX != 0 && m_targets.m_destY != 0 && m_targets.m_destZ != 0) { if (!m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, max_range)) + { return SPELL_FAILED_OUT_OF_RANGE; + } if (min_range && m_caster->IsWithinDist3d(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, min_range)) + { return SPELL_FAILED_TOO_CLOSE; + } } return SPELL_CAST_OK; @@ -6878,17 +7336,23 @@ uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spel { // item cast not used power if (castItem) + { return 0; + } // Spell drain all exist power on cast (Only paladin lay of Hands) if (spellInfo->HasAttribute(SPELL_ATTR_EX_DRAIN_ALL_POWER)) { // If power type - health drain all if (spellInfo->powerType == POWER_HEALTH) + { return caster->GetHealth(); + } // Else drain all power if (spellInfo->powerType < MAX_POWERS) + { return caster->GetPower(Powers(spellInfo->powerType)); + } sLog.outError("Spell::CalculateManaCost: Unknown power type '%d' in spell %d", spellInfo->powerType, spellInfo->Id); return 0; } @@ -6965,7 +7429,9 @@ SpellCastResult Spell::CheckPower() { // item cast not used power if (m_CastItem) + { return SPELL_CAST_OK; + } // Do precise power regen on spell cast if (m_powerCost > 0 && m_caster->GetTypeId() == TYPEID_PLAYER) @@ -6980,7 +7446,9 @@ SpellCastResult Spell::CheckPower() if (m_spellInfo->powerType == POWER_HEALTH) { if (m_caster->GetHealth() <= m_powerCost) + { return SPELL_FAILED_CASTER_AURASTATE; + } return SPELL_CAST_OK; } @@ -6996,13 +7464,17 @@ SpellCastResult Spell::CheckPower() { SpellCastResult failReason = CheckRunePower(); if (failReason != SPELL_CAST_OK) + { return failReason; + } } // Check power amount Powers powerType = Powers(m_spellInfo->powerType); if (m_caster->GetPower(powerType) < m_powerCost) + { return SPELL_FAILED_NO_POWER; + } return SPELL_CAST_OK; } @@ -7011,14 +7483,18 @@ bool Spell::IgnoreItemRequirements() const { /// Check if it's an enchant scroll. These have no required reagents even though their spell does. if (m_CastItem && (m_CastItem->GetProto()->Flags & ITEM_FLAG_ENCHANT_SCROLL)) + { return true; + } if (m_IsTriggeredSpell) { /// Not own traded item (in trader trade slot) req. reagents including triggered spell case if (Item* targetItem = m_targets.getItemTarget()) if (targetItem->GetOwnerGuid() != m_caster->GetObjectGuid()) + { return false; + } /// Some triggered spells have same reagents that have master spell /// expected in test: master spell have reagents in first slot then triggered don't must use own @@ -7026,7 +7502,9 @@ bool Spell::IgnoreItemRequirements() const { SpellReagentsEntry const* spellReagents = m_triggeredBySpellInfo->GetSpellReagents(); if (!spellReagents || !spellReagents->Reagent[0]) + { return false; + } } return true; @@ -7038,7 +7516,9 @@ bool Spell::IgnoreItemRequirements() const SpellCastResult Spell::CheckItems() { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return SPELL_CAST_OK; + } Player* p_caster = (Player*)m_caster; bool isScrollItem = false; @@ -7048,15 +7528,21 @@ SpellCastResult Spell::CheckItems() if (m_CastItem) { if (m_CastItem->IsInTrade()) + { return SPELL_FAILED_ITEM_NOT_FOUND; + } uint32 itemid = m_CastItem->GetEntry(); if (!p_caster->HasItemCount(itemid, 1)) + { return SPELL_FAILED_ITEM_NOT_FOUND; + } ItemPrototype const* proto = m_CastItem->GetProto(); if (!proto) + { return SPELL_FAILED_ITEM_NOT_FOUND; + } if (proto->Flags & ITEM_FLAG_ENCHANT_SCROLL) isScrollItem = true; @@ -7064,7 +7550,9 @@ SpellCastResult Spell::CheckItems() for (int i = 0; i < 5; ++i) if (proto->Spells[i].SpellCharges) if (m_CastItem->GetSpellCharges(i) == 0) + { return SPELL_FAILED_NO_CHARGES_REMAIN; + } // consumable cast item checks if (proto->Class == ITEM_CLASS_CONSUMABLE && m_targets.getUnitTarget()) @@ -7117,7 +7605,9 @@ SpellCastResult Spell::CheckItems() } } if (failReason != SPELL_CAST_OK) + { return failReason; + } } } @@ -7146,7 +7636,9 @@ SpellCastResult Spell::CheckItems() else { if (m_caster->GetTypeId() == TYPEID_PLAYER && !((Player*)m_caster)->HasItemFitToSpellReqirements(m_spellInfo)) + { return m_IsTriggeredSpell ? SPELL_FAILED_DONT_REPORT : SPELL_FAILED_EQUIPPED_ITEM_CLASS; + } } // check reagents (ignore triggered spells with reagents processed by original spell) and special reagent ignore case. @@ -7170,7 +7662,9 @@ SpellCastResult Spell::CheckItems() { ItemPrototype const *proto = m_CastItem->GetProto(); if (!proto) + { return SPELL_FAILED_REAGENTS; + } for(int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s) { // CastItem will be used up and does not count as reagent @@ -7184,7 +7678,9 @@ SpellCastResult Spell::CheckItems() } if (!p_caster->HasItemCount(itemid, itemcount)) + { return SPELL_FAILED_REAGENTS; + } } } } @@ -7209,7 +7705,9 @@ SpellCastResult Spell::CheckItems() } if (totems != 0) + { return SPELL_FAILED_TOTEMS; + } } } @@ -7235,7 +7733,9 @@ SpellCastResult Spell::CheckItems() if (item->GetProto()->ItemLevel <= itemProto->ItemLevel) { if (item->HasMaxCharges()) + { return SPELL_FAILED_ITEM_AT_MAX_CHARGES; + } // will recharge in next effect continue; @@ -7258,7 +7758,9 @@ SpellCastResult Spell::CheckItems() { if (Item* item = p_caster->GetItemByEntry(spellEffect->EffectItemType)) if (item->HasMaxCharges()) + { return SPELL_FAILED_ITEM_AT_MAX_CHARGES; + } break; } @@ -7267,10 +7769,14 @@ SpellCastResult Spell::CheckItems() { Item* targetItem = m_targets.getItemTarget(); if (!targetItem) + { return SPELL_FAILED_ITEM_NOT_FOUND; + } if( targetItem->GetProto()->ItemLevel < m_spellInfo->GetBaseLevel() ) + { return SPELL_FAILED_LOWLEVEL; + } // Check if we can store a new scroll, enchanting vellum has implicit SPELL_EFFECT_CREATE_ITEM if (isVellumTarget && spellEffect->EffectItemType) { @@ -7288,12 +7794,18 @@ SpellCastResult Spell::CheckItems() uint32 enchant_id = spellEffect->EffectMiscValue; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if(!pEnchant) + { return SPELL_FAILED_ERROR; + } if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) + { return SPELL_FAILED_NOT_TRADEABLE; + } // cannot replace vellum with scroll in trade slot if (isVellumTarget) + { return SPELL_FAILED_ITEM_ENCHANT_TRADE_WINDOW; + } } break; } @@ -7301,16 +7813,22 @@ SpellCastResult Spell::CheckItems() { Item* item = m_targets.getItemTarget(); if (!item) + { return SPELL_FAILED_ITEM_NOT_FOUND; + } // Not allow enchant in trade slot for some enchant type if (item->GetOwner() != m_caster) { uint32 enchant_id = spellEffect->EffectMiscValue; SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if(!pEnchant) + { return SPELL_FAILED_ERROR; + } if (pEnchant->slot & ENCHANTMENT_CAN_SOULBOUND) + { return SPELL_FAILED_NOT_TRADEABLE; + } } break; } @@ -7320,69 +7838,103 @@ SpellCastResult Spell::CheckItems() case SPELL_EFFECT_DISENCHANT: { if (!m_targets.getItemTarget()) + { return SPELL_FAILED_CANT_BE_DISENCHANTED; + } // prevent disenchanting in trade slot if (m_targets.getItemTarget()->GetOwnerGuid() != m_caster->GetObjectGuid()) + { return SPELL_FAILED_CANT_BE_DISENCHANTED; + } ItemPrototype const* itemProto = m_targets.getItemTarget()->GetProto(); if (!itemProto) + { return SPELL_FAILED_CANT_BE_DISENCHANTED; + } // must have disenchant loot (other static req. checked at item prototype loading) if (!itemProto->DisenchantID) + { return SPELL_FAILED_CANT_BE_DISENCHANTED; + } // 2.0.x addon: Check player enchanting level against the item disenchanting requirements int32 item_disenchantskilllevel = itemProto->RequiredDisenchantSkill; if (item_disenchantskilllevel > int32(p_caster->GetSkillValue(SKILL_ENCHANTING))) + { return SPELL_FAILED_LOW_CASTLEVEL; + } break; } case SPELL_EFFECT_PROSPECTING: { if (!m_targets.getItemTarget()) + { return SPELL_FAILED_CANT_BE_PROSPECTED; + } // ensure item is a prospectable ore if (!(m_targets.getItemTarget()->GetProto()->Flags & ITEM_FLAG_PROSPECTABLE)) + { return SPELL_FAILED_CANT_BE_PROSPECTED; + } // prevent prospecting in trade slot if (m_targets.getItemTarget()->GetOwnerGuid() != m_caster->GetObjectGuid()) + { return SPELL_FAILED_CANT_BE_PROSPECTED; + } // Check for enough skill in jewelcrafting uint32 item_prospectingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; if (item_prospectingskilllevel > p_caster->GetSkillValue(SKILL_JEWELCRAFTING)) + { return SPELL_FAILED_LOW_CASTLEVEL; + } // make sure the player has the required ores in inventory if (int32(m_targets.getItemTarget()->GetCount()) < CalculateDamage(SpellEffectIndex(i), m_caster)) + { return SPELL_FAILED_NEED_MORE_ITEMS; + } if (!LootTemplates_Prospecting.HaveLootFor(m_targets.getItemTargetEntry())) + { return SPELL_FAILED_CANT_BE_PROSPECTED; + } break; } case SPELL_EFFECT_MILLING: { if (!m_targets.getItemTarget()) + { return SPELL_FAILED_CANT_BE_MILLED; + } // ensure item is a millable herb if (!(m_targets.getItemTarget()->GetProto()->Flags & ITEM_FLAG_MILLABLE)) + { return SPELL_FAILED_CANT_BE_MILLED; + } // prevent milling in trade slot if (m_targets.getItemTarget()->GetOwnerGuid() != m_caster->GetObjectGuid()) + { return SPELL_FAILED_CANT_BE_MILLED; + } // Check for enough skill in inscription uint32 item_millingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; if (item_millingskilllevel > p_caster->GetSkillValue(SKILL_INSCRIPTION)) + { return SPELL_FAILED_LOW_CASTLEVEL; + } // make sure the player has the required herbs in inventory if (int32(m_targets.getItemTarget()->GetCount()) < CalculateDamage(SpellEffectIndex(i), m_caster)) + { return SPELL_FAILED_NEED_MORE_ITEMS; + } if (!LootTemplates_Milling.HaveLootFor(m_targets.getItemTargetEntry())) + { return SPELL_FAILED_CANT_BE_MILLED; + } break; } @@ -7394,7 +7946,9 @@ SpellCastResult Spell::CheckItems() break; Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(m_attackType, true, false); if (!pItem) + { return SPELL_FAILED_EQUIPPED_ITEM; + } switch (pItem->GetProto()->SubClass) { @@ -7402,7 +7956,9 @@ SpellCastResult Spell::CheckItems() { uint32 ammo = pItem->GetEntry(); if (!((Player*)m_caster)->HasItemCount(ammo, 1)) + { return SPELL_FAILED_NO_AMMO; + } }; break; case ITEM_SUBCLASS_WEAPON_WAND: break; @@ -7421,17 +7977,23 @@ SpellCastResult Spell::CheckItems() void Spell::Delayed() { if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (m_spellState == SPELL_STATE_DELAYED) return; // spell is active and can't be time-backed if (isDelayableNoMore()) // Spells may only be delayed twice + { return; + } // spells not loosing casting time ( slam, dynamites, bombs.. ) if(!(m_spellInfo->GetInterruptFlags() & SPELL_INTERRUPT_FLAG_DAMAGE)) + { return; + } // check pushback reduce int32 delaytime = 500; // spellcasting delay is normally 500ms @@ -7439,7 +8001,9 @@ void Spell::Delayed() ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; if (delayReduce >= 100) + { return; + } delaytime = delaytime * (100 - delayReduce) / 100; @@ -7463,10 +8027,14 @@ void Spell::Delayed() void Spell::DelayedChannel() { if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER || getState() != SPELL_STATE_CASTING) + { return; + } if (isDelayableNoMore()) // Spells may only be delayed twice + { return; + } // check pushback reduce int32 delaytime = GetSpellDuration(m_spellInfo) * 25 / 100;// channeling delay is normally 25% of its time per hit @@ -7474,7 +8042,9 @@ void Spell::DelayedChannel() ((Player*)m_caster)->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; if (delayReduce >= 100) + { return; + } delaytime = delaytime * (100 - delayReduce) / 100; @@ -7544,7 +8114,9 @@ bool Spell::CheckTargetCreatureType(Unit* target) const { // not allow cast at player if (target->GetTypeId() == TYPEID_PLAYER) + { return false; + } spellCreatureTargetMask = 0x7FF; } @@ -7565,26 +8137,38 @@ bool Spell::CheckTargetCreatureType(Unit* target) const CurrentSpellTypes Spell::GetCurrentContainer() { if (IsNextMeleeSwingSpell()) + { return (CURRENT_MELEE_SPELL); + } else if (IsAutoRepeat()) + { return (CURRENT_AUTOREPEAT_SPELL); + } else if (IsChanneledSpell(m_spellInfo)) + { return (CURRENT_CHANNELED_SPELL); + } else + { return (CURRENT_GENERIC_SPELL); + } } bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) { SpellEffectEntry const* spellEffect = m_spellInfo->GetSpellEffect(eff); if(!spellEffect) + { return false; + } // Check targets for creature type mask and remove not appropriate (skip explicit self target case, maybe need other explicit targets) if(spellEffect->EffectImplicitTargetA != TARGET_SELF ) { if (!CheckTargetCreatureType(target)) + { return false; + } } // Check Aura spell req (need for AoE spells) @@ -7592,9 +8176,13 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) if(auraRestrictions) { if(auraRestrictions->targetAuraSpell && !target->HasAura(auraRestrictions->targetAuraSpell)) + { return false; + } if (auraRestrictions->excludeTargetAuraSpell && target->HasAura(auraRestrictions->excludeTargetAuraSpell)) + { return false; + } } // Check targets for not_selectable unit flag and remove @@ -7603,7 +8191,9 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) { // any unattackable target skipped if (target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) + { return false; + } // unselectable targets skipped in all cases except TARGET_SCRIPT targeting or vehicle passengers // in case TARGET_SCRIPT target selected by server always and can't be cheated @@ -7628,10 +8218,14 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) if (target != m_caster && target->GetTypeId() == TYPEID_PLAYER) { if (((Player*)target)->GetVisibility() == VISIBILITY_OFF) + { return false; + } if (((Player*)target)->isGameMaster() && !IsPositiveSpell(m_spellInfo->Id)) + { return false; + } } // Check targets for LOS visibility (except spells without range limitations ) @@ -7650,14 +8244,20 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) if (target != m_caster && !m_spellInfo->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !target->IsWithinLOSInMap(m_caster)) { if (!m_targets.getCorpseTargetGuid()) + { return false; + } Corpse* corpse = m_caster->GetMap()->GetCorpse(m_targets.getCorpseTargetGuid()); if (!corpse) + { return false; + } if (target->GetObjectGuid() != corpse->GetOwnerGuid()) + { return false; + } if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !corpse->IsWithinLOSInMap(m_caster)) { @@ -7687,12 +8287,16 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) { case 37433: // Spout (The Lurker Below), only players affected if its not in water if (target->GetTypeId() != TYPEID_PLAYER || target->IsInWater()) + { return false; + } break; case 68921: // Soulstorm (FoS), only targets farer than 10 away case 69049: // Soulstorm - = - if (m_caster->IsWithinDist(target, 10.0f, false)) + { return false; + } break; default: break; @@ -7716,15 +8320,21 @@ bool Spell::HaveTargetsForEffect(SpellEffectIndex effect) const { for (TargetList::const_iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) if (itr->effectMask & (1 << effect)) + { return true; + } for (GOTargetList::const_iterator itr = m_UniqueGOTargetInfo.begin(); itr != m_UniqueGOTargetInfo.end(); ++itr) if (itr->effectMask & (1 << effect)) + { return true; + } for (ItemTargetList::const_iterator itr = m_UniqueItemInfo.begin(); itr != m_UniqueItemInfo.end(); ++itr) if (itr->effectMask & (1 << effect)) + { return true; + } return false; } @@ -7851,13 +8461,17 @@ bool SpellEvent::IsDeletable() const SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, SkillType& skillId, int32& reqSkillValue, int32& skillValue) { if (!lockId) // possible case for GO and maybe for items. + { return SPELL_CAST_OK; + } // Get LockInfo LockEntry const* lockInfo = sLockStore.LookupEntry(lockId); if (!lockInfo) + { return SPELL_FAILED_BAD_TARGETS; + } bool reqKey = false; // some locks not have reqs @@ -7868,7 +8482,9 @@ SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, Ski // check key item (many fit cases can be) case LOCK_KEY_ITEM: if (lockInfo->Index[j] && m_CastItem && m_CastItem->GetEntry() == lockInfo->Index[j]) + { return SPELL_CAST_OK; + } reqKey = true; break; // check key skill (only single first fit case can be) @@ -7899,7 +8515,9 @@ SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, Ski skillValue += spellSkillBonus; if (skillValue < reqSkillValue) + { return SPELL_FAILED_LOW_CASTLEVEL; + } } return SPELL_CAST_OK; @@ -7908,7 +8526,9 @@ SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, Ski } if (reqKey) + { return SPELL_FAILED_BAD_TARGETS; + } return SPELL_CAST_OK; } @@ -8011,19 +8631,27 @@ void Spell::FillRaidOrPartyHealthPriorityTargets(UnitList& targetUnitMap, Unit* WorldObject* Spell::GetAffectiveCasterObject() const { if (!m_originalCasterGUID) + { return m_caster; + } if (m_originalCasterGUID.IsGameObject() && m_caster->IsInWorld()) + { return m_caster->GetMap()->GetGameObject(m_originalCasterGUID); + } return m_originalCaster; } WorldObject* Spell::GetCastingObject() const { if (m_originalCasterGUID.IsGameObject()) + { return m_caster->IsInWorld() ? m_caster->GetMap()->GetGameObject(m_originalCasterGUID) : NULL; + } else + { return m_caster; + } } void Spell::ResetEffectDamageAndHeal() @@ -8035,13 +8663,17 @@ void Spell::ResetEffectDamageAndHeal() void Spell::SelectMountByAreaAndSkill(Unit* target, SpellEntry const* parentSpell, uint32 spellId75, uint32 spellId150, uint32 spellId225, uint32 spellId300, uint32 spellIdSpecial) { if (!target || target->GetTypeId() != TYPEID_PLAYER) + { return; + } // Prevent stacking of mounts target->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); uint16 skillval = ((Player*)target)->GetSkillValue(SKILL_RIDING); if (!skillval) + { return; + } if (skillval >= 225 && (spellId300 > 0 || spellId225 > 0)) { @@ -8113,18 +8745,26 @@ bool Spell::HasGlobalCooldown() { // global cooldown have only player or controlled units if (m_caster->GetCharmInfo()) + { return m_caster->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(m_spellInfo); + } else if (m_caster->GetTypeId() == TYPEID_PLAYER) + { return ((Player*)m_caster)->GetGlobalCooldownMgr().HasGlobalCooldown(m_spellInfo); + } else + { return false; + } } void Spell::TriggerGlobalCooldown() { int32 gcd = m_spellInfo->GetStartRecoveryTime(); if (!gcd) + { return; + } // global cooldown can't leave range 1..1.5 secs (if it it) // exist some spells (mostly not player directly casted) that have < 1 sec and > 1.5 sec global cooldowns @@ -8154,11 +8794,15 @@ void Spell::TriggerGlobalCooldown() void Spell::CancelGlobalCooldown() { if (!m_spellInfo->GetStartRecoveryTime()) + { return; + } // cancel global cooldown when interrupting current cast if (m_caster->GetCurrentSpell(CURRENT_GENERIC_SPELL) != this) + { return; + } // global cooldown have only player or controlled units if (m_caster->GetCharmInfo()) diff --git a/src/game/WorldHandlers/Spell.h b/src/game/WorldHandlers/Spell.h index 219364d2b..c9111e83e 100644 --- a/src/game/WorldHandlers/Spell.h +++ b/src/game/WorldHandlers/Spell.h @@ -564,7 +564,9 @@ class Spell bool isDelayableNoMore() { if (m_delayAtDamageCount >= 2) + { return true; + } ++m_delayAtDamageCount; return false; @@ -751,7 +753,9 @@ namespace MaNGOS void Visit(PlayerMapType& m) { if (!i_originalCaster) + { return; + } for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { @@ -832,7 +836,9 @@ namespace MaNGOS MANGOS_ASSERT(i_data); if (!i_originalCaster || !i_castingObject) + { return; + } for (typename GridRefManager::iterator itr = m.begin(); itr != m.end(); ++itr) { diff --git a/src/game/WorldHandlers/SpellAuras.cpp b/src/game/WorldHandlers/SpellAuras.cpp index 694c05f33..e5029903d 100644 --- a/src/game/WorldHandlers/SpellAuras.cpp +++ b/src/game/WorldHandlers/SpellAuras.cpp @@ -617,7 +617,9 @@ Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* curr { SpellEffectEntry const* triggeredeffectEntry = triggeredSpellInfo->GetSpellEffect(SpellEffectIndex(i)); if (triggeredeffectEntry && triggeredeffectEntry->EffectImplicitTargetA == TARGET_SINGLE_ENEMY) + { return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); + } } } return new Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); @@ -944,10 +946,14 @@ void PersistentAreaAura::Update(uint32 diff) } } else - { remove = true; } + { + remove = true; + } } else - { remove = true; } + { + remove = true; + } Aura::Update(diff); @@ -988,11 +994,15 @@ bool Aura::CanProcFrom(SpellEntry const* spell, uint32 /*procFlag*/, uint32 Even if (GetHolder()->GetAuraCharges() > 0) { if (procEx != PROC_EX_CAST_END && EventProcEx == PROC_EX_NONE) + { return false; + } } } else if (EventProcEx == PROC_EX_NONE && procEx == PROC_EX_CAST_END) + { return false; + } // if no class mask defined, or spell_proc_event has SpellFamilyName=0 - allow proc if (!useClassMask || !mask) @@ -1008,7 +1018,9 @@ bool Aura::CanProcFrom(SpellEntry const* spell, uint32 /*procFlag*/, uint32 Even return true; } else - { return false; } + { + return false; + } } else // Passive spells hits here only if resist/reflect/immune/evade { @@ -1027,7 +1039,9 @@ bool Aura::CanProcFrom(SpellEntry const* spell, uint32 /*procFlag*/, uint32 Even // note: SpellFamilyName is not checked if no spell_proc_event is defined SpellClassOptionsEntry const* classOpt = spell->GetSpellClassOptions(); if(!classOpt) + { return true; + } return mask.IsFitToFamilyMask(classOpt->SpellFamilyFlags); } @@ -1217,11 +1231,15 @@ void Aura::TriggerSpell() trigger_spell_id = 25779; // Mana Burn if (GetTarget()->GetTypeId() != TYPEID_UNIT) + { return; + } triggerTarget = ((Creature*)GetTarget())->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 0, trigger_spell_id, SELECT_FLAG_POWER_MANA); if (!triggerTarget) + { return; + } break; } @@ -1338,7 +1356,9 @@ void Aura::TriggerSpell() // Note: In 1.12 triggered spell 24781 still exists, need to script dummy effect for this spell then // Select an unfriendly enemy in 100y range and attack it if (target->GetTypeId() != TYPEID_UNIT) + { return; + } ThreatList const& tList = target->GetThreatManager().getThreatList(); for (ThreatList::const_iterator itr = tList.begin(); itr != tList.end(); ++itr) @@ -1394,7 +1414,9 @@ void Aura::TriggerSpell() newAngle += M_PI_F / 40; } else - { newAngle -= M_PI_F / 40; } + { + newAngle -= M_PI_F / 40; + } newAngle = NormalizeOrientation(newAngle); @@ -1485,7 +1507,9 @@ void Aura::TriggerSpell() case 29528: // Inoculate Nestlewood Owlkin // prevent error reports in case ignored player target if (triggerTarget->GetTypeId() != TYPEID_UNIT) + { return; + } break; // // Overload // case 29768: break; @@ -1512,7 +1536,9 @@ void Aura::TriggerSpell() { Unit* caster = GetCaster(); if (!caster) + { return; + } // move loot to player inventory and despawn target if (caster->GetTypeId() == TYPEID_PLAYER && triggerTarget->GetTypeId() == TYPEID_UNIT && @@ -1522,7 +1548,9 @@ void Aura::TriggerSpell() Creature* creature = (Creature*)triggerTarget; // missing Lootid has been reported on startup - just return if (!creature->GetCreatureInfo()->SkinningLootId) + { return; + } player->AutoStoreLoot(creature, creature->GetCreatureInfo()->SkinningLootId, LootTemplates_Skinning, true); @@ -1691,12 +1719,16 @@ void Aura::TriggerSpell() case 38554: // Absorb Eye of Grillok (Zezzak's Shard) { if (target->GetTypeId() != TYPEID_UNIT) + { return; + } if (Unit* caster = GetCaster()) caster->CastSpell(caster, 38495, true, NULL, this); else + { return; + } Creature* creatureTarget = (Creature*)target; @@ -1835,7 +1867,9 @@ void Aura::TriggerSpell() case 58886: // Food { if (GetAuraTicks() != 1) + { return; + } uint32 randomBuff[5] = {57288, 57139, 57111, 57286, 57291}; @@ -1970,7 +2004,9 @@ void Aura::TriggerSpell() case 53303: case 53304: if (triggerTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Reset reapply counter at move if (((Player*)triggerTarget)->isMoving()) @@ -1996,7 +2032,9 @@ void Aura::TriggerSpell() // If aura is active - no need to continue if (triggerTarget->HasAura(trigger_spell_id)) + { return; + } break; default: @@ -2081,7 +2119,9 @@ void Aura::TriggerSpell() { SpellEntry const* spell = itr->second->GetSpellProto(); if (spell->IsFitToFamily(SPELLFAMILY_SHAMAN, UI64LIT(0x0000000000000400))) + { return; + } } triggerTarget->RemoveAurasDueToSpell(28820); return; @@ -2126,7 +2166,9 @@ void Aura::TriggerSpell() triggerTarget = (Unit*)channelTarget; } else - { triggerTargetObject = channelTarget; } + { + triggerTargetObject = channelTarget; + } } } // or periodic aura at caster channel target @@ -2273,7 +2315,9 @@ void Aura::TriggerSpell() triggerCaster->CastSpell(triggerTargetObject->GetPositionX(), triggerTargetObject->GetPositionY(), triggerTargetObject->GetPositionZ(), triggeredSpellInfo, true, NULL, this, casterGUID); else - { triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this, casterGUID); } + { + triggerCaster->CastSpell(triggerTarget, triggeredSpellInfo, true, NULL, this, casterGUID); + } } else { @@ -2293,7 +2337,9 @@ void Aura::TriggerSpellWithValue() Unit* target = GetTriggerTarget(); if (!casterGuid || !target) + { return; + } // generic casting code with custom spells and target/caster customs uint32 trigger_spell_id = m_spellEffect->EffectTriggerSpell; @@ -2310,7 +2356,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } Unit* target = GetTarget(); @@ -2342,7 +2390,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (Unit* caster = GetCaster()) { if (caster->GetTypeId() != TYPEID_UNIT) + { return; + } caster->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); caster->addUnitState(UNIT_STAT_ROOT); @@ -2476,7 +2526,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 58600: // Restricted Flight Area { if (!target || target->GetTypeId() != TYPEID_PLAYER) + { return; + } const char* text = sObjectMgr.GetMangosString(LANG_NO_FLY_ZONE, ((Player*)target)->GetSession()->GetSessionDbLocaleIndex()); target->MonsterWhisper(text, target, true); return; @@ -2563,7 +2615,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 41099: // Battle Stance { if (target->GetTypeId() != TYPEID_UNIT) + { return; + } // Stance Cooldown target->CastSpell(target, 41102, true, NULL, this); @@ -2580,7 +2634,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 41100: // Berserker Stance { if (target->GetTypeId() != TYPEID_UNIT) + { return; + } // Stance Cooldown target->CastSpell(target, 41102, true, NULL, this); @@ -2597,7 +2653,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 41101: // Defensive Stance { if (target->GetTypeId() != TYPEID_UNIT) + { return; + } // Stance Cooldown target->CastSpell(target, 41102, true, NULL, this); @@ -2614,7 +2672,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 53790: // Defensive Stance { if (target->GetTypeId() != TYPEID_UNIT) + { return; + } // Stance Cooldown target->CastSpell(target, 59526, true, NULL, this); @@ -2631,7 +2691,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 53791: // Berserker Stance { if (target->GetTypeId() != TYPEID_UNIT) + { return; + } // Stance Cooldown target->CastSpell(target, 59526, true, NULL, this); @@ -2648,7 +2710,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 53792: // Battle Stance { if (target->GetTypeId() != TYPEID_UNIT) + { return; + } // Stance Cooldown target->CastSpell(target, 59526, true, NULL, this); @@ -2669,11 +2733,15 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { // Must be casting target if (!target->IsNonMeleeSpellCasted(false)) + { return; + } Unit* caster = GetCaster(); if (!caster) + { return; + } Unit::AuraList const& modifierAuras = caster->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER); for (Unit::AuraList::const_iterator itr = modifierAuras.begin(); itr != modifierAuras.end(); ++itr) @@ -2745,7 +2813,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { Unit* caster = GetCaster(); if (!caster || !caster->IsAlive()) + { return; + } uint32 finalSpellId = 0; switch (GetId()) @@ -2783,7 +2853,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (Unit* caster = GetCaster()) { if (caster->GetTypeId() != TYPEID_UNIT) + { return; + } // see dummy effect of spell 10254 for removal of flags etc caster->CastSpell(caster, 10254, true); @@ -2796,7 +2868,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 12774: // (DND) Belnistrasz Idol Shutdown Visual { if (m_removeMode == AURA_REMOVE_BY_DEATH) + { return; + } // Idom Rool Camera Shake <- wtf, don't drink while making spellnames? if (Unit* caster = GetCaster()) @@ -2875,12 +2949,16 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (m_removeMode == AURA_REMOVE_BY_DEFAULT) { if (target->getDeathState() != CORPSE) + { return; + } Unit* pCaster = GetCaster(); if (!pCaster) + { return; + } // Captured Totem Test Credit if (Player* pPlayer = pCaster->GetCharmerOrOwnerPlayerOrPlayerItself()) @@ -3100,7 +3178,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { Unit* caster = GetCaster(); if (!caster) + { return; + } caster->CastSpell(target, 24659, true, NULL, NULL, GetCasterGuid()); } @@ -3114,7 +3194,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { Unit* caster = GetCaster(); if (!caster) + { return; + } caster->CastSpell(target, 24662, true, NULL, NULL, GetCasterGuid()); } @@ -3179,7 +3261,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { Unit* caster = GetCaster(); if (!caster) + { return; + } Unit* owner = caster->GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER) @@ -3195,7 +3279,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { Unit* caster = GetCaster(); if (!caster) + { return; + } Unit* owner = caster->GetOwner(); if (owner && owner->GetTypeId() == TYPEID_PLAYER) @@ -3237,7 +3323,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { Unit* caster = GetCaster(); if (!caster || target->GetTypeId() != TYPEID_PLAYER) + { return; + } if (apply) caster->FixateTarget(target); @@ -3327,7 +3415,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (apply) { if (target->GetShapeshiftForm() != FORM_CAT) + { return; + } target->CastSpell(target, 62071, true); } @@ -3340,7 +3430,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (apply) { if (!target->IsInFeralForm()) + { return; + } int32 bp0 = int32(target->GetMaxHealth() * m_modifier.m_amount / 100); target->CastCustomSpell(target, 50322, &bp0, NULL, NULL, true); @@ -3370,7 +3462,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { // Final heal on duration end if (m_removeMode != AURA_REMOVE_BY_EXPIRE) + { return; + } // final heal if (target->IsInWorld() && GetStackAmount() > 0) @@ -3412,7 +3506,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (apply) { if (target->GetShapeshiftForm() != FORM_MOONKIN) + { return; + } target->CastSpell(target, spell_id, true); } @@ -3479,7 +3575,9 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 6495: // Sentry Totem { if (target->GetTypeId() != TYPEID_PLAYER) + { return; + } Totem* totem = target->GetTotem(TOTEM_SLOT_AIR); @@ -3599,7 +3697,9 @@ void Aura::HandleAuraFeatherFall(bool apply, bool Real) { // only at real add/remove aura if (!Real) + { return; + } GetTarget()->SetFeatherFall(apply); } @@ -3608,7 +3708,9 @@ void Aura::HandleAuraHover(bool apply, bool Real) { // only at real add/remove aura if (!Real) + { return; + } GetTarget()->SetHover(apply); } @@ -3625,7 +3727,9 @@ void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/) void Aura::HandleAuraModShapeshift(bool apply, bool Real) { if (!Real) + { return; + } ShapeshiftForm form = ShapeshiftForm(m_modifier.m_miscvalue); @@ -4105,7 +4209,9 @@ void Aura::HandleAuraTransform(bool apply, bool Real) model_id = 26452; } else if (caster->HasAura(57927)) // Glyph of the Monkey - { model_id = 21362; } + { + model_id = 21362; + } } } @@ -4225,7 +4331,9 @@ void Aura::HandleAuraModSkill(bool apply, bool /*Real*/) // defense skill is removed in 4.x.x, spell tooltips updated, // but auras still exist if (prot == SKILL_DEFENSE) + { return; + } ((Player*)GetTarget())->ModifySkillBonus(prot, (apply ? points : -points), m_modifier.m_auraname == SPELL_AURA_MOD_SKILL_TALENT); } @@ -4308,7 +4416,9 @@ void Aura::HandleBindSight(bool apply, bool /*Real*/) camera.SetView(GetTarget()); } else - { camera.ResetView(); } + { + camera.ResetView(); + } } void Aura::HandleFarSight(bool apply, bool /*Real*/) @@ -4325,7 +4435,9 @@ void Aura::HandleFarSight(bool apply, bool /*Real*/) camera.SetView(GetTarget()); } else - { camera.ResetView(); } + { + camera.ResetView(); + } } void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/) @@ -4345,7 +4457,9 @@ void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/) GetTarget()->SetFlag(PLAYER_TRACK_CREATURES, uint32(1) << (m_modifier.m_miscvalue - 1)); } else - { GetTarget()->RemoveFlag(PLAYER_TRACK_CREATURES, uint32(1) << (m_modifier.m_miscvalue - 1)); } + { + GetTarget()->RemoveFlag(PLAYER_TRACK_CREATURES, uint32(1) << (m_modifier.m_miscvalue - 1)); + } } void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/) @@ -4365,7 +4479,9 @@ void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/) GetTarget()->SetFlag(PLAYER_TRACK_RESOURCES, uint32(1) << (m_modifier.m_miscvalue - 1)); } else - { GetTarget()->RemoveFlag(PLAYER_TRACK_RESOURCES, uint32(1) << (m_modifier.m_miscvalue - 1)); } + { + GetTarget()->RemoveFlag(PLAYER_TRACK_RESOURCES, uint32(1) << (m_modifier.m_miscvalue - 1)); + } } void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/) @@ -4392,17 +4508,23 @@ void Aura::HandleAuraModScale(bool apply, bool /*Real*/) void Aura::HandleModPossess(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); // not possess yourself if (GetCasterGuid() == target->GetObjectGuid()) + { return; + } Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) // TODO:: well i know some bosses can take control of player??? + { return; + } if (apply) { @@ -4424,15 +4546,21 @@ void Aura::HandleModPossess(bool apply, bool Real) void Aura::HandleModPossessPet(bool apply, bool Real) { if (!Real) + { return; + } Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Unit* target = GetTarget(); if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->IsPet()) + { return; + } Pet* pet = (Pet*)target; @@ -4463,7 +4591,9 @@ void Aura::HandleModPossessPet(bool apply, bool Real) void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real) { if (!Real) + { return; + } // Recalculate pet talent points if (Pet* pet = GetTarget()->GetPet()) @@ -4585,7 +4715,9 @@ void Aura::HandleModCharm(bool apply, bool Real) target->GetCharmInfo()->SetPetNumber(0, true); } else - { sLog.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", target->GetGUIDLow(), target->GetTypeId()); } + { + sLog.outError("Aura::HandleModCharm: target (GUID: %u TypeId: %u) has a charm aura but no charm info!", target->GetGUIDLow(), target->GetTypeId()); + } } } @@ -4698,7 +4830,9 @@ void Aura::HandleAuraModDisarm(bool apply, bool Real) if (apply) target->SetAttackTime(attack_type, BASE_ATTACK_TIME); else - { ((Player*)target)->SetRegularAttackTime(); } + { + ((Player*)target)->SetRegularAttackTime(); + } target->UpdateDamagePhysical(attack_type); } @@ -4906,7 +5040,9 @@ void Aura::HandleModStealth(bool apply, bool Real) target->SetVisibility(VISIBILITY_GROUP_INVISIBILITY); } else - { target->SetVisibility(VISIBILITY_ON); } + { + target->SetVisibility(VISIBILITY_ON); + } } // apply delayed talent bonus remover at last stealth aura remove @@ -5043,7 +5179,9 @@ void Aura::HandleAuraModRoot(bool apply, bool Real) ((Player*)target)->m_movementInfo.SetMovementFlags(MOVEFLAG_NONE); } else - { target->StopMoving(); } + { + target->StopMoving(); + } } else { @@ -5227,7 +5365,9 @@ void Aura::HandleAuraFakeInebriation(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) + { return; + } Unit* target = GetTarget(); @@ -5278,7 +5418,9 @@ void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) + { return; + } Unit* target = GetTarget(); @@ -5464,7 +5606,9 @@ void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/) bg->EventPlayerDroppedFlag(player); } else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId())) - { outdoorPvP->HandleDropFlag(player, GetSpellProto()->Id); } + { + outdoorPvP->HandleDropFlag(player, GetSpellProto()->Id); + } } target->ApplySpellImmune(GetId(), IMMUNITY_EFFECT, m_modifier.m_miscvalue, apply); @@ -5483,7 +5627,9 @@ void Aura::HandleAuraModStateImmunity(bool apply, bool Real) itr = auraList.begin(); } else - { ++itr; } + { + ++itr; + } } } @@ -5524,7 +5670,9 @@ void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) break; } else - { next = Auras.begin(); } + { + next = Auras.begin(); + } } } } @@ -5535,7 +5683,9 @@ void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) target->addUnitState(UNIT_STAT_ISOLATED); } else - { target->clearUnitState(UNIT_STAT_ISOLATED); } + { + target->clearUnitState(UNIT_STAT_ISOLATED); + } } } @@ -5593,7 +5743,9 @@ void Aura::HandleAuraModStalked(bool apply, bool /*Real*/) GetTarget()->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); } else - { GetTarget()->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); } + { + GetTarget()->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); + } } /*********************************************************/ @@ -5651,7 +5803,9 @@ void Aura::HandlePeriodicTriggerSpellWithValue(bool apply, bool /*Real*/) void Aura::HandlePeriodicEnergize(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); @@ -5704,7 +5858,9 @@ void Aura::HandleAuraPeriodicDummy(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } Unit* target = GetTarget(); @@ -5806,7 +5962,9 @@ void Aura::HandleDamagePercentTaken(bool apply, bool Real) Unit* target = GetTarget(); if (!Real) + { return; + } // For prevent double apply bonuses bool loading = (target->GetTypeId() == TYPEID_PLAYER && ((Player*)target)->GetSession()->PlayerLoading()); @@ -5814,7 +5972,9 @@ void Aura::HandleDamagePercentTaken(bool apply, bool Real) if (apply) { if (loading) + { return; + } // Hand of Salvation (only it have this aura and mask) if (GetSpellProto()->IsFitToFamily(SPELLFAMILY_PALADIN, UI64LIT(0x0000000000000100))) @@ -5859,7 +6019,9 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) } if(!classOptions) + { return; + } switch (classOptions->SpellFamilyName) { @@ -6197,7 +6359,9 @@ void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/) void Aura::HandleAuraModDispelResist(bool apply, bool Real) { if (!Real || !apply) + { return; + } if (GetId() == 33206) GetTarget()->CastSpell(GetTarget(), 44416, true, NULL, this, GetCasterGuid()); @@ -6206,7 +6370,9 @@ void Aura::HandleAuraModDispelResist(bool apply, bool Real) void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } // Magic damage modifiers implemented in Unit::SpellDamageBonusDone // This information for client side use only @@ -6217,7 +6383,9 @@ void Aura::HandleModSpellDamagePercentFromAttackPower(bool /*apply*/, bool /*Rea void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } // Recalculate bonus ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); @@ -6237,7 +6405,9 @@ void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/) void Aura::HandleModTotalPercentStat(bool apply, bool /*Real*/) { if (!m_modifier.m_amount) + { return; + } Unit* target = GetTarget(); uint32 miscValueB = GetSpellEffect()->EffectMiscValueB; @@ -6333,7 +6503,9 @@ void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking m_modifier.periodictime = 3000; } else - { m_modifier.periodictime = 2000; } + { + m_modifier.periodictime = 2000; + } } m_periodicTimer = 5000; @@ -6370,10 +6542,14 @@ void Aura::HandleModManaRegen(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } // Note: an increase in regen does NOT cause threat. ((Player*)GetTarget())->UpdateManaRegen(); @@ -6429,7 +6605,9 @@ void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real) target->ModifyHealth(-m_modifier.m_amount); } else - { target->SetHealth(1); } + { + target->SetHealth(1); + } target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); } } @@ -6769,7 +6947,9 @@ void Aura::HandleAuraModAttackPowerOfArmor(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } // Recalculate bonus if (GetTarget()->GetTypeId() == TYPEID_PLAYER) @@ -6824,7 +7004,9 @@ void Aura::HandleModDamageDone(bool apply, bool Real) target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, m_modifier.m_amount, apply); } else - { target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, m_modifier.m_amount, apply); } + { + target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG, m_modifier.m_amount, apply); + } } } @@ -6995,10 +7177,14 @@ void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } Unit* target = GetTarget(); if (target->GetTypeId() != TYPEID_PLAYER) + { return; + } ClassFamilyMask mask; Unit::AuraList const& noReagent = target->GetAurasByType(SPELL_AURA_NO_REAGENT_USE); @@ -7281,7 +7467,9 @@ void Aura::HandleShapeshiftBoosts(bool apply) itr = tAuras.begin(); } else - { ++itr; } + { + ++itr; + } } } } @@ -7289,7 +7477,9 @@ void Aura::HandleShapeshiftBoosts(bool apply) void Aura::HandleAuraEmpathy(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_UNIT) + { return; + } CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(GetTarget()->GetEntry()); if (ci && ci->CreatureType == CREATURE_TYPE_BEAST) @@ -7303,7 +7493,9 @@ void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/) GetTarget()->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); } else - { GetTarget()->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); } + { + GetTarget()->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); + } } void Aura::HandleAuraModPacify(bool apply, bool /*Real*/) @@ -7313,7 +7505,9 @@ void Aura::HandleAuraModPacify(bool apply, bool /*Real*/) GetTarget()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); } else - { GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); } + { + GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); + } } void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real) @@ -7343,7 +7537,9 @@ void Aura::HandleAuraAllowFlight(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) + { return; + } GetTarget()->SetCanFly(apply); } @@ -7352,10 +7548,14 @@ void Aura::HandleModRating(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) if (m_modifier.m_miscvalue & (1 << rating)) @@ -7366,10 +7566,14 @@ void Aura::HandleModRatingFromStat(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } // Just recalculate ratings for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating) if (m_modifier.m_miscvalue & (1 << rating)) @@ -7379,7 +7583,9 @@ void Aura::HandleModRatingFromStat(bool apply, bool Real) void Aura::HandleForceMoveForward(bool apply, bool Real) { if (!Real) + { return; + } if (apply) GetTarget()->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVE); @@ -7390,7 +7596,9 @@ void Aura::HandleForceMoveForward(bool apply, bool Real) void Aura::HandleAuraModExpertise(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)GetTarget())->UpdateExpertise(BASE_ATTACK); ((Player*)GetTarget())->UpdateExpertise(OFF_ATTACK); @@ -7400,7 +7608,9 @@ void Aura::HandleModTargetResistance(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } Unit* target = GetTarget(); // applied to damage as HandleNoImmediateEffect in Unit::CalculateAbsorbAndResist and Unit::CalcArmorReducedDamage // show armor penetration @@ -7481,7 +7691,9 @@ void Aura::HandleSpiritOfRedemption(bool apply, bool Real) } // die at aura end else - { target->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false); } + { + target->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, GetSpellProto(), false); + } } void Aura::HandleSchoolAbsorb(bool apply, bool Real) @@ -7717,7 +7929,9 @@ void Aura::PeriodicTick() pdamage = amount; } else - { pdamage = uint32(target->GetMaxHealth() * amount / 100); } + { + pdamage = uint32(target->GetMaxHealth() * amount / 100); + } // SpellDamageBonus for magic spells uint32 dmgClass = spellProto->GetDmgClass(); @@ -7930,7 +8144,9 @@ void Aura::PeriodicTick() { Unit* pCaster = GetCaster(); if (!pCaster) + { return; + } bool canApplyHealthPart = true; @@ -8395,7 +8611,9 @@ void Aura::PeriodicDummyTick() case 30019: // Control Piece { if (target->GetTypeId() != TYPEID_PLAYER) + { return; + } Unit* chessPiece = target->GetCharm(); if (!chessPiece) @@ -8586,7 +8804,9 @@ void Aura::PeriodicDummyTick() if (GetAuraTicks() == 3 && target->GetTypeId() == TYPEID_UNIT) ((Creature*)target)->ForcedDespawn(); if (GetAuraTicks() != 2) + { return; + } if (Unit* pCaster = GetCaster()) pCaster->CastSpell(target, spell->Id == 49555 ? 49618 : 59809, true); @@ -8672,7 +8892,9 @@ void Aura::PeriodicDummyTick() case 62038: // Biting Cold { if (target->GetTypeId() != TYPEID_PLAYER) + { return; + } // if player is moving remove one aura stack if (((Player*)target)->isMoving()) @@ -8775,7 +8997,9 @@ void Aura::PeriodicDummyTick() { Unit* caster = GetCaster(); if (!caster) + { return; + } int32 lifeLeeched = int32(target->GetHealth() * m_modifier.m_amount * 0.01f); @@ -8794,7 +9018,9 @@ void Aura::PeriodicDummyTick() { Unit* caster = GetCaster(); if (!caster) + { return; + } caster->CastSpell(target, 66797, true, NULL, this); target->RemoveAurasDueToSpell(GetId()); @@ -8827,7 +9053,9 @@ void Aura::PeriodicDummyTick() if (GetEffIndex() > EFFECT_INDEX_0 && spell->GetEffectApplyAuraNameByIndex(SpellEffectIndex(GetEffIndex()-1)) == SPELL_AURA_MOD_POWER_REGEN) { if (target->GetTypeId() != TYPEID_PLAYER) + { return; + } // Search SPELL_AURA_MOD_POWER_REGEN aura for this spell and add bonus if (Aura* aura = GetHolder()->GetAuraByEffectIndex(SpellEffectIndex(GetEffIndex() - 1))) { @@ -8864,7 +9092,9 @@ void Aura::PeriodicDummyTick() case 55342: // Mirror Image { if (GetAuraTicks() != 1) + { return; + } if (Unit* pCaster = GetCaster()) pCaster->CastSpell(pCaster, GetSpellProto()->CalculateSimpleValue(m_effIndex), true, NULL, this); return; @@ -8884,11 +9114,15 @@ void Aura::PeriodicDummyTick() // Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health. // Should be manauser if (target->GetPowerType() != POWER_RAGE) + { return; + } uint32 rage = target->GetPower(POWER_RAGE); // Nothing todo if (rage == 0) + { return; + } int32 mod = (rage < 100) ? rage : 100; int32 points = target->CalculateSpellDamage(target, spell, EFFECT_INDEX_1); int32 regen = target->GetMaxHealth() * (mod * points / 10) / 1000; @@ -8912,7 +9146,9 @@ void Aura::PeriodicDummyTick() case 51690: { if (target->hasUnitState(UNIT_STAT_STUNNED) || target->isFeared()) + { return; + } Spell::UnitList targets; { @@ -8925,7 +9161,9 @@ void Aura::PeriodicDummyTick() } if (targets.empty()) + { return; + } Spell::UnitList::const_iterator itr = targets.begin(); std::advance(itr, rand() % targets.size()); @@ -9063,7 +9301,9 @@ void Aura::HandlePreventFleeing(bool apply, bool Real) GetTarget()->SetFeared(false, fearAuras.front()->GetCasterGuid()); } else - { GetTarget()->SetFeared(true); } + { + GetTarget()->SetFeared(true); + } } } @@ -9107,7 +9347,9 @@ void Aura::HandleManaShield(bool apply, bool Real) void Aura::HandleArenaPreparation(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); @@ -9135,15 +9377,21 @@ void Aura::HandleArenaPreparation(bool apply, bool Real) void Aura::HandleAuraControlVehicle(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); if (!target->IsVehicle()) + { return; + } Unit* caster = GetCaster(); if (!caster) + { return; + } if (apply) { @@ -9156,18 +9404,24 @@ void Aura::HandleAuraControlVehicle(bool apply, bool Real) void Aura::HandleAuraAddMechanicAbilities(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); if (!target || target->GetTypeId() != TYPEID_PLAYER) // only players should be affected by this aura + { return; + } uint16 i_OverrideSetId = GetMiscValue(); const OverrideSpellDataEntry* spellSet = sOverrideSpellDataStore.LookupEntry(i_OverrideSetId); if (!spellSet) + { return; + } if (apply) { @@ -9192,7 +9446,9 @@ void Aura::HandleAuraAddMechanicAbilities(bool apply, bool Real) void Aura::HandleAuraOpenStable(bool apply, bool Real) { if (!Real || GetTarget()->GetTypeId() != TYPEID_PLAYER || !GetTarget()->IsInWorld()) + { return; + } Player* player = (Player*)GetTarget(); @@ -9205,7 +9461,9 @@ void Aura::HandleAuraOpenStable(bool apply, bool Real) void Aura::HandleAuraMirrorImage(bool apply, bool Real) { if (!Real) + { return; + } // Target of aura should always be creature (ref Spell::CheckCast) Creature* pCreature = (Creature*)GetTarget(); @@ -9245,13 +9503,17 @@ void Aura::HandleAuraMirrorImage(bool apply, bool Real) void Aura::HandleMirrorName(bool apply, bool Real) { if (!Real) + { return; + } Unit* caster = GetCaster(); Unit* target = GetTarget(); if (!target || !caster || target->GetTypeId() != TYPEID_UNIT) + { return; + } if (apply) target->SetName(caster->GetName()); @@ -9259,7 +9521,9 @@ void Aura::HandleMirrorName(bool apply, bool Real) { CreatureInfo const* cinfo = ((Creature*)target)->GetCreatureInfo(); if (!cinfo) + { return; + } target->SetName(cinfo->Name); } @@ -9268,15 +9532,21 @@ void Aura::HandleMirrorName(bool apply, bool Real) void Aura::HandleAuraConvertRune(bool apply, bool Real) { if (!Real) + { return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* plr = (Player*)GetTarget(); if (plr->getClass() != CLASS_DEATH_KNIGHT) + { return; + } RuneType runeFrom = RuneType(m_spellEffect->EffectMiscValue); RuneType runeTo = RuneType(m_spellEffect->EffectMiscValueB); @@ -9308,7 +9578,9 @@ void Aura::HandleAuraConvertRune(bool apply, bool Real) void Aura::HandlePhase(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); @@ -9363,12 +9635,16 @@ void Aura::HandleAuraModAllCritChance(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) + { return; + } Unit* target = GetTarget(); if (target->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)target)->HandleBaseModValue(CRIT_PERCENTAGE, FLAT_MOD, float(m_modifier.m_amount), apply); ((Player*)target)->HandleBaseModValue(OFFHAND_CRIT_PERCENTAGE, FLAT_MOD, float(m_modifier.m_amount), apply); @@ -9381,7 +9657,9 @@ void Aura::HandleAuraModAllCritChance(bool apply, bool Real) void Aura::HandleAuraStopNaturalManaRegen(bool apply, bool Real) { if (!Real) + { return; + } GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER, !apply); } @@ -9389,7 +9667,9 @@ void Aura::HandleAuraStopNaturalManaRegen(bool apply, bool Real) void Aura::HandleAuraSetVehicleId(bool apply, bool Real) { if (!Real) + { return; + } GetTarget()->SetVehicleId(apply ? GetMiscValue() : 0, 0); } @@ -9398,7 +9678,9 @@ void Aura::HandleAuraMastery(bool apply, bool Real) { Unit* target = GetTarget(); if (target->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)target)->UpdateMasteryAuras(); } @@ -9412,11 +9694,15 @@ void Aura::HandleAuraModBlockCritChance(bool apply, bool Real) void Aura::HandlePreventResurrection(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); if (!target || target->GetTypeId() != TYPEID_PLAYER) + { return; + } if (apply) target->RemoveByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER); @@ -9427,11 +9713,15 @@ void Aura::HandlePreventResurrection(bool apply, bool Real) void Aura::HandleFactionOverride(bool apply, bool Real) { if (!Real) + { return; + } Unit* target = GetTarget(); if (!target || !sFactionTemplateStore.LookupEntry(GetMiscValue())) + { return; + } if (apply) target->setFaction(GetMiscValue()); @@ -9443,7 +9733,9 @@ void Aura::HandleFactionOverride(bool apply, bool Real) void Aura::HandleTriggerLinkedAura(bool apply, bool Real) { if (!Real) + { return; + } uint32 linkedSpell = m_spellEffect->EffectTriggerSpell; SpellEntry const* spellInfo = sSpellStore.LookupEntry(linkedSpell); @@ -9468,14 +9760,18 @@ bool Aura::IsLastAuraOnHolder() { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (i != GetEffIndex() && GetHolder()->m_auras[i]) + { return false; + } return true; } bool Aura::HasMechanic(uint32 mechanic) const { if (GetSpellProto()->GetMechanic() == mechanic) + { return true; + } return m_spellEffect->EffectMechanic == mechanic; } @@ -10037,19 +10333,33 @@ bool SpellAuraHolder::IsNeedVisibleSlot(Unit const* caster) const bool totemAura = caster && caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->IsTotem(); if (m_spellProto->GetProcFlags()) + { return true; + } else if (HasAuraWithTriggerEffect(m_spellProto)) + { return true; + } else if (IsSpellHaveAura(m_spellProto, SPELL_AURA_MOD_IGNORE_SHAPESHIFT)) + { return true; + } else if (IsSpellHaveAura(m_spellProto, SPELL_AURA_IGNORE_UNIT_STATE)) + { return true; + } else if (IsSpellHaveAura(m_spellProto, SPELL_AURA_ALLOW_CAST_WHILE_MOVING)) + { return true; + } else if (IsSpellHaveAura(m_spellProto, SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS)) + { return true; + } else if (IsSpellHaveAura(m_spellProto, SPELL_AURA_OVERRIDE_ACTIONBAR_SPELLS_2)) + { return true; + } // passive auras (except totem auras) do not get placed in the slots return !m_isPassive || totemAura || HasAreaAuraEffect(m_spellProto); @@ -10089,7 +10399,9 @@ void SpellAuraHolder::BuildUpdatePacket(WorldPacket& data) const data << int32(aura->GetModifier()->m_amount); } else - { data << int32(0); } + { + data << int32(0); + } } } } @@ -10135,7 +10447,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) spellId1 = 55594; } else + { return; + } break; } case 55053: // Deathbloom (25 man) @@ -10146,7 +10460,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) spellId1 = 55601; } else + { return; + } break; } case 50720: // Vigilance (warrior spell but not have warrior family) @@ -10162,7 +10478,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) spellId1 = 60242; // Darkmoon Card: Illusion } else + { return; + } break; } case 58914: // Kill Command, pet aura @@ -10186,7 +10504,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) spellId2 = 72523; // Shadowmourne Visual High } else + { return; + } break; } default: @@ -10216,7 +10536,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) } } else + { return; + } break; } @@ -10227,7 +10549,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if(!apply) spellId1 = 28682; else + { return; + } break; } case 28682: // Combustion (remove main aura) @@ -10235,7 +10559,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if(!apply) spellId1 = 11129; else + { return; + } break; } case 44401: // Missile Barrage (triggered) @@ -10248,13 +10574,17 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) Unit* caster = GetCaster(); // Item - Mage T10 2P Bonus if (!caster || !caster->HasAura(70752)) + { return; + } cast_at_remove = true; spellId1 = 70753; // Pushing the Limit } else + { return; + } break; } case 74396: // Fingers of Frost (remove main aura) @@ -10262,7 +10592,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if (!apply) spellId1 = 44544; else + { return; + } break; } default: @@ -10276,7 +10608,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) { // Remove Blood Frenzy only if target no longer has any Deep Wound or Rend (applying is handled by procs) if (GetSpellProto()->GetMechanic() != MECHANIC_BLEED) + { return; + } // If target still has one of Warrior's bleeds, do nothing Unit::AuraList const& PeriodicDamage = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); @@ -10300,7 +10634,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) { Unit* caster = GetCaster(); if (!caster) + { return; + } Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) @@ -10322,7 +10658,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) } } else + { return; + } } // Shadowflame (DoT) else if (m_spellProto->IsFitToFamilyMask(UI64LIT(0x0000000000000000), 0x00000002)) @@ -10334,10 +10672,14 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) else if (((caster = GetCaster())) && caster->HasAura(63310)) spellId1 = 63311; else + { return; + } } else + { return; + } break; } case SPELLFAMILY_PRIEST: @@ -10349,7 +10691,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) { Unit* caster = GetCaster(); if (!caster) + { return; + } Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) @@ -10366,14 +10710,18 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) } } else + { return; + } } // Power Word: Shield else if (apply && classOptions && classOptions->SpellFamilyFlags & UI64LIT(0x0000000000000001) && m_spellProto->GetMechanic() == MECHANIC_SHIELD) { Unit* caster = GetCaster(); if (!caster) + { return; + } // Glyph of Power Word: Shield if (Aura* glyph = caster->GetAura(55672, EFFECT_INDEX_0)) @@ -10434,7 +10782,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) else if (!apply && GetId() == 5229) // Enrage (Druid Bear) spellId1 = 51185; // King of the Jungle (Enrage damage aura) else + { return; + } break; } case SPELLFAMILY_ROGUE: @@ -10444,10 +10794,14 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if (!apply || m_target->HasAura(58039)) // Glyph of Blurred Speed spellId1 = 61922; // Sprint (waterwalk) else + { return; + } } else + { return; + } break; case SPELLFAMILY_HUNTER: { @@ -10458,7 +10812,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if (!apply || m_target->HasAura(60144)) // Viper Attack Speed spellId1 = 61609; // Vicious Viper else + { return; + } break; } case 19574: // Bestial Wrath - immunity @@ -10479,7 +10835,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) else if (m_target->HasAura(35030)) // Focused Fire, rank 2 spellId1 = 60113; // Kill Command, Focused Fire rank 2 bonus else + { return; + } } else { @@ -10494,7 +10852,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) case 35029: // Focused Fire, rank 1 { if (apply && !m_target->HasAura(34027)) // Kill Command, owner casting aura + { return; + } spellId1 = 60110; // Kill Command, Focused Fire rank 1 bonus break; @@ -10502,7 +10862,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) case 35030: // Focused Fire, rank 2 { if (apply && !m_target->HasAura(34027)) // Kill Command, owner casting aura + { return; + } spellId1 = 60113; // Kill Command, Focused Fire rank 2 bonus break; @@ -10521,10 +10883,14 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) spellId1 = 61394; } else + { return; + } } else + { return; + } } // Aspect of the Dragonhawk dodge else if (GetSpellProto()->IsFitToFamilyMask(UI64LIT(0x0000000000000000), 0x00001000)) @@ -10536,7 +10902,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) ((Player*)m_target)->RemoveSpellCooldown(61848); } else + { return; + } break; } break; @@ -10577,10 +10945,14 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) // Only process on player casting paladin aura // all aura bonuses applied also in aura area effect way to caster if (GetCasterGuid() != m_target->GetObjectGuid() || !GetCasterGuid().IsPlayer()) + { return; + } if (GetSpellSpecific(m_spellProto->Id) != SPELL_AURA) + { return; + } // Sanctified Retribution and Swift Retribution (they share one aura), but not Retribution Aura (already gets modded) if (classOptions && (classOptions->SpellFamilyFlags & UI64LIT(0x0000000000000008))==0) @@ -10724,7 +11096,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) { Aura* aura = GetAuraByEffectIndex(EFFECT_INDEX_0); if (!aura) + { return; + } int32 bp = aura->GetModifier()->m_amount; m_target->CastCustomSpell(m_target, 63611, &bp, NULL, NULL, true, NULL, NULL, GetCasterGuid()); @@ -10742,7 +11116,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) { Aura* aura = GetAuraByEffectIndex(EFFECT_INDEX_0); if (!aura) + { return; + } int32 bp0 = aura->GetModifier()->m_amount; int32 bp1 = 0; // disable threat mod part for not Frost Presence case @@ -10773,7 +11149,9 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if (!apply || m_target->HasAura(48263) || m_target->HasAura(48266)) spellId1 = 49772; else + { return; + } break; } break; @@ -10936,7 +11314,9 @@ bool SpellAuraHolder::HasMechanic(uint32 mechanic) const if (Aura* aura = m_auras[i]) { if (aura->GetSpellEffect()->EffectMechanic == mechanic) + { return true; + } } } return false; @@ -10954,7 +11334,9 @@ bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const if (Aura* aura = m_auras[i]) { if (aura->GetSpellEffect()->EffectMechanic && ((1 << (aura->GetSpellEffect()->EffectMechanic - 1)) & mechanicMask)) + { return true; + } } } return false; @@ -11046,7 +11428,9 @@ void SpellAuraHolder::UnregisterAndCleanupTrackedAuras() void Aura::HandleModIncreaseSpellPowerPct(bool apply, bool Real) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); } @@ -11054,7 +11438,9 @@ void Aura::HandleModIncreaseSpellPowerPct(bool apply, bool Real) void Aura::HandleOverrideSpellPowerByAp(bool apply, bool Real) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); } diff --git a/src/game/WorldHandlers/SpellAuras.h b/src/game/WorldHandlers/SpellAuras.h index ffe072e18..46e0a020f 100644 --- a/src/game/WorldHandlers/SpellAuras.h +++ b/src/game/WorldHandlers/SpellAuras.h @@ -175,7 +175,9 @@ class SpellAuraHolder void SetAuraCharges(uint32 charges, bool update = true) { if (m_procCharges == charges) + { return; + } m_procCharges = charges; if (update) @@ -184,7 +186,9 @@ class SpellAuraHolder bool DropAuraCharge() // return true if last charge dropped { if (m_procCharges == 0) + { return false; + } --m_procCharges; SendAuraUpdate(false); diff --git a/src/game/WorldHandlers/SpellEffects.cpp b/src/game/WorldHandlers/SpellEffects.cpp index 5f3d826dc..7138be761 100644 --- a/src/game/WorldHandlers/SpellEffects.cpp +++ b/src/game/WorldHandlers/SpellEffects.cpp @@ -275,18 +275,26 @@ void Spell::EffectUnused(SpellEffectEntry const* /*effect*/) void Spell::EffectResurrectNew(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->IsAlive()) + { return; + } if (unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!unitTarget->IsInWorld()) + { return; + } Player* pTarget = ((Player*)unitTarget); if (pTarget->isRessurectRequested()) // already have one active request + { return; + } uint32 health = damage; uint32 mana = effect->EffectMiscValue; @@ -297,7 +305,9 @@ void Spell::EffectResurrectNew(SpellEffectEntry const* effect) void Spell::EffectInstaKill(SpellEffectEntry const* /*effect*/) { if (!unitTarget || !unitTarget->IsAlive()) + { return; + } if (m_caster == unitTarget) // prevent interrupt message finish(); @@ -809,7 +819,9 @@ void Spell::EffectSchoolDMG(SpellEffectEntry const* effect) void Spell::EffectDummy(SpellEffectEntry const* effect) { if (!unitTarget && !gameObjTarget && !itemTarget) + { return; + } // selection by spell family switch(m_spellInfo->GetSpellFamilyName()) @@ -821,7 +833,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 3360: // Curse of the Eye { if (!unitTarget) + { return; + } uint32 spell_id = (unitTarget->getGender() == GENDER_MALE) ? 10651 : 10653; @@ -831,7 +845,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 7671: // Transformation (human<->worgen) { if (!unitTarget) + { return; + } // Transform Visual unitTarget->CastSpell(unitTarget, 24085, true); @@ -840,7 +856,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 8063: // Deviate Fish { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (urand(1, 5)) @@ -857,7 +875,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 8213: // Savory Deviate Delight { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (urand(1, 2)) @@ -874,7 +894,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 9976: // Polly Eats the E.C.A.C. { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // Summon Polly Jr. unitTarget->CastSpell(unitTarget, 9998, true); @@ -885,7 +907,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 10254: // Stone Dwarf Awaken Visual { if (m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } // see spell 10255 (aura dummy) m_caster->clearUnitState(UNIT_STAT_ROOT); @@ -895,7 +919,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 13120: // net-o-matic { if (!unitTarget) + { return; + } uint32 spell_id = 0; @@ -914,7 +940,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 13489: { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 14744, true); return; @@ -923,7 +951,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) { // can be used for different aura triggering, so select by aura if (!m_triggeredByAuraSpell || !unitTarget) + { return; + } switch (m_triggeredByAuraSpell->Id) { @@ -939,7 +969,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 14537: // Six Demon Bag { if (!unitTarget) + { return; + } Unit* newTarget = unitTarget; uint32 spell_id = 0; @@ -972,7 +1004,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 29435: // Capture Female Kaliri Hatchling { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } Creature* creatureTarget = (Creature*)unitTarget; @@ -982,7 +1016,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 16589: // Noggenfogger Elixir { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (urand(1, 3)) @@ -998,7 +1034,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 17009: // Voodoo { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (urand(0, 6)) @@ -1018,7 +1056,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 17251: // Spirit Healer Res { if (!unitTarget) + { return; + } Unit* caster = GetAffectiveCaster(); @@ -1033,7 +1073,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 17271: // Test Fetid Skull { if (!itemTarget && m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = urand(0, 1) ? 17269 // Create Resonating Skull @@ -1050,7 +1092,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 17950: // Shadow Portal { if (!unitTarget) + { return; + } // Shadow Portal const uint32 spell_list[6] = {17863, 17939, 17943, 17944, 17946, 17948}; @@ -1061,7 +1105,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 19395: // Gordunni Trap { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, urand(0, 1) ? 19394 : 11756, true); return; @@ -1070,7 +1116,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 20474: // Lava Bomb { if (!unitTarget) + { return; + } // Hack alert! // This dummy are expected to cast spell 20494 to summon GO entry 177704 @@ -1109,7 +1157,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 19869: // Dragon Orb { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->HasAura(23958)) + { return; + } unitTarget->CastSpell(unitTarget, 19832, true); return; @@ -1117,7 +1167,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 20037: // Explode Orb Effect { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 20038, true); return; @@ -1132,7 +1184,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 21147: // Arcane Vacuum { if (!unitTarget) + { return; + } // Spell used by Azuregos to teleport all the players to him // This also resets the target threat @@ -1147,11 +1201,15 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 23019: // Crystal Prison Dummy DND { if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetTypeId() != TYPEID_UNIT || ((Creature*)unitTarget)->IsPet()) + { return; + } Creature* creatureTarget = (Creature*)unitTarget; if (creatureTarget->IsPet()) + { return; + } GameObject* pGameObj = new GameObject; @@ -1181,7 +1239,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 23074: // Arcanite Dragonling { if (!m_CastItem) + { return; + } m_caster->CastSpell(m_caster, 19804, true, m_CastItem); return; @@ -1189,7 +1249,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 23075: // Mithril Mechanical Dragonling { if (!m_CastItem) + { return; + } m_caster->CastSpell(m_caster, 12749, true, m_CastItem); return; @@ -1197,7 +1259,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 23076: // Mechanical Dragonling { if (!m_CastItem) + { return; + } m_caster->CastSpell(m_caster, 4073, true, m_CastItem); return; @@ -1205,7 +1269,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 23133: // Gnomish Battle Chicken { if (!m_CastItem) + { return; + } m_caster->CastSpell(m_caster, 13166, true, m_CastItem); return; @@ -1213,7 +1279,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 23138: // Gate of Shazzrah { if (!unitTarget) + { return; + } // Effect probably include a threat change, but it is unclear if fully // reset or just forced upon target for teleport (SMSG_HIGHEST_THREAT_UPDATE) @@ -1268,7 +1336,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 25860: // Reindeer Transformation { if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) + { return; + } float flyspeed = m_caster->GetSpeedRate(MOVE_FLIGHT); float speed = m_caster->GetSpeedRate(MOVE_RUN); @@ -1308,7 +1378,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 29126: // Cleansing Flames (Darnassus) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, 29099, true); return; @@ -1320,7 +1392,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 29139: // Cleansing Flames (Undercity) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spellIDs[] = {29102, 29130, 29101, 29132, 29133}; unitTarget->CastSpell(unitTarget, spellIDs[m_spellInfo->Id - 29135], true); @@ -1329,7 +1403,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 29200: // Purify Helboar Meat { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = roll_chance_i(50) ? 29277 // Summon Purified Helboar Meat @@ -1348,7 +1424,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 29969: // Summon Blizzard { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 29952, true, NULL, NULL, m_caster->GetObjectGuid()); return; @@ -1356,7 +1434,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 29979: // Massive Magnetic Pull { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 30010, true); return; @@ -1364,7 +1444,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 30004: // Flame Wreath { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 29946, true); return; @@ -1372,7 +1454,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 30458: // Nigh Invulnerability { if (!m_CastItem) + { return; + } if (roll_chance_i(86)) // Nigh-Invulnerability - success m_caster->CastSpell(m_caster, 30456, true, m_CastItem); @@ -1384,7 +1468,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 30507: // Poultryizer { if (!m_CastItem) + { return; + } if (roll_chance_i(80)) // Poultryized! - success m_caster->CastSpell(unitTarget, 30501, true, m_CastItem); @@ -1403,7 +1489,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 32146: // Liquid Fire { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)m_caster)->KilledMonsterCredit(unitTarget->GetEntry(), unitTarget->GetObjectGuid()); ((Creature*)unitTarget)->ForcedDespawn(); @@ -1412,7 +1500,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 32300: // Focus Fire { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, unitTarget->GetMap()->IsRegularDifficulty() ? 32302 : 38382, true); return; @@ -1421,7 +1511,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 37388: // Move 2 (Chess event AI long distance move) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // cast generic move spell m_caster->CastSpell(unitTarget, 30012, true); @@ -1430,7 +1522,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 33060: // Make a Wish { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; @@ -1457,7 +1551,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 36677: // Chaos Breath { if (!unitTarget) + { return; + } uint32 possibleSpells[] = {36693, 36694, 36695, 36696, 36697, 36698, 36699, 36700} ; std::vector spellPool(possibleSpells, possibleSpells + countof(possibleSpells)); @@ -1472,7 +1568,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 38796: // Sonic Boom (heroic) { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, m_spellInfo->Id == 33923 ? 33666 : 38795, true); return; @@ -1493,7 +1591,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 37674: // Chaos Blast { if (!unitTarget) + { return; + } int32 basepoints0 = 100; m_caster->CastCustomSpell(unitTarget, 37675, &basepoints0, NULL, NULL, true); @@ -1502,11 +1602,15 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 39189: // Sha'tari Torch { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // Flames if (unitTarget->HasAura(39199)) + { return; + } unitTarget->CastSpell(unitTarget, 39199, true); ((Player*)m_caster)->KilledMonsterCredit(unitTarget->GetEntry(), unitTarget->GetObjectGuid()); @@ -1517,7 +1621,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 39849: // Throw Glaive (second) { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 41466, true, NULL, NULL, m_caster->GetObjectGuid()); return; @@ -1558,7 +1664,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 40834: // Agonizing Flames { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 40932, true); return; @@ -1566,7 +1674,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 40869: // Fatal Attraction { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 41001, true); return; @@ -1574,7 +1684,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 40962: // Blade's Edge Terrace Demon Boss Summon Branch { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (urand(1, 4)) @@ -1590,7 +1702,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 41283: // Abyssal Toss { if (!unitTarget) + { return; + } m_caster->SummonCreature(23416, unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 30000); return; @@ -1598,7 +1712,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 41333: // Empyreal Equivalency { if (!unitTarget) + { return; + } // Equilize the health of all targets based on the corresponding health percent float health_diff = (float)unitTarget->GetMaxHealth() / (float)m_caster->GetMaxHealth(); @@ -1608,7 +1724,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 42287: // Salvage Wreckage { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (roll_chance_i(66)) m_caster->CastSpell(m_caster, 42289, true, m_CastItem); @@ -1620,7 +1738,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 42485: // End of Ooze Channel { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } unitTarget->CastSpell(m_caster, 42486, true); @@ -1633,10 +1753,14 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) // only process first effect // the logic is described by spell 42488 - Caster Spell 1 Only if Aura 2 Is On Caster (not used here) if (effect->EffectIndex != EFFECT_INDEX_0) + { return; + } if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || !m_caster->HasAura(m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_1))) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); ((Creature*)unitTarget)->AI()->AttackStart(m_caster); @@ -1645,7 +1769,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 42628: // Fire Bomb (throw) { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 42629, true); return; @@ -1653,7 +1779,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 42631: // Fire Bomb (explode) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } unitTarget->RemoveAurasDueToSpell(42629); unitTarget->CastSpell(unitTarget, 42630, true); @@ -1665,14 +1793,18 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 42793: // Burn Body { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Creature* pCreature = (Creature*)unitTarget; // Spell can be used in combat and may affect different target than the expected. // If target is not the expected we need to prevent this effect. if (pCreature->HasLootRecipient() || pCreature->IsInCombat()) + { return; + } // set loot recipient, prevent re-use same target pCreature->SetLootRecipient(m_caster); @@ -1686,7 +1818,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43014: // Despawn Self { if (m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } ((Creature*)m_caster)->ForcedDespawn(); return; @@ -1694,10 +1828,14 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43036: // Dismembering Corpse { if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (unitTarget->HasAura(43059, EFFECT_INDEX_0)) + { return; + } unitTarget->CastSpell(m_caster, 43037, true); unitTarget->CastSpell(unitTarget, 43059, true); @@ -1712,7 +1850,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43096: // Summon All Players { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 43097, true); return; @@ -1720,7 +1860,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43144: // Hatch All Eggs { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 42493, true, NULL, NULL, m_caster->GetObjectGuid()); return; @@ -1728,7 +1870,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43209: // Place Ram Meat { if (!unitTarget) + { return; + } // Self Visual - Sleep Until Cancelled (DND) unitTarget->RemoveAurasDueToSpell(6606); @@ -1738,7 +1882,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) { // This spell should cast the next spell only for one (player)target, however it should hit multiple targets, hence this kind of implementation if (!unitTarget || m_UniqueTargetInfo.rbegin()->targetGUID != unitTarget->GetObjectGuid()) + { return; + } std::vector possibleTargets; possibleTargets.reserve(m_UniqueTargetInfo.size()); @@ -1761,7 +1907,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43572: // Send Them Packing: On /Raise Emote Dummy to Player { if (!unitTarget) + { return; + } // m_caster (creature) should start walking back to it's "home" here, no clear way how to do that @@ -1773,7 +1921,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43723: { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)m_caster)->CastSpell(unitTarget, 43753, true, m_CastItem, NULL, m_originalCasterGUID, m_spellInfo); return; @@ -1781,7 +1931,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 43882: // Scourging Crystal Controller Dummy { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // see spell dummy 50133 unitTarget->RemoveAurasDueToSpell(43874); @@ -1790,7 +1942,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 44454: // Tasty Reef Fish { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } m_caster->CastSpell(unitTarget, 44455, true, m_CastItem); return; @@ -1798,11 +1952,15 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 44869: // Spectral Blast { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // If target has spectral exhaustion or spectral realm aura return if (unitTarget->HasAura(44867) || unitTarget->HasAura(46021)) + { return; + } // Cast the spectral realm effect spell, visual spell and spectral blast rift summoning unitTarget->CastSpell(unitTarget, 44866, true, NULL, NULL, m_caster->GetObjectGuid()); @@ -1813,7 +1971,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 44875: // Complete Raptor Capture { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } Creature* creatureTarget = (Creature*)unitTarget; @@ -1826,7 +1986,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 44997: // Converting Sentry { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } Creature* creatureTarget = (Creature*)unitTarget; @@ -1862,7 +2024,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 45583: // Throw Gnomish Grenade { if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)m_caster)->KilledMonsterCredit(unitTarget->GetEntry(), unitTarget->GetObjectGuid()); @@ -1921,7 +2085,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46177: // Open All Portals { if (!unitTarget) + { return; + } // portal visual unitTarget->CastSpell(unitTarget, 45977, true); @@ -1949,7 +2115,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 45989: // Summon Void Sentinel Summoner Visual { if (!unitTarget) + { return; + } // summon void sentinel unitTarget->CastSpell(unitTarget, 45988, true); @@ -1959,7 +2127,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 45990: // Collect Oil { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (const SpellEntry* pSpell = sSpellStore.LookupEntry(45991)) { @@ -1981,7 +2151,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 74904: // Pickup Sen'jin Frog { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spellId = 0; @@ -2013,7 +2185,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46171: // Scuttle Wrecked Flying Machine { if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)m_caster)->KilledMonsterCredit(unitTarget->GetEntry(), unitTarget->GetObjectGuid()); @@ -2038,7 +2212,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46292: // Cataclysm Breath { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spellId = 0; @@ -2060,7 +2236,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46372: // Ice Spear Target Picker { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 46359, true); return; @@ -2068,7 +2246,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46485: // Greatmother's Soulcatcher { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (const SpellEntry* pSpell = sSpellStore.LookupEntry(46486)) { @@ -2087,7 +2267,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46606: // Plague Canister Dummy { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } unitTarget->CastSpell(m_caster, 43160, true); unitTarget->SetDeathState(JUST_DIED); @@ -2098,7 +2280,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46672: // Cleansing Flames (Silvermoon) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, m_spellInfo->Id == 46671 ? 46690 : 46689, true); return; @@ -2106,7 +2290,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 46797: // Quest - Borean Tundra - Set Explosives Cart { if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)m_caster)->KilledMonsterCredit(unitTarget->GetEntry(), unitTarget->GetObjectGuid()); @@ -2139,7 +2325,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 47170: // Impale Leviroth { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } unitTarget->SetHealthPercent(8.0f); @@ -2154,7 +2342,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) // Spell has wrong areaGroupid, so it can not be casted where expected. // TODO: research if spells casted by NPC, having TARGET_SCRIPT, can have disabled area check if (!unitTarget) + { return; + } // Plague Effect Self unitTarget->CastSpell(unitTarget, 47178, true); @@ -2163,11 +2353,15 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 47305: // Potent Explosive Charge { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // only if below 80% hp if (unitTarget->GetHealthPercent() > 80.0f) + { return; + } // Issues with explosion animation (remove insta kill spell resolves the issue) @@ -2186,7 +2380,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 50441: // Reagent Check (Survival Mojo) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } switch (m_spellInfo->Id) { @@ -2213,7 +2409,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 48046: // Use Camera { if (!unitTarget) + { return; + } // No despawn expected, nor any change in dynamic flags/other flags. // Need internal way to track if credit has been given for this object. @@ -2225,7 +2423,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 48790: // Neltharion's Flame { if (!unitTarget) + { return; + } // Neltharion's Flame Fire Bunny: Periodic Fire Aura unitTarget->CastSpell(unitTarget, 48786, false); @@ -2234,10 +2434,14 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 49357: // Brewfest Mount Transformation { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) + { return; + } m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); @@ -2265,7 +2469,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 49634: // Sergeant's Flare { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // Towers of Certain Doom: Tower Bunny Smoke Flare Effect // TODO: MaNGOS::DynamicObjectUpdater::VisitHelper prevent aura to be applied to dummy creature (see HandleAuraDummy for effect of aura) @@ -2296,7 +2502,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 49859: // Rune of Command { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // Captive Stone Giant Kill Credit unitTarget->CastSpell(m_caster, 43564, true); @@ -2307,14 +2515,18 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 50133: // Scourging Crystal Controller { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // Scourge Mur'gul Camp: Force Shield Arcane Purple x3 if (unitTarget->HasAura(43874)) { // someone else is already channeling target if (unitTarget->HasAura(43878)) + { return; + } // Scourging Crystal Controller m_caster->CastSpell(unitTarget, 43878, true, m_CastItem); @@ -2325,11 +2537,15 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 50243: // Teach Language { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // spell has a 1/3 chance to trigger one of the below if (roll_chance_i(66)) + { return; + } if (((Player*)m_caster)->GetTeam() == ALLIANCE) { @@ -2347,7 +2563,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 50440: // Envision Drakuru { if (!unitTarget) + { return; + } // Script Cast Summon Image of Drakuru 05 unitTarget->CastSpell(unitTarget, 50439, true); @@ -2358,7 +2576,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 50548: // Ley Line Focus Control Talisman Effect { if (!m_originalCaster || !unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } switch (m_spellInfo->Id) { @@ -2372,7 +2592,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51276: // Incinerate Corpse { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } unitTarget->CastSpell(unitTarget, 51278, true); unitTarget->CastSpell(m_caster, 51279, true); @@ -2383,7 +2605,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51330: // Shoot RJR { if (!unitTarget) + { return; + } // guessed chances if (roll_chance_i(75)) @@ -2396,7 +2620,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51333: // Dig For Treasure { if (!unitTarget) + { return; + } if (roll_chance_i(75)) m_caster->CastSpell(unitTarget, 51370, true, m_CastItem); @@ -2408,7 +2634,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51336: // Magic Pull { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 50770, true); return; @@ -2416,12 +2644,16 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51420: // Digging for Treasure Ping { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // only spell related protector pets exist currently Pet* pPet = m_caster->GetProtectorPet(); if (!pPet) + { return; + } pPet->SetFacingToObject(unitTarget); @@ -2434,7 +2666,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51582: // Rocket Boots Engaged (Rocket Boots Xtreme and Rocket Boots Xtreme Lite) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (BattleGround* bg = ((Player*)m_caster)->GetBattleGround()) bg->EventPlayerDroppedFlag((Player*)m_caster); @@ -2445,7 +2679,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51840: // Despawn Fruit Tosser { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (roll_chance_i(20)) { @@ -2472,15 +2708,21 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) // If so, unclear how it should work and using the below instead (even though it could be a bit hack-ish) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // Only own guardian pet if (m_caster != unitTarget->GetOwner()) + { return; + } // This means we already set state (see below) and need to wait. if (unitTarget->hasUnitState(UNIT_STAT_ROOT)) + { return; + } // Expecting pTargetDummy to be summoned by AI at death of target creatures. @@ -2511,7 +2753,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51872: // Hair Sample Collected { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // clear state to allow follow again m_caster->clearUnitState(UNIT_STAT_ROOT); @@ -2527,7 +2771,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51964: // Tormentor's Incense { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // This might not be the best way, and effect may need some adjustment. Removal of any aura from surrounding dummy creatures? if (((Creature*)unitTarget)->AI()) @@ -2538,7 +2784,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 51858: // Siphon of Acherus { if (!m_originalCaster || !unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (Player* pPlayer = m_originalCaster->GetCharmerOrOwnerPlayerOrPlayerItself()) pPlayer->KilledMonsterCredit(unitTarget->GetEntry(), unitTarget->GetObjectGuid()); @@ -2568,7 +2816,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 52371: // Detonate Explosives { if (!unitTarget) + { return; + } // Cosmetic - Explosion unitTarget->CastSpell(unitTarget, 46419, true); @@ -2597,7 +2847,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 52759: // Ancestral Awakening { if (!unitTarget) + { return; + } m_caster->CastCustomSpell(unitTarget, 52752, &damage, NULL, NULL, true); return; @@ -2605,10 +2857,14 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 52845: // Brewfest Mount Transformation (Faction Swap) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!m_caster->HasAuraType(SPELL_AURA_MOUNTED)) + { return; + } m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); @@ -2645,7 +2901,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 54015: // Set Oracle Faction Honored { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (effect->EffectIndex == EFFECT_INDEX_0) { @@ -2657,7 +2915,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); if (!factionEntry) + { return; + } // Set rep to baserep + basepoints (expecting spillover for oposite faction -> become hated) // Not when player already has equal or higher rep with this faction @@ -2686,7 +2946,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) } if (m_caster->HasAura(spellTransf)) + { return; + } m_caster->CastSpell(m_caster, spellShrink, true); return; @@ -2694,7 +2956,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 54577: // Throw U.D.E.D. { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // Sometimes issues with explosion animation. Unclear why // but possibly caused by the order of spells. @@ -2718,7 +2982,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 54092: // Monster Slayer's Kit { if (!unitTarget) + { return; + } uint32 spellIds[] = {51853, 54063, 54071, 54086}; m_caster->CastSpell(unitTarget, spellIds[urand(0, 3)], true); @@ -2727,7 +2993,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 55004: // Nitro Boosts { if (!m_CastItem) + { return; + } if (roll_chance_i(95)) // Nitro Boosts - success m_caster->CastSpell(m_caster, 54861, true, m_CastItem); @@ -2749,7 +3017,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 56430: // Arcane Bomb { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 56431, true, NULL, NULL, m_caster->GetObjectGuid()); unitTarget->CastSpell(unitTarget, 56432, true, NULL, NULL, m_caster->GetObjectGuid()); @@ -2758,7 +3028,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 57578: // Lava Strike { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -2786,7 +3058,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 59640: // Underbelly Elixir { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (urand(1, 3)) @@ -2802,7 +3076,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 60932: // Disengage (one from creature versions) { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 60934, true, NULL); return; @@ -2810,7 +3086,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 62105: // To'kini's Blowgun { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // Sleeping Sleep unitTarget->CastSpell(unitTarget, 62248, true); @@ -2827,7 +3105,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 62278: // Lightning Orb Charger { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, 62466, true); unitTarget->CastSpell(unitTarget, 62279, true); @@ -2836,7 +3116,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 62652: // Tidal Wave { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, m_caster->GetMap()->IsRegularDifficulty() ? 62653 : 62935, true); return; @@ -2844,7 +3126,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 62797: // Storm Cloud { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, m_caster->GetMap()->IsRegularDifficulty() ? 65123 : 65133, true); return; @@ -2852,7 +3136,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 62907: // Freya's Ward { if (!unitTarget) + { return; + } for (uint8 i = 0; i < 5; ++i) m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); @@ -2861,7 +3147,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 63030: // Boil Ominously { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 63031, true); return; @@ -2869,7 +3157,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 63499: // Dispel Magic { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); return; @@ -2877,7 +3167,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 63545: // Icicle { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -2887,7 +3179,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 63747: // Sara's Fervor { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -2895,7 +3189,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 63984: // Hate to Zero { if (!unitTarget) + { return; + } if (m_caster->GetThreatManager().getThreat(unitTarget)) m_caster->GetThreatManager().modifyThreatPercent(unitTarget, -100); @@ -2904,7 +3200,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 64172: // Titanic Storm { if (!unitTarget || !unitTarget->HasAura(effect->CalculateSimpleValue())) + { return; + } // There is no known spell to kill the target m_caster->DealDamage(unitTarget, unitTarget->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); @@ -2918,7 +3216,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 64402: // Rocket Strike { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 63681, true); return; @@ -2926,7 +3226,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 64489: // Feral Rush { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 64496, true); return; @@ -2934,7 +3236,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 64543: // Melt Ice { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); m_caster->CastSpell(m_caster, 64540, true); @@ -2943,7 +3247,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 64555: // Insane Periodic { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->HasAura(63050) || unitTarget->HasAura(effect->CalculateSimpleValue())) + { return; + } m_caster->CastSpell(unitTarget, 64464, true); m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); @@ -2952,7 +3258,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 64673: // Feral Rush (h) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 64674, true); return; @@ -2974,7 +3282,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 65206: // Destabilization Matrix { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -2982,7 +3292,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 65346: // Proximity Mine { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(m_caster, m_caster->GetMap()->IsRegularDifficulty() ? 66351 : 63009, true); m_caster->RemoveAurasDueToSpell(65345); @@ -2992,7 +3304,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 65869: // Disengage { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 65870, true); return; @@ -3000,7 +3314,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 66312: // Light Ball Passive { if (!unitTarget || m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } if (unitTarget->GetTypeId() == TYPEID_PLAYER) { @@ -3016,7 +3332,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 66314: // Dark Ball Passive { if (!unitTarget || m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } if (unitTarget->GetTypeId() == TYPEID_PLAYER) { @@ -3032,7 +3350,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 66390: // Read Last Rites { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // Summon Tualiq Proxy // Not known what purpose this has @@ -3052,7 +3372,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 67019: // Flask of the North { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (m_caster->getClass()) @@ -3087,7 +3409,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 69922: // Temper Quel'Delar { if (!unitTarget) + { return; + } // Return Tempered Quel'Delar unitTarget->CastSpell(m_caster, 69956, true); @@ -3096,7 +3420,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 71307: // Vile Gas { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -3105,7 +3431,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 71471: // Twilight Bloodbolt { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 71818, true); return; @@ -3114,7 +3442,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 72040: // Conjure Empowered Flame { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -3122,7 +3452,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 71837: // Vampiric Bite { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 71726, true); return; @@ -3130,7 +3462,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 71861: // Swarming Shadows { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 71264, true); return; @@ -3138,7 +3472,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 72202: // Blood Link { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 72195, true); return; @@ -3146,7 +3482,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 72254: // Mark of the Fallen Champion { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->HasAura(effect->CalculateSimpleValue())) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -3154,7 +3492,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 72261: // Delirious Slash { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, m_caster->CanReachWithMeleeAttack(unitTarget) ? 71623 : 72264, true); return; @@ -3162,7 +3502,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 72285: // Vile Gas Trigger { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -3170,7 +3512,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 74452: // Conflagration { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 74453, true); m_caster->CastSpell(unitTarget, 74454, true, NULL, NULL, m_caster->GetObjectGuid(), m_spellInfo); @@ -3186,7 +3530,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 11958: // Cold Snap { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // immediately finishes the cooldown on Frost spells const SpellCooldowns& cm = ((Player*)m_caster)->GetSpellCooldownMap(); @@ -3246,12 +3592,16 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (effect->EffectIndex == EFFECT_INDEX_1 && m_spellInfo->GetSpellEffectIdByIndex(EFFECT_INDEX_0) == SPELL_EFFECT_CREATE_ITEM) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // checked in create item check, avoid unexpected if (Item* item = ((Player*)m_caster)->GetItemByLimitedCategory(ITEM_LIMIT_CATEGORY_MANA_GEM)) if (item->HasMaxCharges()) + { return; + } unitTarget->CastSpell( unitTarget, effect->CalculateSimpleValue(), true, m_CastItem); return; @@ -3272,7 +3622,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (warClassOptions && warClassOptions->SpellFamilyFlags & UI64LIT(0x20000000)) { if (!unitTarget) + { return; + } uint32 rage = m_caster->GetPower(POWER_RAGE); @@ -3316,7 +3668,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (warClassOptions && warClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000200000)) { if (!unitTarget) + { return; + } // dummy cast itself ignored by client in logs m_caster->CastCustomSpell(unitTarget, 50782, &damage, NULL, NULL, true); @@ -3335,7 +3689,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 21977: { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 21887, true); // spell mod return; } @@ -3355,14 +3711,18 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 30012: // Move { if (!unitTarget || unitTarget->HasAura(39400)) + { return; + } unitTarget->CastSpell(m_caster, 30253, true); } case 30284: // Change Facing { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, 30270, true); return; @@ -3375,7 +3735,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 37153: // Move (Chess event player king move) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // cast generic move spell m_caster->CastSpell(unitTarget, 30012, true); @@ -3434,7 +3796,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (prtsClassOptions && prtsClassOptions->SpellFamilyFlags & UI64LIT(0x0080000000000000)) { if (!unitTarget) + { return; + } int hurt = 0; int heal = 0; @@ -3477,7 +3841,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) // Any effect which causes you to lose control of your character will supress the starfall effect. if (m_caster->hasUnitState(UNIT_STAT_NO_FREE_MOVE)) + { return; + } switch (m_spellInfo->Id) { @@ -3499,22 +3865,30 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 5938: // Shiv { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* pCaster = ((Player*)m_caster); Item* item = pCaster->GetWeaponForAttack(OFF_ATTACK); if (!item) + { return; + } // all poison enchantments is temporary uint32 enchant_id = item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT); if (!enchant_id) + { return; + } SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) + { return; + } for (int s = 0; s < 3; ++s) { @@ -3534,7 +3908,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 14185: // Preparation { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // immediately finishes the cooldown on certain Rogue abilities const SpellCooldowns& cm = ((Player*)m_caster)->GetSpellCooldownMap(); @@ -3570,7 +3946,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (huntClassOptions && huntClassOptions->SpellFamilyFlags & UI64LIT(0x100000000)) { if (!unitTarget || !unitTarget->IsAlive()) + { return; + } bool found = false; @@ -3604,7 +3982,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) return; } if (!target || !target->IsAlive()) + { return; + } m_caster->CastSpell(target, spellid, true, NULL); } @@ -3613,7 +3993,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 23989: // Readiness talent { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // immediately finishes the cooldown for hunter abilities const SpellCooldowns& cm = ((Player*)m_caster)->GetSpellCooldownMap(); @@ -3631,7 +4013,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 37506: // Scatter Shot { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // break Auto Shot and autohit m_caster->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); @@ -3643,7 +4027,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 53478: { if (!unitTarget) + { return; + } int32 healthModSpellBasePoints0 = int32(unitTarget->GetMaxHealth() * 0.3); unitTarget->CastCustomSpell(unitTarget, 53479, &healthModSpellBasePoints0, NULL, NULL, true, NULL); return; @@ -3653,7 +4039,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) { Pet* pet = m_caster->GetPet(); if (!pet || !unitTarget) + { return; + } pet->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -3668,7 +4056,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 156: // Holy Shock { if (!unitTarget) + { return; + } int hurt = 0; int heal = 0; @@ -3697,12 +4087,16 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 561: // Judgement of command { if (!unitTarget) + { return; + } uint32 spell_id = m_currentBasePoints[effect->EffectIndex]; SpellEntry const* spell_proto = sSpellStore.LookupEntry(spell_id); if (!spell_proto) + { return; + } m_caster->CastSpell(unitTarget, spell_proto, true, NULL); return; @@ -3759,7 +4153,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) case 37877: // Blessing of Faith { if (!unitTarget) + { return; + } uint32 spell_id = 0; switch (unitTarget->getClass()) @@ -3820,7 +4216,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (shamClassOptions && shamClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000004000)) { if (!unitTarget || unitTarget->GetPowerType() != POWER_MANA) + { return; + } m_caster->CastCustomSpell(unitTarget, 52032, &damage, 0, 0, true, 0, 0, m_originalCasterGUID); return; } @@ -3844,7 +4242,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (m_spellInfo->Id == 39610) // Mana Tide Totem effect { if (!unitTarget || unitTarget->GetPowerType() != POWER_MANA) + { return; + } // Glyph of Mana Tide if (Unit* owner = m_caster->GetOwner()) @@ -3859,7 +4259,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (m_spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000000000000), 0x00000004)) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Item* item = ((Player*)m_caster)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (item) { @@ -3883,7 +4285,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) // fire totems slot Totem* totem = m_caster->GetTotem(TOTEM_SLOT_FIRE); if (!totem) + { return; + } uint32 triggered_spell_id; switch (m_spellInfo->Id) @@ -3917,7 +4321,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if (m_caster->IsFriendlyTo(unitTarget)) { if (!unitTarget || unitTarget->GetCreatureType() != CREATURE_TYPE_UNDEAD) + { return; + } int32 bp = int32(damage * 1.5f); m_caster->CastCustomSpell(unitTarget, 47633, &bp, NULL, NULL, true); @@ -3974,7 +4380,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) else if (m_spellInfo->Id == 49576) { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 49560, true); return; @@ -3983,7 +4391,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) else if (m_spellInfo->Id == 49560) { if (!unitTarget || unitTarget == m_caster) + { return; + } uint32 spellId = m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_0); float dest_x, dest_y; @@ -4001,7 +4411,9 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) if ((*itr)->GetSpellProto()->GetSpellFamilyName() == SPELLFAMILY_DEATHKNIGHT && (*itr)->GetSpellProto()->SpellIconID == 2710) { if (roll_chance_i((*itr)->GetModifier()->m_amount)) // don't consume if found + { return; + } else break; } @@ -4032,11 +4444,15 @@ void Spell::EffectDummy(SpellEffectEntry const* effect) libraryResult = sScriptMgr.OnEffectDummy(m_caster, m_spellInfo->Id, SpellEffectIndex(effect->EffectIndex), itemTarget, m_originalCasterGUID); if (libraryResult || !unitTarget) + { return; + } // Previous effect might have started script if (!ScriptMgr::CanSpellEffectStartDBScript(m_spellInfo, SpellEffectIndex(effect->EffectIndex))) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectDummy", m_spellInfo->Id); m_caster->GetMap()->ScriptsStart(DBS_ON_SPELL, m_spellInfo->Id, m_caster, unitTarget); @@ -4078,7 +4494,9 @@ void Spell::EffectTriggerRitualOfSummoning(SpellEffectEntry const* effect) void Spell::EffectClearQuest(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)m_caster; @@ -4110,7 +4528,9 @@ void Spell::EffectClearQuest(SpellEffectEntry const* effect) void Spell::EffectForceCast(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectDummy", m_spellInfo->Id); m_caster->GetMap()->ScriptsStart(DBS_ON_SPELL, m_spellInfo->Id, m_caster, unitTarget); @@ -4139,7 +4559,9 @@ void Spell::EffectTriggerSpell(SpellEffectEntry const* effect) // if this spell is given to NPC it must handle rest by it's own AI if (unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spellId = 1784; // reset cooldown on it if needed @@ -4213,11 +4635,15 @@ void Spell::EffectTriggerSpell(SpellEffectEntry const* effect) // skip spell if no weapon in slot or broken if (!item) + { return; + } // skip spell if weapon not fit to triggered spell if (!item->IsFitToSpellRequirements(spellInfo)) + { return; + } } // offhand hand weapon required @@ -4227,11 +4653,15 @@ void Spell::EffectTriggerSpell(SpellEffectEntry const* effect) // skip spell if no weapon in slot or broken if (!item) + { return; + } // skip spell if weapon not fit to triggered spell if (!item->IsFitToSpellRequirements(spellInfo)) + { return; + } } } else @@ -4276,7 +4706,9 @@ void Spell::EffectTriggerMissileSpell(SpellEffectEntry const* effect) void Spell::EffectJump(SpellEffectEntry const* effect) { if (m_caster->IsTaxiFlying()) + { return; + } // Init dest coordinates float x, y, z, o; @@ -4327,7 +4759,9 @@ void Spell::EffectJump(SpellEffectEntry const* effect) void Spell::EffectTeleportUnits(SpellEffectEntry const* effect) // TODO - Use target settings for this effect! { if (!unitTarget || unitTarget->IsTaxiFlying()) + { return; + } switch (m_spellInfo->Id) { @@ -4366,7 +4800,9 @@ void Spell::EffectTeleportUnits(SpellEffectEntry const* effect) // TODO - Use { // Only players can teleport to innkeeper if (unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)unitTarget)->TeleportToHomebind(unitTarget == m_caster ? TELE_TO_SPELL : 0); return; @@ -4539,7 +4975,9 @@ void Spell::EffectTeleportUnits(SpellEffectEntry const* effect) // TODO - Use void Spell::EffectApplyAura(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) if ((!unitTarget->IsAlive() && !(IsDeathOnlySpell(m_spellInfo) || IsDeathPersistentSpell(m_spellInfo))) && @@ -4554,7 +4992,9 @@ void Spell::EffectApplyAura(SpellEffectEntry const* effect) if (m_originalCasterGUID.IsGameObject()) caster = unitTarget; else + { return; + } } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell: Aura is: %u", effect->EffectApplyAuraName); @@ -4566,7 +5006,9 @@ void Spell::EffectApplyAura(SpellEffectEntry const* effect) void Spell::EffectUnlearnSpecialization(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player *_player = (Player*)unitTarget; uint32 spellToUnlearn = effect->EffectTriggerSpell; @@ -4580,18 +5022,28 @@ void Spell::EffectUnlearnSpecialization(SpellEffectEntry const* effect) void Spell::EffectPowerDrain(SpellEffectEntry const* effect) { if(effect->EffectMiscValue < 0 || effect->EffectMiscValue >= MAX_POWERS) + { return; + } Powers drain_power = Powers(effect->EffectMiscValue); if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } if (unitTarget->GetPowerType() != drain_power) + { return; + } if (damage < 0) + { return; + } uint32 curPower = unitTarget->GetPower(drain_power); @@ -4641,18 +5093,28 @@ void Spell::EffectSendEvent(SpellEffectEntry const* effect) void Spell::EffectPowerBurn(SpellEffectEntry const* effect) { if (effect->EffectMiscValue < 0 || effect->EffectMiscValue >= MAX_POWERS) + { return; + } Powers powertype = Powers(effect->EffectMiscValue); if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } if (unitTarget->GetPowerType() != powertype) + { return; + } if (damage < 0) + { return; + } // burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn) if (m_spellInfo->GetManaCostPercentage()) @@ -4689,7 +5151,9 @@ void Spell::EffectHeal(SpellEffectEntry const* /*effect*/) // Try to get original caster Unit* caster = GetAffectiveCaster(); if (!caster) + { return; + } int32 addhealth = damage; @@ -4799,7 +5263,9 @@ void Spell::EffectHealPct(SpellEffectEntry const* /*effect*/) // Try to get original caster Unit* caster = GetAffectiveCaster(); if (!caster) + { return; + } uint32 addhealth = unitTarget->GetMaxHealth() * damage / 100; @@ -4822,7 +5288,9 @@ void Spell::EffectHealMechanical(SpellEffectEntry const* /*effect*/) // Try to get original caster Unit* caster = GetAffectiveCaster(); if (!caster) + { return; + } uint32 addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, damage, HEAL); addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL); @@ -4837,12 +5305,18 @@ void Spell::EffectHealMechanical(SpellEffectEntry const* /*effect*/) void Spell::EffectHealthLeech(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } if (damage < 0) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "HealthLeech :%i", damage); @@ -4871,7 +5345,9 @@ void Spell::EffectHealthLeech(SpellEffectEntry const* effect) void Spell::DoCreateItem(SpellEffectEntry const* effect, uint32 itemtype) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)unitTarget; @@ -4932,7 +5408,9 @@ void Spell::DoCreateItem(SpellEffectEntry const* effect, uint32 itemtype) { // ignore mana gem case (next effect will recharge existing example) if (effect->EffectIndex == EFFECT_INDEX_0 && m_spellInfo->GetSpellEffectIdByIndex(EFFECT_INDEX_1) == SPELL_EFFECT_DUMMY ) + { return; + } // if not created by another reason from full inventory or unique items amount limitation player->SendEquipError(msg, NULL, NULL, newitemid); @@ -4973,7 +5451,9 @@ void Spell::EffectCreateItem(SpellEffectEntry const* effect) void Spell::EffectCreateItem2(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)m_caster; // explicit item (possible fake) @@ -4988,7 +5468,9 @@ void Spell::EffectCreateItem2(SpellEffectEntry const* effect) if (item_id) { if (!player->HasItemCount(item_id, 1)) + { return; + } // remove reagent uint32 count = 1; @@ -5003,7 +5485,9 @@ void Spell::EffectCreateItem2(SpellEffectEntry const* effect) void Spell::EffectCreateRandomItem(SpellEffectEntry const* /*effect*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)m_caster; // create some random items @@ -5036,12 +5520,18 @@ void Spell::EffectPersistentAA(SpellEffectEntry const* effect) void Spell::EffectEnergize(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } if(effect->EffectMiscValue < 0 || effect->EffectMiscValue >= MAX_POWERS) + { return; + } Powers power = Powers(effect->EffectMiscValue); @@ -5087,10 +5577,14 @@ void Spell::EffectEnergize(SpellEffectEntry const* effect) damage -= level_multiplier * level_diff; if (damage < 0) + { return; + } if (unitTarget->GetMaxPower(power) == 0) + { return; + } m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, damage, power); @@ -5140,18 +5634,26 @@ void Spell::EffectEnergize(SpellEffectEntry const* effect) void Spell::EffectEnergisePct(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } if (effect->EffectMiscValue < 0 || effect->EffectMiscValue >= MAX_POWERS) + { return; + } Powers power = Powers(effect->EffectMiscValue); uint32 maxPower = unitTarget->GetMaxPower(power); if (maxPower == 0) + { return; + } uint32 gain = damage * maxPower / 100; m_caster->EnergizeBySpell(unitTarget, m_spellInfo->Id, gain, power); @@ -5191,7 +5693,9 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype, LockType lockType) } if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // Send loot ((Player*)m_caster)->SendLoot(guid, loottype); @@ -5295,21 +5799,29 @@ void Spell::EffectOpenLock(SpellEffectEntry const* effect) void Spell::EffectSummonChangeItem(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)m_caster; // applied only to using item if (!m_CastItem) + { return; + } // ... only to item in own inventory/bank/equip_slot if (m_CastItem->GetOwnerGuid() != player->GetObjectGuid()) + { return; + } uint32 newitemid = effect->EffectItemType; if (!newitemid) + { return; + } Item* oldItem = m_CastItem; @@ -5322,13 +5834,17 @@ void Spell::EffectSummonChangeItem(SpellEffectEntry const* effect) void Spell::EffectProficiency(SpellEffectEntry const* /*effect*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player *p_target = (Player*)unitTarget; SpellEquippedItemsEntry const* eqItems = m_spellInfo->GetSpellEquippedItems(); if (!eqItems) + { return; + } if (eqItems->EquippedItemClass == ITEM_CLASS_WEAPON && !(p_target->GetWeaponProficiency() & eqItems->EquippedItemSubClassMask)) { @@ -5345,9 +5861,13 @@ void Spell::EffectProficiency(SpellEffectEntry const* /*effect*/) void Spell::EffectApplyAreaAura(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } AreaAura* Aur = new AreaAura(m_spellInfo, SpellEffectIndex(effect->EffectIndex), &m_currentBasePoints[effect->EffectIndex], m_spellAuraHolder, unitTarget, m_caster, m_CastItem); m_spellAuraHolder->AddAura(Aur, SpellEffectIndex(effect->EffectIndex)); @@ -5357,7 +5877,9 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect) { // if this spell already have an aura applied cancel the summon if (m_caster->HasAura(m_spellInfo->Id)) + { return; + } uint32 prop_id = effect->EffectMiscValueB; SummonPropertiesEntry const *summon_prop = sSummonPropertiesStore.LookupEntry(prop_id); @@ -5477,7 +5999,9 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect) CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(effect->EffectMiscValue); if (!cInfo) + { return; + } // FIXME: not all totems and similar cases selected by this check... if (cInfo->CreatureType == CREATURE_TYPE_TOTEM) @@ -5609,7 +6133,9 @@ bool Spell::DoSummonWild(CreatureSummonPositions& list, SummonPropertiesEntry co ((Creature*)m_originalCaster)->AI()->JustSummoned(summon); } else + { return false; + } return true; } @@ -5705,7 +6231,9 @@ bool Spell::DoSummonGuardian(CreatureSummonPositions& list, SummonPropertiesEntr } if (found) + { return false; + } } // protectors allowed only in single amount @@ -5866,10 +6394,14 @@ bool Spell::DoSummonPossessed(CreatureSummonPositions& list, SummonPropertiesEnt bool Spell::DoSummonPet(SpellEffectEntry const* effect) { if (m_caster->GetPetGuid()) + { return false; + } if (!unitTarget) + { return false; + } uint32 pet_entry = effect->EffectMiscValue; CreatureInfo const* cInfo = ObjectMgr::GetCreatureTemplate(pet_entry); @@ -6025,7 +6557,9 @@ bool Spell::DoSummonVehicle(CreatureSummonPositions& list, SummonPropertiesEntry void Spell::EffectLearnSpell(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (unitTarget->GetTypeId() != TYPEID_PLAYER) { @@ -6047,7 +6581,9 @@ void Spell::EffectLearnSpell(SpellEffectEntry const* effect) void Spell::EffectDispel(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } // Fill possible dispel list std::list > dispel_list; @@ -6194,11 +6730,15 @@ void Spell::EffectDistract(SpellEffectEntry const* /*effect*/) { // Check for possible target if (!unitTarget || unitTarget->IsInCombat()) + { return; + } // target must be OK to do this if (unitTarget->hasUnitState(UNIT_STAT_CAN_NOT_REACT)) + { return; + } unitTarget->SetFacingTo(unitTarget->GetAngle(m_targets.m_destX, m_targets.m_destY)); unitTarget->clearUnitState(UNIT_STAT_MOVING); @@ -6210,11 +6750,15 @@ void Spell::EffectDistract(SpellEffectEntry const* /*effect*/) void Spell::EffectPickPocket(SpellEffectEntry const* /*effect*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // victim must be creature and attackable if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget)) + { return; + } // victim have to be alive and humanoid or undead if (unitTarget->IsAlive() && (unitTarget->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) @@ -6239,7 +6783,9 @@ void Spell::EffectPickPocket(SpellEffectEntry const* /*effect*/) void Spell::EffectAddFarsight(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } int32 duration = GetSpellDuration(m_spellInfo); DynamicObject* dynObj = new DynamicObject; @@ -6260,10 +6806,14 @@ void Spell::EffectAddFarsight(SpellEffectEntry const* effect) void Spell::EffectTeleUnitsFaceCaster(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (unitTarget->IsTaxiFlying()) + { return; + } float fx, fy, fz; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) @@ -6280,10 +6830,14 @@ void Spell::EffectTeleUnitsFaceCaster(SpellEffectEntry const* effect) void Spell::EffectLearnSkill(SpellEffectEntry const* effect) { if (unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (damage < 0) + { return; + } uint32 skillid = effect->EffectMiscValue; uint16 skillval = ((Player*)unitTarget)->GetPureSkillValue(skillid); @@ -6296,7 +6850,9 @@ void Spell::EffectLearnSkill(SpellEffectEntry const* effect) void Spell::EffectTradeSkill(SpellEffectEntry const* /*effect*/) { if (unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // uint32 skillid = m_spellInfo->EffectMiscValue[i]; // uint16 skillmax = ((Player*)unitTarget)->(skillid); // ((Player*)unitTarget)->SetSkill(skillid,skillval?skillval:1,skillmax+75); @@ -6305,22 +6861,32 @@ void Spell::EffectTradeSkill(SpellEffectEntry const* /*effect*/) void Spell::EffectEnchantItemPerm(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!itemTarget) + { return; + } uint32 enchant_id = effect->EffectMiscValue; if (!enchant_id) + { return; + } SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) + { return; + } // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); if (!item_owner) + { return; + } Player* p_caster = (Player*)m_caster; @@ -6361,19 +6927,27 @@ void Spell::EffectEnchantItemPerm(SpellEffectEntry const* effect) void Spell::EffectEnchantItemPrismatic(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!itemTarget) + { return; + } Player* p_caster = (Player*)m_caster; uint32 enchant_id = effect->EffectMiscValue; if (!enchant_id) + { return; + } SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) + { return; + } // support only enchantings with add socket in this slot { @@ -6397,7 +6971,9 @@ void Spell::EffectEnchantItemPrismatic(SpellEffectEntry const* effect) // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); if (!item_owner) + { return; + } if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { @@ -6419,7 +6995,9 @@ void Spell::EffectEnchantItemPrismatic(SpellEffectEntry const* effect) void Spell::EffectEnchantItemTmp(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* p_caster = (Player*)m_caster; @@ -6466,7 +7044,9 @@ void Spell::EffectEnchantItemTmp(SpellEffectEntry const* effect) } if (!itemTarget) + { return; + } uint32 enchant_id = effect->EffectMiscValue; @@ -6515,7 +7095,9 @@ void Spell::EffectEnchantItemTmp(SpellEffectEntry const* effect) // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); if (!item_owner) + { return; + } if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { @@ -6728,19 +7310,27 @@ void Spell::EffectSummonPet(SpellEffectEntry const* effect) void Spell::EffectLearnPetSpell(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* _player = (Player*)m_caster; Pet* pet = _player->GetPet(); if (!pet) + { return; + } if (!pet->IsAlive()) + { return; + } SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(effect->EffectTriggerSpell); if(!learn_spellproto) + { return; + } pet->learnSpell(learn_spellproto->Id); @@ -6754,7 +7344,9 @@ void Spell::EffectLearnPetSpell(SpellEffectEntry const* effect) void Spell::EffectTaunt(SpellEffectEntry const* /*effect*/) { if (!unitTarget) + { return; + } // this effect use before aura Taunt apply for prevent taunt already attacking target // for spell as marked "non effective at already attacking target" @@ -6775,9 +7367,13 @@ void Spell::EffectTaunt(SpellEffectEntry const* /*effect*/) void Spell::EffectWeaponDmg(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } // multiple weapon dmg effect workaround // execute only the last weapon damage @@ -6791,7 +7387,9 @@ void Spell::EffectWeaponDmg(SpellEffectEntry const* effect) case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: if (j < int(effect->EffectIndex)) // we must calculate only at last weapon effect + { return; + } break; } } @@ -7079,10 +7677,14 @@ void Spell::EffectWeaponDmg(SpellEffectEntry const* effect) void Spell::EffectThreat(SpellEffectEntry const* /*effect*/) { if (!unitTarget || !unitTarget->IsAlive() || !m_caster->IsAlive()) + { return; + } if (!unitTarget->CanHaveThreatList()) + { return; + } unitTarget->AddThreat(m_caster, float(damage), false, GetSpellSchoolMask(m_spellInfo), m_spellInfo); } @@ -7090,9 +7692,13 @@ void Spell::EffectThreat(SpellEffectEntry const* /*effect*/) void Spell::EffectHealMaxHealth(SpellEffectEntry const* /*effect*/) { if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } uint32 heal = m_caster->GetMaxHealth(); @@ -7102,9 +7708,13 @@ void Spell::EffectHealMaxHealth(SpellEffectEntry const* /*effect*/) void Spell::EffectInterruptCast(SpellEffectEntry const* /*effect*/) { if (!unitTarget) + { return; + } if (!unitTarget->IsAlive()) + { return; + } // TODO: not all spells that used this effect apply cooldown at school spells // also exist case: apply cooldown to interrupted cast only and to all spells @@ -7205,7 +7815,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 8856: // Bending Shinbone { if (!itemTarget && m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spell_id = 0; switch (urand(1, 5)) @@ -7220,7 +7832,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 17512: // Piccolo of the Flaming Fire { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->HandleEmoteCommand(EMOTE_STATE_DANCE); return; @@ -7228,7 +7842,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 20589: // Escape artist { if (!unitTarget) + { return; + } unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); @@ -7249,11 +7865,15 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 22985: { if (!unitTarget || !unitTarget->IsAlive()) + { return; + } // Onyxia Scale Cloak if (unitTarget->GetDummyAura(22683)) + { return; + } // Shadow Flame m_caster->CastSpell(unitTarget, 22682, true); @@ -7263,7 +7883,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24195: // Grom's Tribute { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } uint8 race = m_caster->getRace(); uint32 spellId = 0; @@ -7305,7 +7927,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24324: // Blood Siphon { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(m_caster, unitTarget->HasAura(24321) ? 24323 : 24322, true); return; @@ -7316,7 +7940,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24714: // Trick { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (roll_chance_i(14)) // Trick (can be different critter models). 14% since below can have 1 of 6 m_caster->CastSpell(m_caster, 24753, true); @@ -7328,7 +7954,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24717: // Pirate Costume { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Pirate Costume (male or female) m_caster->CastSpell(unitTarget, unitTarget->getGender() == GENDER_MALE ? 24708 : 24709, true); @@ -7337,7 +7965,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24718: // Ninja Costume { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Ninja Costume (male or female) m_caster->CastSpell(unitTarget, unitTarget->getGender() == GENDER_MALE ? 24711 : 24710, true); @@ -7346,7 +7976,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24719: // Leper Gnome Costume { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Leper Gnome Costume (male or female) m_caster->CastSpell(unitTarget, unitTarget->getGender() == GENDER_MALE ? 24712 : 24713, true); @@ -7355,7 +7987,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24720: // Random Costume { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spellId = 0; @@ -7390,7 +8024,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24737: // Ghost Costume { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Ghost Costume (male or female) m_caster->CastSpell(unitTarget, unitTarget->getGender() == GENDER_MALE ? 24735 : 24736, true); @@ -7399,7 +8035,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 24751: // Trick or Treat { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Tricked or Treated unitTarget->CastSpell(unitTarget, 24755, true); @@ -7418,7 +8056,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 35727: { if (!unitTarget) + { return; + } uint32 spellid; switch (m_spellInfo->Id) @@ -7441,7 +8081,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 26004: // Mistletoe { if (!unitTarget) + { return; + } unitTarget->HandleEmote(EMOTE_ONESHOT_CHEER); return; @@ -7449,7 +8091,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 26137: // Rotate Trigger { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, urand(0, 1) ? 26009 : 26136, true); return; @@ -7457,7 +8101,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 26218: // Mistletoe { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spells[3] = {26206, 26207, 45036}; @@ -7471,7 +8117,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) // check presence for (int j = 0; j < 4; ++j) if (unitTarget->HasAura(spells[j], EFFECT_INDEX_0)) + { return; + } // cast unitTarget->CastSpell(unitTarget, spells[urand(0, 3)], true); @@ -7483,7 +8131,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 26656: // Summon Black Qiraji Battle Tank { if (!unitTarget) + { return; + } // Prevent stacking of mounts unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); @@ -7499,7 +8149,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 27687: // Summon Bone Minions { if (!unitTarget) + { return; + } // Spells 27690, 27691, 27692, 27693 are missing from DBC // So we need to summon creature 16119 manually @@ -7515,7 +8167,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 27695: // Summon Bone Mages { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 27696, true); unitTarget->CastSpell(unitTarget, 27697, true); @@ -7526,7 +8180,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 28352: // Breath of Sargeras { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, 28342, true); return; @@ -7536,7 +8192,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 71123: // Decimate (ICC: Precious / Stinky) { if (!unitTarget) + { return; + } float downToHealthPercent = (m_spellInfo->Id != 71123 ? 5 : effect->CalculateSimpleValue()) * 0.01f; @@ -7548,7 +8206,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 28560: // Summon Blizzard { if (!unitTarget) + { return; + } m_caster->SummonCreature(16474, unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 30000); return; @@ -7565,7 +8225,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { // Cleanse all magic, curse, disease and poison if (!unitTarget) + { return; + } unitTarget->RemoveAurasWithDispelType(DISPEL_MAGIC); unitTarget->RemoveAurasWithDispelType(DISPEL_CURSE); @@ -7614,7 +8276,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 30541: // Blaze { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 30542, true); break; @@ -7622,7 +8286,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 30469: // Nether Beam { if (!unitTarget) + { return; + } // The player and boss spells are different if (unitTarget->GetTypeId() == TYPEID_PLAYER) @@ -7631,21 +8297,27 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { case 17367: if (unitTarget->HasAura(38638)) + { return; + } m_caster->CastSpell(unitTarget, 30401, true); m_caster->CastSpell(unitTarget, 30422, true); break; case 17368: if (unitTarget->HasAura(38639)) + { return; + } m_caster->CastSpell(unitTarget, 30402, true); m_caster->CastSpell(unitTarget, 30423, true); break; case 17369: if (unitTarget->HasAura(38637)) + { return; + } m_caster->CastSpell(unitTarget, 30400, true); m_caster->CastSpell(unitTarget, 30421, true); @@ -7676,7 +8348,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 30769: // Pick Red Riding Hood { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // cast Little Red Riding Hood m_caster->CastSpell(unitTarget, 30768, true); @@ -7685,7 +8359,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 30835: // Infernal Relay { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 30836, true, NULL, NULL, m_caster->GetObjectGuid()); break; @@ -7693,7 +8369,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 30918: // Improved Sprint { if (!unitTarget) + { return; + } // Removes snares and roots. unitTarget->RemoveAurasAtMechanicImmunity(IMMUNE_TO_ROOT_AND_SNARE_MASK, 30918, true); @@ -7713,7 +8391,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 37348: // Karazhan - Chess NPC Action: Melee Attack: Warchief Blackhand { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 32247, true); return; @@ -7721,7 +8401,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 32301: // Ping Shirrak { if (!unitTarget) + { return; + } // Cast Focus fire on caster unitTarget->CastSpell(m_caster, 32300, true); @@ -7730,7 +8412,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 33676: // Incite Chaos { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 33684, true); return; @@ -7739,7 +8423,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 36920: // Fireball (h) { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, unitTarget->GetMap()->IsRegularDifficulty() ? 23971 : 30928, true, NULL, NULL, m_caster->GetObjectGuid()); return; @@ -7747,7 +8433,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 35865: // Summon Nether Vapor { if (!unitTarget) + { return; + } float x, y, z; for (uint8 i = 0; i < 4; ++i) @@ -7760,7 +8448,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 37431: // Spout { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, urand(0, 1) ? 37429 : 37430, true); return; @@ -7768,7 +8458,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 37775: // Karazhan - Chess NPC Action - Poison Cloud { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 37469, true); return; @@ -7776,7 +8468,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 37824: // Karazhan - Chess NPC Action - Shadow Mend { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 37456, true); return; @@ -7784,7 +8478,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 38358: // Tidal Surge { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 38353, true, NULL, NULL, m_caster->GetObjectGuid()); return; @@ -7793,7 +8489,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 39342: // Karazhan - Chess, Medivh CHEAT: Hand of Medivh, Target Alliance { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 39339, true); return; @@ -7802,7 +8500,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 39344: // Karazhan - Chess, Medivh CHEAT: Fury of Medivh, Target Alliance { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -7812,7 +8512,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69891: // Copy Weapon (No Threat) { if (m_caster->GetTypeId() != TYPEID_UNIT || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (Item* pItem = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND)) { @@ -7827,7 +8529,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 41072: // Bloodbolt { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -7835,7 +8539,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 41126: // Flame Crash { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 41131, true); break; @@ -7846,7 +8552,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 73076: // Throw Shield { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -7854,7 +8562,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 42281: // Sprouting { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(42280); unitTarget->RemoveAurasDueToSpell(42294); @@ -7865,11 +8575,15 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 42492: // Cast Energized { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 questId = m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_1); if (!questId || !GetQuestTemplateStore(questId) || !((Player*)unitTarget)->IsCurrentQuest(questId)) + { return; + } m_caster->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -7877,7 +8591,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 42578: // Cannon Blast { if (!unitTarget) + { return; + } int32 basePoints = effect->CalculateSimpleValue(); unitTarget->CastCustomSpell(unitTarget, 42576, &basePoints, NULL, NULL, true); @@ -7886,7 +8602,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 43365: // The Cleansing: Shrine Cast { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // Script Effect Player Cast Mirror Image m_caster->CastSpell(m_caster, 50217, true); @@ -7895,7 +8613,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 43375: // Mixing Vrykul Blood { if (!unitTarget) + { return; + } uint32 triggeredSpell[] = {43376, 43378, 43970, 43377}; @@ -7906,13 +8626,19 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 44407: // Hawk Hunting { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } // check target entry specific to each spell if (m_spellInfo->Id == 44323 && unitTarget->GetEntry() != 24746) + { return; + } if (m_spellInfo->Id == 44407 && unitTarget->GetEntry() != 24747) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); // despawn delay depends on the distance between caster and target @@ -7922,7 +8648,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 44364: // Rock Falcon Primer { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Are there anything special with this, a random chance or condition? // Feeding Rock Falcon @@ -7932,7 +8660,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 44455: // Character Script Effect Reverse Cast { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } Creature* pTarget = (Creature*)unitTarget; @@ -7971,7 +8701,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 44462: // Cast Quest Complete on Master { if (m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } Creature* pQuestCow = NULL; @@ -7985,10 +8717,14 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) // no cows found, so return if (!pQuestCow) + { return; + } if (!((Creature*)m_caster)->IsTemporarySummon()) + { return; + } if (const SpellEntry *pSpell = sSpellStore.LookupEntry(effect->CalculateSimpleValue())) { @@ -8004,7 +8740,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 44876: // Force Cast - Portal Effect: Sunwell Isle { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 44870, true); break; @@ -8012,7 +8750,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 44811: // Spectral Realm { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // If the player can't be teleported, send him a notification if (unitTarget->HasAura(44867)) @@ -8031,7 +8771,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45141: // Burn { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 46394, true, NULL, NULL, m_caster->GetObjectGuid()); return; @@ -8039,7 +8781,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45151: // Burn { if (!unitTarget || unitTarget->HasAura(46394)) + { return; + } // Make the burn effect jump to another friendly target unitTarget->CastSpell(unitTarget, 46394, true); @@ -8048,7 +8792,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45185: // Stomp { if (!unitTarget) + { return; + } // Remove the burn effect unitTarget->RemoveAurasDueToSpell(46394); @@ -8057,7 +8803,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45204: // Clone Me! { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -8066,7 +8814,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69892: // Copy Off-hand Weapon (No Threat) { if (m_caster->GetTypeId() != TYPEID_UNIT || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (Item* pItem = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) { @@ -8081,7 +8831,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45235: // Blaze { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 45236, true, NULL, NULL, m_caster->GetObjectGuid()); return; @@ -8089,7 +8841,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45260: // Karazhan - Chess - Force Player to Kill Bunny { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, 45259, true); return; @@ -8097,7 +8851,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45313: // Anchor Here { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } ((Creature*)unitTarget)->SetRespawnCoord(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), unitTarget->GetOrientation()); return; @@ -8105,7 +8861,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45625: // Arcane Chains: Character Force Cast { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -8113,10 +8871,14 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45668: // Ultra-Advanced Proto-Typical Shortening Blaster { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (roll_chance_i(25)) // chance unknown, using 25 + { return; + } static uint32 const spellPlayer[5] = { @@ -8145,12 +8907,16 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { // assuming caster is creature, if not, then return if (m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } Player* pPlayer = ((Creature*)m_caster)->GetOriginalLootRecipient(); if (!pPlayer) + { return; + } if (pPlayer->HasAura(45674) || pPlayer->HasAura(45675) || pPlayer->HasAura(45678) || pPlayer->HasAura(45682) || pPlayer->HasAura(45684)) pPlayer->CastSpell(pPlayer, 45686, true); @@ -8162,7 +8928,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45713: // Naked Caravan Guard - Master Transform { if (m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } const CreatureInfo* cTemplate = NULL; @@ -8173,7 +8941,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) } if (!cTemplate) + { return; + } uint32 display_id = 0; @@ -8217,7 +8987,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45714: // Fog of Corruption (caster inform) { if (!unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -8225,7 +8997,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45717: // Fog of Corruption (player buff) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, 45726, true); return; @@ -8233,7 +9007,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45785: // Sinister Reflection Clone { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -8241,7 +9017,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45833: // Power of the Blue Flight { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 45836, true); return; @@ -8249,7 +9027,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45892: // Sinister Reflection { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Summon 4 clones of the same player for (uint8 i = 0; i < 4; ++i) @@ -8259,7 +9039,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 45918: // Soul Sever { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || !unitTarget->HasAura(45717)) + { return; + } // kill all charmed targets unitTarget->CastSpell(unitTarget, 45917, true); @@ -8269,7 +9051,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { // "escort" aura not present, so let nothing happen if (!m_caster->HasAura(effect->CalculateSimpleValue())) + { return; + } // "escort" aura is present so break; and let DB table dbscripts_on_spell be used and process further. else break; @@ -8277,7 +9061,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 46203: // Goblin Weather Machine { if (!unitTarget) + { return; + } uint32 spellId = 0; switch (rand() % 4) @@ -8293,7 +9079,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 46289: // Negative Energy { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 46285, true); return; @@ -8301,7 +9089,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 46430: // Synch Health { if (!unitTarget) + { return; + } unitTarget->SetHealth(m_caster->GetHealth()); return; @@ -8309,7 +9099,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 46642: // 5,000 Gold { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)unitTarget)->ModifyMoney(5000 * GOLD); break; @@ -8317,7 +9109,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 47097: // Surge Needle Teleporter { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (unitTarget->GetAreaId() == 4157) unitTarget->CastSpell(unitTarget, 47324, true); @@ -8347,7 +9141,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 47393: // The Focus on the Beach: Quest Completion Script { if (!unitTarget) + { return; + } // Ley Line Information unitTarget->RemoveAurasDueToSpell(47391); @@ -8356,7 +9152,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 47615: // Atop the Woodlands: Quest Completion Script { if (!unitTarget) + { return; + } // Ley Line Information unitTarget->RemoveAurasDueToSpell(47473); @@ -8365,7 +9163,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 47638: // The End of the Line: Quest Completion Script { if (!unitTarget) + { return; + } // Ley Line Information unitTarget->RemoveAurasDueToSpell(47636); @@ -8385,7 +9185,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 57083: // Crystal Spikes (h2) { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 47954, true); unitTarget->CastSpell(unitTarget, 47955, true); @@ -8396,7 +9198,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 48590: // Avenging Spirits { if (!unitTarget) + { return; + } // Summon 4 spirits summoners unitTarget->CastSpell(unitTarget, 48586, true); @@ -8416,7 +9220,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { // Compelled if (!unitTarget || !m_caster->HasAura(48714)) + { return; + } unitTarget->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -8428,7 +9234,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69673: // Silver Covenant Disguise { if (!unitTarget) + { return; + } uint8 gender = unitTarget->getGender(); uint32 spellId; @@ -8446,7 +9254,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 48810: // Death's Door { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // Spell effect order will summon creature first and then apply invisibility to caster. // This result in that summoner/summoned can not see each other and that is not expected. @@ -8469,17 +9279,23 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 48811: // Despawn Forgotten Soul { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (!((Creature*)unitTarget)->IsTemporarySummon()) + { return; + } TemporarySummon* pSummon = (TemporarySummon*)unitTarget; Unit::AuraList const& images = unitTarget->GetAurasByType(SPELL_AURA_MIRROR_IMAGE); if (images.empty()) + { return; + } Unit* pCaster = images.front()->GetCaster(); Unit* pSummoner = unitTarget->GetMap()->GetUnit(pSummon->GetSummonerGuid()); @@ -8492,7 +9308,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 48917: // Who Are They: Cast from Questgiver { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Male Shadowy Disguise / Female Shadowy Disguise unitTarget->CastSpell(unitTarget, unitTarget->getGender() == GENDER_MALE ? 38080 : 38081, true); @@ -8504,7 +9322,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 59803: // Consume (heroic) { if (!unitTarget) + { return; + } // Each target hit buffs the caster unitTarget->CastSpell(m_caster, m_spellInfo->Id == 49380 ? 49381 : 59805, true, NULL, NULL, m_caster->GetObjectGuid()); @@ -8513,7 +9333,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 49405: // Invader Taunt Trigger { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -8534,7 +9356,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 50218: // The Cleansing: Your Inner Turmoil's Mirror Image Aura { if (!m_originalCaster || m_originalCaster->GetTypeId() != TYPEID_PLAYER || !unitTarget) + { return; + } // determine if and what weapons can be copied switch(effect->EffectIndex) @@ -8557,7 +9381,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 50238: // The Cleansing: Your Inner Turmoil's On Death Cast on Master { if (m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } if (((Creature*)m_caster)->IsTemporarySummon()) { @@ -8581,7 +9407,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 59331: // Poisoned Spear (heroic) { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, effect->CalculateSimpleValue(), true, NULL, NULL, m_originalCasterGUID); return; @@ -8603,7 +9431,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { Unit* caster = GetAffectiveCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)caster)->RemoveSpellCategoryCooldown(82, true); return; @@ -8611,7 +9441,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 50742: // Ooze Combine { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } m_caster->CastSpell(unitTarget, 50747, true); ((Creature*)m_caster)->ForcedDespawn(); @@ -8621,10 +9453,14 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 61546: // Shatter (h) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!unitTarget->HasAura(50812)) + { return; + } unitTarget->RemoveAurasDueToSpell(50812); unitTarget->CastSpell(unitTarget, m_spellInfo->Id == 50810 ? 50811 : 61547 , true, NULL, NULL, m_caster->GetObjectGuid()); @@ -8633,7 +9469,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 50894: // Zul'Drak Rat { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (SpellAuraHolder* pHolder = unitTarget->GetSpellAuraHolder(m_spellInfo->Id)) { @@ -8650,7 +9488,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 51519: // Death Knight Initiate Visual { if (!unitTarget) + { return; + } uint32 spellId = 0; @@ -8678,7 +9518,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { Unit* caster = GetAffectiveCaster(); if (!caster) + { return; + } caster->CastSpell(caster, damage, false); break; @@ -8686,7 +9528,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 51864: // Player Summon Nass { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // Summon Nass if (const SpellEntry* pSpell = sSpellStore.LookupEntry(51865)) @@ -8715,7 +9559,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 51904: // Summon Ghouls On Scarlet Crusade { if (!unitTarget) + { return; + } // cast Summon Ghouls On Scarlet Crusade float x, y, z; @@ -8726,7 +9572,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 51910: // Kickin' Nass: Quest Completion { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (const SpellEntry* pSpell = sSpellStore.LookupEntry(51865)) { @@ -8739,7 +9587,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 52479: // Gift of the Harvester { if (m_caster->GetTypeId() != TYPEID_PLAYER || !unitTarget) + { return; + } // Each ghoul casts 52500 onto player, so use number of auras as check Unit::SpellAuraHolderConstBounds bounds = m_caster->GetSpellAuraHolderBounds(52500); @@ -8751,7 +9601,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 52555: // Dispel Scarlet Ghoul Credit Counter { if (!unitTarget) + { return; + } unitTarget->RemoveAurasByCasterSpell(effect->CalculateSimpleValue(), m_caster->GetObjectGuid()); return; @@ -8759,11 +9611,15 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 52694: // Recall Eye of Acherus { if (!m_caster || m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } Unit* charmer = m_caster->GetCharmer(); if (!charmer || charmer->GetTypeId() != TYPEID_PLAYER) + { return; + } charmer->RemoveAurasDueToSpell(51923); charmer->RemoveAurasDueToSpell(51852); @@ -8772,7 +9628,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 52751: // Death Gate { if (!unitTarget || unitTarget->getClass() != CLASS_DEATH_KNIGHT) + { return; + } // triggered spell is stored in m_spellInfo->EffectBasePoints[0] unitTarget->CastSpell(unitTarget, damage, false); @@ -8797,7 +9655,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 53110: // Devour Humanoid { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); ((Creature*)unitTarget)->ForcedDespawn(8000); @@ -8806,7 +9666,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 54182: // An End to the Suffering: Quest Completion Script { if (!unitTarget) + { return; + } // Remove aura (Mojo of Rhunok) given at quest accept / gossip unitTarget->RemoveAurasDueToSpell(51967); @@ -8815,7 +9677,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 54581: // Mammoth Explosion Spell Spawner { if (m_caster->GetTypeId() != TYPEID_UNIT) + { return; + } // Summons misc npc's. They are expected to summon GO from 54625 // but there is no way to get the summoned, to trigger a spell @@ -8838,7 +9702,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 54436: // Demonic Empowerment (succubus Vanish effect) { if (!unitTarget) + { return; + } unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); unitTarget->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); @@ -8849,7 +9715,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 55693: // Remove Collapsing Cave Aura { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); break; @@ -8857,7 +9725,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 56072: // Ride Red Dragon Buddy { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); break; @@ -8865,7 +9735,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 57082: // Crystal Spikes (h1) { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 57077, true); unitTarget->CastSpell(unitTarget, 57078, true); @@ -8876,7 +9748,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 57337: // Great Feast { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 58067, true); break; @@ -8884,7 +9758,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 57397: // Fish Feast { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 45548, true); unitTarget->CastSpell(unitTarget, 57073, true); @@ -8895,7 +9771,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 58475: // Small Feast { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 57085, true); break; @@ -8904,7 +9782,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 58420: // Portal to Stormwind { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || effect->EffectIndex != EFFECT_INDEX_0) + { return; + } uint32 spellID = m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_0); uint32 questID = m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_1); @@ -8917,7 +9797,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 59317: // Teleporting { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // return from top if (((Player*)unitTarget)->GetAreaId() == 4637) @@ -8931,7 +9813,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 59789: // Oracle Ablutions { if (!unitTarget) + { return; + } switch (unitTarget->GetPowerType()) { @@ -8971,7 +9855,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64323: // Book of Glyph Mastery { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } // learn random explicit discovery recipe (if any) if (uint32 discoveredSpell = GetExplicitDiscoverySpell(m_spellInfo->Id, (Player*)m_caster)) @@ -8982,7 +9868,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62042: // Stormhammer { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, 62470, true); unitTarget->CastSpell(m_caster, 64909, true); @@ -8992,7 +9880,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62922: // Unstable Energy (h) { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); return; @@ -9000,7 +9890,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62262: // Brightleaf Flux { if (!unitTarget) + { return; + } if (unitTarget->HasAura(62239)) unitTarget->RemoveAurasDueToSpell(62239); @@ -9019,7 +9911,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 63601: // Strengthened Iron Roots (h) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || !((Creature*)unitTarget)->IsTemporarySummon()) + { return; + } uint32 ownerAura = 0; @@ -9038,7 +9932,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62381: // Chill { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(62373); unitTarget->CastSpell(unitTarget, 62382, true); @@ -9047,7 +9943,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62488: // Activate Construct { if (!unitTarget || !unitTarget->HasAura(62468)) + { return; + } unitTarget->RemoveAurasDueToSpell(62468); unitTarget->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); @@ -9062,7 +9960,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62521: // Attuned to Nature 25 Dose Reduction { if (!unitTarget) + { return; + } uint32 numStacks = 0; @@ -9080,7 +9980,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62552: // Defend { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 63119, true); return; @@ -9089,7 +9991,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 68282: // Charge (player) { if (!unitTarget) + { return; + } unitTarget->RemoveAuraHolderFromStack(62719); unitTarget->RemoveAuraHolderFromStack(64100); @@ -9108,7 +10012,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 62707: // Grab { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, 62708, true); return; @@ -9118,11 +10024,15 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 68504: // Shield-Breaker { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } Unit* owner = unitTarget->GetCharmerOrOwnerPlayerOrPlayerItself(); if (!owner) + { return; + } owner->RemoveAuraHolderFromStack(62552); owner->RemoveAuraHolderFromStack(63119); @@ -9145,7 +10055,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 63027: // Proximity Mines { if (!unitTarget) + { return; + } for (uint8 i = 0; i < 15; ++i) unitTarget->CastSpell(unitTarget, 65347, true); @@ -9155,10 +10067,14 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64192: // Block! { if (!unitTarget) + { return; + } if (unitTarget->HasAura(63132)) + { return; + } else if (unitTarget->HasAura(63131)) { unitTarget->RemoveAurasDueToSpell(63131); @@ -9176,7 +10092,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 63122: // Clear Insane { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); return; @@ -9184,7 +10102,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 63633: // Summon Rubble { if (!unitTarget) + { return; + } for (uint8 i = 0; i < 5; ++i) unitTarget->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); @@ -9193,7 +10113,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 63667: // Napalm Shell { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, m_caster->GetMap()->IsRegularDifficulty() ? 63666 : 65026, true); return; @@ -9201,7 +10123,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 63681: // Rocket Strike { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } m_caster->CastSpell(unitTarget, 63036, true); return; @@ -9210,7 +10134,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 65301: // Psychosis (h) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->HasAura(effect->CalculateSimpleValue())) + { return; + } unitTarget->RemoveAuraHolderFromStack(63050, 12); return; @@ -9220,7 +10146,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64168: // Lunatic Gaze (Skull) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint8 removedAmount = 0; switch (m_spellInfo->Id) @@ -9236,7 +10164,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 63993: // Cancel Illusion Room Aura { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, 63992, true); unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); @@ -9245,7 +10175,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64059: // Induce Madness { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || !unitTarget->HasAura(effect->CalculateSimpleValue())) + { return; + } unitTarget->RemoveAurasDueToSpell(63050); return; @@ -9253,7 +10185,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64069: // Match Health (Rank 1) { if (!unitTarget) + { return; + } unitTarget->SetHealthPercent(m_caster->GetHealthPercent()); return; @@ -9261,7 +10195,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64123: // Lunge { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(unitTarget, unitTarget->GetMap()->IsRegularDifficulty() ? 64125 : 64126, true); return; @@ -9269,7 +10205,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64131: // Lunge { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -9277,7 +10215,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64456: // Feral Essence Application Removal { if (!unitTarget) + { return; + } uint32 spellId = effect->CalculateSimpleValue(); unitTarget->RemoveAuraHolderFromStack(spellId); @@ -9286,7 +10226,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64466: // Empowering Shadows { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -9294,7 +10236,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64467: // Empowering Shadows { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, m_caster->GetMap()->IsRegularDifficulty() ? 64468 : 64486, true); return; @@ -9302,7 +10246,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64475: // Strength of the Creator { if (!unitTarget) + { return; + } unitTarget->RemoveAuraHolderFromStack(64473); return; @@ -9310,7 +10256,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64623: // Frost Bomb { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 64627, true); return; @@ -9318,7 +10266,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64767: // Stormhammer { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (Creature* target = (Creature*)unitTarget) { @@ -9333,7 +10283,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 64841: // Rapid Burst { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, 63382, false); return; @@ -9341,7 +10293,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 65238: // Shattered Illusion { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); return; @@ -9349,7 +10303,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 66477: // Bountiful Feast { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 65422, true); unitTarget->CastSpell(unitTarget, 66622, true); @@ -9358,7 +10314,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 66545: // Summon Memory { if (!unitTarget) + { return; + } uint32 memorySpells[25] = {66543, 66691, 66692, 66694, 66695, 66696, 66697, 66698, 66699, 66700, 66701, 66702, 66703, 66704, 66705, 66706, 66707, 66708, 66709, 66710, 66711, 66712, 66713, 66714, 66715 @@ -9371,7 +10329,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) { // maybe this check should be done sooner? if (!m_caster->IsInWater()) + { return; + } uint32 spellId = 0; @@ -9396,7 +10356,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 66744: // Make Player Destroy Totems { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Totem of the Earthen Ring does not really require or take reagents. // Expecting RewardQuest() to already destroy them or we need additional code here to destroy. @@ -9406,7 +10368,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 67009: // Nether Power (ToC25: Lord Jaraxxus) { if (!unitTarget) + { return; + } for (uint8 i = 0; i < 11; ++i) unitTarget->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); @@ -9416,7 +10380,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 67547: // Clear Val'kyr Essence { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(67590); unitTarget->RemoveAurasDueToSpell(65684); @@ -9426,7 +10392,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 67590: // Powering Up { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (SpellAuraHolder* playerAura = unitTarget->GetSpellAuraHolder(m_spellInfo->Id)) { @@ -9445,7 +10413,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 67751: // Ghoul Explode { if (!unitTarget) + { return; + } unitTarget->InterruptNonMeleeSpells(false); unitTarget->CastSpell(unitTarget, 67729, false); @@ -9454,7 +10424,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 68084: // Clear Val'kyr Touch of Light/Dark { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(66001); unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); @@ -9473,7 +10445,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69048: // Mirrored Soul { if (!unitTarget) + { return; + } // This is extremely strange! // The spell should send SMSG_CHANNEL_START, SMSG_SPELL_START @@ -9484,7 +10458,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69051: // Mirrored Soul { if (!unitTarget) + { return; + } // Actually this spell should be sent with SMSG_SPELL_START unitTarget->CastSpell(m_caster, 69023, true); @@ -9493,7 +10469,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69057: // Bone Spike Graveyard { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->HasAura(m_spellInfo->CalculateSimpleValue(EFFECT_INDEX_1))) + { return; + } unitTarget->CastSpell(unitTarget, 69062, true); return; @@ -9501,7 +10479,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69140: // Coldflame (random target selection) { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -9509,7 +10489,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69147: // Coldflame { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -9517,7 +10499,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69195: // Pungent Blight { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); return; @@ -9525,7 +10509,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69298: // Cancel Resistant to Blight { if (!unitTarget) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); return; @@ -9533,7 +10519,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69377: // Fortitude { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 72590, true); return; @@ -9541,7 +10529,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69378: // Blessing of Forgotten Kings { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 72586, true); return; @@ -9549,7 +10539,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69381: // Gift of the Wild { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, 72588, true); return; @@ -9557,7 +10549,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 69828: // Halls of Reflection Clone { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -9565,7 +10559,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 71806: // Glittering Sparks { if (!unitTarget) + { return; + } m_caster->CastSpell(unitTarget, effect->CalculateSimpleValue(), true); return; @@ -9580,7 +10576,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 72195: // Blood Link { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } uint32 auraStacks = 0; if (SpellAuraHolder* playerAura = unitTarget->GetSpellAuraHolder(72371)) @@ -9588,7 +10586,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) int32 missingStacks = unitTarget->GetPower(unitTarget->GetPowerType()) - auraStacks; if (missingStacks <= 0) + { return; + } unitTarget->CastCustomSpell(unitTarget, 72371, &missingStacks, &missingStacks, NULL, true); return; @@ -9596,7 +10596,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 72219: // Gastric Bloat { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 auraStacks = 0; if (SpellAuraHolder* playerAura = unitTarget->GetSpellAuraHolder(m_spellInfo->Id)) @@ -9610,7 +10612,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 72257: // Remove Marks of the Fallen Champion { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } unitTarget->RemoveAurasDueToSpell(effect->CalculateSimpleValue()); return; @@ -9618,7 +10622,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 72409: // Rune of Blood { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -9626,7 +10632,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 72705: // Coldflame (summon around the caster) { if (!unitTarget) + { return; + } // Cast summon spells 72701, 72702, 72703, 72704 for (uint32 triggeredSpell = effect->CalculateSimpleValue(); triggeredSpell < m_spellInfo->Id; ++triggeredSpell) @@ -9637,7 +10645,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 72900: // Start Halls of Reflection Quest AE { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (Player* target = (Player*)unitTarget) target->CastSpell(target, target->GetTeam() == ALLIANCE ? 71351 : 71542, true); @@ -9646,7 +10656,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 73142: // Bone Spike Graveyard (during storm) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER || unitTarget->HasAura(69065)) + { return; + } uint32 spellId = 0; switch (urand(0, 2)) @@ -9662,7 +10674,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 74455: // Conflagration { if (!unitTarget) + { return; + } unitTarget->CastSpell(m_caster, effect->CalculateSimpleValue(), true); return; @@ -9684,7 +10698,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 47878: { if (!unitTarget) + { return; + } uint32 itemtype; uint32 rank = 0; @@ -9742,7 +10758,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 47193: // Demonic Empowerment { if (!unitTarget) + { return; + } uint32 entry = unitTarget->GetEntry(); uint32 spellID; @@ -9792,7 +10810,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 47948: // Pain and Suffering { if (!unitTarget) + { return; + } // Refresh Shadow Word: Pain on target Unit::SpellAuraHolderMap& auras = unitTarget->GetSpellAuraHolderMap(); @@ -9822,7 +10842,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 53209: // Chimera Shot { if (!unitTarget) + { return; + } uint32 spellId = 0; int32 basePoint = 0; @@ -9897,7 +10919,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 53412: // Invigoration (pet triggered script, master targeted) { if (!unitTarget) + { return; + } Unit::AuraList const& auras = unitTarget->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = auras.begin(); i != auras.end(); ++i) @@ -9917,7 +10941,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 53271: // Master's Call { if (!unitTarget) + { return; + } // script effect have in value, but this outdated removed part unitTarget->CastSpell(unitTarget, 62305, true); @@ -9934,7 +10960,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) if (m_spellInfo->GetCategory() == SPELLCATEGORY_JUDGEMENT) { if (!unitTarget || !unitTarget->IsAlive()) + { return; + } uint32 spellId1 = 0; uint32 spellId2 = 0; @@ -9995,7 +11023,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 28698: // Dreaming Glory { if (!unitTarget) + { return; + } unitTarget->CastSpell(unitTarget, 28694, true); break; @@ -10003,11 +11033,15 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 28702: // Netherbloom { if (!unitTarget) + { return; + } // 25% chance of casting a random buff if (roll_chance_i(75)) + { return; + } // triggered spells are 28703 to 28707 // Note: some sources say, that there was the possibility of @@ -10017,7 +11051,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) // don't overwrite an existing aura for (uint8 i = 0; i < 5; ++i) if (unitTarget->HasAura(spellid + i, EFFECT_INDEX_0)) + { return; + } unitTarget->CastSpell(unitTarget, spellid + urand(0, 4), true); break; @@ -10025,11 +11061,15 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 28720: // Nightmare Vine { if (!unitTarget) + { return; + } // 25% chance of casting Nightmare Pollen if (roll_chance_i(75)) + { return; + } unitTarget->CastSpell(unitTarget, 28721, true); break; @@ -10044,15 +11084,21 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) case 50842: // Pestilence { if (!unitTarget) + { return; + } Unit* mainTarget = m_targets.getUnitTarget(); if (!mainTarget) + { return; + } // do only refresh diseases on main target if caster has Glyph of Disease if (mainTarget == unitTarget && !m_caster->HasAura(63334)) + { return; + } // Blood Plague if (mainTarget->HasAura(55078)) @@ -10071,19 +11117,25 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) // normal DB scripted effect if (!unitTarget) + { return; + } // Script based implementation. Must be used only for not good for implementation in core spell effects // So called only for not processed cases if (unitTarget->GetTypeId() == TYPEID_UNIT) { if (sScriptMgr.OnEffectScriptEffect(m_caster, m_spellInfo->Id, SpellEffectIndex(effect->EffectIndex), (Creature*)unitTarget, m_originalCasterGUID)) + { return; + } } // Previous effect might have started script if (!ScriptMgr::CanSpellEffectStartDBScript(m_spellInfo, SpellEffectIndex(effect->EffectIndex))) + { return; + } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell ScriptStart spellid %u in EffectScriptEffect", m_spellInfo->Id); m_caster->GetMap()->ScriptsStart(DBS_ON_SPELL, m_spellInfo->Id, m_caster, unitTarget); @@ -10092,7 +11144,9 @@ void Spell::EffectScriptEffect(SpellEffectEntry const* effect) void Spell::EffectSanctuary(SpellEffectEntry const* /*effect*/) { if (!unitTarget) + { return; + } // unitTarget->CombatStop(); unitTarget->CombatStop(); @@ -10106,13 +11160,19 @@ void Spell::EffectSanctuary(SpellEffectEntry const* /*effect*/) void Spell::EffectAddComboPoints(SpellEffectEntry const* effect /*effect*/) { if (!unitTarget) + { return; + } if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } if (damage <= 0) + { return; + } ((Player*)m_caster)->AddComboPoints(unitTarget, damage); } @@ -10120,14 +11180,18 @@ void Spell::EffectAddComboPoints(SpellEffectEntry const* effect /*effect*/) void Spell::EffectDuel(SpellEffectEntry const* effect) { if (!m_caster || !unitTarget || m_caster->GetTypeId() != TYPEID_PLAYER || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* caster = (Player*)m_caster; Player* target = (Player*)unitTarget; // caster or target already have requested duel if (caster->duel || target->duel || !target->GetSocial() || target->GetSocial()->HasIgnore(caster->GetObjectGuid())) + { return; + } // Players can only fight a duel with each other outside (=not inside dungeons and not in capital cities) AreaTableEntry const* casterAreaEntry = GetAreaEntryByAreaID(caster->GetAreaId()); @@ -10204,10 +11268,14 @@ void Spell::EffectDuel(SpellEffectEntry const* effect) void Spell::EffectStuck(SpellEffectEntry const* effect /*effect*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!sWorld.getConfig(CONFIG_BOOL_CAST_UNSTUCK)) + { return; + } Player* pTarget = (Player*)unitTarget; @@ -10215,7 +11283,9 @@ void Spell::EffectStuck(SpellEffectEntry const* effect /*effect*/) DETAIL_LOG("Player %s (guid %u) used auto-unstuck future at map %u (%f, %f, %f)", pTarget->GetName(), pTarget->GetGUIDLow(), m_caster->GetMapId(), m_caster->GetPositionX(), pTarget->GetPositionY(), pTarget->GetPositionZ()); if (pTarget->IsTaxiFlying()) + { return; + } // homebind location is loaded always pTarget->TeleportToHomebind(unitTarget == m_caster ? TELE_TO_SPELL : 0); @@ -10223,7 +11293,9 @@ void Spell::EffectStuck(SpellEffectEntry const* effect /*effect*/) // Stuck spell trigger Hearthstone cooldown SpellEntry const* spellInfo = sSpellStore.LookupEntry(8690); if (!spellInfo) + { return; + } Spell spell(pTarget, spellInfo, true); spell.SendSpellCooldown(); } @@ -10231,11 +11303,15 @@ void Spell::EffectStuck(SpellEffectEntry const* effect /*effect*/) void Spell::EffectSummonPlayer(SpellEffectEntry const* /*effect*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // Evil Twin (ignore player summon, but hide this for summoner) if (unitTarget->GetDummyAura(23445)) + { return; + } float x, y, z; m_caster->GetClosePoint(x, y, z, unitTarget->GetObjectBoundingRadius()); @@ -10263,7 +11339,9 @@ static ScriptInfo generateActivateCommand() void Spell::EffectActivateObject(SpellEffectEntry const* effect) { if (!gameObjTarget) + { return; + } uint32 misc_value = uint32(effect->EffectMiscValue); @@ -10409,7 +11487,9 @@ void Spell::EffectActivateObject(SpellEffectEntry const* effect) void Spell::EffectApplyGlyph(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)m_caster; @@ -10465,17 +11545,23 @@ void Spell::EffectEnchantHeldItem(SpellEffectEntry const* effect) { // this is only item spell effect applied to main-hand weapon of target player (players in area) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* item_owner = (Player*)unitTarget; Item* item = item_owner->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); if (!item) + { return; + } // must be equipped if (!item ->IsEquipped()) + { return; + } if (effect->EffectMiscValue) { @@ -10488,14 +11574,18 @@ void Spell::EffectEnchantHeldItem(SpellEffectEntry const* effect) SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) + { return; + } // Always go to temp enchantment slot EnchantmentSlot slot = TEMP_ENCHANTMENT_SLOT; // Enchantment will not be applied if a different one already exists if (item->GetEnchantmentId(slot) && item->GetEnchantmentId(slot) != enchant_id) + { return; + } // Apply the temporary enchantment item->SetEnchantment(slot, enchant_id, duration * IN_MILLISECONDS, 0, m_caster->GetObjectGuid()); @@ -10506,11 +11596,15 @@ void Spell::EffectEnchantHeldItem(SpellEffectEntry const* effect) void Spell::EffectDisEnchant(SpellEffectEntry const* /*effect*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* p_caster = (Player*)m_caster; if (!itemTarget || !itemTarget->GetProto()->DisenchantID) + { return; + } p_caster->UpdateCraftSkill(m_spellInfo->Id); @@ -10522,7 +11616,9 @@ void Spell::EffectDisEnchant(SpellEffectEntry const* /*effect*/) void Spell::EffectInebriate(SpellEffectEntry const* /*effect*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)unitTarget; @@ -10539,24 +11635,34 @@ void Spell::EffectInebriate(SpellEffectEntry const* /*effect*/) void Spell::EffectFeedPet(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* _player = (Player*)m_caster; Item* foodItem = m_targets.getItemTarget(); if (!foodItem) + { return; + } Pet* pet = _player->GetPet(); if (!pet) + { return; + } if (!pet->IsAlive()) + { return; + } int32 benefit = pet->GetCurrentFoodBenefitLevel(foodItem->GetProto()->ItemLevel); if (benefit <= 0) + { return; + } uint32 count = 1; _player->DestroyItemCount(foodItem, count, true); @@ -10568,13 +11674,17 @@ void Spell::EffectFeedPet(SpellEffectEntry const* effect) void Spell::EffectDismissPet(SpellEffectEntry const* /*effect*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Pet* pet = m_caster->GetPet(); // not let dismiss dead pet if (!pet || !pet->IsAlive()) + { return; + } pet->Unsummon(PET_SAVE_NOT_IN_SLOT, m_caster); } @@ -10584,7 +11694,9 @@ void Spell::EffectSummonObject(SpellEffectEntry const* effect) uint32 go_id = effect->EffectMiscValue; uint8 slot = effect->EffectMiscValueB; if (slot >= MAX_OBJECT_SLOT) + { return; + } if (ObjectGuid guid = m_caster->m_ObjectSlotGuid[slot]) { @@ -10631,10 +11743,14 @@ void Spell::EffectSummonObject(SpellEffectEntry const* effect) void Spell::EffectResurrect(SpellEffectEntry const* /*effect*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (unitTarget->IsAlive() || !unitTarget->IsInWorld()) + { return; + } switch (m_spellInfo->Id) { @@ -10666,7 +11782,9 @@ void Spell::EffectResurrect(SpellEffectEntry const* /*effect*/) Player* pTarget = ((Player*)unitTarget); if (pTarget->isRessurectRequested()) // already have one active request + { return; + } uint32 health = pTarget->GetMaxHealth() * damage / 100; uint32 mana = pTarget->GetMaxPower(POWER_MANA) * damage / 100; @@ -10678,10 +11796,14 @@ void Spell::EffectResurrect(SpellEffectEntry const* /*effect*/) void Spell::EffectAddExtraAttacks(SpellEffectEntry const* /*effect*/) { if (!unitTarget || !unitTarget->IsAlive()) + { return; + } if (unitTarget->m_extraAttacks) + { return; + } unitTarget->m_extraAttacks = damage; } @@ -10858,7 +11980,9 @@ void Spell::EffectLeapForward(SpellEffectEntry const* effect) void Spell::EffectLeapBack(SpellEffectEntry const* effect) { if (unitTarget->IsTaxiFlying()) + { return; + } m_caster->KnockBackFrom(unitTarget, float(effect->EffectMiscValue) / 10, float(damage) / 10); } @@ -10866,7 +11990,9 @@ void Spell::EffectLeapBack(SpellEffectEntry const* effect) void Spell::EffectReputation(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* _player = (Player*)unitTarget; @@ -10876,7 +12002,9 @@ void Spell::EffectReputation(SpellEffectEntry const* effect) FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); if (!factionEntry) + { return; + } rep_change = _player->CalculateReputationGain(REPUTATION_SOURCE_SPELL, rep_change, faction_id); @@ -10886,7 +12014,9 @@ void Spell::EffectReputation(SpellEffectEntry const* effect) void Spell::EffectQuestComplete(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } // A few spells has additional value from basepoints, check condition here. switch (m_spellInfo->Id) @@ -10894,7 +12024,9 @@ void Spell::EffectQuestComplete(SpellEffectEntry const* effect) case 43458: // Secrets of Nifflevar { if (!unitTarget->HasAura(effect->CalculateSimpleValue())) + { return; + } break; } @@ -10914,11 +12046,17 @@ void Spell::EffectQuestComplete(SpellEffectEntry const* effect) void Spell::EffectSelfResurrect(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->IsAlive()) + { return; + } if (unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!unitTarget->IsInWorld()) + { return; + } uint32 health = 0; uint32 mana = 0; @@ -10951,9 +12089,13 @@ void Spell::EffectSelfResurrect(SpellEffectEntry const* effect) void Spell::EffectSkinning(SpellEffectEntry const* /*effect*/) { if (unitTarget->GetTypeId() != TYPEID_UNIT) + { return; + } if (!m_caster || m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Creature* creature = (Creature*) unitTarget; int32 targetLevel = creature->getLevel(); @@ -10974,7 +12116,9 @@ void Spell::EffectSkinning(SpellEffectEntry const* /*effect*/) void Spell::EffectCharge(SpellEffectEntry const* /*effect*/) { if (!unitTarget) + { return; + } // TODO: research more ContactPoint/attack distance. // 3.666666 instead of ATTACK_DISTANCE(5.0f) in below seem to give more accurate result. @@ -11005,7 +12149,9 @@ void Spell::EffectCharge2(SpellEffectEntry const* /*effect*/) else if (unitTarget && unitTarget != m_caster) unitTarget->GetContactPoint(m_caster, x, y, z, 3.666666f); else + { return; + } // Only send MOVEMENTFLAG_WALK_MODE, client has strange issues with other move flags m_caster->MonsterMoveWithSpeed(x, y, z, 24.f, true, true); @@ -11018,7 +12164,9 @@ void Spell::EffectCharge2(SpellEffectEntry const* /*effect*/) void Spell::EffectKnockBack(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } unitTarget->KnockBackFrom(m_caster, float(effect->EffectMiscValue) / 10, float(damage) / 10); } @@ -11026,7 +12174,9 @@ void Spell::EffectKnockBack(SpellEffectEntry const* effect) void Spell::EffectSendTaxi(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)unitTarget)->ActivateTaxiPathTo(effect->EffectMiscValue, m_spellInfo->Id); } @@ -11034,7 +12184,9 @@ void Spell::EffectSendTaxi(SpellEffectEntry const* effect) void Spell::EffectPlayerPull(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } float x, y, z; m_caster->GetPosition(x, y, z); @@ -11053,7 +12205,9 @@ void Spell::EffectPlayerPull(SpellEffectEntry const* effect) void Spell::EffectDispelMechanic(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } uint32 mechanic = effect->EffectMiscValue; @@ -11077,13 +12231,19 @@ void Spell::EffectDispelMechanic(SpellEffectEntry const* effect) void Spell::EffectSummonDeadPet(SpellEffectEntry const* /*effect*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* _player = (Player*)m_caster; Pet* pet = _player->GetPet(); if (!pet) + { return; + } if (pet->IsAlive()) + { return; + } if (_player->GetDistance(pet) >= 2.0f) { @@ -11107,7 +12267,9 @@ void Spell::EffectSummonDeadPet(SpellEffectEntry const* /*effect*/) void Spell::EffectSummonAllTotems(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } int32 start_button = ACTION_BUTTON_SHAMAN_TOTEMS_BAR + effect->EffectMiscValue; int32 amount_buttons = effect->EffectMiscValueB; @@ -11146,7 +12308,9 @@ void Spell::EffectDestroyAllTotems(SpellEffectEntry const* /*effect*/) void Spell::EffectBreakPlayerTargeting (SpellEffectEntry const* /*effect*/) { if (!unitTarget) + { return; + } WorldPacket data(SMSG_CLEAR_TARGET, 8); data << unitTarget->GetObjectGuid(); @@ -11156,7 +12320,9 @@ void Spell::EffectBreakPlayerTargeting (SpellEffectEntry const* /*effect*/) void Spell::EffectDurabilityDamage(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } int32 slot = effect->EffectMiscValue; @@ -11170,7 +12336,9 @@ void Spell::EffectDurabilityDamage(SpellEffectEntry const* effect) // invalid slot value if (slot >= INVENTORY_SLOT_BAG_END) + { return; + } if (Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) ((Player*)unitTarget)->DurabilityPointsLoss(item, damage); @@ -11179,7 +12347,9 @@ void Spell::EffectDurabilityDamage(SpellEffectEntry const* effect) void Spell::EffectDurabilityDamagePCT(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } int32 slot = effect->EffectMiscValue; @@ -11193,10 +12363,14 @@ void Spell::EffectDurabilityDamagePCT(SpellEffectEntry const* effect) // invalid slot value if (slot >= INVENTORY_SLOT_BAG_END) + { return; + } if (damage <= 0) + { return; + } if (Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) ((Player*)unitTarget)->DurabilityLoss(item, double(damage) / 100.0f); @@ -11205,7 +12379,9 @@ void Spell::EffectDurabilityDamagePCT(SpellEffectEntry const* effect) void Spell::EffectModifyThreatPercent(SpellEffectEntry const* /*effect*/) { if (!unitTarget) + { return; + } unitTarget->GetThreatManager().modifyThreatPercent(m_caster, damage); } @@ -11364,7 +12540,9 @@ void Spell::EffectTransmitted(SpellEffectEntry const* effect) void Spell::EffectProspecting(SpellEffectEntry const* /*effect*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER || !itemTarget) + { return; + } Player* p_caster = (Player*)m_caster; @@ -11381,7 +12559,9 @@ void Spell::EffectProspecting(SpellEffectEntry const* /*effect*/) void Spell::EffectMilling(SpellEffectEntry const* /*effect*/) { if (m_caster->GetTypeId() != TYPEID_PLAYER || !itemTarget) + { return; + } Player* p_caster = (Player*)m_caster; @@ -11404,13 +12584,21 @@ void Spell::EffectSpiritHeal(SpellEffectEntry const* /*effect*/) { // TODO player can't see the heal-animation - he should respawn some ticks later if (!unitTarget || unitTarget->IsAlive()) + { return; + } if (unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (!unitTarget->IsInWorld()) + { return; + } if (m_spellInfo->Id == 22012 && !unitTarget->HasAura(2584)) + { return; + } ((Player*)unitTarget)->ResurrectPlayer(1.0f); ((Player*)unitTarget)->SpawnCorpseBones(); @@ -11421,7 +12609,9 @@ void Spell::EffectSkinPlayerCorpse(SpellEffectEntry const* /*effect*/) { DEBUG_LOG("Effect: SkinPlayerCorpse"); if ((m_caster->GetTypeId() != TYPEID_PLAYER) || (unitTarget->GetTypeId() != TYPEID_PLAYER) || (unitTarget->IsAlive())) + { return; + } ((Player*)unitTarget)->RemovedInsignia((Player*)m_caster); } @@ -11431,7 +12621,9 @@ void Spell::EffectStealBeneficialBuff(SpellEffectEntry const* effect) DEBUG_LOG("Effect: StealBeneficialBuff"); if (!unitTarget || unitTarget == m_caster) // can't steal from self + { return; + } typedef std::vector StealList; StealList steal_list; @@ -11503,7 +12695,9 @@ void Spell::EffectWMODamage(SpellEffectEntry const* effect) DEBUG_LOG("Effect: WMODamage"); if (!gameObjTarget) + { return; + } if (gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { @@ -11512,11 +12706,15 @@ void Spell::EffectWMODamage(SpellEffectEntry const* effect) } if (!gameObjTarget->GetHealth()) + { return; + } Unit* caster = GetAffectiveCaster(); if (!caster) + { return; + } DEBUG_LOG("Spell::EffectWMODamage, spell Id %u, go entry %u, damage %u", m_spellInfo->Id, gameObjTarget->GetEntry(), uint32(damage)); gameObjTarget->DealGameObjectDamage(uint32(damage), m_spellInfo->Id, caster); @@ -11527,7 +12725,9 @@ void Spell::EffectWMORepair(SpellEffectEntry const* effect) DEBUG_LOG("Effect: WMORepair"); if (!gameObjTarget) + { return; + } if (gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { @@ -11537,7 +12737,9 @@ void Spell::EffectWMORepair(SpellEffectEntry const* effect) Unit* caster = GetAffectiveCaster(); if (!caster) + { return; + } DEBUG_LOG("Spell::EffectWMORepair, spell Id %u, go entry %u", m_spellInfo->Id, gameObjTarget->GetEntry()); gameObjTarget->RebuildGameObject(m_spellInfo->Id, caster); @@ -11548,7 +12750,9 @@ void Spell::EffectWMOChange(SpellEffectEntry const* effect) DEBUG_LOG("Effect: WMOChange"); if (!gameObjTarget) + { return; + } if (gameObjTarget->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { @@ -11560,7 +12764,9 @@ void Spell::EffectWMOChange(SpellEffectEntry const* effect) Unit* caster = GetAffectiveCaster(); if (!caster) + { return; + } switch (effect->EffectMiscValue) { @@ -11585,7 +12791,9 @@ void Spell::EffectWMOChange(SpellEffectEntry const* effect) void Spell::EffectKillCreditPersonal(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)unitTarget)->KilledMonsterCredit(effect->EffectMiscValue); } @@ -11593,7 +12801,9 @@ void Spell::EffectKillCreditPersonal(SpellEffectEntry const* effect) void Spell::EffectKillCreditGroup(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)unitTarget)->RewardPlayerAndGroupAtEvent(effect->EffectMiscValue, unitTarget); } @@ -11601,7 +12811,9 @@ void Spell::EffectKillCreditGroup(SpellEffectEntry const* effect) void Spell::EffectQuestFail(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)unitTarget)->FailQuest(effect->EffectMiscValue); } @@ -11609,12 +12821,16 @@ void Spell::EffectQuestFail(SpellEffectEntry const* effect) void Spell::EffectActivateRune(SpellEffectEntry const* effect) { if (m_caster->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* plr = (Player*)m_caster; if (plr->getClass() != CLASS_DEATH_KNIGHT) + { return; + } int32 count = damage; // max amount of reset runes @@ -11647,7 +12863,9 @@ void Spell::EffectRenamePet(SpellEffectEntry const* /*effect*/) void Spell::EffectPlaySound(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 soundId = effect->EffectMiscValue; if (!sSoundEntriesStore.LookupEntry(soundId)) @@ -11662,7 +12880,9 @@ void Spell::EffectPlaySound(SpellEffectEntry const* effect) void Spell::EffectPlayMusic(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 soundId = effect->EffectMiscValue; if (!sSoundEntriesStore.LookupEntry(soundId)) @@ -11677,7 +12897,9 @@ void Spell::EffectPlayMusic(SpellEffectEntry const* effect) void Spell::EffectSpecCount(SpellEffectEntry const* /*effect*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } ((Player*)unitTarget)->UpdateSpecCount(damage); } @@ -11685,7 +12907,9 @@ void Spell::EffectSpecCount(SpellEffectEntry const* /*effect*/) void Spell::EffectActivateSpec(SpellEffectEntry const* /*effect*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } uint32 spec = damage - 1; @@ -11695,7 +12919,9 @@ void Spell::EffectActivateSpec(SpellEffectEntry const* /*effect*/) void Spell::EffectBind(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)unitTarget; @@ -11749,13 +12975,17 @@ void Spell::EffectBind(SpellEffectEntry const* effect) void Spell::EffectRestoreItemCharges(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)unitTarget; ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(effect->EffectItemType); if (!itemProto) + { return; + } // In case item from limited category recharge any from category, is this valid checked early in spell checks Item* item; @@ -11765,7 +12995,9 @@ void Spell::EffectRestoreItemCharges(SpellEffectEntry const* effect) item = player->GetItemByEntry(effect->EffectItemType); if (!item) + { return; + } item->RestoreCharges(); } @@ -11773,7 +13005,9 @@ void Spell::EffectRestoreItemCharges(SpellEffectEntry const* effect) void Spell::EffectRedirectThreat(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } if (m_spellInfo->Id == 59665) // Vigilance if (Aura* glyph = unitTarget->GetDummyAura(63326)) // Glyph of Vigilance @@ -11785,13 +13019,17 @@ void Spell::EffectRedirectThreat(SpellEffectEntry const* effect) void Spell::EffectTeachTaxiNode(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } Player* player = (Player*)unitTarget; uint32 taxiNodeId = effect->EffectMiscValue; if (!sTaxiNodesStore.LookupEntry(taxiNodeId)) + { return; + } if (player->m_taxi.SetTaximaskNode(taxiNodeId)) { @@ -11808,7 +13046,9 @@ void Spell::EffectTeachTaxiNode(SpellEffectEntry const* effect) void Spell::EffectQuestOffer(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + { return; + } if (Quest const* quest = sObjectMgr.GetQuestTemplate(effect->EffectMiscValue)) { @@ -11822,7 +13062,9 @@ void Spell::EffectQuestOffer(SpellEffectEntry const* effect) void Spell::EffectCancelAura(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } uint32 spellId = effect->EffectTriggerSpell; @@ -11838,7 +13080,9 @@ void Spell::EffectCancelAura(SpellEffectEntry const* effect) void Spell::EffectKnockBackFromPosition(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } float x, y, z; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) @@ -11855,7 +13099,9 @@ void Spell::EffectKnockBackFromPosition(SpellEffectEntry const* effect) void Spell::EffectGravityPull(SpellEffectEntry const* effect) { if (!unitTarget) + { return; + } float x, y, z; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) @@ -11872,7 +13118,9 @@ void Spell::EffectGravityPull(SpellEffectEntry const* effect) void Spell::EffectCreateTamedPet(SpellEffectEntry const* effect) { if (!unitTarget || unitTarget->getClass() != CLASS_HUNTER) + { return; + } uint32 creatureEntry = effect->EffectMiscValue; diff --git a/src/game/WorldHandlers/SpellHandler.cpp b/src/game/WorldHandlers/SpellHandler.cpp index 27b5924ae..1ed62d0a6 100644 --- a/src/game/WorldHandlers/SpellHandler.cpp +++ b/src/game/WorldHandlers/SpellHandler.cpp @@ -213,7 +213,9 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) // ignore for remote control state if (!pUser->IsSelfMover()) + { return; + } Item* pItem = pUser->GetItemByPos(bagIndex, slot); if (!pItem) @@ -291,14 +293,20 @@ void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recv_data) // ignore for remote control state if (!_player->IsSelfMover()) + { return; + } GameObject* obj = _player->GetMap()->GetGameObject(guid); if (!obj) + { return; + } if (!obj->IsWithinDistInMap(_player, obj->GetInteractionDistance())) + { return; + } // Additional check preventing exploits (ie loot despawned chests) if (!obj->isSpawned()) @@ -333,14 +341,20 @@ void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) // ignore for remote control state if (!_player->IsSelfMover()) + { return; + } GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid); if (!go) + { return; + } if (!go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) + { return; + } _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, go->GetEntry()); } @@ -446,11 +460,15 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) // ignore for remote control state (for player case) Unit* mover = _player->GetMover(); if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER) + { return; + } // FIXME: hack, ignore unexpected client cancel Deadly Throw cast if (spellId == 26679) + { return; + } if (mover->IsNonMeleeSpellCasted(false)) mover->InterruptNonMeleeSpells(false, spellId); @@ -463,13 +481,19 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) + { return; + } if (spellInfo->HasAttribute(SPELL_ATTR_CANT_CANCEL)) + { return; + } if (IsPassiveSpell(spellInfo)) + { return; + } if (!IsPositiveSpell(spellId)) { @@ -491,10 +515,14 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) // this also include case when aura not found if (!allow) + { return; + } } else + { return; + } } // channeled spell case (it currently casted then) @@ -510,7 +538,9 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) // not own area auras can't be cancelled (note: maybe need to check for aura on holder and not general on spell) if (holder && holder->GetCasterGuid() != _player->GetObjectGuid() && HasAreaAuraEffect(holder->GetSpellProto())) + { return; + } // non channeled case _player->RemoveAurasDueToSpellByCancel(spellId); @@ -526,7 +556,9 @@ void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket) // ignore for remote control state if (!_player->IsSelfMover()) + { return; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) @@ -579,7 +611,9 @@ void WorldSession::HandleCancelChanneling(WorldPacket& recv_data) // ignore for remote control state (for player case) Unit* mover = _player->GetMover(); if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER) + { return; + } mover->InterruptSpell(CURRENT_CHANNELED_SPELL); } @@ -592,10 +626,14 @@ void WorldSession::HandleTotemDestroyed(WorldPacket& recvPacket) // ignore for remote control state if (!_player->IsSelfMover()) + { return; + } if (int(slotId) >= MAX_TOTEM_SLOT) + { return; + } if (Totem* totem = GetPlayer()->GetTotem(TotemSlot(slotId))) totem->UnSummon(); @@ -606,7 +644,9 @@ void WorldSession::HandleSelfResOpcode(WorldPacket& /*recv_data*/) DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: CMSG_SELF_RES"); // empty opcode if (_player->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION)) + { return; + } if (_player->GetUInt32Value(PLAYER_SELF_RES_SPELL)) { @@ -625,11 +665,15 @@ void WorldSession::HandleSpellClick(WorldPacket& recv_data) // client prevent click and set different icon at combat state; however combat state is allowed for dungeons if (_player->IsInCombat() && !_player->GetMap()->IsDungeon()) + { return; + } Creature* unit = _player->GetMap()->GetAnyTypeCreature(guid); if (!unit || unit->IsInCombat()) // client prevent click and set different icon at combat state + { return; + } SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(unit->GetEntry()); for (SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) @@ -637,7 +681,9 @@ void WorldSession::HandleSpellClick(WorldPacket& recv_data) if (itr->second.IsFitToRequirements(_player, unit)) { if (sScriptMgr.OnNpcSpellClick(_player, unit, itr->second.spellId)) + { return; + } Unit* caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit; Unit* target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit; @@ -661,12 +707,16 @@ void WorldSession::HandleGetMirrorimageData(WorldPacket& recv_data) Creature* pCreature = _player->GetMap()->GetAnyTypeCreature(guid); if (!pCreature) + { return; + } Unit::AuraList const& images = pCreature->GetAurasByType(SPELL_AURA_MIRROR_IMAGE); if (images.empty()) + { return; + } Unit* pCaster = images.front()->GetCaster(); diff --git a/src/game/WorldHandlers/TaxiHandler.cpp b/src/game/WorldHandlers/TaxiHandler.cpp index 1c5c2b284..7738895b5 100644 --- a/src/game/WorldHandlers/TaxiHandler.cpp +++ b/src/game/WorldHandlers/TaxiHandler.cpp @@ -58,7 +58,9 @@ void WorldSession::SendTaxiStatus(ObjectGuid guid) // not found nearest if (curloc == 0) + { return; + } DEBUG_LOG("WORLD: current location %u ", curloc); @@ -87,7 +89,9 @@ void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket& recv_data) // unknown taxi node case if (SendLearnNewTaxiNode(unit)) + { return; + } // known taxi node case SendTaxiMenu(unit); @@ -99,7 +103,9 @@ void WorldSession::SendTaxiMenu(Creature* unit) uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam()); if (curloc == 0) + { return; + } DEBUG_LOG("WORLD: CMSG_TAXINODE_STATUS_QUERY %u ", curloc); @@ -145,7 +151,9 @@ bool WorldSession::SendLearnNewTaxiNode(Creature* unit) return true; } else + { return false; + } } void WorldSession::SendActivateTaxiReply(ActivateTaxiReply reply) @@ -190,7 +198,9 @@ void WorldSession::HandleActivateTaxiExpressOpcode(WorldPacket& recv_data) } if (nodes.empty()) + { return; + } DEBUG_LOG("WORLD: Received opcode CMSG_ACTIVATETAXIEXPRESS from %d to %d" , nodes.front(), nodes.back()); @@ -210,7 +220,9 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) // we need process only (1) uint32 curDest = GetPlayer()->m_taxi.GetTaxiDestination(); if (!curDest) + { return; + } TaxiNodesEntry const* curDestNode = sTaxiNodesStore.LookupEntry(curDest); diff --git a/src/game/WorldHandlers/TradeHandler.cpp b/src/game/WorldHandlers/TradeHandler.cpp index f749c5aaf..199fc9333 100644 --- a/src/game/WorldHandlers/TradeHandler.cpp +++ b/src/game/WorldHandlers/TradeHandler.cpp @@ -182,7 +182,9 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { Player* trader = _player->GetTrader(); if (!trader) + { return; + } for (int i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i) { @@ -304,13 +306,17 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) TradeData* my_trade = _player->m_trade; if (!my_trade) + { return; + } Player* trader = my_trade->GetTrader(); TradeData* his_trade = trader->m_trade; if (!his_trade) + { return; + } Item* myItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; Item* hisItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; @@ -552,7 +558,9 @@ void WorldSession::HandleUnacceptTradeOpcode(WorldPacket& /*recvPacket*/) { TradeData* my_trade = _player->m_trade; if (!my_trade) + { return; + } my_trade->SetAccepted(false, true); } @@ -561,7 +569,9 @@ void WorldSession::HandleBeginTradeOpcode(WorldPacket& /*recvPacket*/) { TradeData* my_trade = _player->m_trade; if (!my_trade) + { return; + } my_trade->GetTrader()->GetSession()->SendTradeStatus(TRADE_STATUS_OPEN_WINDOW); SendTradeStatus(TRADE_STATUS_OPEN_WINDOW); @@ -570,7 +580,9 @@ void WorldSession::HandleBeginTradeOpcode(WorldPacket& /*recvPacket*/) void WorldSession::SendCancelTrade() { if (m_playerRecentlyLogout) + { return; + } SendTradeStatus(TRADE_STATUS_TRADE_CANCELED); } @@ -589,7 +601,9 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) recvPacket.ReadGuidBytes<7, 4, 3, 5, 1, 2, 6, 0>(otherGuid); if (GetPlayer()->m_trade) + { return; + } if (!GetPlayer()->IsAlive()) { @@ -693,7 +707,9 @@ void WorldSession::HandleSetTradeGoldOpcode(WorldPacket& recvPacket) TradeData* my_trade = _player->GetTradeData(); if (!my_trade) + { return; + } // gold can be incorrect, but this is checked at trade finished. my_trade->SetMoney(gold); @@ -712,7 +728,9 @@ void WorldSession::HandleSetTradeItemOpcode(WorldPacket& recvPacket) TradeData* my_trade = _player->m_trade; if (!my_trade) + { return; + } // invalid slot number if (tradeSlot >= TRADE_SLOT_COUNT) @@ -747,11 +765,15 @@ void WorldSession::HandleClearTradeItemOpcode(WorldPacket& recvPacket) TradeData* my_trade = _player->m_trade; if (!my_trade) + { return; + } // invalid slot number if (tradeSlot >= TRADE_SLOT_COUNT) + { return; + } my_trade->SetItem(TradeSlots(tradeSlot), NULL); } diff --git a/src/game/WorldHandlers/TransportSystem.cpp b/src/game/WorldHandlers/TransportSystem.cpp index 2c591d779..17382ce31 100644 --- a/src/game/WorldHandlers/TransportSystem.cpp +++ b/src/game/WorldHandlers/TransportSystem.cpp @@ -153,7 +153,9 @@ bool TransportBase::HasOnBoard(WorldObject const* passenger) const { // pasenger is boarded onto this if (passenger->GetTransportInfo()->GetTransport() == m_owner) + { return true; + } else passenger = passenger->GetTransportInfo()->GetTransport(); } @@ -177,7 +179,9 @@ void TransportBase::UnBoardPassenger(WorldObject* passenger) PassengerMap::iterator itr = m_passengers.find(passenger); if (itr == m_passengers.end()) + { return; + } // Set passengers transportInfo to NULL passenger->SetTransportInfo(NULL); diff --git a/src/game/WorldHandlers/Transports.cpp b/src/game/WorldHandlers/Transports.cpp index ebb2dee65..976a04370 100644 --- a/src/game/WorldHandlers/Transports.cpp +++ b/src/game/WorldHandlers/Transports.cpp @@ -222,7 +222,9 @@ struct keyFrame bool Transport::GenerateWaypoints(uint32 pathid, std::set& mapids) { if (pathid >= sTaxiPathNodesByPath.size()) + { return false; + } TaxiPathNodeList const& path = sTaxiPathNodesByPath[pathid]; @@ -509,7 +511,9 @@ bool Transport::RemovePassenger(Player* passenger) void Transport::Update(uint32 update_diff, uint32 /*p_time*/) { if (m_WayPoints.size() <= 1) + { return; + } m_timer = WorldTimer::getMSTime() % m_period; while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime)) @@ -552,7 +556,9 @@ void Transport::UpdateForMap(Map const* targetMap) { Map::PlayerList const& pl = targetMap->GetPlayers(); if (pl.isEmpty()) + { return; + } if (GetMapId() == targetMap->GetId()) { @@ -567,7 +573,9 @@ void Transport::UpdateForMap(Map const* targetMap) // Prevent sending transport maps in player update object if (packet.ReadUInt16() != itr->getSource()->GetMapId()) + { return; + } itr->getSource()->SendDirectMessage(&packet); } @@ -586,7 +594,9 @@ void Transport::UpdateForMap(Map const* targetMap) { // Prevent sending transport maps in player update object if (out_packet.ReadUInt16() != itr->getSource()->GetMapId()) + { return; + } itr->getSource()->SendDirectMessage(&out_packet); } diff --git a/src/game/WorldHandlers/UnitAuraProcHandler.cpp b/src/game/WorldHandlers/UnitAuraProcHandler.cpp index ebee627c2..0bd04e814 100644 --- a/src/game/WorldHandlers/UnitAuraProcHandler.cpp +++ b/src/game/WorldHandlers/UnitAuraProcHandler.cpp @@ -426,11 +426,15 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, S EventProcFlag = spellProto->GetProcFlags(); // else get from spell proto // Continue if no trigger exist if (!EventProcFlag) + { return false; + } // Check spellProcEvent data requirements if (!SpellMgr::IsSpellProcEventCanTriggeredBy(spellProcEvent, EventProcFlag, procSpell, procFlag, procExtra)) + { return false; + } // In most cases req get honor or XP from kill if (EventProcFlag & PROC_FLAG_KILL && GetTypeId() == TYPEID_PLAYER) @@ -440,12 +444,16 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, S if (holder->GetId() == 32409) allow = true; if (!allow) + { return false; + } } // Aura added by spell can`t trigger from self (prevent drop charges/do triggers) // But except periodic triggers (can triggered from self) if (procSpell && procSpell->Id == spellProto->Id && !(EventProcFlag & PROC_FLAG_ON_TAKE_PERIODIC)) + { return false; + } // Check if current equipment allows aura to proc if (!isVictim && GetTypeId() == TYPEID_PLAYER) @@ -463,14 +471,18 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, S item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); if(!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1<GetProto()->SubClass) & eqItems->EquippedItemSubClassMask)) + { return false; + } } else if(eqItems && eqItems->EquippedItemClass == ITEM_CLASS_ARMOR) { // Check if player is wearing shield Item *item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if(!item || item->IsBroken() || !CanUseEquippedWeapon(OFF_ATTACK) || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<GetProto()->SubClass) & eqItems->EquippedItemSubClassMask)) + { return false; + } } } // Get chance from spell @@ -517,7 +529,9 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura { target = SelectRandomUnfriendlyTarget(pVictim); if (!target) + { return SPELL_AURA_PROC_FAILED; + } basepoints0 = damage; triggered_spell_id = 22482; break; @@ -529,7 +543,9 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura // processed charge only counting case if (!triggered_spell_id) + { return SPELL_AURA_PROC_OK; + } SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); @@ -541,10 +557,14 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura // default case if (!target || (target != this && !target->IsAlive())) + { return SPELL_AURA_PROC_FAILED; + } if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + { return SPELL_AURA_PROC_FAILED; + } if (basepoints0) CastCustomSpell(target, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura); @@ -560,7 +580,9 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 cooldown) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } SpellEntry const* triggeredByAuraSpell = triggeredByAura->GetSpellProto(); @@ -582,7 +604,9 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /* { Unit* caster = triggeredByAura->GetCaster(); if (!caster) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 54648; target = caster; @@ -594,7 +618,9 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /* // processed charge only counting case if (!triggered_spell_id) + { return SPELL_AURA_PROC_OK; + } SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); @@ -606,10 +632,14 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /* // default case if (!target || (target != this && !target->IsAlive())) + { return SPELL_AURA_PROC_FAILED; + } if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + { return SPELL_AURA_PROC_FAILED; + } if (basepoints0) CastCustomSpell(target, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura); @@ -663,11 +693,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // prevent chain of triggered spell from same triggered spell if (procSpell && procSpell->Id == 26654) + { return SPELL_AURA_PROC_FAILED; + } target = SelectRandomUnfriendlyTarget(pVictim); if (!target) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 26654; break; @@ -680,7 +714,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 24658: { if (!procSpell || procSpell->Id == 24659) + { return SPELL_AURA_PROC_FAILED; + } // Need remove one 24659 aura RemoveAuraHolderFromStack(24659); return SPELL_AURA_PROC_OK; @@ -696,7 +732,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 28764: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // find Mage Armor bool found = false; @@ -714,7 +752,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura } } if (!found) + { return SPELL_AURA_PROC_FAILED; + } switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { @@ -737,7 +777,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 27539: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { @@ -762,7 +804,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Cast on owner target = GetOwner(); if (!target) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 34650; break; @@ -773,7 +817,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Roll chance if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } // Remove any stun effect on target SpellAuraHolderMap& Auras = pVictim->GetSpellAuraHolderMap(); @@ -794,7 +840,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Cast finish spell at last charge if (triggeredByAura->GetHolder()->GetAuraCharges() > 1) + { return SPELL_AURA_PROC_FAILED; + } target = this; triggered_spell_id = 33494; @@ -805,7 +853,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { basepoints[0] = 3 * damage; // 300% if (basepoints[0] < 0) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 31285; target = this; @@ -826,7 +876,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 39446: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // Select class defined buff switch (getClass()) @@ -875,7 +927,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 45481: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // Get Aldor reputation rank if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) @@ -895,10 +949,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { target = ObjectAccessor::GetUnit(*this, ((Player*)this)->GetSelectionGuid()); if (!target) + { return SPELL_AURA_PROC_FAILED; + } } if (IsFriendlyTo(target)) + { return SPELL_AURA_PROC_FAILED; + } } triggered_spell_id = 45429; @@ -912,7 +970,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 45482: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // Get Aldor reputation rank if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) @@ -935,7 +995,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 45483: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // Get Aldor reputation rank if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) @@ -959,7 +1021,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 45484: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // Get Aldor reputation rank if (((Player*)this)->GetReputationRank(932) == REP_EXALTED) @@ -1004,7 +1068,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // Glyph of Shadowfiend (need cast as self cast for owner, no hidden cooldown) owner->CastSpell(owner, 58227, true, castItem, triggeredByAura); @@ -1019,7 +1085,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Remove only single aura from stack if (triggeredByAura->GetStackAmount() > 1 && !triggeredByAura->GetHolder()->ModStackAmount(-1)) + { return SPELL_AURA_PROC_CANT_TRIGGER; + } } // Grim Reprisal case 63305: @@ -1074,7 +1142,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 71903: { if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 71905; // Soul Fragment @@ -1108,7 +1178,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 459) // only this spell have SpellIconID == 459 and dummy aura { if (GetPowerType() != POWER_MANA) + { return SPELL_AURA_PROC_FAILED; + } // mana reward basepoints[0] = (triggerAmount * GetMaxPower(POWER_MANA) / 100); @@ -1120,13 +1192,17 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 1920) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // mana cost save int32 cost = procSpell->GetManaCost() + procSpell->GetManaCostPercentage() * GetCreateMana() / 100; basepoints[0] = cost * triggerAmount/100; if (basepoints[0] <=0) + { return SPELL_AURA_PROC_FAILED; + } target = this; triggered_spell_id = 29077; @@ -1137,7 +1213,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2120) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } target = this; switch (dummySpell->Id) @@ -1155,10 +1233,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2999) { if (effIndex != EFFECT_INDEX_0) + { return SPELL_AURA_PROC_OK; + } Aura* counter = GetAura(triggeredByAura->GetId(), EFFECT_INDEX_1); if (!counter) + { return SPELL_AURA_PROC_OK; + } // Count spell criticals in a row in second aura Modifier* mod = counter->GetModifier(); @@ -1166,7 +1248,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { mod->m_amount *= 2; if (mod->m_amount < 100) // not enough + { return SPELL_AURA_PROC_OK; + } // Critical counted -> roll chance if (roll_chance_i(triggerAmount)) CastSpell(this, 48108, true, castItem, triggeredByAura); @@ -1178,12 +1262,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2998) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } int32 cost = procSpell->GetManaCost() + procSpell->GetManaCostPercentage() * GetCreateMana() / 100; basepoints[0] = cost * triggerAmount/100; if (basepoints[0] <=0) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 44450; target = this; break; @@ -1216,7 +1304,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 56372: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // not 100% safe with client version switches but for 3.1.3 no spells with cooldown that can have mage player except Frost Nova. ((Player*)this)->RemoveSpellCategoryCooldown(35, true); @@ -1226,7 +1316,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 56375: { if (!pVictim || !pVictim->IsAlive()) + { return SPELL_AURA_PROC_FAILED; + } pVictim->RemoveSpellsCausingAura(SPELL_AURA_PERIODIC_DAMAGE); pVictim->RemoveSpellsCausingAura(SPELL_AURA_PERIODIC_DAMAGE_PERCENT); @@ -1237,7 +1329,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // for DOT procs if (!IsPositiveSpell(procSpell->Id)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 64413; basepoints[0] = damage * 15 / 100; @@ -1260,7 +1354,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // check attack comes not from behind if (!HasInArc(M_PI_F, pVictim)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 22858; break; @@ -1270,10 +1366,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // only for spells and hit/crit (trigger start always) and not start from self casted spells (5530 Mace Stun Effect for example) if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) || this == pVictim) + { return SPELL_AURA_PROC_FAILED; + } // Need stun or root mechanic if (!(GetAllSpellMechanicMask(procSpell) & IMMUNE_TO_ROOT_AND_STUN_MASK)) + { return SPELL_AURA_PROC_FAILED; + } switch (dummySpell->Id) { @@ -1294,11 +1394,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // prevent chain of triggered spell from same triggered spell if (procSpell && procSpell->Id == 26654) + { return SPELL_AURA_PROC_FAILED; + } target = SelectRandomUnfriendlyTarget(pVictim); if (!target) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 26654; break; @@ -1355,7 +1459,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { target = GetPet(); if (!target) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = damage * triggerAmount / 100; triggered_spell_id = 54181; break; @@ -1393,7 +1499,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { target = GetPet(); if (!target) + { return SPELL_AURA_PROC_FAILED; + } // heal amount basepoints[0] = damage * triggerAmount / 100; @@ -1426,11 +1534,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummyClassOptions && dummyClassOptions->SpellFamilyFlags & UI64LIT(0x0000040000000000)) { if (!pVictim || !pVictim->IsAlive()) + { return SPELL_AURA_PROC_FAILED; + } // pVictim is caster of aura if (triggeredByAura->GetCasterGuid() != pVictim->GetObjectGuid()) + { return SPELL_AURA_PROC_FAILED; + } // Energize 0.25% of max. mana pVictim->CastSpell(pVictim, 57669, true, castItem, triggeredByAura); @@ -1443,7 +1555,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 217: { if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); @@ -1460,12 +1574,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 3021: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // Renew Aura* healingAura = pVictim->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_PRIEST, UI64LIT(0x40), 0, GetObjectGuid()); if (!healingAura) + { return SPELL_AURA_PROC_FAILED; + } int32 healingfromticks = healingAura->GetModifier()->m_amount * GetSpellAuraMaxTicks(procSpell); @@ -1477,11 +1595,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 3790: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } Aura* leachAura = pVictim->GetAura(SPELL_AURA_PERIODIC_LEECH, SPELLFAMILY_PRIEST, UI64LIT(0x02000000), 0, GetObjectGuid()); if (!leachAura) + { return SPELL_AURA_PROC_FAILED; + } int32 damagefromticks = leachAura->GetModifier()->m_amount * GetSpellAuraMaxTicks(procSpell); basepoints[0] = damagefromticks * triggerAmount / 100; @@ -1497,7 +1619,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Return if self damage if (this == pVictim) + { return SPELL_AURA_PROC_FAILED; + } // Heal amount - Self/Team int32 team = triggerAmount * damage / 500; @@ -1515,7 +1639,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura else if (procClassOptions && procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000010)) triggered_spell_id = 40440; else + { return SPELL_AURA_PROC_FAILED; + } target = this; break; @@ -1533,7 +1659,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 39372: { if (!procSpell || (GetSpellSchoolMask(procSpell) & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW)) == 0) + { return SPELL_AURA_PROC_FAILED; + } // heal amount basepoints[0] = damage * triggerAmount / 100; @@ -1551,7 +1679,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 55677: { if (!target->IsFriendlyTo(this)) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = int32(target->GetMaxHealth() * triggerAmount / 100); // triggered_spell_id in spell data @@ -1584,11 +1714,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // dummy m_amount store health percent (!=0 if Improved Leader of the Pack applied) int32 heal_percent = triggeredByAura->GetModifier()->m_amount; if (!heal_percent) + { return SPELL_AURA_PROC_FAILED; + } // check explicitly only to prevent mana cast when halth cast cooldown if (cooldown && ((Player*)this)->HasSpellCooldown(34299)) + { return SPELL_AURA_PROC_FAILED; + } // health triggered_spell_id = 34299; @@ -1654,10 +1788,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura chance = 40.0f; } else + { return SPELL_AURA_PROC_FAILED; + } if (!roll_chance_f(chance)) + { return SPELL_AURA_PROC_FAILED; + } target = this; break; @@ -1674,7 +1812,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // less 50% health if (pVictim->GetMaxHealth() < 2 * pVictim->GetHealth()) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = triggerAmount * damage / 100; triggered_spell_id = 54755; break; @@ -1689,7 +1829,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 70664: { if (!procSpell || GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } float radius; SpellEffectEntry const* spellEffect = procSpell->GetSpellEffect(EFFECT_INDEX_0); @@ -1703,7 +1845,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura Unit* second = pVictim->SelectRandomFriendlyTarget(pVictim, radius); if (!second) + { return SPELL_AURA_PROC_FAILED; + } pVictim->CastSpell(second, procSpell, true, NULL, triggeredByAura, GetObjectGuid()); return SPELL_AURA_PROC_OK; @@ -1742,15 +1886,21 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2856) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // Wrath crit if (procClassOptions && procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000001)) { if (HasAura(48517)) + { return SPELL_AURA_PROC_FAILED; + } if (!roll_chance_i(60)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 48518; target = this; break; @@ -1759,7 +1909,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (procClassOptions && procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000004)) { if (HasAura(48518)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 48517; target = this; break; @@ -1783,7 +1935,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 23582: // triggered spell have same masks and etc with main Vanish spell if (!procSpell || procSpell->GetSpellEffectIdByIndex(EFFECT_INDEX_0) == SPELL_EFFECT_NONE) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 23583; break; // Deadly Throw Interrupt @@ -1791,7 +1945,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Prevent cast Deadly Throw Interrupt on self from last effect (apply dummy) of Deadly Throw if (this == pVictim) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 32747; break; @@ -1802,7 +1958,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura triggered_spell_id = 57933; // Tricks of the Trade, increased damage buff target = GetHostileRefManager().GetThreatRedirectionTarget(); if (!target) + { return SPELL_AURA_PROC_FAILED; + } CastSpell(this, 59628, true); // Tricks of the Trade (caster timer) break; @@ -1837,12 +1995,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2116) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // energy cost save basepoints[0] = procSpell->GetManaCost() * triggerAmount/100; if (basepoints[0] <= 0) + { return SPELL_AURA_PROC_FAILED; + } target = this; triggered_spell_id = 31663; @@ -1856,13 +2018,17 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2236) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // mana cost save int32 mana = procSpell->GetManaCost() + procSpell->GetManaCostPercentage() * GetCreateMana() / 100; basepoints[0] = mana * 40/100; if (basepoints[0] <= 0) + { return SPELL_AURA_PROC_FAILED; + } target = this; triggered_spell_id = 34720; @@ -1880,7 +2046,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Proc only from periodic (from trap activation proc another aura of this spell) if (!(procFlag & PROC_FLAG_ON_DO_PERIODIC) || !roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 56453; target = this; break; @@ -1890,7 +2058,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // This effect only from Rapid Killing (mana regen) if (!(procClassOptions && procClassOptions->SpellFamilyFlags & UI64LIT(0x0100000000000000))) + { return SPELL_AURA_PROC_FAILED; + } target = this; @@ -1954,7 +2124,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // only at real damage if (!damage) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = int32(pVictim->GetMaxHealth() * triggeredByAura->GetModifier()->m_amount / 100); pVictim->CastCustomSpell(pVictim, 20267, &basepoints[0], NULL, NULL, true, NULL, triggeredByAura); @@ -1965,7 +2137,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // only at real damage if (!damage) + { return SPELL_AURA_PROC_FAILED; + } if (pVictim->GetPowerType() == POWER_MANA) { @@ -2007,7 +2181,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 28789: { if (!pVictim) + { return SPELL_AURA_PROC_FAILED; + } // Set class defined buff switch (pVictim->getClass()) @@ -2040,12 +2216,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // if healed by another unit (pVictim) if (this == pVictim) + { return SPELL_AURA_PROC_FAILED; + } // dont count overhealing uint32 diff = GetMaxHealth() - GetHealth(); if (!diff) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = triggerAmount * (damage > diff ? diff : damage) / 100; target = this; triggered_spell_id = 31786; @@ -2055,7 +2235,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 31801: { if (effIndex != EFFECT_INDEX_0) // effect 1,2 used by seal unleashing code + { return SPELL_AURA_PROC_FAILED; + } // At melee attack or Hammer of the Righteous spell damage considered as melee attack if ((procFlag & PROC_FLAG_SUCCESSFUL_MELEE_HIT) || (procSpell && procSpell->Id == 53595)) @@ -2082,7 +2264,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 31878: // triggered only at casted Judgement spells, not at additional Judgement effects if(!procSpell || procSpell->GetCategory() != 1210) + { return SPELL_AURA_PROC_FAILED; + } target = this; triggered_spell_id = 31930; @@ -2094,7 +2278,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 40470: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } float chance; @@ -2111,10 +2297,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura chance = 50.0f; } else + { return SPELL_AURA_PROC_FAILED; + } if (!roll_chance_f(chance)) + { return SPELL_AURA_PROC_FAILED; + } break; } @@ -2123,12 +2313,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // not do bonus heal for explicit beacon focus healing if (GetObjectGuid() == triggeredByAura->GetCasterGuid()) + { return SPELL_AURA_PROC_FAILED; + } // beacon Unit* beacon = triggeredByAura->GetCaster(); if (!beacon) + { return SPELL_AURA_PROC_FAILED; + } // find caster main aura at beacon Aura* dummy = NULL; @@ -2144,7 +2338,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // original heal must be form beacon caster if (!dummy) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 53652; // Beacon of Light basepoints[0] = triggeredByAura->GetModifier()->m_amount * damage / 100; @@ -2157,7 +2353,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 53736: { if (effIndex != EFFECT_INDEX_0) // effect 1,2 used by seal unleashing code + { return SPELL_AURA_PROC_FAILED; + } // At melee attack or Hammer of the Righteous spell damage considered as melee attack if ((procFlag & PROC_FLAG_SUCCESSFUL_MELEE_HIT) || (procSpell && procSpell->Id == 53595)) @@ -2191,11 +2389,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura triggered_spell_id = 66922; SpellEntry const* triggeredEntry = sSpellStore.LookupEntry(triggered_spell_id); if (!triggeredEntry) + { return SPELL_AURA_PROC_FAILED; + } SpellEffectEntry const* spellEffect = triggeredEntry->GetSpellEffect(EFFECT_INDEX_0); if(!spellEffect) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = int32(damage / (GetSpellDuration(triggeredEntry) / spellEffect->EffectAmplitude)); target = this; @@ -2220,11 +2422,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 71545: // heroic { if (!pVictim) + { return SPELL_AURA_PROC_FAILED; + } SpellEntry const* mote = sSpellStore.LookupEntry(71432); if (!mote) + { return SPELL_AURA_PROC_FAILED; + } uint32 maxStack = mote->GetStackAmount() - (dummySpell->Id == 71545 ? 1 : 0); SpellAuraHolder* aurHolder = GetSpellAuraHolder(71432); @@ -2245,7 +2451,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 71880: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } switch (this->GetPowerType()) { @@ -2261,7 +2469,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 71892: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } switch (this->GetPowerType()) { @@ -2284,7 +2494,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 28823: { if (!pVictim) + { return SPELL_AURA_PROC_FAILED; + } // Set class defined buff switch (pVictim->getClass()) @@ -2322,14 +2534,20 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 33757: { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } if (!castItem || !castItem->IsEquipped()) + { return SPELL_AURA_PROC_FAILED; + } // custom cooldown processing case if (cooldown && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) + { return SPELL_AURA_PROC_FAILED; + } // Now amount of extra power stored in 1 effect of Enchant spell // Get it by item enchant id @@ -2394,7 +2612,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 40463: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } float chance; if (procClassOptions && procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000001)) @@ -2413,10 +2633,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura chance = 50.0f; } else + { return SPELL_AURA_PROC_FAILED; + } if (!roll_chance_f(chance)) + { return SPELL_AURA_PROC_FAILED; + } target = this; break; @@ -2426,7 +2650,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Not proc from self heals if (this == pVictim) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = triggerAmount * damage / 100; target = this; triggered_spell_id = 55533; @@ -2438,7 +2664,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Cast on owner target = GetOwner(); if (!target) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = triggerAmount * damage / 100; triggered_spell_id = 58879; break; @@ -2448,7 +2676,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { Totem* totem = GetTotem(TOTEM_SLOT_FIRE); if (!totem) + { return SPELL_AURA_PROC_FAILED; + } // find totem aura bonus AuraList const& spellPower = totem->GetAurasByType(SPELL_AURA_NONE); @@ -2466,7 +2696,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura } if (!basepoints[0]) + { return SPELL_AURA_PROC_FAILED; + } basepoints[1] = basepoints[0]; triggered_spell_id = 63283; // Totem of Wrath, caster bonus @@ -2500,10 +2732,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Earthbind Totem summon only if (procSpell->Id != 2484) + { return SPELL_AURA_PROC_FAILED; + } if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 64695; break; @@ -2520,12 +2756,16 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummyClassOptions && dummyClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000200000)) { if (GetTypeId() != TYPEID_PLAYER || !castItem) + { return SPELL_AURA_PROC_FAILED; + } // Only proc for enchanted weapon Item* usedWeapon = ((Player*)this)->GetWeaponForAttack(procFlag & PROC_FLAG_SUCCESSFUL_OFFHAND_HIT ? OFF_ATTACK : BASE_ATTACK, true, true); if (usedWeapon != castItem) + { return SPELL_AURA_PROC_FAILED; + } switch (dummySpell->Id) { @@ -2567,14 +2807,20 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2287) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // Lesser Healing Wave need aditional 60% roll if (procClassOptions && (procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000080)) && !roll_chance_i(60)) + { return SPELL_AURA_PROC_FAILED; + } // Chain Heal needs additional 30% roll if (procClassOptions && (procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000100)) && !roll_chance_i(30)) + { return SPELL_AURA_PROC_FAILED; + } // lookup water shield AuraList const& vs = GetAurasByType(SPELL_AURA_PROC_TRIGGER_SPELL); for (AuraList::const_iterator itr = vs.begin(); itr != vs.end(); ++itr) @@ -2595,11 +2841,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 2018) // only this spell have SpellFamily Shaman SpellIconID == 2018 and dummy aura { if (!procSpell || GetTypeId() != TYPEID_PLAYER || !pVictim) + { return SPELL_AURA_PROC_FAILED; + } // custom cooldown processing case if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) + { return SPELL_AURA_PROC_FAILED; + } uint32 spellId = 0; // Every Lightning Bolt and Chain Lightning spell have duplicate vs half damage and zero cost @@ -2687,13 +2937,17 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura Unit* caster = triggeredByAura->GetCaster(); if (!procSpell || !caster) + { return SPELL_AURA_PROC_FAILED; + } float distance = caster->GetDistance(pVictim); int32 chance = triggerAmount; if (distance < 15.0f || !roll_chance_i(chance)) + { return SPELL_AURA_PROC_FAILED; + } // make triggered cast apply after current damage spell processing for prevent remove by it if (Spell* spell = GetCurrentSpell(CURRENT_GENERIC_SPELL)) @@ -2717,7 +2971,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // 1 dummy aura for dismiss rune blade if (effIndex != EFFECT_INDEX_2) + { return SPELL_AURA_PROC_FAILED; + } // TODO: wite script for this "fights on its own, doing the same attacks" // NOTE: Trigger here on every attack and spell cast return SPELL_AURA_PROC_FAILED; @@ -2742,7 +2998,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // only melee auto attack affected and Rune Strike if (procSpell && procSpell->Id != 56815) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = triggerAmount * damage / 100; triggered_spell_id = 51460; @@ -2753,10 +3011,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // Must Dual Wield if (!procSpell || !haveOffhandWeapon()) + { return SPELL_AURA_PROC_FAILED; + } // Chance as basepoints for dummy aura if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } switch (procSpell->Id) { @@ -2832,10 +3094,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // only for spells and hit/crit (trigger start always) and not start from self casted spells if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) || this == pVictim) + { return SPELL_AURA_PROC_FAILED; + } // Need snare or root mechanic if (!(GetAllSpellMechanicMask(procSpell) & IMMUNE_TO_ROOT_AND_SNARE_MASK)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 61258; target = this; break; @@ -2844,7 +3110,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 1614) { if (!roll_chance_f(GetUnitCriticalChance(BASE_ATTACK, pVictim))) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = triggerAmount * damage / 100; triggered_spell_id = 50526; break; @@ -2854,7 +3122,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { // only main hand melee auto attack affected and Rune Strike if ((procFlag & PROC_FLAG_SUCCESSFUL_OFFHAND_HIT) || (procSpell && procSpell->Id != 56815)) + { return SPELL_AURA_PROC_FAILED; + } // triggered_spell_id in spell data break; @@ -2867,7 +3137,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // processed charge only counting case if (!triggered_spell_id) + { return SPELL_AURA_PROC_OK; + } SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); @@ -2879,10 +3151,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // default case if (!target || (target != this && !target->IsAlive())) + { return SPELL_AURA_PROC_FAILED; + } if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + { return SPELL_AURA_PROC_FAILED; + } if (basepoints[EFFECT_INDEX_0] || basepoints[EFFECT_INDEX_1] || basepoints[EFFECT_INDEX_2]) CastCustomSpell(target, triggered_spell_id, @@ -2970,7 +3246,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // whenever you deal damage to a target who is below 20% health. if (pVictim->GetHealth() > pVictim->GetMaxHealth() / 5) + { return SPELL_AURA_PROC_FAILED; + } target = this; trigger_spell_id = 22588; @@ -3008,7 +3286,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d case 45057: // Evasive Maneuvers (Commendation of Kael`thas trinket) // reduce you below $s1% health (in fact in this specific case can proc from any attack while health in result less $s1%) if (int32(GetHealth()) - int32(damage) >= int32(GetMaxHealth() * triggerAmount / 100)) + { return SPELL_AURA_PROC_FAILED; + } break; // case 45903: break: // Offensive State // case 46146: break: // [PH] Ahune Spanky Hands @@ -3073,7 +3353,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // for DOT procs if (!IsPositiveSpell(procSpell->Id)) + { return SPELL_AURA_PROC_FAILED; + } break; } case 64440: // Blade Warding @@ -3091,7 +3373,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // When your health drops below 35% .... int32 health35 = int32(GetMaxHealth() * 35 / 100); if (int32(GetHealth()) - int32(damage) >= health35 || int32(GetHealth()) < health35) + { return SPELL_AURA_PROC_FAILED; + } trigger_spell_id = 64569; @@ -3176,7 +3460,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // proc chance for spells in basepoints if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } } break; } @@ -3213,7 +3499,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // only at real damage if (!damage) + { return SPELL_AURA_PROC_FAILED; + } } else if (auraSpellInfo->Id == 50421) // Scent of Blood { @@ -3250,13 +3538,17 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { Aura* heal = triggeredByAura->GetHolder()->GetAuraByEffectIndex(EFFECT_INDEX_0); if (!heal || heal->GetAuraTicks() > 1) + { return SPELL_AURA_PROC_FAILED; + } } // Nether Protection else if (auraSpellInfo->SpellIconID == 1985) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { @@ -3277,7 +3569,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // When your health drops below 20% .... int32 health20 = int32(GetMaxHealth()) / 5; if (int32(GetHealth()) - int32(damage) >= health20 || int32(GetHealth()) < health20) + { return SPELL_AURA_PROC_FAILED; + } } // Decimation else if (auraSpellInfo->Id == 63156 || auraSpellInfo->Id == 63158) @@ -3285,11 +3579,15 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // Looking for dummy effect Aura* aur = GetAura(auraSpellInfo->Id, EFFECT_INDEX_1); if (!aur) + { return SPELL_AURA_PROC_FAILED; + } // If target's health is not below equal certain value (35%) not proc if (int32(pVictim->GetHealth() * 100 / pVictim->GetMaxHealth()) > aur->GetModifier()->m_amount) + { return SPELL_AURA_PROC_FAILED; + } } break; } @@ -3300,10 +3598,14 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // Not give if target already have full health if (pVictim->GetHealth() == pVictim->GetMaxHealth()) + { return SPELL_AURA_PROC_FAILED; + } // If your Greater Heal brings the target to full health, you gain $37595s1 mana. if (pVictim->GetHealth() + damage < pVictim->GetMaxHealth()) + { return SPELL_AURA_PROC_FAILED; + } trigger_spell_id = 37595; } // Blessed Recovery @@ -3363,7 +3665,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d if (auraSpellInfo->SpellIconID == 2260) // Combat Potency { if (!(procFlags & PROC_FLAG_SUCCESSFUL_OFFHAND_HIT)) + { return SPELL_AURA_PROC_FAILED; + } } break; @@ -3382,14 +3686,18 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // This effect only from Rapid Fire (ability cast) if (!(procClassOptions && procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000020))) + { return SPELL_AURA_PROC_FAILED; + } } // Lock and Load else if (auraSpellInfo->SpellIconID == 3579) { // Check for Lock and Load Marker if (HasAura(67544)) + { return SPELL_AURA_PROC_FAILED; + } } // Item - Hunter T9 4P Bonus else if (auraSpellInfo->Id == 67151) @@ -3433,7 +3741,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d else if (auraSpellInfo->SpellIconID == 241) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // procspell is triggered spell but we need mana cost of original casted spell uint32 originalSpellId = procSpell->Id; // Holy Shock heal @@ -3469,14 +3779,18 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d else if (auraSpellInfo->Id == 37657) { if (!pVictim || !pVictim->IsAlive()) + { return SPELL_AURA_PROC_FAILED; + } // stacking CastSpell(this, 37658, true, NULL, triggeredByAura); Aura* dummy = GetDummyAura(37658); // release at 3 aura in stack (cont contain in basepoint of trigger aura) if (!dummy || dummy->GetStackAmount() < uint32(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } RemoveAurasDueToSpell(37658); trigger_spell_id = 37661; @@ -3487,13 +3801,17 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // If your target is below $s1% health if (pVictim->GetHealth() > pVictim->GetMaxHealth() * triggerAmount / 100) + { return SPELL_AURA_PROC_FAILED; + } } // Thunder Capacitor else if (auraSpellInfo->Id == 54841) { if (!pVictim || !pVictim->IsAlive()) + { return SPELL_AURA_PROC_FAILED; + } // stacking CastSpell(this, 54842, true, NULL, triggeredByAura); @@ -3501,7 +3819,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d Aura* dummy = GetDummyAura(54842); // release at 3 aura in stack (cont contain in basepoint of trigger aura) if (!dummy || dummy->GetStackAmount() < uint32(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } RemoveAurasDueToSpell(54842); trigger_spell_id = 54843; @@ -3511,7 +3831,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d else if (auraSpellInfo->Id == 67712 || auraSpellInfo->Id == 67758) { if (!pVictim || !pVictim->IsAlive()) + { return SPELL_AURA_PROC_FAILED; + } uint32 castSpell = auraSpellInfo->Id == 67758 ? 67759 : 67713; @@ -3523,7 +3845,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // release at 3 aura in stack (count contained in basepoint of trigger aura) if (!dummy || dummy->GetStackAmount() < uint32(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } RemoveAurasDueToSpell(castSpell); trigger_spell_id = castSpell + 1; @@ -3579,7 +3903,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d else if (auraSpellInfo->Id == 23572) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = procSpell->GetManaCost() * 35 / 100; trigger_spell_id = 23571; target = this; @@ -3590,7 +3916,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // Check health condition - should drop to less 30% (trigger at any attack with result health less 30%, independent original health state) int32 health30 = int32(GetMaxHealth()) * 3 / 10; if (int32(GetHealth()) - int32(damage) >= health30) + { return SPELL_AURA_PROC_FAILED; + } if (pVictim && pVictim->IsAlive()) pVictim->GetThreatManager().modifyThreatPercent(this, -10); @@ -3607,7 +3935,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d if (auraSpellInfo->SpellIconID == 1930) { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } switch (GetFirstSchoolInMask(GetSpellSchoolMask(procSpell))) { case SPELL_SCHOOL_NORMAL: @@ -3633,7 +3963,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d else if (auraSpellInfo->Id == 63611) { if (GetTypeId() != TYPEID_PLAYER || !((Player*)this)->isHonorOrXPTarget(pVictim) || !damage) + { return SPELL_AURA_PROC_FAILED; + } basepoints[0] = triggerAmount * damage / 100; trigger_spell_id = 50475; } @@ -3654,7 +3986,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // not allow proc extra attack spell at extra attack if (m_extraAttacks && IsSpellHaveEffect(triggerEntry, SPELL_EFFECT_ADD_EXTRA_ATTACKS)) + { return SPELL_AURA_PROC_FAILED; + } // Custom basepoints/target for exist spell // dummy basepoints or other customs @@ -3673,7 +4007,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d case 15250: // Rogue Setup { if (!pVictim || pVictim != getVictim()) // applied only for main target + { return SPELL_AURA_PROC_FAILED; + } break; // continue normal case } // Finishing moves that add combo points @@ -3706,7 +4042,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { SpellPowerEntry const* spellPower = procSpell->GetSpellPower(); if(!spellPower || !procSpell || procSpell->powerType!=POWER_MANA || spellPower->manaCost==0 && spellPower->ManaCostPercentage==0 && spellPower->manaCostPerlevel==0) + { return SPELL_AURA_PROC_FAILED; + } break; } // Demonic Pact @@ -3715,7 +4053,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // As the spell is proced from pet's attack - find owner Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } // This spell doesn't stack, but refreshes duration. So we receive current bonuses to minus them later. int32 curBonus = 0; @@ -3723,7 +4063,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d curBonus = aur->GetModifier()->m_amount; int32 spellDamage = owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_MAGIC) - curBonus; if (spellDamage <= 0) + { return SPELL_AURA_PROC_FAILED; + } // percent stored in owner talent dummy AuraList const& dummyAuras = owner->GetAurasByType(SPELL_AURA_DUMMY); @@ -3753,14 +4095,18 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d uint32 rank = sSpellMgr.GetSpellRank(auraSpellInfo->Id); // 5 rank -> 100% 4 rank -> 80% and etc from full rate if (!roll_chance_i(20 * rank)) + { return SPELL_AURA_PROC_FAILED; + } break; } // Brain Freeze case 57761: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // For trigger from Blizzard need exist Improved Blizzard if (procClassOptions && procClassOptions->SpellFamilyName==SPELLFAMILY_MAGE && (procClassOptions->SpellFamilyFlags & UI64LIT(0x0000000000000080))) { @@ -3776,7 +4122,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d } } if (!found) + { return SPELL_AURA_PROC_FAILED; + } } break; } @@ -3784,21 +4132,29 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d case 52179: { if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) || this == pVictim) + { return SPELL_AURA_PROC_FAILED; + } // Need stun, fear or silence mechanic if (!(GetAllSpellMechanicMask(procSpell) & IMMUNE_TO_SILENCE_AND_STUN_AND_FEAR_MASK)) + { return SPELL_AURA_PROC_FAILED; + } break; } // Burning Determination case 54748: { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } // Need Interrupt or Silenced mechanic if (!(GetAllSpellMechanicMask(procSpell) & IMMUNE_TO_INTERRUPT_AND_SILENCE_MASK)) + { return SPELL_AURA_PROC_FAILED; + } break; } // Lock and Load @@ -3806,7 +4162,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d { // Proc only from trap activation (from periodic proc another aura of this spell) if (!(procFlags & PROC_FLAG_ON_TRAP_ACTIVATION) || !roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } break; } // Freezing Fog (Rime triggered) @@ -3826,7 +4184,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d } if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(trigger_spell_id)) + { return SPELL_AURA_PROC_FAILED; + } // try detect target manually if not set if (target == NULL) @@ -3834,7 +4194,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // default case if (!target || (target != this && !target->IsAlive())) + { return SPELL_AURA_PROC_FAILED; + } if (basepoints[EFFECT_INDEX_0] || basepoints[EFFECT_INDEX_1] || basepoints[EFFECT_INDEX_2]) CastCustomSpell(target, trigger_spell_id, @@ -3870,7 +4232,9 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; if (!pVictim || !pVictim->IsAlive()) + { return SPELL_AURA_PROC_FAILED; + } Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; @@ -3885,21 +4249,27 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 case 836: // Improved Blizzard (Rank 1) { if (!procSpell || procSpell->SpellVisual[0] != 9487) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 12484; break; } case 988: // Improved Blizzard (Rank 2) { if (!procSpell || procSpell->SpellVisual[0] != 9487) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 12485; break; } case 989: // Improved Blizzard (Rank 3) { if (!procSpell || procSpell->SpellVisual[0] != 9487) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 12486; break; } @@ -3907,7 +4277,9 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 case 4087: // Improved Mend Pet (Rank 2) { if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } triggered_spell_id = 24406; break; @@ -3916,7 +4288,9 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 { // Chance 50% if (!roll_chance_i(50)) + { return SPELL_AURA_PROC_FAILED; + } switch (pVictim->GetPowerType()) { @@ -3942,7 +4316,9 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 case 7012: // Revitalize (rank 3) { if (!roll_chance_i(triggerAmount)) + { return SPELL_AURA_PROC_FAILED; + } switch (pVictim->GetPowerType()) { @@ -3958,7 +4334,9 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 // not processed if (!triggered_spell_id) + { return SPELL_AURA_PROC_FAILED; + } // standard non-dummy case SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); @@ -3970,7 +4348,9 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 } if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + { return SPELL_AURA_PROC_FAILED; + } CastSpell(pVictim, triggered_spell_id, true, castItem, triggeredByAura); @@ -4077,15 +4457,21 @@ SpellAuraProcResult Unit::HandleAddFlatModifierAuraProc(Unit* pVictim, uint32 /* { // Remove only single aura from stack if (triggeredByAura->GetStackAmount() > 1 && !triggeredByAura->GetHolder()->ModStackAmount(-1)) + { return SPELL_AURA_PROC_CANT_TRIGGER; + } } else if (spellInfo->Id == 53695 || spellInfo->Id == 53696) // Judgements of the Just { if (!procSpell) + { return SPELL_AURA_PROC_FAILED; + } if (GetSpellSpecific(procSpell->Id) != SPELL_JUDGEMENT) + { return SPELL_AURA_PROC_FAILED; + } int bp = triggeredByAura->GetModifier()->m_amount; CastCustomSpell(pVictim, 68055, &bp, NULL, NULL, true, NULL, triggeredByAura); @@ -4156,7 +4542,9 @@ SpellAuraProcResult Unit::HandleModDamagePercentDoneAuraProc(Unit* /*pVictim*/, int32 bp = int32(maxmana * GetAttackTime(RANGED_ATTACK) / 1000.0f / 100.0f); if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(34075)) + { return SPELL_AURA_PROC_FAILED; + } CastCustomSpell(this, 34075, &bp, NULL, NULL, true, castItem, triggeredByAura); } @@ -4176,7 +4564,9 @@ SpellAuraProcResult Unit::HandleModRating(Unit* /*pVictim*/, uint32 /*damage*/, { // Remove only single aura from stack if (triggeredByAura->GetStackAmount() > 1 && !triggeredByAura->GetHolder()->ModStackAmount(-1)) + { return SPELL_AURA_PROC_CANT_TRIGGER; + } } return SPELL_AURA_PROC_OK; @@ -4215,7 +4605,9 @@ SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit* pVictim, uint32 /*damag if (dummyClassOptions->IsFitToFamilyMask(UI64LIT(0x0000000000008000))) { if (GetTypeId() != TYPEID_PLAYER) + { return SPELL_AURA_PROC_FAILED; + } target = this; triggered_spell_id = 37436; @@ -4229,7 +4621,9 @@ SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit* pVictim, uint32 /*damag // processed charge only counting case if (!triggered_spell_id) + { return SPELL_AURA_PROC_OK; + } SpellEntry const* triggerEntry = sSpellStore.LookupEntry(triggered_spell_id); @@ -4241,10 +4635,14 @@ SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit* pVictim, uint32 /*damag // default case if (!target || (target != this && !target->IsAlive())) + { return SPELL_AURA_PROC_FAILED; + } if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + { return SPELL_AURA_PROC_FAILED; + } CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura); @@ -4263,7 +4661,9 @@ SpellAuraProcResult Unit::HandleModResistanceAuraProc(Unit* /*pVictim*/, uint32 { // only at real damage if (!damage) + { return SPELL_AURA_PROC_FAILED; + } } return SPELL_AURA_PROC_OK; @@ -4288,7 +4688,9 @@ SpellAuraProcResult Unit::HandleRemoveByDamageChanceProc(Unit* /*pVictim*/, uint SpellAuraProcResult Unit::HandleInvisibilityAuraProc(Unit* pVictim, uint32 damage, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 procFlag, uint32 procEx, uint32 cooldown) { if (triggeredByAura->GetSpellProto()->HasAttribute(SPELL_ATTR_PASSIVE) || triggeredByAura->GetSpellProto()->HasAttribute(SPELL_ATTR_NEGATIVE)) + { return SPELL_AURA_PROC_FAILED; + } RemoveAurasDueToSpell(triggeredByAura->GetId()); return SPELL_AURA_PROC_OK; diff --git a/src/game/WorldHandlers/VehicleHandler.cpp b/src/game/WorldHandlers/VehicleHandler.cpp index 9156d165e..e74431664 100644 --- a/src/game/WorldHandlers/VehicleHandler.cpp +++ b/src/game/WorldHandlers/VehicleHandler.cpp @@ -43,13 +43,17 @@ void WorldSession::HandleDismissControlledVehicle(WorldPacket& recvPacket) TransportInfo* transportInfo = _player->GetTransportInfo(); if (!transportInfo || !transportInfo->IsOnVehicle()) + { return; + } Unit* vehicle = (Unit*)transportInfo->GetTransport(); // Something went wrong if (movementInfo.GetGuid() != vehicle->GetObjectGuid()) + { return; + } // Remove Vehicle Control Aura vehicle->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE, _player->GetObjectGuid()); @@ -62,7 +66,9 @@ void WorldSession::HandleRequestVehicleExit(WorldPacket& recvPacket) TransportInfo* transportInfo = _player->GetTransportInfo(); if (!transportInfo || !transportInfo->IsOnVehicle()) + { return; + } Unit* vehicle = (Unit*)transportInfo->GetTransport(); @@ -85,13 +91,17 @@ void WorldSession::HandleRequestVehicleSwitchSeat(WorldPacket& recvPacket) TransportInfo* transportInfo = _player->GetTransportInfo(); if (!transportInfo || !transportInfo->IsOnVehicle()) + { return; + } Unit* vehicle = (Unit*)transportInfo->GetTransport(); // Something went wrong if (vehicleGuid != vehicle->GetObjectGuid()) + { return; + } vehicle->GetVehicleInfo()->SwitchSeat(_player, seat); } @@ -114,24 +124,32 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvPacket) TransportInfo* transportInfo = _player->GetTransportInfo(); if (!transportInfo || !transportInfo->IsOnVehicle()) + { return; + } Unit* srcVehicle = (Unit*)transportInfo->GetTransport(); // Something went wrong if (srcVehicleGuid != srcVehicle->GetObjectGuid()) + { return; + } if (srcVehicleGuid != destVehicleGuid) { Unit* destVehicle = _player->GetMap()->GetUnit(destVehicleGuid); if (!destVehicle || !destVehicle->IsVehicle()) + { return; + } // Change vehicle is not possible if (destVehicle->GetVehicleInfo()->GetVehicleEntry()->m_flags & VEHICLE_FLAG_DISABLE_SWITCH) + { return; + } SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(destVehicle->GetEntry()); for (SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) @@ -153,11 +171,15 @@ void WorldSession::HandleRideVehicleInteract(WorldPacket& recvPacket) Player* vehicle = _player->GetMap()->GetPlayer(playerGuid); if (!vehicle || !vehicle->IsVehicle()) + { return; + } // Only allowed if in same raid if (!vehicle->IsInSameRaidWith(_player)) + { return; + } _player->CastSpell(vehicle, SPELL_RIDE_VEHICLE_HARDCODED, true); } @@ -173,17 +195,23 @@ void WorldSession::HandleEjectPassenger(WorldPacket& recvPacket) Unit* passenger = _player->GetMap()->GetUnit(passengerGuid); if (!passenger || !passenger->IsBoarded()) + { return; + } // _player is not a vehicle if (!_player->IsVehicle()) + { return; + } VehicleInfo* vehicleInfo = _player->GetVehicleInfo(); // _player must be transporting passenger if (!vehicleInfo->HasOnBoard(passenger)) + { return; + } // Check for eject flag if (VehicleSeatEntry const* seatEntry = vehicleInfo->GetSeatEntry(passenger->GetTransportInfo()->GetTransportSeat())) diff --git a/src/game/WorldHandlers/WaypointManager.cpp b/src/game/WorldHandlers/WaypointManager.cpp index a6d4b723b..fa33179bd 100644 --- a/src/game/WorldHandlers/WaypointManager.cpp +++ b/src/game/WorldHandlers/WaypointManager.cpp @@ -36,11 +36,15 @@ INSTANTIATE_SINGLETON_1(WaypointManager); bool WaypointBehavior::isEmpty() { if (emote || spell || model1 || model2) + { return false; + } for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) if (textid[i]) + { return false; + } return true; } @@ -63,7 +67,9 @@ void WaypointManager::Load() ScriptChainMap const* scm = sScriptMgr.GetScriptChainMap(DBS_ON_CREATURE_MOVEMENT); if (!scm) + { return; + } std::set movementScriptSet; @@ -445,7 +451,9 @@ WaypointNode const* WaypointManager::AddNode(uint32 entry, uint32 dbGuid, uint32 { // Support only normal movement tables if (wpDest != PATH_FROM_GUID && wpDest != PATH_FROM_ENTRY) + { return NULL; + } // Prepare information char const* const table = wpDest == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template"; @@ -494,11 +502,15 @@ void WaypointManager::DeleteNode(uint32 entry, uint32 dbGuid, uint32 point, int3 { // Support only normal movement tables if (wpOrigin != PATH_FROM_GUID && wpOrigin != PATH_FROM_ENTRY) + { return; + } WaypointPath* path = GetPathFromOrigin(entry, dbGuid, pathId, wpOrigin); if (!path) + { return; + } char const* const table = wpOrigin == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template"; char const* const key_field = wpOrigin == PATH_FROM_GUID ? "id" : "entry"; @@ -524,11 +536,15 @@ void WaypointManager::SetNodePosition(uint32 entry, uint32 dbGuid, uint32 point, { // Support only normal movement tables if (wpOrigin != PATH_FROM_GUID && wpOrigin != PATH_FROM_ENTRY) + { return; + } WaypointPath* path = GetPathFromOrigin(entry, dbGuid, pathId, wpOrigin); if (!path) + { return; + } char const* const table = wpOrigin == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template"; char const* const key_field = wpOrigin == PATH_FROM_GUID ? "id" : "entry"; @@ -548,11 +564,15 @@ void WaypointManager::SetNodeWaittime(uint32 entry, uint32 dbGuid, uint32 point, { // Support only normal movement tables if (wpOrigin != PATH_FROM_GUID && wpOrigin != PATH_FROM_ENTRY) + { return; + } WaypointPath* path = GetPathFromOrigin(entry, dbGuid, pathId, wpOrigin); if (!path) + { return; + } char const* const table = wpOrigin == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template"; char const* const key_field = wpOrigin == PATH_FROM_GUID ? "id" : "entry"; @@ -568,11 +588,15 @@ void WaypointManager::SetNodeOrientation(uint32 entry, uint32 dbGuid, uint32 poi { // Support only normal movement tables if (wpOrigin != PATH_FROM_GUID && wpOrigin != PATH_FROM_ENTRY) + { return; + } WaypointPath* path = GetPathFromOrigin(entry, dbGuid, pathId, wpOrigin); if (!path) + { return; + } char const* const table = wpOrigin == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template"; char const* const key_field = wpOrigin == PATH_FROM_GUID ? "id" : "entry"; @@ -589,11 +613,15 @@ bool WaypointManager::SetNodeScriptId(uint32 entry, uint32 dbGuid, uint32 point, { // Support only normal movement tables if (wpOrigin != PATH_FROM_GUID && wpOrigin != PATH_FROM_ENTRY) + { return false; + } WaypointPath* path = GetPathFromOrigin(entry, dbGuid, pathId, wpOrigin); if (!path) + { return false; + } char const* const table = wpOrigin == PATH_FROM_GUID ? "creature_movement" : "creature_movement_template"; char const* const key_field = wpOrigin == PATH_FROM_GUID ? "id" : "entry"; @@ -606,7 +634,9 @@ bool WaypointManager::SetNodeScriptId(uint32 entry, uint32 dbGuid, uint32 point, ScriptChainMap const* scm = sScriptMgr.GetScriptChainMap(DBS_ON_CREATURE_MOVEMENT); if (!scm) + { return false; + } return scm->find(scriptId) != scm->end(); } diff --git a/src/game/WorldHandlers/WaypointManager.h b/src/game/WorldHandlers/WaypointManager.h index 97b23547f..90b7c12b4 100644 --- a/src/game/WorldHandlers/WaypointManager.h +++ b/src/game/WorldHandlers/WaypointManager.h @@ -121,13 +121,17 @@ class WaypointManager break; case PATH_FROM_ENTRY: if (pathId >= 0xFF || pathId < 0) + { return NULL; + } key = (entry << 8) + pathId; wpMap = &m_pathTemplateMap; break; case PATH_FROM_EXTERNAL: if (pathId >= 0xFF || pathId < 0) + { return NULL; + } key = (entry << 8) + pathId; wpMap = &m_externalPathTemplateMap; break; diff --git a/src/game/WorldHandlers/Weather.cpp b/src/game/WorldHandlers/Weather.cpp index 89eeac348..470e68cc0 100644 --- a/src/game/WorldHandlers/Weather.cpp +++ b/src/game/WorldHandlers/Weather.cpp @@ -65,7 +65,9 @@ bool Weather::Update(uint32 diff, Map const* _map) { ///- Weather will be removed if not updated (no players in zone anymore) if (!SendWeatherForPlayersInZone(_map)) + { return false; + } } } return true; @@ -75,7 +77,9 @@ bool Weather::Update(uint32 diff, Map const* _map) bool Weather::ReGenerate() { if (m_isPermanentWeather) + { return false; + } // remember old values WeatherType old_type = m_type; @@ -230,7 +234,9 @@ bool Weather::SendWeatherForPlayersInZone(Map const* _map) ///- Send the weather packet to all players in this zone if (!_map->SendToPlayersInZone(&data, m_zone)) + { return false; + } ///- Log the event LogWeatherState(state); @@ -246,7 +252,9 @@ bool Weather::UpdateWeather() { Player* player = sWorld.FindPlayerInZone(m_zone); if (!player) + { return false; + } ///- Send the weather packet to all players in this zone if (m_grade >= 1) @@ -314,7 +322,9 @@ void Weather::SetWeather(WeatherType type, float grade, Map const* _map, bool is m_isPermanentWeather = isPermanent; if (m_type == type && m_grade == grade) + { return; + } m_type = type; m_grade = grade; @@ -325,31 +335,51 @@ void Weather::SetWeather(WeatherType type, float grade, Map const* _map, bool is WeatherState Weather::GetWeatherState() const { if (m_grade < 0.27f) + { return WEATHER_STATE_FINE; + } switch (m_type) { case WEATHER_TYPE_RAIN: // rain if (m_grade < 0.40f) + { return WEATHER_STATE_LIGHT_RAIN; + } else if (m_grade < 0.70f) + { return WEATHER_STATE_MEDIUM_RAIN; + } else + { return WEATHER_STATE_HEAVY_RAIN; + } case WEATHER_TYPE_SNOW: // snow if (m_grade < 0.40f) + { return WEATHER_STATE_LIGHT_SNOW; + } else if (m_grade < 0.70f) + { return WEATHER_STATE_MEDIUM_SNOW; + } else + { return WEATHER_STATE_HEAVY_SNOW; + } case WEATHER_TYPE_STORM: // storm if (m_grade < 0.40f) + { return WEATHER_STATE_LIGHT_SANDSTORM; + } else if (m_grade < 0.70f) + { return WEATHER_STATE_MEDIUM_SANDSTORM; + } else + { return WEATHER_STATE_HEAVY_SANDSTORM; + } case WEATHER_TYPE_BLACKRAIN: return WEATHER_STATE_BLACKRAIN; case WEATHER_TYPE_THUNDER: @@ -443,7 +473,9 @@ Weather* WeatherSystem::FindOrCreateWeather(uint32 zoneId) WeatherMap::const_iterator itr = m_weathers.find(zoneId); // Return if found if (itr != m_weathers.end()) + { return itr->second; + } // Create Weather* w = new Weather(zoneId, sWeatherMgr.GetWeatherChances(zoneId)); m_weathers[zoneId] = w; diff --git a/src/game/WorldHandlers/World.cpp b/src/game/WorldHandlers/World.cpp index 969ba4fd8..65b3e0400 100644 --- a/src/game/WorldHandlers/World.cpp +++ b/src/game/WorldHandlers/World.cpp @@ -2925,7 +2925,9 @@ void World::InvalidatePlayerDataToAllClient(ObjectGuid guid) void World::LoadBroadcastStrings() { if (!m_broadcastEnable) - return; + { + return; + } std::string queryStr = "SELECT `autobroadcast`.`id`, `autobroadcast`.`content`,`autobroadcast`.`ratio` FROM `autobroadcast`"; diff --git a/src/game/movement/MoveSpline.cpp b/src/game/movement/MoveSpline.cpp index 6f4b62290..cfd625d95 100644 --- a/src/game/movement/MoveSpline.cpp +++ b/src/game/movement/MoveSpline.cpp @@ -52,7 +52,9 @@ namespace Movement else if (splineflags.parabolic) computeParabolicElevation(c.z); else if (splineflags.falling) - { computeFallElevation(c.z); } + { + computeFallElevation(c.z); + } if (splineflags.done && splineflags.isFacing()) { @@ -61,7 +63,9 @@ namespace Movement c.orientation = facing.angle; } else if (splineflags.final_point) - { c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x); } + { + c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x); + } // nothing to do for MoveSplineFlag::Final_Target flag } else @@ -101,7 +105,9 @@ namespace Movement el = final_z; } else - { el = z_now; } + { + el = z_now; + } } inline uint32 computeDuration(float length, float velocity) @@ -311,9 +317,13 @@ namespace Movement str << "facing angle: " << facing.angle; } else if (splineflags.final_target) - { str << "facing target: " << facing.target; } + { + str << "facing target: " << facing.target; + } else if (splineflags.final_point) - { str << "facing point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z; } + { + str << "facing point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z; + } str << std::endl; str << "time passed: " << time_passed << std::endl; str << "total time: " << Duration() << std::endl; diff --git a/src/game/movement/MoveSplineInit.cpp b/src/game/movement/MoveSplineInit.cpp index b35d2848e..9fb2d20ec 100644 --- a/src/game/movement/MoveSplineInit.cpp +++ b/src/game/movement/MoveSplineInit.cpp @@ -35,9 +35,13 @@ namespace Movement if (moveFlags & MOVEFLAG_FLYING) { if (moveFlags & MOVEFLAG_BACKWARD /*&& speed_obj.flight >= speed_obj.flight_back*/) + { return MOVE_FLIGHT_BACK; + } else + { return MOVE_FLIGHT; + } } else if (moveFlags & MOVEFLAG_SWIMMING) { @@ -46,7 +50,9 @@ namespace Movement return MOVE_SWIM_BACK; } else - { return MOVE_SWIM; } + { + return MOVE_SWIM; + } } else if (moveFlags & MOVEFLAG_WALK_MODE) { @@ -54,7 +60,9 @@ namespace Movement return MOVE_WALK; } else if (moveFlags & MOVEFLAG_BACKWARD /*&& speed_obj.run >= speed_obj.run_back*/) - { return MOVE_RUN_BACK; } + { + return MOVE_RUN_BACK; + } return MOVE_RUN; } @@ -130,7 +138,9 @@ namespace Movement // No need to stop if we are not moving if (move_spline.Finalized()) + { return; + } TransportInfo* transportInfo = unit.GetTransportInfo(); diff --git a/src/game/movement/packet_builder.cpp b/src/game/movement/packet_builder.cpp index 3350a54ec..96f7ece11 100644 --- a/src/game/movement/packet_builder.cpp +++ b/src/game/movement/packet_builder.cpp @@ -135,16 +135,22 @@ namespace Movement WriteCatmullRomCyclicPath(spline, data); } else - { WriteCatmullRomPath(spline, data); } + { + WriteCatmullRomPath(spline, data); + } } else - { WriteLinearPath(spline, data); } + { + WriteLinearPath(spline, data); + } } void PacketBuilder::WriteCreateBits(const MoveSpline& move_spline, ByteBuffer& data) { if (!data.WriteBit(!move_spline.Finalized())) + { return; + } MoveSplineFlag splineFlags = move_spline.splineflags; uint32 nodes = move_spline.getPath().size(); diff --git a/src/game/movement/spline.cpp b/src/game/movement/spline.cpp index a662eadf0..955a54609 100644 --- a/src/game/movement/spline.cpp +++ b/src/game/movement/spline.cpp @@ -237,7 +237,9 @@ namespace Movement points[count] = controls[cyclic_point]; } else - { points[count] = controls[count - 1]; } + { + points[count] = controls[count - 1]; + } index_lo = 0; index_hi = cyclic ? count : (count - 1); @@ -263,7 +265,9 @@ namespace Movement points[0] = controls[count - 1]; } else - { points[0] = controls[0].lerp(controls[1], -1); } + { + points[0] = controls[0].lerp(controls[1], -1); + } points[high_index + 1] = controls[cyclic_point]; points[high_index + 2] = controls[cyclic_point + 1]; diff --git a/src/game/movement/typedefs.h b/src/game/movement/typedefs.h index dfbab29fa..161ade0d9 100644 --- a/src/game/movement/typedefs.h +++ b/src/game/movement/typedefs.h @@ -88,7 +88,9 @@ namespace Movement init(); } else - { ++m_counter; } + { + ++m_counter; + } } /** diff --git a/src/game/movement/util.cpp b/src/game/movement/util.cpp index 8ebed148c..00b15e2ad 100644 --- a/src/game/movement/util.cpp +++ b/src/game/movement/util.cpp @@ -53,7 +53,9 @@ namespace Movement time = (path_length - terminal_savefall_length) / terminalSavefallVelocity + terminalSavefallVelocity / gravity; } else - { time = sqrtf(2.f * path_length / gravity); } + { + time = sqrtf(2.f * path_length / gravity); + } } else { @@ -62,7 +64,9 @@ namespace Movement time = (path_length - terminal_length) / terminalVelocity + terminalFallTime; } else - { time = sqrtf(2.f * path_length / gravity); } + { + time = sqrtf(2.f * path_length / gravity); + } } return time; @@ -78,7 +82,9 @@ namespace Movement termVel = terminalSavefallVelocity; } else - { termVel = terminalVelocity; } + { + termVel = terminalVelocity; + } if (start_velocity > termVel) { @@ -93,7 +99,9 @@ namespace Movement start_velocity * terminal_time + gravity * terminal_time * terminal_time * 0.5f; } else - { result = t_passed * (start_velocity + t_passed * gravity * 0.5f); } + { + result = t_passed * (start_velocity + t_passed * gravity * 0.5f); + } return result; } @@ -109,7 +117,9 @@ namespace Movement result = terminalVelocity * (t_passed - terminalFallTime) + terminal_length; } else - { result = t_passed * t_passed * gravity * 0.5f; } + { + result = t_passed * t_passed * gravity * 0.5f; + } return result; } diff --git a/src/game/vmap/BIH.cpp b/src/game/vmap/BIH.cpp index 021c1cc7b..8d07d5c5e 100644 --- a/src/game/vmap/BIH.cpp +++ b/src/game/vmap/BIH.cpp @@ -230,7 +230,9 @@ void BIH::subdivide(int left, int right, std::vector& tempTree, buildDat tempTree.push_back(0); } else - { nextIndex -= 3; } + { + nextIndex -= 3; + } // allocate right node if (nr > 0) { @@ -255,13 +257,17 @@ void BIH::subdivide(int left, int right, std::vector& tempTree, buildDat subdivide(left, right, tempTree, dat, gridBoxL, nodeBoxL, nextIndex, depth + 1, stats); } else - { stats.updateLeaf(depth + 1, 0); } + { + stats.updateLeaf(depth + 1, 0); + } if (nr > 0) { subdivide(right + 1, rightOrig, tempTree, dat, gridBoxR, nodeBoxR, nextIndex + 3, depth + 1, stats); } else - { stats.updateLeaf(depth + 1, 0); } + { + stats.updateLeaf(depth + 1, 0); + } } bool BIH::writeToFile(FILE* wf) const diff --git a/src/game/vmap/BIHWrap.h b/src/game/vmap/BIHWrap.h index efca47d4e..57ef2f1a4 100644 --- a/src/game/vmap/BIHWrap.h +++ b/src/game/vmap/BIHWrap.h @@ -144,7 +144,9 @@ class BIHWrap m_objects[Idx] = NULL; } else - { m_objects_to_push.remove(&obj); } + { + m_objects_to_push.remove(&obj); + } } /** diff --git a/src/game/vmap/DynamicTree.cpp b/src/game/vmap/DynamicTree.cpp index ff9fe35b4..d9b51bc8a 100644 --- a/src/game/vmap/DynamicTree.cpp +++ b/src/game/vmap/DynamicTree.cpp @@ -292,5 +292,7 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist, return v.z - maxSearchDist; } else - { return -G3D::inf(); } + { + return -G3D::inf(); + } } diff --git a/src/game/vmap/MapTree.cpp b/src/game/vmap/MapTree.cpp index 16139e49c..9f7079446 100644 --- a/src/game/vmap/MapTree.cpp +++ b/src/game/vmap/MapTree.cpp @@ -455,7 +455,9 @@ namespace VMAP DEBUG_LOG("Error: trying to load wrong spawn in node!"); } else if (iTreeValues[referencedVal].name != spawn.name) - { DEBUG_LOG("Error: name mismatch on GUID=%u", spawn.ID); } + { + DEBUG_LOG("Error: name mismatch on GUID=%u", spawn.ID); + } #endif } } @@ -464,7 +466,9 @@ namespace VMAP fclose(tf); } else - { iLoadedTiles[packTileID(tileX, tileY)] = false; } + { + iLoadedTiles[packTileID(tileX, tileY)] = false; + } return result; } diff --git a/src/game/vmap/TileAssembler.cpp b/src/game/vmap/TileAssembler.cpp index 0ccaed72a..63731cb5c 100644 --- a/src/game/vmap/TileAssembler.cpp +++ b/src/game/vmap/TileAssembler.cpp @@ -330,7 +330,9 @@ namespace VMAP modelBound = AABox(v, v), boundEmpty = false; } else - { modelBound.merge(v); } + { + modelBound.merge(v); + } } } spawn.iBound = modelBound + spawn.iPos; @@ -455,7 +457,9 @@ namespace VMAP bounds = AABox(v, v), boundEmpty = false; } else - { bounds.merge(v); } + { + bounds.merge(v); + } } } diff --git a/src/game/vmap/VMapManager2.cpp b/src/game/vmap/VMapManager2.cpp index 21218048f..3a029a7f9 100644 --- a/src/game/vmap/VMapManager2.cpp +++ b/src/game/vmap/VMapManager2.cpp @@ -90,7 +90,9 @@ namespace VMAP result = VMAP_LOAD_RESULT_OK; } else - { result = VMAP_LOAD_RESULT_ERROR; } + { + result = VMAP_LOAD_RESULT_ERROR; + } } return result; } @@ -151,7 +153,9 @@ namespace VMAP bool VMapManager2::isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2) { if (!isLineOfSightCalcEnabled() || IsVMAPDisabledForPtr(pMapId, VMAP_DISABLE_LOS)) + { return true; + } bool result = true; InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId); diff --git a/src/game/vmap/WorldModel.cpp b/src/game/vmap/WorldModel.cpp index 215c2c13f..e6f5467dc 100644 --- a/src/game/vmap/WorldModel.cpp +++ b/src/game/vmap/WorldModel.cpp @@ -152,14 +152,18 @@ namespace VMAP memcpy(iHeight, other.iHeight, (iTilesX + 1) * (iTilesY + 1) * sizeof(float)); } else - { iHeight = NULL; } + { + iHeight = NULL; + } if (other.iFlags) { iFlags = new uint8[iTilesX * iTilesY]; memcpy(iFlags, other.iFlags, iTilesX * iTilesY * sizeof(uint8)); } else - { iFlags = NULL; } + { + iFlags = NULL; + } return *this; } diff --git a/src/mangosd/SOAP/SoapThread.cpp b/src/mangosd/SOAP/SoapThread.cpp index 0dffe3424..6884448f3 100644 --- a/src/mangosd/SOAP/SoapThread.cpp +++ b/src/mangosd/SOAP/SoapThread.cpp @@ -220,7 +220,9 @@ int ns1__executeCommand(soap* soap, char* command, char** result) return SOAP_OK; } else - { return soap_sender_fault(soap, printBuffer, printBuffer); } + { + return soap_sender_fault(soap, printBuffer, printBuffer); + } } void SOAPCommand::commandFinished(void* soapconnection, bool success) diff --git a/src/shared/Config/Config.cpp b/src/shared/Config/Config.cpp index 4b6fc8d90..f7c2a4d43 100644 --- a/src/shared/Config/Config.cpp +++ b/src/shared/Config/Config.cpp @@ -115,7 +115,9 @@ bool Config::GetBoolDefault(const char* name, bool def) strcmp(str, "1") == 0) { return true; } else - { return false; } + { + return false; + } } int32 Config::GetIntDefault(const char* name, int32 def) diff --git a/src/shared/DataStores/DB2FileLoader.cpp b/src/shared/DataStores/DB2FileLoader.cpp index 799cae273..bcfb03050 100644 --- a/src/shared/DataStores/DB2FileLoader.cpp +++ b/src/shared/DataStores/DB2FileLoader.cpp @@ -303,7 +303,9 @@ char* DB2FileLoader::AutoProduceData(const char* format, uint32& records, char** indexTable[getRecord(y).getUInt(i)] = &dataTable[offset]; } else - { indexTable[y] = &dataTable[offset]; } + { + indexTable[y] = &dataTable[offset]; + } for (uint32 x = 0; x < fieldCount; ++x) { @@ -409,7 +411,9 @@ char* DB2FileLoader::AutoProduceStringsArrayHolders(const char* format, char* da char* DB2FileLoader::AutoProduceStrings(const char* format, char* dataTable, LocaleConstant loc) { if(strlen(format)!=fieldCount) + { return NULL; + } // each string field at load have array of string for each locale size_t stringHolderSize = sizeof(char*) * MAX_LOCALE; diff --git a/src/shared/DataStores/DBCFileLoader.cpp b/src/shared/DataStores/DBCFileLoader.cpp index ad990bfda..755358446 100644 --- a/src/shared/DataStores/DBCFileLoader.cpp +++ b/src/shared/DataStores/DBCFileLoader.cpp @@ -100,7 +100,9 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt) fieldsOffset[i] += 1; } else // 4 byte fields (int32/float/strings) - { fieldsOffset[i] += 4; } + { + fieldsOffset[i] += 4; + } } data = new unsigned char[recordSize * recordCount + stringSize]; @@ -243,7 +245,9 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char** indexTable[getRecord(y).getUInt(i)] = &dataTable[offset]; } else - { indexTable[y] = &dataTable[offset]; } + { + indexTable[y] = &dataTable[offset]; + } for (uint32 x = 0; x < fieldCount; ++x) { @@ -288,7 +292,9 @@ static char const* const nullStr = ""; char* DBCFileLoader::AutoProduceStringsArrayHolders(const char* format, char* dataTable) { if(strlen(format)!=fieldCount) + { return NULL; + } // we store flat holders pool as single memory block size_t stringFields = GetFormatStringsFields(format); diff --git a/src/shared/DataStores/DBCStore.h b/src/shared/DataStores/DBCStore.h index 0783af1c1..f70db14b8 100644 --- a/src/shared/DataStores/DBCStore.h +++ b/src/shared/DataStores/DBCStore.h @@ -85,7 +85,9 @@ class DBCStorage { typename std::map::const_iterator it = data.find(id); if (it != data.end()) + { return it->second; + } } return (id >= nCount) ? NULL : indexTable[id]; } diff --git a/src/shared/Database/Database.cpp b/src/shared/Database/Database.cpp index faffebac5..c703dfb04 100644 --- a/src/shared/Database/Database.cpp +++ b/src/shared/Database/Database.cpp @@ -96,7 +96,9 @@ SqlPreparedStatement* SqlConnection::GetStmt(uint32 nIndex) m_holder[nIndex] = pStmt; } else - { pStmt = m_holder[nIndex]; } + { + pStmt = m_holder[nIndex]; + } return pStmt; } @@ -146,9 +148,13 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/) m_nQueryConnPoolSize = MIN_CONNECTION_POOL_SIZE; } else if (nConns > MAX_CONNECTION_POOL_SIZE) - { m_nQueryConnPoolSize = MAX_CONNECTION_POOL_SIZE; } + { + m_nQueryConnPoolSize = MAX_CONNECTION_POOL_SIZE; + } else - { m_nQueryConnPoolSize = nConns; } + { + m_nQueryConnPoolSize = nConns; + } // create connection pool for sync requests for (int i = 0; i < m_nQueryConnPoolSize; ++i) @@ -263,7 +269,9 @@ SqlConnection* Database::getQueryConnection() m_nQueryCounter = 0; } else - { nCount = ++m_nQueryCounter; } + { + nCount = ++m_nQueryCounter; + } return m_pQueryConnections[nCount % m_nQueryConnPoolSize]; } @@ -658,7 +666,9 @@ SqlStatement Database::CreateStatement(SqlStatementID& index, const char* fmt) m_stmtRegistry[szFmt] = nId; } else - { nId = iter->second; } + { + nId = iter->second; + } // save initialized statement index info index.init(nId, nParams); diff --git a/src/shared/Database/DatabaseMysql.cpp b/src/shared/Database/DatabaseMysql.cpp index 80a4d1d1e..43de889e7 100644 --- a/src/shared/Database/DatabaseMysql.cpp +++ b/src/shared/Database/DatabaseMysql.cpp @@ -184,7 +184,9 @@ bool MySQLConnection::Initialize(const char* infoString) DETAIL_LOG("AUTOCOMMIT SUCCESSFULLY SET TO 1"); } else - { DETAIL_LOG("AUTOCOMMIT NOT SET TO 1"); } + { + DETAIL_LOG("AUTOCOMMIT NOT SET TO 1"); + } /*-------------------------------------*/ // set connection properties to UTF8 to properly handle locales for different diff --git a/src/shared/Database/DatabasePostgre.cpp b/src/shared/Database/DatabasePostgre.cpp index d07c697b3..9b167ed69 100644 --- a/src/shared/Database/DatabasePostgre.cpp +++ b/src/shared/Database/DatabasePostgre.cpp @@ -97,7 +97,9 @@ bool PostgreSQLConnection::Initialize(const char* infoString) mPGconn = PQsetdbLogin(NULL, port_or_socket_dir == "." ? NULL : port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str()); } else - { mPGconn = PQsetdbLogin(host.c_str(), port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str()); } + { + mPGconn = PQsetdbLogin(host.c_str(), port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str()); + } /* check to see that the backend connection was successfully made */ if (PQstatus(mPGconn) != CONNECTION_OK) diff --git a/src/shared/Database/SQLStorageImpl.h b/src/shared/Database/SQLStorageImpl.h index 4f927e2c7..ade61fccd 100644 --- a/src/shared/Database/SQLStorageImpl.h +++ b/src/shared/Database/SQLStorageImpl.h @@ -270,7 +270,9 @@ void SQLStorageLoaderBase::Load(StorageClass& store sLog.outError("%s table is empty!\n", store.GetTableName()); } else - { sLog.outString("%s table is empty!\n", store.GetTableName()); } + { + sLog.outString("%s table is empty!\n", store.GetTableName()); + } recordCount = 0; return; diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index 64a880ef1..2d43b929d 100644 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -188,7 +188,9 @@ QueryResult* SqlQueryHolder::GetResult(size_t index) return m_queries[index].second; } else - { return NULL; } + { + return NULL; + } } void SqlQueryHolder::SetResult(size_t index, QueryResult* result) diff --git a/src/shared/Log/Log.cpp b/src/shared/Log/Log.cpp index f231de81a..1bc8e6a0d 100644 --- a/src/shared/Log/Log.cpp +++ b/src/shared/Log/Log.cpp @@ -205,7 +205,9 @@ void Log::SetLogLevel(char* level) newLevel = LOG_LVL_MINIMAL; } else if (newLevel > LOG_LVL_DEBUG) - { newLevel = LOG_LVL_DEBUG; } + { + newLevel = LOG_LVL_DEBUG; + } m_logLevel = LogLevel(newLevel); @@ -221,7 +223,9 @@ void Log::SetLogFileLevel(char* level) newLevel = LOG_LVL_MINIMAL; } else if (newLevel > LOG_LVL_DEBUG) - { newLevel = LOG_LVL_DEBUG; } + { + newLevel = LOG_LVL_DEBUG; + } m_logFileLevel = LogLevel(newLevel); @@ -326,7 +330,9 @@ FILE* Log::openLogFile(char const* configFileName, char const* configTimeStampFl logfn.insert(dot_pos, m_logsTimestamp); } else - { logfn += m_logsTimestamp; } + { + logfn += m_logsTimestamp; + } } return fopen((m_logsDir + logfn).c_str(), mode); @@ -610,7 +616,9 @@ void Log::outErrorEluna() {} void Log::outErrorEluna(const char* err, ...) { if (!err) + { return; + } if (m_colored) SetColor(false, m_colors[LogError]); @@ -1060,7 +1068,9 @@ void Log::outErrorScriptLib() fprintf(logfile, "<%s ERROR:> ", m_scriptLibName); } else - { fprintf(logfile, ": "); } + { + fprintf(logfile, ": "); + } fflush(logfile); } @@ -1112,7 +1122,9 @@ void Log::outErrorScriptLib(const char* err, ...) fprintf(logfile, "<%s ERROR>: ", m_scriptLibName); } else - { fprintf(logfile, ": "); } + { + fprintf(logfile, ": "); + } va_start(ap, err); vfprintf(logfile, err, ap); diff --git a/src/shared/Threading/DelayExecutor.cpp b/src/shared/Threading/DelayExecutor.cpp index e69629b38..ffd6fb50d 100644 --- a/src/shared/Threading/DelayExecutor.cpp +++ b/src/shared/Threading/DelayExecutor.cpp @@ -52,7 +52,9 @@ DelayExecutor::~DelayExecutor() int DelayExecutor::deactivate() { if (!activated()) + { return -1; + } activated(false); queue_.queue()->deactivate(); @@ -86,10 +88,14 @@ int DelayExecutor::svc() int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, ACE_Method_Request* post_svc_hook) { if (activated()) + { return -1; + } if (num_threads < 1) + { return -1; + } if (pre_svc_hook_) delete pre_svc_hook_; @@ -103,7 +109,9 @@ int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, A queue_.queue()->activate(); if (ACE_Task_Base::activate(THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, num_threads) == -1) + { return -1; + } activated(true); @@ -113,7 +121,9 @@ int DelayExecutor::activate(int num_threads, ACE_Method_Request* pre_svc_hook, A int DelayExecutor::execute(ACE_Method_Request* new_req) { if (new_req == NULL) + { return -1; + } if (queue_.enqueue(new_req, (ACE_Time_Value*)&ACE_Time_Value::zero) == -1) { diff --git a/src/shared/Utilities/ByteBuffer.h b/src/shared/Utilities/ByteBuffer.h index f83d16b1f..74fc88d66 100644 --- a/src/shared/Utilities/ByteBuffer.h +++ b/src/shared/Utilities/ByteBuffer.h @@ -199,7 +199,9 @@ class ByteBuffer void FlushBits() { if (_bitpos == 8) + { return; + } append((uint8 *)&_curbitval, sizeof(uint8)); _curbitval = 0; @@ -983,7 +985,9 @@ class ByteBuffer ByteBuffer& append(const uint8* src, size_t cnt) { if (!cnt) + { return *this; + } MANGOS_ASSERT(size() < 10000000); @@ -1005,7 +1009,9 @@ class ByteBuffer ByteBuffer& append(const ByteBuffer& buffer) { if (buffer.wpos()) + { return append(buffer.contents(), buffer.wpos()); + } return *this; } diff --git a/src/shared/Utilities/Util.cpp b/src/shared/Utilities/Util.cpp index 7b218e86e..8c1af40c5 100644 --- a/src/shared/Utilities/Util.cpp +++ b/src/shared/Utilities/Util.cpp @@ -209,7 +209,9 @@ void stripLineInvisibleChars(std::string& str) str[wpos++] = str[pos]; } else - { ++wpos; } + { + ++wpos; + } space = false; } } @@ -351,7 +353,9 @@ bool IsIPAddrInNetwork(ACE_INET_Addr const& net, ACE_INET_Addr const& addr, ACE_ { uint32 mask = subnetMask.get_ip_address(); if ((net.get_ip_address() & mask) == (addr.get_ip_address() & mask)) + { return true; + } return false; } @@ -416,7 +420,9 @@ bool Utf8ToUpperOnlyLatin(std::string& utf8String) { std::wstring wstr; if (!Utf8toWStr(utf8String, wstr)) + { return false; + } std::transform(wstr.begin(), wstr.end(), wstr.begin(), wcharToUpperOnlyLatin); @@ -655,7 +661,9 @@ void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result) encodedNibble = '0' + nibble; } else - { encodedNibble = 'A' + nibble - 0x0A; } + { + encodedNibble = 'A' + nibble - 0x0A; + } ss << encodedNibble; } } @@ -690,7 +698,9 @@ void HexStrToByteArray(std::string const& str, uint8* out, bool reverse /*= fals { // string must have even number of characters if (str.length() & 1) + { return; + } int32 init = 0; int32 end = str.length(); diff --git a/src/shared/Win/WheatyExceptionReport.cpp b/src/shared/Win/WheatyExceptionReport.cpp index 6bb4a9ae4..44f822060 100644 --- a/src/shared/Win/WheatyExceptionReport.cpp +++ b/src/shared/Win/WheatyExceptionReport.cpp @@ -119,7 +119,9 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter( return m_previousFilter(pExceptionInfo); } else - { return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/; } + { + return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/; + } } BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxcount) @@ -186,7 +188,9 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) _tcsncat(szVersion, _T("Windows 8 "), cntMax); } else - { _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); } + { + _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); + } break; case 1: if (osvi.wProductType == VER_NT_WORKSTATION) @@ -194,7 +198,9 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) _tcsncat(szVersion, _T("Windows 7 "), cntMax); } else - { _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax); } + { + _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax); + } break; case 0: if (osvi.wProductType == VER_NT_WORKSTATION) @@ -202,7 +208,9 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) _tcsncat(szVersion, _T("Windows Vista "), cntMax); } else - { _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax); } + { + _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax); + } break; } break; @@ -260,7 +268,9 @@ void WheatyExceptionReport::PrintSystemInfo() _tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString); } else - { _tprintf(_T("\r\n*** Operation System:\r\n\r\n")); } + { + _tprintf(_T("\r\n*** Operation System:\r\n\r\n")); + } } //=========================================================================== @@ -701,7 +711,9 @@ bool WheatyExceptionReport::FormatSymbolValue( pszCurrBuffer += sprintf(pszCurrBuffer, "Parameter "); } else if (pSym->Flags & IMAGEHLP_SYMBOL_INFO_LOCAL) - { pszCurrBuffer += sprintf(pszCurrBuffer, "Local "); } + { + pszCurrBuffer += sprintf(pszCurrBuffer, "Local "); + } // If it's a function, don't do anything. if (pSym->Tag == 5) // SymTagFunction from CVCONST.H from the DIA SDK @@ -879,7 +891,9 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer, pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PBYTE)pAddress); } else if (length == 2) - { pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PWORD)pAddress); } + { + pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PWORD)pAddress); + } else if (length == 4) { if (basicType == btFloat) @@ -898,7 +912,9 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer, *(PDWORD)pAddress); } else - { pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress); } + { + pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress); + } } else if (length == 8) { diff --git a/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp b/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp index 5705fece3..dcbb2e4c7 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp +++ b/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp @@ -149,10 +149,22 @@ namespace MMAP fwrite(&(chf->ch), sizeof(chf->ch), 1, file); int tmp = 0; - if (chf->cells) { tmp |= 1; } - if (chf->spans) { tmp |= 2; } - if (chf->dist) { tmp |= 4; } - if (chf->areas) { tmp |= 8; } + if (chf->cells) + { + tmp |= 1; + } + if (chf->spans) + { + tmp |= 2; + } + if (chf->dist) + { + tmp |= 4; + } + if (chf->areas) + { + tmp |= 8; + } fwrite(&tmp, sizeof(tmp), 1, file); diff --git a/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h b/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h index 3286bf5c1..6053b1ac8 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h +++ b/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h @@ -152,7 +152,9 @@ namespace MMAP } } else - { break; } + { + break; + } } if (dirp) @@ -160,7 +162,9 @@ namespace MMAP closedir(dirp); } else - { return LISTFILE_DIRECTORY_NOT_FOUND; } + { + return LISTFILE_DIRECTORY_NOT_FOUND; + } #endif return LISTFILE_OK; diff --git a/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp b/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp index 3d0a41605..9804c107f 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp +++ b/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp @@ -311,9 +311,13 @@ namespace MMAP rcVmax(bmax, lmax); } else if (meshData.solidVerts.size()) - { rcCalcBounds(meshData.solidVerts.getCArray(), meshData.solidVerts.size() / 3, bmin, bmax); } + { + rcCalcBounds(meshData.solidVerts.getCArray(), meshData.solidVerts.size() / 3, bmin, bmax); + } else - { rcCalcBounds(meshData.liquidVerts.getCArray(), meshData.liquidVerts.size() / 3, lmin, lmax); } + { + rcCalcBounds(meshData.liquidVerts.getCArray(), meshData.liquidVerts.size() / 3, lmin, lmax); + } // convert coord bounds to grid bounds maxX = 32 - bmin[0] / GRID_SIZE; @@ -351,14 +355,18 @@ namespace MMAP tileXMax = tileX; } else if (tileX < tileXMin) - { tileXMin = tileX; } + { + tileXMin = tileX; + } if (tileY > tileYMax) { tileYMax = tileY; } else if (tileY < tileYMin) - { tileYMin = tileY; } + { + tileYMin = tileY; + } } // use Max because '32 - tileX' is negative for values over 32 diff --git a/src/tools/Extractor_projects/Movemap-Generator/generator.cpp b/src/tools/Extractor_projects/Movemap-Generator/generator.cpp index bb91817d2..daea1b23a 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/generator.cpp +++ b/src/tools/Extractor_projects/Movemap-Generator/generator.cpp @@ -116,7 +116,9 @@ bool handleArgs(int argc, char** argv, maxAngle = maxangle; } else - { printf("invalid option for '--maxAngle', using default\n"); } + { + printf("invalid option for '--maxAngle', using default\n"); + } } else if (strcmp(argv[i], "--tile") == 0) { @@ -159,9 +161,13 @@ bool handleArgs(int argc, char** argv, skipLiquid = true; } else if (strcmp(param, "false") == 0) - { skipLiquid = false; } + { + skipLiquid = false; + } else - { printf("invalid option for '--skipLiquid', using default\n"); } + { + printf("invalid option for '--skipLiquid', using default\n"); + } } else if (strcmp(argv[i], "--skipContinents") == 0) { @@ -176,9 +182,13 @@ bool handleArgs(int argc, char** argv, skipContinents = true; } else if (strcmp(param, "false") == 0) - { skipContinents = false; } + { + skipContinents = false; + } else - { printf("invalid option for '--skipContinents', using default\n"); } + { + printf("invalid option for '--skipContinents', using default\n"); + } } else if (strcmp(argv[i], "--skipJunkMaps") == 0) { @@ -193,9 +203,13 @@ bool handleArgs(int argc, char** argv, skipJunkMaps = true; } else if (strcmp(param, "false") == 0) - { skipJunkMaps = false; } + { + skipJunkMaps = false; + } else - { printf("invalid option for '--skipJunkMaps', using default\n"); } + { + printf("invalid option for '--skipJunkMaps', using default\n"); + } } else if (strcmp(argv[i], "--skipBattlegrounds") == 0) { @@ -210,9 +224,13 @@ bool handleArgs(int argc, char** argv, skipBattlegrounds = true; } else if (strcmp(param, "false") == 0) - { skipBattlegrounds = false; } + { + skipBattlegrounds = false; + } else - { printf("invalid option for '--skipBattlegrounds', using default\n"); } + { + printf("invalid option for '--skipBattlegrounds', using default\n"); + } } else if (strcmp(argv[i], "--debugOutput") == 0) { @@ -227,9 +245,13 @@ bool handleArgs(int argc, char** argv, debugOutput = true; } else if (strcmp(param, "false") == 0) - { debugOutput = false; } + { + debugOutput = false; + } else - { printf("invalid option for '--debugOutput', using default true\n"); } + { + printf("invalid option for '--debugOutput', using default true\n"); + } } else if (strcmp(argv[i], "--silent") == 0) { @@ -248,9 +270,13 @@ bool handleArgs(int argc, char** argv, bigBaseUnit = true; } else if (strcmp(param, "false") == 0) - { bigBaseUnit = false; } + { + bigBaseUnit = false; + } else - { printf("invalid option for '--bigBaseUnit', using default false\n"); } + { + printf("invalid option for '--bigBaseUnit', using default false\n"); + } } else if (strcmp(argv[i], "--offMeshInput") == 0) { @@ -312,7 +338,9 @@ int main(int argc, char** argv) debugOutput, silent, bigBaseUnit, offMeshInputPath); if (!validParam) + { return silent ? -1 : finish("You have specified invalid parameters (use -? for more help)", -1); + } if (mapnum == -1 && debugOutput) { @@ -347,6 +375,6 @@ int main(int argc, char** argv) else builder.buildAllMaps(); - + return silent ? 1 : finish(" Movemap build is complete! Press enter to exit\n", 1); } diff --git a/src/tools/Extractor_projects/map-extractor/System.cpp b/src/tools/Extractor_projects/map-extractor/System.cpp index f84d2b6eb..8c2cf193f 100644 --- a/src/tools/Extractor_projects/map-extractor/System.cpp +++ b/src/tools/Extractor_projects/map-extractor/System.cpp @@ -200,7 +200,9 @@ void AppendDBCFileListTo(HANDLE mpqHandle, std::set& filelist) HANDLE searchHandle = SFileFindFirstFile(mpqHandle, "*.dbc", &findFileData, NULL); if (!searchHandle) + { return; + } filelist.insert(findFileData.cFileName); @@ -216,7 +218,9 @@ void AppendDB2FileListTo(HANDLE mpqHandle, std::set& filelist) HANDLE searchHandle = SFileFindFirstFile(mpqHandle, "*.db2", &findFileData, NULL); if (!searchHandle) + { return; + } filelist.insert(findFileData.cFileName); @@ -525,7 +529,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 ADT_file adt; if (!adt.loadFile(filename, false)) + { return false; + } memset(liquid_show, 0, sizeof(liquid_show)); memset(liquid_flags, 0, sizeof(liquid_flags)); @@ -675,8 +681,14 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 for (int x = 0; x < ADT_GRID_SIZE; x++) { float h = V8[y][x]; - if (maxHeight < h) { maxHeight = h; } - if (minHeight > h) { minHeight = h; } + if (maxHeight < h) + { + maxHeight = h; + } + if (minHeight > h) + { + minHeight = h; + } } } for (int y = 0; y <= ADT_GRID_SIZE; y++) @@ -684,8 +696,14 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 for (int x = 0; x <= ADT_GRID_SIZE; x++) { float h = V9[y][x]; - if (maxHeight < h) { maxHeight = h; } - if (minHeight > h) { minHeight = h; } + if (maxHeight < h) + { + maxHeight = h; + } + if (minHeight > h) + { + minHeight = h; + } } } @@ -776,7 +794,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 map.heightMapSize += sizeof(uint16_V9) + sizeof(uint16_V8); } else - { map.heightMapSize += sizeof(V9) + sizeof(V8); } + { + map.heightMapSize += sizeof(V9) + sizeof(V8); + } } // Get from MCLQ chunk (old) @@ -919,7 +939,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 liquid_height[cy][cx] = height[pos]; } else - { liquid_height[cy][cx] = h->heightLevel1; } + { + liquid_height[cy][cx] = h->heightLevel1; + } pos++; } } @@ -965,16 +987,36 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { if (liquid_show[y][x]) { - if (minX > x) { minX = x; } - if (maxX < x) { maxX = x; } - if (minY > y) { minY = y; } - if (maxY < y) { maxY = y; } + if (minX > x) + { + minX = x; + } + if (maxX < x) + { + maxX = x; + } + if (minY > y) + { + minY = y; + } + if (maxY < y) + { + maxY = y; + } float h = liquid_height[y][x]; - if (maxHeight < h) { maxHeight = h; } - if (minHeight > h) { minHeight = h; } + if (maxHeight < h) + { + maxHeight = h; + } + if (minHeight > h) + { + minHeight = h; + } } else - { liquid_height[y][x] = CONF_use_minHeight; } + { + liquid_height[y][x] = CONF_use_minHeight; + } } } map.liquidMapOffset = map.heightMapOffset + map.heightMapSize; @@ -1009,7 +1051,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 liquidHeader.liquidType = type; } else - { map.liquidMapSize += sizeof(liquid_entry) + sizeof(liquid_flags); } + { + map.liquidMapSize += sizeof(liquid_entry) + sizeof(liquid_flags); + } if (!(liquidHeader.flags & MAP_LIQUID_NO_HEIGHT)) { @@ -1025,7 +1069,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 map.holesOffset = map.liquidMapOffset + map.liquidMapSize; } else - { map.holesOffset = map.heightMapOffset + map.heightMapSize; } + { + map.holesOffset = map.heightMapOffset + map.heightMapSize; + } map.holesSize = sizeof(holes); memset(holes, 0, map.holesSize); @@ -1283,7 +1329,7 @@ void LoadLocaleMPQFiles(int const locale) AppendPatchMPQFilesToList(Locales[locale], Locales[locale], NULL, updates); // now update to newer view, root AppendPatchMPQFilesToList(NULL, NULL, Locales[locale], updates); - + // ./Data wow-update-base files for (int i = 0; Builds[i] && Builds[i] <= CONF_TargetBuild; ++i) { @@ -1320,7 +1366,7 @@ void LoadLocaleMPQFiles(int const locale) //if (!OpenArchive(filename)) if (!SFileOpenPatchArchive(localeMpqHandle, filename, "", 0)) printf("Error open patch archive: %s\n\n", filename); - } + } // ./Data/Cache/ patch files for (int i = 0; Builds[i] && Builds[i] <= CONF_TargetBuild; ++i) @@ -1384,11 +1430,11 @@ void LoadBaseMPQFiles() printf("Error open patch archive: %s\n\n", filename); return; } - } - + } + // ./Data/Cache patch-base files for (int i = 0; Builds[i] && Builds[i] <= CONF_TargetBuild; ++i) - { + { sprintf(filename, "%s/Data/Cache/patch-base-%u.MPQ", input_path, Builds[i]); printf("\nPatching : %s\n", filename); @@ -1396,7 +1442,7 @@ void LoadBaseMPQFiles() //if (!OpenArchive(filename)) if (!SFileOpenPatchArchive(worldMpqHandle, filename, "", 0)) printf("Error open patch archive: %s\n\n", filename); - } + } } int main(int argc, char* arg[]) @@ -1443,7 +1489,7 @@ int main(int argc, char* arg[]) CloseArchives(); } } - + if (FirstLocale < 0) { printf("No locales detected\n"); diff --git a/src/tools/Extractor_projects/shared/ExtractorCommon.cpp b/src/tools/Extractor_projects/shared/ExtractorCommon.cpp index 565c0b837..41d65c9ee 100644 --- a/src/tools/Extractor_projects/shared/ExtractorCommon.cpp +++ b/src/tools/Extractor_projects/shared/ExtractorCommon.cpp @@ -42,7 +42,7 @@ /* This isn't the nicest way to do things.. * TODO: Fix this with snprintf instead and check that it still works */ -#define sprintf_s sprintf +#define sprintf_s sprintf #endif #if defined( __GNUC__ ) @@ -90,7 +90,7 @@ FILE* openWoWExe() /** * This function loads up a binary file (WoW executable), then searches for and returns * the build number of the file. The build number is searched for in hex form. -* +* * @PARAM sFilename is the filename of the WoW executable to be loaded * @RETURN iBuild the build number of the WoW executable, or 0 if failed */ @@ -392,10 +392,14 @@ bool CreateDir(const std::string& sPath) { #ifdef WIN32 if (_mkdir(sPath.c_str()) == 0) + { return 1; + } #else if (mkdir(sPath.c_str(), 0777) == 0) + { return 1; + } #endif return 0; // failed to create the directory } diff --git a/src/tools/Extractor_projects/vmap-assembler/vmap_assembler.cpp b/src/tools/Extractor_projects/vmap-assembler/vmap_assembler.cpp index 97cda08f0..8aeca52ff 100644 --- a/src/tools/Extractor_projects/vmap-assembler/vmap_assembler.cpp +++ b/src/tools/Extractor_projects/vmap-assembler/vmap_assembler.cpp @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) std::string src = argv[1]; std::string dest = argv[2]; - + std::cout << "using " << src << " as source directory and writing output to " << dest << std::endl; std::cout << "Create TileAssembler " << std::endl; diff --git a/src/tools/Extractor_projects/vmap-extractor/adtfile.cpp b/src/tools/Extractor_projects/vmap-extractor/adtfile.cpp index 54e4a932d..d4cc1b81e 100644 --- a/src/tools/Extractor_projects/vmap-extractor/adtfile.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/adtfile.cpp @@ -80,7 +80,9 @@ char const* GetExtension(char const* FileName) { char const* szTemp; if ((szTemp = strrchr(FileName, '.')) != NULL) + { return szTemp; + } return NULL; } @@ -93,7 +95,10 @@ ADTFile::ADTFile(char* filename): ADT(WorldMpq, filename) bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failedPaths) { - if (ADT.isEof()) { return false; } + if (ADT.isEof()) + { + return false; + } uint32 size; @@ -107,7 +112,7 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY, StringSet& failed xMap = TempMapNumber.substr(TempMapNumber.find("_") + 1, (TempMapNumber.find_last_of("_") - 1) - (TempMapNumber.find("_"))); yMap = TempMapNumber.substr(TempMapNumber.find_last_of("_") + 1, (TempMapNumber.length()) - (TempMapNumber.find_last_of("_"))); AdtFilename.erase((AdtFilename.length() - xMap.length() - yMap.length() - 2), (xMap.length() + yMap.length() + 2)); - + string AdtMapNumber = xMap + ' ' + yMap + ' ' + GetPlainName((char*)AdtFilename.c_str()); std::string dirname = std::string(szWorkDirWmo) + "/dir_bin"; diff --git a/src/tools/Extractor_projects/vmap-extractor/dbcfile.cpp b/src/tools/Extractor_projects/vmap-extractor/dbcfile.cpp index 64de2be7f..2e75858b3 100644 --- a/src/tools/Extractor_projects/vmap-extractor/dbcfile.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/dbcfile.cpp @@ -34,7 +34,9 @@ DBCFile::DBCFile(HANDLE mpq, const char* filename) : bool DBCFile::open() { if (!SFileOpenFileEx(_mpq, _filename, SFILE_OPEN_FROM_MPQ, &_file)) + { return false; + } char header[4]; unsigned int na, nb, es, ss; @@ -42,37 +44,51 @@ bool DBCFile::open() DWORD readBytes = 0; SFileReadFile(_file, header, 4, &readBytes, NULL); if (readBytes != 4) // Number of records + { return false; + } if (header[0] != 'W' || header[1] != 'D' || header[2] != 'B' || header[3] != 'C') + { return false; + } readBytes = 0; SFileReadFile(_file, &na, 4, &readBytes, NULL); if (readBytes != 4) // Number of records + { return false; + } readBytes = 0; SFileReadFile(_file, &nb, 4, &readBytes, NULL); if (readBytes != 4) // Number of fields + { return false; + } readBytes = 0; SFileReadFile(_file, &es, 4, &readBytes, NULL); if (readBytes != 4) // Size of a record + { return false; + } readBytes = 0; SFileReadFile(_file, &ss, 4, &readBytes, NULL); if (readBytes != 4) // String size + { return false; + } _recordSize = es; _recordCount = na; _fieldCount = nb; _stringSize = ss; if (_fieldCount * 4 != _recordSize) + { return false; + } _data = new unsigned char[_recordSize * _recordCount + _stringSize]; _stringTable = _data + _recordSize * _recordCount; @@ -81,7 +97,9 @@ bool DBCFile::open() readBytes = 0; SFileReadFile(_file, _data, data_size, &readBytes, NULL); if (readBytes != data_size) + { return false; + } return true; } diff --git a/src/tools/Extractor_projects/vmap-extractor/gameobject_extract.cpp b/src/tools/Extractor_projects/vmap-extractor/gameobject_extract.cpp index 06203fab2..addd8c92c 100644 --- a/src/tools/Extractor_projects/vmap-extractor/gameobject_extract.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/gameobject_extract.cpp @@ -27,11 +27,15 @@ bool ExtractSingleModel(std::string& origPath, std::string& fixedName, StringSet output += fixedName; if (FileExists(output.c_str())) + { return true; + } Model mdl(origPath); // Possible changed fname if (!mdl.open(failedPaths)) + { return false; + } return mdl.ConvertToVMAPModel(output.c_str()); } diff --git a/src/tools/Extractor_projects/vmap-extractor/model.cpp b/src/tools/Extractor_projects/vmap-extractor/model.cpp index 9877d4894..ef1d495f5 100644 --- a/src/tools/Extractor_projects/vmap-extractor/model.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/model.cpp @@ -182,7 +182,10 @@ ModelInstance::ModelInstance(MPQFile& f, const char* ModelInstName, uint32 mapID uint16 adtId = 0;// not used for models uint32 flags = MOD_M2; - if (tileX == 65 && tileY == 65) { flags |= MOD_WORLDSPAWN; } + if (tileX == 65 && tileY == 65) + { + flags |= MOD_WORLDSPAWN; + } //write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, name fwrite(&mapID, sizeof(uint32), 1, pDirfile); fwrite(&tileX, sizeof(uint32), 1, pDirfile); diff --git a/src/tools/Extractor_projects/vmap-extractor/mpqfile.h b/src/tools/Extractor_projects/vmap-extractor/mpqfile.h index 4e749299c..5a61fb81f 100644 --- a/src/tools/Extractor_projects/vmap-extractor/mpqfile.h +++ b/src/tools/Extractor_projects/vmap-extractor/mpqfile.h @@ -56,9 +56,9 @@ class MPQFile public: MPQFile(HANDLE mpq, const char* filename); // filenames are not case sensitive - ~MPQFile() - { - close(); + ~MPQFile() + { + close(); } size_t read(void* dest, size_t bytes); size_t getSize() { return size; } diff --git a/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp b/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp index 264909874..24373388b 100644 --- a/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp @@ -481,7 +481,9 @@ bool ExtractSingleWmo(std::string& fname) fixnamen(szLocalFile, strlen(szLocalFile)); if (FileExists(szLocalFile)) + { return true; + } int p = 0; //Select root wmo files @@ -499,7 +501,9 @@ bool ExtractSingleWmo(std::string& fname) } if (p == 3) + { return true; + } bool file_ok = true; std::cout << "Extracting " << fname << std::endl; diff --git a/src/tools/Extractor_projects/vmap-extractor/wmo.cpp b/src/tools/Extractor_projects/vmap-extractor/wmo.cpp index dc2388550..eb614351e 100644 --- a/src/tools/Extractor_projects/vmap-extractor/wmo.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/wmo.cpp @@ -418,9 +418,13 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool pPrecis liquidEntry = liquidType; } else if (liquidType == 15) - { liquidEntry = 0; } + { + liquidEntry = 0; + } else - { liquidEntry = liquidType + 1; } + { + liquidEntry = liquidType + 1; + } if (!liquidEntry) { @@ -559,7 +563,10 @@ WMOInstance::WMOInstance(MPQFile& f, const char* WmoInstName, uint32 mapID, uint float scale = 1.0f; uint32 flags = MOD_HAS_BOUND; - if (tileX == 65 && tileY == 65) { flags |= MOD_WORLDSPAWN; } + if (tileX == 65 && tileY == 65) + { + flags |= MOD_WORLDSPAWN; + } //write mapID, tileX, tileY, Flags, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name fwrite(&mapID, sizeof(uint32), 1, pDirfile); fwrite(&tileX, sizeof(uint32), 1, pDirfile);