From 35405dd5493e9eda49e4babb2da8ea43ca87b85f Mon Sep 17 00:00:00 2001 From: Antz Date: Fri, 10 Jan 2020 23:13:44 +0000 Subject: [PATCH] Apply style fix --- src/framework/Dynamic/ObjectRegistry.h | 8 +- src/framework/GameSystem/Grid.h | 8 +- src/framework/GameSystem/GridReference.h | 4 +- src/framework/GameSystem/TypeContainer.h | 4 +- src/framework/Policies/CreationPolicy.h | 4 +- src/framework/Utilities/EventProcessor.cpp | 12 +- .../Utilities/LinkedReference/Reference.h | 4 +- src/game/AuctionHouseBot/AuctionHouseBot.cpp | 292 +++- src/game/BattleGround/BattleGround.cpp | 224 ++- src/game/BattleGround/BattleGround.h | 12 +- src/game/BattleGround/BattleGroundAB.cpp | 132 +- src/game/BattleGround/BattleGroundAV.cpp | 192 ++- src/game/BattleGround/BattleGroundHandler.cpp | 94 +- src/game/BattleGround/BattleGroundMgr.cpp | 136 +- src/game/BattleGround/BattleGroundMgr.h | 12 +- src/game/BattleGround/BattleGroundWS.cpp | 120 +- src/game/ChatCommands/Level0.cpp | 20 +- src/game/ChatCommands/Level1.cpp | 496 +++++-- src/game/ChatCommands/Level2.cpp | 920 +++++++++--- src/game/ChatCommands/Level3.cpp | 1292 ++++++++++++----- src/game/ChatCommands/Level4.cpp | 84 +- src/game/ChatCommands/debugcmds.cpp | 276 +++- .../ConfusedMovementGenerator.cpp | 16 +- .../FleeingMovementGenerator.cpp | 24 +- .../HomeMovementGenerator.cpp | 8 +- .../IdleMovementGenerator.cpp | 4 +- src/game/MotionGenerators/MotionMaster.cpp | 144 +- src/game/MotionGenerators/MotionMaster.h | 8 +- src/game/MotionGenerators/PathFinder.cpp | 68 +- .../PointMovementGenerator.cpp | 40 +- .../RandomMovementGenerator.cpp | 8 +- .../TargetedMovementGenerator.cpp | 64 +- .../WaypointMovementGenerator.cpp | 88 +- src/game/Object/AggressorAI.cpp | 20 +- src/game/Object/AuctionHouseMgr.cpp | 88 +- src/game/Object/Bag.cpp | 52 +- src/game/Object/Bag.h | 4 +- src/game/Object/Camera.cpp | 24 +- src/game/Object/Corpse.cpp | 28 +- src/game/Object/Creature.cpp | 644 ++++++-- src/game/Object/Creature.h | 16 +- src/game/Object/CreatureAI.cpp | 48 +- src/game/Object/CreatureAISelector.cpp | 16 +- src/game/Object/CreatureEventAI.cpp | 446 ++++-- src/game/Object/CreatureEventAIMgr.cpp | 264 +++- src/game/Object/DynamicObject.cpp | 24 +- src/game/Object/Formulas.h | 20 +- src/game/Object/GMTicketMgr.cpp | 8 +- src/game/Object/GMTicketMgr.h | 16 +- src/game/Object/GameObject.cpp | 576 ++++++-- src/game/Object/GameObject.h | 4 +- src/game/Object/GuardAI.cpp | 24 +- src/game/Object/Guild.cpp | 148 +- src/game/Object/Guild.h | 8 +- src/game/Object/Item.cpp | 272 +++- src/game/Object/LootMgr.cpp | 252 +++- src/game/Object/Object.cpp | 232 ++- src/game/Object/Object.h | 40 +- src/game/Object/ObjectAccessor.cpp | 52 +- src/game/Object/ObjectGuid.cpp | 8 +- src/game/Object/ObjectMgr.cpp | 944 +++++++++--- src/game/Object/ObjectMgr.h | 68 +- src/game/Object/ObjectPosSelector.cpp | 28 +- src/game/Object/Pet.cpp | 300 +++- src/game/Object/PetAI.cpp | 76 +- src/game/Object/Player.cpp | 148 +- src/game/Object/Player.h | 40 +- src/game/Object/StatSystem.cpp | 36 +- src/game/Object/Unit.cpp | 406 ++++-- src/game/Object/Unit.h | 48 +- src/game/OutdoorPvP/OutdoorPvP.cpp | 40 +- src/game/OutdoorPvP/OutdoorPvPEP.cpp | 40 +- src/game/OutdoorPvP/OutdoorPvPMgr.cpp | 16 +- src/game/OutdoorPvP/OutdoorPvPSI.cpp | 36 +- src/game/References/ThreatManager.cpp | 60 +- src/game/Server/DBCStores.cpp | 4 +- src/game/Server/SharedDefines.h | 4 +- src/game/Server/WorldSession.cpp | 86 +- src/game/Server/WorldSession.h | 4 +- src/game/Server/WorldSocket.cpp | 80 +- src/game/Server/WorldSocketMgr.cpp | 4 +- src/game/Tools/CharacterDatabaseCleaner.cpp | 16 +- src/game/Tools/PlayerDump.cpp | 184 ++- src/game/WorldHandlers/AccountMgr.cpp | 24 +- src/game/WorldHandlers/ChatHandler.cpp | 12 +- src/game/WorldHandlers/GridDefines.h | 20 +- src/game/WorldHandlers/GroupHandler.cpp | 18 +- src/game/WorldHandlers/InstanceData.cpp | 12 +- src/game/WorldHandlers/Map.cpp | 212 ++- src/game/WorldHandlers/MoveMap.cpp | 20 +- src/game/WorldHandlers/ScriptMgr.cpp | 344 +++-- src/game/WorldHandlers/Spell.cpp | 12 +- src/game/WorldHandlers/SpellAuras.cpp | 1052 ++++++++++---- src/game/movement/MoveSpline.cpp | 20 +- src/game/movement/MoveSplineInit.cpp | 16 +- src/game/movement/packet_builder.cpp | 4 +- src/game/movement/spline.cpp | 8 +- src/game/movement/typedefs.h | 4 +- src/game/movement/util.cpp | 24 +- src/game/vmap/BIH.cpp | 20 +- src/game/vmap/BIH.h | 56 +- src/game/vmap/BIHWrap.h | 24 +- src/game/vmap/DynamicTree.cpp | 20 +- src/game/vmap/GameObjectModel.cpp | 28 +- src/game/vmap/MapTree.cpp | 64 +- src/game/vmap/ModelInstance.cpp | 20 +- src/game/vmap/RegularGrid.h | 36 +- src/game/vmap/TileAssembler.cpp | 56 +- src/game/vmap/VMapFactory.cpp | 4 +- src/game/vmap/VMapManager2.cpp | 16 +- src/game/vmap/WorldModel.cpp | 72 +- src/mangosd/SOAP/SoapThread.cpp | 4 +- src/shared/Auth/BigNumber.cpp | 4 +- src/shared/Common/Common.cpp | 4 +- src/shared/Config/Config.cpp | 16 +- src/shared/DataStores/DB2FileLoader.cpp | 16 +- src/shared/DataStores/DBCFileLoader.cpp | 24 +- src/shared/DataStores/DBCStore.h | 16 +- src/shared/Database/Database.cpp | 100 +- src/shared/Database/Database.h | 4 +- src/shared/Database/DatabaseMysql.cpp | 64 +- src/shared/Database/DatabasePostgre.cpp | 60 +- src/shared/Database/Field.h | 4 +- src/shared/Database/QueryResult.h | 4 +- src/shared/Database/QueryResultMysql.cpp | 4 +- src/shared/Database/QueryResultPostgre.cpp | 8 +- src/shared/Database/SQLStorage.cpp | 8 +- src/shared/Database/SQLStorage.h | 8 +- src/shared/Database/SQLStorageImpl.h | 8 +- src/shared/Database/SqlOperations.cpp | 20 +- src/shared/Database/SqlPreparedStatement.cpp | 16 +- src/shared/Database/SqlPreparedStatement.h | 8 +- src/shared/LockedQueue/LockedQueue.h | 12 +- src/shared/Log/Log.cpp | 240 ++- src/shared/Log/Log.h | 32 +- src/shared/Threading/Threading.cpp | 44 +- src/shared/Threading/Threading.h | 4 +- src/shared/Utilities/ByteBuffer.h | 28 +- src/shared/Utilities/ProgressBar.cpp | 12 +- src/shared/Utilities/Timer.h | 12 +- src/shared/Utilities/Util.cpp | 82 +- src/shared/Utilities/Util.h | 176 ++- src/shared/Win/ServiceWin32.cpp | 4 +- src/shared/Win/WheatyExceptionReport.cpp | 76 +- .../Movemap-Generator/IntermediateValues.cpp | 56 +- .../Movemap-Generator/MMapCommon.h | 28 +- .../Movemap-Generator/MapBuilder.cpp | 68 +- .../Movemap-Generator/TerrainBuilder.cpp | 84 +- .../Movemap-Generator/generator.cpp | 92 +- .../map-extractor/System.cpp | 104 +- .../map-extractor/dbcfile.cpp | 4 +- .../vmap-extractor/model.cpp | 4 +- .../vmap-extractor/vmapexport.cpp | 4 +- .../vmap-extractor/wdtfile.cpp | 4 +- .../Extractor_projects/vmap-extractor/wmo.cpp | 20 +- 155 files changed, 10968 insertions(+), 3660 deletions(-) diff --git a/src/framework/Dynamic/ObjectRegistry.h b/src/framework/Dynamic/ObjectRegistry.h index 0bb097c30..019450ae4 100644 --- a/src/framework/Dynamic/ObjectRegistry.h +++ b/src/framework/Dynamic/ObjectRegistry.h @@ -73,7 +73,9 @@ class ObjectRegistry if (iter != i_registeredObjects.end()) { if (!replace) - { return false; } + { + return false; + } delete iter->second; i_registeredObjects.erase(iter); } @@ -94,7 +96,9 @@ class ObjectRegistry if (iter != i_registeredObjects.end()) { if (delete_object) - { delete iter->second; } + { + delete iter->second; + } i_registeredObjects.erase(iter); } } diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index 2c5b8bdac..8b7bd53fc 100644 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -131,7 +131,9 @@ class Grid bool AddGridObject(SPECIFIC_OBJECT* obj) { if (obj->IsActiveObject()) - { m_activeGridObjects.insert(obj); } + { + m_activeGridObjects.insert(obj); + } return i_container.template insert(obj); } @@ -146,7 +148,9 @@ class Grid bool RemoveGridObject(SPECIFIC_OBJECT* obj) { if (obj->IsActiveObject()) - { m_activeGridObjects.erase(obj); } + { + m_activeGridObjects.erase(obj); + } return i_container.template remove(obj); } diff --git a/src/framework/GameSystem/GridReference.h b/src/framework/GameSystem/GridReference.h index f874bef62..3fb162630 100644 --- a/src/framework/GameSystem/GridReference.h +++ b/src/framework/GameSystem/GridReference.h @@ -57,7 +57,9 @@ class GridReference : public Reference, OBJECT> { // called from unlink() if (this->isValid()) - { this->getTarget()->decSize(); } + { + this->getTarget()->decSize(); + } } /** diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h index 33fccebdb..5c777aca4 100644 --- a/src/framework/GameSystem/TypeContainer.h +++ b/src/framework/GameSystem/TypeContainer.h @@ -208,7 +208,9 @@ class TypeUnorderedMapContainer { typename UNORDERED_MAP::iterator i = elements._element.find(hdl); if (i == elements._element.end()) - { return NULL; } + { + return NULL; + } else { return i->second; } } diff --git a/src/framework/Policies/CreationPolicy.h b/src/framework/Policies/CreationPolicy.h index acc5c038f..a61bdb1f9 100644 --- a/src/framework/Policies/CreationPolicy.h +++ b/src/framework/Policies/CreationPolicy.h @@ -137,7 +137,9 @@ namespace MaNGOS void* p = malloc(sizeof(T)); if (!p) - { return NULL; } + { + return NULL; + } return new(p) T; } diff --git a/src/framework/Utilities/EventProcessor.cpp b/src/framework/Utilities/EventProcessor.cpp index fe3c3d347..1936cd8e7 100644 --- a/src/framework/Utilities/EventProcessor.cpp +++ b/src/framework/Utilities/EventProcessor.cpp @@ -82,19 +82,25 @@ void EventProcessor::KillAllEvents(bool force) delete i_old->second; if (!force) // need per-element cleanup - { m_events.erase(i_old); } + { + m_events.erase(i_old); + } } } // fast clear event list (in force case) if (force) - { m_events.clear(); } + { + m_events.clear(); + } } void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime) { if (set_addtime) - { Event->m_addTime = m_time; } + { + Event->m_addTime = m_time; + } Event->m_execTime = e_time; m_events.insert(std::pair(e_time, Event)); diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h index acb5f4c4d..524dface4 100644 --- a/src/framework/Utilities/LinkedReference/Reference.h +++ b/src/framework/Utilities/LinkedReference/Reference.h @@ -88,7 +88,9 @@ class Reference : public LinkedListElement { assert(fromObj); // fromObj MUST not be NULL if (isValid()) - { unlink(); } + { + unlink(); + } if (toObj != NULL) { diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/game/AuctionHouseBot/AuctionHouseBot.cpp index b0b30fd6c..73442ef4a 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -144,7 +144,9 @@ class AHB_Seller_Config uint32 GetMinTime() const { if (m_minTime < 1) - { return 1; } + { + return 1; + } else if ((m_maxTime) && (m_minTime > m_maxTime)) { return m_maxTime; } else @@ -161,7 +163,9 @@ class AHB_Seller_Config void SetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass, uint32 found) { if (m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems > found) - { m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems = m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems - found; } + { + m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems = m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems - found; + } else { m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems = 0; } } @@ -421,10 +425,14 @@ bool AuctionBotConfig::Initialize() return false; } if ((getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO) == 0) && (getConfig(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO) == 0) && (getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_ITEM_AMOUNT_RATIO) == 0)) - { sLog.outString("AuctionHouseBot SELLER is disabled! (If you want to use it please set config in 'ahbot.conf')"); } + { + sLog.outString("AuctionHouseBot SELLER is disabled! (If you want to use it please set config in 'ahbot.conf')"); + } if (!getConfig(CONFIG_BOOL_AHBOT_BUYER_ALLIANCE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_HORDE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_NEUTRAL_ENABLED)) - { sLog.outString("AuctionHouseBot BUYER is disabled! (If you want to use it please set config in 'ahbot.conf')"); } + { + sLog.outString("AuctionHouseBot BUYER is disabled! (If you want to use it please set config in 'ahbot.conf')"); + } m_ItemsPerCycleBoost = getConfig(CONFIG_UINT32_AHBOT_ITEMS_PER_CYCLE_BOOST); m_ItemsPerCycleNormal = getConfig(CONFIG_UINT32_AHBOT_ITEMS_PER_CYCLE_NORMAL); @@ -439,7 +447,9 @@ void AuctionBotConfig::SetAHBotId(const std::string& BotCharName) { m_BotId = sObjectMgr.GetPlayerGuidByName(BotCharName.c_str()).GetCounter(); if (!m_BotId) - { sLog.outError("AHBot uses an invalid character name `%s`", BotCharName.c_str()); } + { + sLog.outError("AHBot uses an invalid character name `%s`", BotCharName.c_str()); + } } } @@ -488,7 +498,9 @@ void AuctionBotConfig::GetConfigFromFile() { // Check config file version if (m_AhBotCfg.GetIntDefault("ConfVersion", 0) != AUCTIONHOUSEBOT_CONF_VERSION) - { sLog.outError("AHBot: Configuration file version doesn't match expected version. Some config variables may be wrong or missing."); } + { + sLog.outError("AHBot: Configuration file version doesn't match expected version. Some config variables may be wrong or missing."); + } setConfigMax(CONFIG_UINT32_AHBOT_ALLIANCE_ITEM_AMOUNT_RATIO , "AuctionHouseBot.Alliance.Items.Amount.Ratio" , 100, 10000); setConfigMax(CONFIG_UINT32_AHBOT_HORDE_ITEM_AMOUNT_RATIO , "AuctionHouseBot.Horde.Items.Amount.Ratio" , 100, 10000); @@ -664,7 +676,9 @@ bool AuctionBotBuyer::Initialize() } } if (!active_house) - { return false; } + { + return false; + } // load Check interval m_CheckInterval = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_BUYER_RECHECK_INTERVAL) * MINUTE; @@ -700,7 +714,9 @@ void AuctionBotBuyer::LoadConfig() { m_HouseConfig[i].BuyerEnabled = sAuctionBotConfig.getConfigBuyerEnabled(AuctionHouseType(i)); if (m_HouseConfig[i].BuyerEnabled) - { LoadBuyerValues(m_HouseConfig[i]); } + { + LoadBuyerValues(m_HouseConfig[i]); + } } } @@ -727,12 +743,16 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config) if (Aentry->buyout != 0) { if (Aentry->buyout / item->GetCount() < buyerItem.MinBuyPrice) - { buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount(); } + { + buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount(); + } else if (buyerItem.MinBuyPrice == 0) { buyerItem.MinBuyPrice = Aentry->buyout / item->GetCount(); } } if (Aentry->startbid / item->GetCount() < buyerItem.MinBidPrice) - { buyerItem.MinBidPrice = Aentry->startbid / item->GetCount(); } + { + buyerItem.MinBidPrice = Aentry->startbid / item->GetCount(); + } else if (buyerItem.MinBidPrice == 0) { buyerItem.MinBidPrice = Aentry->startbid / item->GetCount(); } @@ -779,7 +799,9 @@ void AuctionBotBuyer::PrepareListOfEntry(AHB_Buyer_Config& config) for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();) { if (itr->second.LastExist < (Now - 5)) - { config.CheckedEntry.erase(itr++); } + { + config.CheckedEntry.erase(itr++); + } else { ++itr; } } @@ -794,14 +816,18 @@ bool AuctionBotBuyer::IsBuyableEntry(uint64 buyoutPrice, double InGame_BuyPrice, if (buyoutPrice <= MinBuyPrice) { if (buyoutPrice <= MaxBuyablePrice) - { Chance = MaxChance; } + { + Chance = MaxChance; + } else { if ((buyoutPrice > 0) && (MaxBuyablePrice > 0)) { double ratio = buyoutPrice / MaxBuyablePrice; if (ratio < 10) - { Chance = MaxChance - (ratio * (MaxChance / 10)); } + { + Chance = MaxChance - (ratio * (MaxChance / 10)); + } else { Chance = 1; } } } @@ -809,14 +835,18 @@ bool AuctionBotBuyer::IsBuyableEntry(uint64 buyoutPrice, double InGame_BuyPrice, else if (buyoutPrice <= InGame_BuyPrice) { if (buyoutPrice <= MaxBuyablePrice) - { Chance = MaxChance / 5; } + { + Chance = MaxChance / 5; + } else { if ((buyoutPrice > 0) && (MaxBuyablePrice > 0)) { double ratio = buyoutPrice / MaxBuyablePrice; if (ratio < 10) - { Chance = (MaxChance / 5) - (ratio * (MaxChance / 50)); } + { + Chance = (MaxChance / 5) - (ratio * (MaxChance / 50)); + } else { Chance = 1; } } } @@ -829,7 +859,9 @@ bool AuctionBotBuyer::IsBuyableEntry(uint64 buyoutPrice, double InGame_BuyPrice, { double ratio = buyoutPrice / MaxBuyablePrice; if (ratio < 10) - { Chance = (MaxChance / 5) - (ratio * (MaxChance / 50)); } + { + Chance = (MaxChance / 5) - (ratio * (MaxChance / 50)); + } else { Chance = 0; } } else { Chance = 0; } @@ -852,14 +884,18 @@ bool AuctionBotBuyer::IsBidableEntry(uint64 bidPrice, double InGame_BuyPrice, do if (bidPrice <= MinBidPrice) { if ((InGame_BuyPrice != 0) && (bidPrice < (InGame_BuyPrice - (InGame_BuyPrice / 30)))) - { Chance = MaxChance; } + { + Chance = MaxChance; + } else { if (bidPrice < MaxBidablePrice) { double ratio = MaxBidablePrice / bidPrice; if (ratio < 3) - { Chance = ((MaxChance / 500) * ratio); } + { + Chance = ((MaxChance / 500) * ratio); + } else { Chance = (MaxChance / 500); } } @@ -873,7 +909,9 @@ bool AuctionBotBuyer::IsBidableEntry(uint64 bidPrice, double InGame_BuyPrice, do { double ratio = MaxBidablePrice / bidPrice; if (ratio < 4) - { Chance = ((MaxChance / 1000) * ratio); } + { + Chance = ((MaxChance / 1000) * ratio); + } else { Chance = (MaxChance / 1000); } } @@ -940,7 +978,9 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) } if (BuyCycles == 0) - { break; } + { + break; + } uint32 MaxChance = 5000; @@ -1024,12 +1064,16 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) else { if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, minBidPrice, MaxChance / 2, config.FactionChance)) - { PlaceBidToEntry(auction, bidPrice); } + { + PlaceBidToEntry(auction, bidPrice); + } } } else // buyout = 0 mean only bid are possible if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, minBidPrice, MaxChance, config.FactionChance)) - { PlaceBidToEntry(auction, bidPrice); } + { + PlaceBidToEntry(auction, bidPrice); + } auctionEval.LastChecked = Now; --BuyCycles; @@ -1044,7 +1088,9 @@ bool AuctionBotBuyer::Update(AuctionHouseType houseType) { DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: %s buying ...", AuctionBotConfig::GetHouseTypeName(houseType)); if (GetBuyableEntry(m_HouseConfig[houseType]) > 0) - { addNewAuctionBuyerBotBid(m_HouseConfig[houseType]); } + { + addNewAuctionBuyerBotBid(m_HouseConfig[houseType]); + } return true; } else { return false; } @@ -1132,7 +1178,9 @@ bool AuctionBotSeller::Initialize() uint32 entry = fields[0].GetUInt32(); if (!entry) - { continue; } + { + continue; + } lootItems.push_back(fields[0].GetUInt32()); } @@ -1159,25 +1207,35 @@ bool AuctionBotSeller::Initialize() bar.step(); if (!prototype) - { continue; } + { + continue; + } // skip items with too high quality (code can't propertly work with its) if (prototype->Quality >= MAX_AUCTION_QUALITY) - { continue; } + { + continue; + } // forced exclude filter bool isExcludeItem = false; for (size_t i = 0; (i < excludeItems.size() && (!isExcludeItem)); ++i) if (itemID == excludeItems[i]) - { isExcludeItem = true; } + { + isExcludeItem = true; + } if (isExcludeItem) - { continue; } + { + continue; + } // forced include filter bool isForcedIncludeItem = false; for (size_t i = 0; (i < includeItems.size() && (!isForcedIncludeItem)); ++i) if (itemID == includeItems[i]) - { isForcedIncludeItem = true; } + { + isForcedIncludeItem = true; + } if (isForcedIncludeItem) { @@ -1191,23 +1249,33 @@ bool AuctionBotSeller::Initialize() { case NO_BIND: if (!sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BIND_NO)) - { continue; } + { + continue; + } break; case BIND_WHEN_PICKED_UP: if (!sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BIND_PICKUP)) - { continue; } + { + continue; + } break; case BIND_WHEN_EQUIPPED: if (!sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BIND_EQUIP)) - { continue; } + { + continue; + } break; case BIND_WHEN_USE: if (!sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BIND_USE)) - { continue; } + { + continue; + } break; case BIND_QUEST_ITEM: if (!sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BIND_QUEST)) - { continue; } + { + continue; + } break; default: continue; @@ -1217,12 +1285,16 @@ bool AuctionBotSeller::Initialize() if (sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BUYPRICE_SELLER)) { if (prototype->BuyPrice == 0) - { continue; } + { + continue; + } } else { if (prototype->SellPrice == 0) - { continue; } + { + continue; + } } // vendor filter @@ -1231,10 +1303,14 @@ bool AuctionBotSeller::Initialize() bool IsVendorItem = false; for (size_t i = 0; (i < npcItems.size()) && (!IsVendorItem); ++i) if (itemID == npcItems[i]) - { IsVendorItem = true; } + { + IsVendorItem = true; + } if (IsVendorItem) - { continue; } + { + continue; + } } // loot filter @@ -1243,9 +1319,13 @@ bool AuctionBotSeller::Initialize() bool isLootItem = false; for (size_t i = 0; (i < lootItems.size()) && (!isLootItem); ++i) if (itemID == lootItems[i]) - { isLootItem = true; } + { + isLootItem = true; + } if (isLootItem) - { continue; } + { + continue; + } } // not vendor/loot filter @@ -1256,14 +1336,20 @@ bool AuctionBotSeller::Initialize() for (size_t i = 0; (i < npcItems.size()) && (!IsVendorItem); ++i) if (itemID == npcItems[i]) - { IsVendorItem = true; } + { + IsVendorItem = true; + } for (size_t i = 0; (i < lootItems.size()) && (!isLootItem); ++i) if (itemID == lootItems[i]) - { isLootItem = true; } + { + isLootItem = true; + } if ((!isLootItem) && (!IsVendorItem)) - { continue; } + { + continue; + } } // item class/subclass specific filters @@ -1275,32 +1361,44 @@ bool AuctionBotSeller::Initialize() if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MIN_ITEM_LEVEL)) { if (prototype->ItemLevel < value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MAX_ITEM_LEVEL)) { if (prototype->ItemLevel > value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MIN_REQ_LEVEL)) { if (prototype->RequiredLevel < value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MAX_REQ_LEVEL)) { if (prototype->RequiredLevel > value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MIN_SKILL_RANK)) { if (prototype->RequiredSkillRank < value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MAX_SKILL_RANK)) { if (prototype->RequiredSkillRank > value) - { continue; } + { + continue; + } } break; } @@ -1311,22 +1409,30 @@ bool AuctionBotSeller::Initialize() if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MIN_REQ_LEVEL)) { if (prototype->RequiredLevel < value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MAX_REQ_LEVEL)) { if (prototype->RequiredLevel > value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MIN_SKILL_RANK)) { if (prototype->RequiredSkillRank < value) - { continue; } + { + continue; + } } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ITEM_MAX_SKILL_RANK)) { if (prototype->RequiredSkillRank > value) - { continue; } + { + continue; + } } break; } @@ -1351,10 +1457,14 @@ bool AuctionBotSeller::Initialize() { // skip any not locked lootable items (mostly quest specific or reward cases) if (!prototype->LockID) - { continue; } + { + continue; + } if (!sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_LOCKBOX_ENABLED)) - { continue; } + { + continue; + } } break; @@ -1378,10 +1488,14 @@ bool AuctionBotSeller::Initialize() { if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_TRADEGOOD_MIN_ITEM_LEVEL)) if (prototype->ItemLevel < value) - { continue; } + { + continue; + } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_TRADEGOOD_MAX_ITEM_LEVEL)) if (prototype->ItemLevel > value) - { continue; } + { + continue; + } break; } case ITEM_CLASS_CONTAINER: @@ -1389,10 +1503,14 @@ bool AuctionBotSeller::Initialize() { if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_CONTAINER_MIN_ITEM_LEVEL)) if (prototype->ItemLevel < value) - { continue; } + { + continue; + } if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_CONTAINER_MAX_ITEM_LEVEL)) if (prototype->ItemLevel > value) - { continue; } + { + continue; + } break; } @@ -1436,7 +1554,9 @@ void AuctionBotSeller::LoadConfig() { for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i) if (sAuctionBotConfig.getConfigItemAmountRatio(AuctionHouseType(i))) - { LoadSellerValues(m_HouseConfig[i]); } + { + LoadSellerValues(m_HouseConfig[i]); + } } void AuctionBotSeller::LoadItemsQuantity(AHB_Seller_Config& config) @@ -1721,7 +1841,9 @@ void AuctionBotSeller::SetItemsRatio(uint32 al, uint32 ho, uint32 ne) void AuctionBotSeller::SetItemsRatioForHouse(AuctionHouseType house, uint32 val) { if (val > 10000) // apply same upper limit as used for config load - { val = 10000; } + { + val = 10000; + } switch (house) { @@ -1831,7 +1953,9 @@ void AuctionBotSeller::addNewAuctions(AHB_Seller_Config& config) uint64 bidPrice = 0; // Not sure if i will keep the next test if (sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BUYPRICE_SELLER)) - { buyoutPrice = prototype->BuyPrice * item->GetCount(); } + { + buyoutPrice = prototype->BuyPrice * item->GetCount(); + } else { buyoutPrice = prototype->SellPrice * item->GetCount(); } // Price of items are set here @@ -1847,7 +1971,9 @@ bool AuctionBotSeller::Update(AuctionHouseType houseType) { DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: %s selling ...", AuctionBotConfig::GetHouseTypeName(houseType)); if (SetStat(m_HouseConfig[houseType])) - { addNewAuctions(m_HouseConfig[houseType]); } + { + addNewAuctions(m_HouseConfig[houseType]); + } return true; } else @@ -1901,25 +2027,33 @@ void AuctionHouseBot::Initialize() void AuctionHouseBot::SetItemsRatio(uint32 al, uint32 ho, uint32 ne) { if (AuctionBotSeller* seller = dynamic_cast(m_Seller)) - { seller->SetItemsRatio(al, ho, ne); } + { + seller->SetItemsRatio(al, ho, ne); + } } void AuctionHouseBot::SetItemsRatioForHouse(AuctionHouseType house, uint32 val) { if (AuctionBotSeller* seller = dynamic_cast(m_Seller)) - { seller->SetItemsRatioForHouse(house, val); } + { + seller->SetItemsRatioForHouse(house, val); + } } void AuctionHouseBot::SetItemsAmount(uint32(&vals) [MAX_AUCTION_QUALITY]) { if (AuctionBotSeller* seller = dynamic_cast(m_Seller)) - { seller->SetItemsAmount(vals); } + { + seller->SetItemsAmount(vals); + } } void AuctionHouseBot::SetItemsAmountForQuality(AuctionQuality quality, uint32 val) { if (AuctionBotSeller* seller = dynamic_cast(m_Seller)) - { seller->SetItemsAmountForQuality(quality, val); } + { + seller->SetItemsAmountForQuality(quality, val); + } } bool AuctionHouseBot::ReloadAllConfig() @@ -1953,7 +2087,9 @@ void AuctionHouseBot::PrepareStatusInfos(AuctionHouseBotStatusInfo& statusInfo) if (Aentry->owner == sAuctionBotConfig.GetAHBotId()) // Add only ahbot items { if (prototype->Quality < MAX_AUCTION_QUALITY) - { ++statusInfo[i].QualityInfo[prototype->Quality]; } + { + ++statusInfo[i].QualityInfo[prototype->Quality]; + } ++statusInfo[i].ItemsCount; } @@ -1982,7 +2118,9 @@ void AuctionHouseBot::Update() { // nothing do... if (!m_Buyer && !m_Seller) - { return; } + { + return; + } // scan all possible update cases until first success for (uint32 count = 0; count < 2 * MAX_AUCTION_HOUSE_TYPE; ++count) @@ -1992,21 +2130,29 @@ void AuctionHouseBot::Update() if (m_OperationSelector < MAX_AUCTION_HOUSE_TYPE) { if (m_Seller) - { successStep = m_Seller->Update(AuctionHouseType(m_OperationSelector)); } + { + successStep = m_Seller->Update(AuctionHouseType(m_OperationSelector)); + } } else { if (m_Buyer) - { successStep = m_Buyer->Update(AuctionHouseType(m_OperationSelector - MAX_AUCTION_HOUSE_TYPE)); } + { + successStep = m_Buyer->Update(AuctionHouseType(m_OperationSelector - MAX_AUCTION_HOUSE_TYPE)); + } } ++m_OperationSelector; if (m_OperationSelector >= 2 * MAX_AUCTION_HOUSE_TYPE) - { m_OperationSelector = 0; } + { + m_OperationSelector = 0; + } // one success update per call if (successStep) - { break; } + { + break; + } } } /** @} */ diff --git a/src/game/BattleGround/BattleGround.cpp b/src/game/BattleGround/BattleGround.cpp index 13e515cad..d45febfb8 100644 --- a/src/game/BattleGround/BattleGround.cpp +++ b/src/game/BattleGround/BattleGround.cpp @@ -211,7 +211,9 @@ void BattleGround::BroadcastWorker(Do& _do) { for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) if (Player* plr = ObjectAccessor::FindPlayer(itr->first)) - { _do(plr); } + { + _do(plr); + } } BattleGround::BattleGround(): m_BuffChange(false), m_ArenaBuffSpawned(false), m_StartDelayTime(0), m_startMaxDist(0) @@ -300,12 +302,16 @@ BattleGround::~BattleGround() // skip template bgs as they were never added to visible bg list BattleGroundBracketId bracketId = GetBracketId(); if (bracketId != BG_BRACKET_ID_TEMPLATE) - { sBattleGroundMgr.DeleteClientVisibleInstanceId(GetTypeID(), bracketId, GetClientInstanceID()); } + { + sBattleGroundMgr.DeleteClientVisibleInstanceId(GetTypeID(), bracketId, GetClientInstanceID()); + } // unload map // map can be null at bg destruction if (m_Map) - { m_Map->SetUnload(); } + { + m_Map->SetUnload(); + } // remove from bg free slot queue this->RemoveFromBGFreeSlotQueue(); @@ -333,7 +339,9 @@ void BattleGround::Update(uint32 diff) // ]] // BattleGround Template instance can not be updated, because it would be deleted if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE)) - { delete this; } + { + delete this; + } return; } @@ -377,13 +385,17 @@ void BattleGround::Update(uint32 diff) if (newtime > (MINUTE * IN_MILLISECONDS)) { if (newtime / (MINUTE * IN_MILLISECONDS) != m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS)) - { PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))); } + { + PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))); + } } else { // announce every 15 seconds if (newtime / (15 * IN_MILLISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILLISECONDS)) - { PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / IN_MILLISECONDS)); } + { + PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, CHAT_MSG_SYSTEM, NULL, (uint32)(m_PrematureCountDownTimer / IN_MILLISECONDS)); + } } m_PrematureCountDownTimer = newtime; } @@ -438,7 +450,9 @@ void BattleGround::Update(uint32 diff) SetStartDelayTime(m_StartDelayTimes[BG_STARTING_EVENT_FIRST]); // first start warning - 2 or 1 minute, only if defined if (m_StartMessageIds[BG_STARTING_EVENT_FIRST]) - { SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FIRST], CHAT_MSG_BG_SYSTEM_NEUTRAL); } + { + SendMessageToAll(m_StartMessageIds[BG_STARTING_EVENT_FIRST], CHAT_MSG_BG_SYSTEM_NEUTRAL); + } } // After 1 minute or 30 seconds, warning is signalled else if (GetStartDelayTime() <= m_StartDelayTimes[BG_STARTING_EVENT_SECOND] && !(m_Events & BG_STARTING_EVENT_2)) @@ -551,10 +565,14 @@ void BattleGround::SendPacketToAll(WorldPacket* packet) for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) - { continue; } + { + continue; + } if (Player* plr = sObjectMgr.GetPlayer(itr->first)) - { plr->GetSession()->SendPacket(packet); } + { + plr->GetSession()->SendPacket(packet); + } else { sLog.outError("BattleGround:SendPacketToAll: %s not found!", itr->first.GetString().c_str()); } } @@ -572,7 +590,9 @@ void BattleGround::SendPacketToTeam(Team teamId, WorldPacket* packet, Player* se for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) - { continue; } + { + continue; + } Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) @@ -582,13 +602,17 @@ void BattleGround::SendPacketToTeam(Team teamId, WorldPacket* packet, Player* se } if (!self && sender == plr) - { continue; } + { + continue; + } Team team = itr->second.PlayerTeam; if (!team) { team = plr->GetTeam(); } if (team == teamId) - { plr->GetSession()->SendPacket(packet); } + { + plr->GetSession()->SendPacket(packet); + } } } @@ -615,7 +639,9 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, Team teamId) for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) - { continue; } + { + continue; + } Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr) @@ -645,7 +671,9 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, Team teamId) for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) - { continue; } + { + continue; + } Player* plr = sObjectMgr.GetPlayer(itr->first); @@ -659,7 +687,9 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, Team teamId) if (!team) { team = plr->GetTeam(); } if (team == teamId) - { plr->CastSpell(plr, SpellID, true); } + { + plr->CastSpell(plr, SpellID, true); + } } } @@ -673,7 +703,9 @@ void BattleGround::RewardHonorToTeam(uint32 Honor, Team teamId) for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) - { continue; } + { + continue; + } Player* plr = sObjectMgr.GetPlayer(itr->first); @@ -687,7 +719,9 @@ void BattleGround::RewardHonorToTeam(uint32 Honor, Team teamId) if (!team) { team = plr->GetTeam(); } if (team == teamId) - { UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor); } + { + UpdatePlayerScore(plr, SCORE_BONUS_HONOR, Honor); + } } } @@ -702,12 +736,16 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id); if (!factionEntry) - { return; } + { + return; + } for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) { if (itr->second.OfflineRemoveTime) - { continue; } + { + continue; + } Player* plr = sObjectMgr.GetPlayer(itr->first); @@ -721,7 +759,9 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, if (!team) { team = plr->GetTeam(); } if (team == teamId) - { plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation); } + { + plr->GetReputationMgr().ModifyReputation(factionEntry, Reputation); + } } } @@ -873,7 +913,9 @@ void BattleGround::EndBattleGround(Team winner) // should remove spirit of redemption if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) - { plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT); } + { + plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT); + } if (!plr->IsAlive()) { @@ -976,7 +1018,9 @@ void BattleGround::EndBattleGround(Team winner) } if (winmsg_id) - { SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL); } + { + SendMessageToAll(winmsg_id, CHAT_MSG_BG_SYSTEM_NEUTRAL); + } } /// @@ -1018,19 +1062,25 @@ void BattleGround::RewardMark(Player* plr, uint32 count) { case BATTLEGROUND_AV: if (count == ITEM_WINNER_COUNT) - { RewardSpellCast(plr, SPELL_AV_MARK_WINNER); } + { + RewardSpellCast(plr, SPELL_AV_MARK_WINNER); + } else { RewardSpellCast(plr, SPELL_AV_MARK_LOSER); } break; case BATTLEGROUND_WS: if (count == ITEM_WINNER_COUNT) - { RewardSpellCast(plr, SPELL_WS_MARK_WINNER); } + { + RewardSpellCast(plr, SPELL_WS_MARK_WINNER); + } else { RewardSpellCast(plr, SPELL_WS_MARK_LOSER); } break; case BATTLEGROUND_AB: if (count == ITEM_WINNER_COUNT) - { RewardSpellCast(plr, SPELL_AB_MARK_WINNER); } + { + RewardSpellCast(plr, SPELL_AB_MARK_WINNER); + } else { RewardSpellCast(plr, SPELL_AB_MARK_LOSER); } break; @@ -1084,14 +1134,20 @@ void BattleGround::RewardItem(Player* plr, uint32 item_id, uint32 count) } if (msg != EQUIP_ERR_OK) // convert to possible store amount - { count -= no_space_count; } + { + count -= no_space_count; + } if (count != 0 && !dest.empty()) // can add some if (Item* item = plr->StoreNewItem(dest, item_id, true, 0)) - { plr->SendNewItem(item, count, true, false); } + { + plr->SendNewItem(item, count, true, false); + } if (no_space_count > 0) - { SendRewardMarkByMail(plr, item_id, no_space_count); } + { + SendRewardMarkByMail(plr, item_id, no_space_count); + } } /// @@ -1104,11 +1160,15 @@ void BattleGround::SendRewardMarkByMail(Player* plr, uint32 mark, uint32 count) { uint32 bmEntry = GetBattlemasterEntry(); if (!bmEntry) - { return; } + { + return; + } ItemPrototype const* markProto = ObjectMgr::GetItemPrototype(mark); if (!markProto) - { return; } + { + return; + } if (Item* markItem = Item::CreateItem(mark, count, plr)) { @@ -1202,7 +1262,9 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen { // should remove spirit of redemption if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) - { plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT); } + { + plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT); + } plr->RemoveAurasDueToSpell(isArena() ? SPELL_ARENA_DAMPENING : SPELL_BATTLEGROUND_DAMPENING); plr->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); @@ -1300,7 +1362,9 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen plr->SetBGTeam(TEAM_NONE); if (Transport) - { plr->TeleportToBGEntryPoint(); } + { + plr->TeleportToBGEntryPoint(); + } DETAIL_LOG("BATTLEGROUND: Removed player %s from BattleGround.", plr->GetName()); } @@ -1331,7 +1395,9 @@ void BattleGround::Reset() } if (m_InvitedAlliance > 0 || m_InvitedHorde > 0) - { sLog.outError("BattleGround system: bad counter, m_InvitedAlliance: %d, m_InvitedHorde: %d", m_InvitedAlliance, m_InvitedHorde); } + { + sLog.outError("BattleGround system: bad counter, m_InvitedAlliance: %d, m_InvitedHorde: %d", m_InvitedAlliance, m_InvitedHorde); + } m_InvitedAlliance = 0; m_InvitedHorde = 0; @@ -1375,7 +1441,9 @@ void BattleGround::AddPlayer(Player* plr) { // remove afk from player if (plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK)) - { plr->ToggleAFK(); } + { + plr->ToggleAFK(); + } // score struct must be created in inherited class @@ -1473,7 +1541,9 @@ void BattleGround::AddOrSetPlayerToCorrectBgGroup(Player* plr, ObjectGuid plr_gu group->AddMember(plr_guid, plr->GetName()); if (Group* originalGroup = plr->GetOriginalGroup()) if (originalGroup->IsLeader(plr_guid)) - { group->ChangeLeader(plr_guid); } + { + group->ChangeLeader(plr_guid); + } } } else // first player joined @@ -1568,7 +1638,9 @@ uint32 BattleGround::GetFreeSlotsForTeam(Team team) const { // return free slot count to MaxPlayerPerTeam if (GetStatus() == STATUS_WAIT_JOIN || GetStatus() == STATUS_IN_PROGRESS) - { return (GetInvitedCount(team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(team) : 0; } + { + return (GetInvitedCount(team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(team) : 0; + } return 0; } @@ -1594,7 +1666,9 @@ void BattleGround::UpdatePlayerScore(Player* Source, uint32 type, uint32 value) BattleGroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetObjectGuid()); if (itr == m_PlayerScores.end()) // player not found... - { return; } + { + return; + } switch (type) { @@ -1685,10 +1759,14 @@ void BattleGround::OnObjectDBLoad(Creature* creature) { const BattleGroundEventIdx eventId = sBattleGroundMgr.GetCreatureEventIndex(creature->GetGUIDLow()); if (eventId.event1 == BG_EVENT_NONE) - { return; } + { + return; + } m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].creatures.push_back(creature->GetObjectGuid()); if (!IsActiveEvent(eventId.event1, eventId.event2)) - { SpawnBGCreature(creature->GetObjectGuid(), RESPAWN_ONE_DAY); } + { + SpawnBGCreature(creature->GetObjectGuid(), RESPAWN_ONE_DAY); + } } /// @@ -1701,7 +1779,9 @@ ObjectGuid BattleGround::GetSingleCreatureGuid(uint8 event1, uint8 event2) { GuidVector::const_iterator itr = m_EventObjects[MAKE_PAIR32(event1, event2)].creatures.begin(); if (itr != m_EventObjects[MAKE_PAIR32(event1, event2)].creatures.end()) - { return *itr; } + { + return *itr; + } return ObjectGuid(); } @@ -1713,7 +1793,9 @@ void BattleGround::OnObjectDBLoad(GameObject* obj) { const BattleGroundEventIdx eventId = sBattleGroundMgr.GetGameObjectEventIndex(obj->GetGUIDLow()); if (eventId.event1 == BG_EVENT_NONE) - { return; } + { + return; + } m_EventObjects[MAKE_PAIR32(eventId.event1, eventId.event2)].gameobjects.push_back(obj->GetObjectGuid()); if (!IsActiveEvent(eventId.event1, eventId.event2)) { @@ -1723,7 +1805,9 @@ void BattleGround::OnObjectDBLoad(GameObject* obj) { // it's possible, that doors aren't spawned anymore (wsg) if (GetStatus() >= STATUS_IN_PROGRESS && IsDoor(eventId.event1, eventId.event2)) - { DoorOpen(obj->GetObjectGuid()); } + { + DoorOpen(obj->GetObjectGuid()); + } } } @@ -1811,12 +1895,16 @@ void BattleGround::SpawnBGObject(ObjectGuid guid, uint32 respawntime) GameObject* obj = map->GetGameObject(guid); if (!obj) - { return; } + { + return; + } if (respawntime == 0) { // we need to change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again if (obj->getLootState() == GO_JUST_DEACTIVATED) - { obj->SetLootState(GO_READY); } + { + obj->SetLootState(GO_READY); + } obj->SetRespawnTime(0); map->Add(obj); } @@ -1839,7 +1927,9 @@ void BattleGround::SpawnBGCreature(ObjectGuid guid, uint32 respawntime) Creature* obj = map->GetCreature(guid); if (!obj) - { return; } + { + return; + } if (respawntime == 0) { obj->Respawn(); @@ -1877,7 +1967,9 @@ void BattleGround::SendYellToAll(int32 entry, uint32 language, ObjectGuid guid) { Creature* source = GetBgMap()->GetCreature(guid); if (!source) - { return; } + { + return; + } MaNGOS::BattleGroundYellBuilder bg_builder(Language(language), entry, source); MaNGOS::LocalizedPacketDo bg_do(bg_builder); BroadcastWorker(bg_do); @@ -1929,7 +2021,9 @@ void BattleGround::SendYell2ToAll(int32 entry, uint32 language, ObjectGuid guid, { Creature* source = GetBgMap()->GetCreature(guid); if (!source) - { return; } + { + return; + } MaNGOS::BattleGround2YellBuilder bg_builder(language, entry, source, arg1, arg2); MaNGOS::LocalizedPacketDo bg_do(bg_builder); BroadcastWorker(bg_do); @@ -1957,7 +2051,9 @@ void BattleGround::HandleTriggerBuff(ObjectGuid go_guid) { GameObject* obj = GetBgMap()->GetGameObject(go_guid); if (!obj || obj->GetGoType() != GAMEOBJECT_TYPE_TRAP || !obj->isSpawned()) - { return; } + { + return; + } obj->SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed return; @@ -1984,10 +2080,14 @@ void BattleGround::HandleKillPlayer(Player* player, Player* killer) Player* plr = sObjectMgr.GetPlayer(itr->first); if (!plr || plr == killer) - { continue; } + { + continue; + } if (plr->GetTeam() == killer->GetTeam() && plr->IsAtGroupRewardDistance(player)) - { UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1); } + { + UpdatePlayerScore(plr, SCORE_HONORABLE_KILLS, 1); + } } } @@ -2006,7 +2106,9 @@ Team BattleGround::GetPlayerTeam(ObjectGuid guid) { BattleGroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) - { return itr->second.PlayerTeam; } + { + return itr->second.PlayerTeam; + } return TEAM_NONE; } @@ -2019,7 +2121,9 @@ bool BattleGround::IsPlayerInBattleGround(ObjectGuid guid) { BattleGroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) - { return true; } + { + return true; + } return false; } @@ -2030,7 +2134,9 @@ bool BattleGround::IsPlayerInBattleGround(ObjectGuid guid) void BattleGround::PlayerAddedToBGCheckIfBGIsRunning(Player* plr) { if (GetStatus() != STATUS_WAIT_LEAVE) - { return; } + { + return; + } WorldPacket data; BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID(), GetArenaType()); @@ -2058,7 +2164,9 @@ uint32 BattleGround::GetAlivePlayersCountByTeam(Team team) const { Player* pl = sObjectMgr.GetPlayer(itr->first); if (pl && pl->IsAlive()) - { ++count; } + { + ++count; + } } } return count; @@ -2082,10 +2190,14 @@ void BattleGround::SetBgRaid(Team team, Group* bg_raid) Group*& old_raid = m_BgRaids[GetTeamIndexByTeamId(team)]; if (old_raid) - { old_raid->SetBattlegroundGroup(NULL); } + { + old_raid->SetBattlegroundGroup(NULL); + } if (bg_raid) - { bg_raid->SetBattlegroundGroup(this); } + { + bg_raid->SetBattlegroundGroup(this); + } old_raid = bg_raid; } diff --git a/src/game/BattleGround/BattleGround.h b/src/game/BattleGround/BattleGround.h index 0116f4109..08aabc777 100644 --- a/src/game/BattleGround/BattleGround.h +++ b/src/game/BattleGround/BattleGround.h @@ -664,7 +664,9 @@ class BattleGround uint32 GetInvitedCount(Team team) const { if (team == ALLIANCE) - { return m_InvitedAlliance; } + { + return m_InvitedAlliance; + } else { return m_InvitedHorde; } } @@ -1030,7 +1032,9 @@ class BattleGround void UpdatePlayersCountByTeam(Team team, bool remove) { if (remove) - { --m_PlayersCount[GetTeamIndexByTeamId(team)]; } + { + --m_PlayersCount[GetTeamIndexByTeamId(team)]; + } else { ++m_PlayersCount[GetTeamIndexByTeamId(team)]; } } @@ -1193,7 +1197,9 @@ class BattleGround bool IsActiveEvent(uint8 event1, uint8 event2) { if (m_ActiveEvents.find(event1) == m_ActiveEvents.end()) - { return false; } + { + return false; + } return m_ActiveEvents[event1] == event2; } /** diff --git a/src/game/BattleGround/BattleGroundAB.cpp b/src/game/BattleGround/BattleGroundAB.cpp index 70b7c2ac5..e7e7d0622 100644 --- a/src/game/BattleGround/BattleGroundAB.cpp +++ b/src/game/BattleGround/BattleGroundAB.cpp @@ -68,7 +68,9 @@ void BattleGroundAB::Update(uint32 diff) if (m_BannerTimers[node].timer) { if (m_BannerTimers[node].timer > diff) - { m_BannerTimers[node].timer -= diff; } + { + m_BannerTimers[node].timer -= diff; + } else { m_BannerTimers[node].timer = 0; @@ -80,7 +82,9 @@ void BattleGroundAB::Update(uint32 diff) if (m_NodeTimers[node]) { if (m_NodeTimers[node] > diff) - { m_NodeTimers[node] -= diff; } + { + m_NodeTimers[node] -= diff; + } else { m_NodeTimers[node] = 0; @@ -109,7 +113,9 @@ void BattleGroundAB::Update(uint32 diff) for (uint8 team = 0; team < PVP_TEAM_COUNT; ++team) if (m_Nodes[node] == team + BG_AB_NODE_TYPE_OCCUPIED) - { ++team_points[team]; } + { + ++team_points[team]; + } } // Accumulate points @@ -117,7 +123,9 @@ void BattleGroundAB::Update(uint32 diff) { int points = team_points[team]; if (!points) - { continue; } + { + continue; + } m_lastTick[team] += diff; if (m_lastTick[team] > BG_AB_TickIntervals[points]) { @@ -138,7 +146,9 @@ void BattleGroundAB::Update(uint32 diff) if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE) { if (team == TEAM_INDEX_ALLIANCE) - { SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL); } + { + 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); } PlaySoundToAll(BG_AB_SOUND_NEAR_VICTORY); @@ -146,11 +156,17 @@ void BattleGroundAB::Update(uint32 diff) } if (m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE) - { m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE; } + { + m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE; + } if (team == TEAM_INDEX_ALLIANCE) - { UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]); } + { + UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]); + } if (team == TEAM_INDEX_HORDE) - { UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]); } + { + UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]); + } // update achievement flags // we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources @@ -163,9 +179,13 @@ void BattleGroundAB::Update(uint32 diff) // Test win condition if (m_TeamScores[TEAM_INDEX_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE) - { EndBattleGround(ALLIANCE); } + { + EndBattleGround(ALLIANCE); + } if (m_TeamScores[TEAM_INDEX_HORDE] >= BG_AB_MAX_TEAM_SCORE) - { EndBattleGround(HORDE); } + { + EndBattleGround(HORDE); + } } } @@ -213,13 +233,17 @@ bool BattleGroundAB::HandleAreaTrigger(Player* source, uint32 trigger) { case 3948: // Arathi Basin Alliance Exit. if (source->GetTeam() != ALLIANCE) - { source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); } + { + source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); + } else { source->LeaveBattleground(); } break; case 3949: // Arathi Basin Horde Exit. if (source->GetTeam() != HORDE) - { source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); } + { + source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); + } else { source->LeaveBattleground(); } break; @@ -250,7 +274,9 @@ void BattleGroundAB::_CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool // cause the node-type is in the generic form // please see in the headerfile for the ids if (type != BG_AB_NODE_TYPE_NEUTRAL) - { type += teamIndex; } + { + type += teamIndex; + } SpawnEvent(node, type, true); // will automaticly despawn other events } @@ -297,7 +323,9 @@ void BattleGroundAB::FillInitialWorldStates(WorldPacket& data, uint32& count) uint8 ally = 0, horde = 0; for (uint8 node = 0; node < BG_AB_NODES_MAX; ++node) if (m_Nodes[node] == BG_AB_NODE_STATUS_ALLY_OCCUPIED) - { ++ally; } + { + ++ally; + } else if (m_Nodes[node] == BG_AB_NODE_STATUS_HORDE_OCCUPIED) { ++horde; } @@ -324,7 +352,9 @@ void BattleGroundAB::_SendNodeUpdate(uint8 node) const uint8 plusArray[] = {0, 2, 3, 0, 1}; if (m_prevNodes[node]) - { UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_prevNodes[node]], WORLD_STATE_REMOVE); } + { + UpdateWorldState(BG_AB_OP_NODESTATES[node] + plusArray[m_prevNodes[node]], WORLD_STATE_REMOVE); + } else { UpdateWorldState(BG_AB_OP_NODEICONS[node], WORLD_STATE_REMOVE); } @@ -334,7 +364,9 @@ void BattleGroundAB::_SendNodeUpdate(uint8 node) uint8 ally = 0, horde = 0; for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i) if (m_Nodes[i] == BG_AB_NODE_STATUS_ALLY_OCCUPIED) - { ++ally; } + { + ++ally; + } else if (m_Nodes[i] == BG_AB_NODE_STATUS_HORDE_OCCUPIED) { ++horde; } @@ -353,12 +385,18 @@ void BattleGroundAB::_NodeOccupied(uint8 node, Team team) for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i) { if (m_Nodes[node] == GetTeamIndexByTeamId(team) + BG_AB_NODE_TYPE_OCCUPIED && !m_NodeTimers[i]) - { ++capturedNodes; } + { + ++capturedNodes; + } } if (capturedNodes >= 5) - { CastSpellOnTeam(SPELL_AB_QUEST_REWARD_5_BASES, team); } + { + CastSpellOnTeam(SPELL_AB_QUEST_REWARD_5_BASES, team); + } if (capturedNodes >= 4) - { CastSpellOnTeam(SPELL_AB_QUEST_REWARD_4_BASES, team); } + { + CastSpellOnTeam(SPELL_AB_QUEST_REWARD_4_BASES, team); + } } /* Invoked if a player used a banner as a gameobject */ @@ -370,18 +408,24 @@ void BattleGroundAB::_NodeOccupied(uint8 node, Team team) void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1; if (event >= BG_AB_NODES_MAX) // not a node - { return; } + { + return; + } BG_AB_Nodes node = BG_AB_Nodes(event); PvpTeamIndex teamIndex = GetTeamIndexByTeamId(source->GetTeam()); // Check if player really could use this banner, not cheated if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node] % 2)) - { return; } + { + return; + } source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); uint32 sound; @@ -400,7 +444,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == 0) - { SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node), LANG_BG_ALLY); } + { + 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); } @@ -421,7 +467,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == TEAM_INDEX_ALLIANCE) - { SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); } + { + 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)); } } @@ -438,7 +486,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target _NodeOccupied(node, (teamIndex == TEAM_INDEX_ALLIANCE) ? ALLIANCE : HORDE); if (teamIndex == TEAM_INDEX_ALLIANCE) - { SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); } + { + 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)); } } @@ -456,7 +506,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == TEAM_INDEX_ALLIANCE) - { SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node)); } + { + 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)); } @@ -467,7 +519,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED) { if (teamIndex == TEAM_INDEX_ALLIANCE) - { SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_ALLY, _GetNodeNameId(node)); } + { + 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)); } } @@ -539,7 +593,9 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) std::vector nodes; for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i) if (m_Nodes[i] == teamIndex + 3) - { nodes.push_back(i); } + { + nodes.push_back(i); + } WorldSafeLocsEntry const* good_entry = NULL; // If so, select the closest node to place ghost on @@ -553,7 +609,9 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) { WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[nodes[i]]); if (!entry) - { continue; } + { + continue; + } float dist = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y); if (mindist > dist) { @@ -565,7 +623,9 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) } // If not, place ghost on starting location if (!good_entry) - { good_entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[teamIndex + 5]); } + { + good_entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[teamIndex + 5]); + } return good_entry; } @@ -580,7 +640,9 @@ void BattleGroundAB::UpdatePlayerScore(Player* source, uint32 type, uint32 value { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid()); if (itr == m_PlayerScores.end()) // player not found... - { return; } + { + return; + } switch (type) { @@ -615,10 +677,14 @@ Team BattleGroundAB::GetPrematureWinner() int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE]; if (hordeScore > allianceScore) - { return HORDE; } + { + return HORDE; + } if (allianceScore > hordeScore) - { return ALLIANCE; } + { + 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/BattleGroundAV.cpp b/src/game/BattleGround/BattleGroundAV.cpp index 3e2312456..bebb30f0c 100644 --- a/src/game/BattleGround/BattleGroundAV.cpp +++ b/src/game/BattleGround/BattleGroundAV.cpp @@ -43,7 +43,9 @@ BattleGroundAV::BattleGroundAV(): m_HonorMapComplete(0), m_RepTowerDestruction(0 void BattleGroundAV::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } BattleGround::HandleKillPlayer(player, killer); UpdateScore(GetTeamIndexByTeamId(player->GetTeam()), -1); @@ -53,10 +55,14 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer) { DEBUG_LOG("BattleGroundAV: HandleKillUnit %i", creature->GetEntry()); if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } uint8 event1 = (sBattleGroundMgr.GetCreatureEventIndex(creature->GetGUIDLow())).event1; if (event1 == BG_EVENT_NONE) - { return; } + { + return; + } switch (event1) { case BG_AV_BOSS_A: @@ -75,7 +81,9 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer) break; case BG_AV_CAPTAIN_A: if (IsActiveEvent(BG_AV_NodeEventCaptainDead_A, 0)) - { return; } + { + return; + } RewardReputationToTeam(BG_AV_FACTION_H, m_RepCaptain, HORDE); RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), HORDE); UpdateScore(TEAM_INDEX_ALLIANCE, (-1) * BG_AV_RES_CAPTAIN); @@ -84,7 +92,9 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer) break; case BG_AV_CAPTAIN_H: if (IsActiveEvent(BG_AV_NodeEventCaptainDead_H, 0)) - { return; } + { + return; + } RewardReputationToTeam(BG_AV_FACTION_A, m_RepCaptain, ALLIANCE); RewardHonorToTeam(GetBonusHonorFromKill(BG_AV_KILL_CAPTAIN), ALLIANCE); UpdateScore(TEAM_INDEX_HORDE, (-1) * BG_AV_RES_CAPTAIN); @@ -103,7 +113,9 @@ void BattleGroundAV::HandleKillUnit(Creature* creature, Player* killer) void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } BattleGroundAVTeamIndex teamIdx = GetAVTeamIndexByTeamId(player->GetTeam()); MANGOS_ASSERT(teamIdx != BG_AV_TEAM_NEUTRAL); @@ -123,7 +135,9 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) DEBUG_LOG("BattleGroundAV: Quest %i completed starting with unit upgrading..", questid); for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) if (m_Nodes[i].Owner == teamIdx && m_Nodes[i].State == POINT_CONTROLLED) - { PopulateNode(i); } + { + PopulateNode(i); + } } break; case BG_AV_QUEST_A_COMMANDER1: @@ -131,21 +145,27 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) m_Team_QuestStatus[teamIdx][1]++; reputation = 1; if (m_Team_QuestStatus[teamIdx][1] == 120) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); + } break; case BG_AV_QUEST_A_COMMANDER2: case BG_AV_QUEST_H_COMMANDER2: m_Team_QuestStatus[teamIdx][2]++; reputation = 2; if (m_Team_QuestStatus[teamIdx][2] == 60) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); + } break; case BG_AV_QUEST_A_COMMANDER3: case BG_AV_QUEST_H_COMMANDER3: m_Team_QuestStatus[teamIdx][3]++; reputation = 5; if (m_Team_QuestStatus[teamIdx][1] == 30) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); + } break; case BG_AV_QUEST_A_BOSS1: case BG_AV_QUEST_H_BOSS1: @@ -156,7 +176,9 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) m_Team_QuestStatus[teamIdx][4]++; reputation += 1; if (m_Team_QuestStatus[teamIdx][4] >= 200) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); + } break; case BG_AV_QUEST_A_NEAR_MINE: case BG_AV_QUEST_H_NEAR_MINE: @@ -166,7 +188,9 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][6] == 7) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); + } } break; case BG_AV_QUEST_A_OTHER_MINE: @@ -177,7 +201,9 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][5] == 20) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - ground assault ready", questid); + } } break; case BG_AV_QUEST_A_RIDER_HIDE: @@ -188,7 +214,9 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][8] == 25) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); + } } break; case BG_AV_QUEST_A_RIDER_TAME: @@ -199,7 +227,9 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here", questid); if (m_Team_QuestStatus[teamIdx][7] == 25) - { DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); } + { + DEBUG_LOG("BattleGroundAV: Quest %i completed (need to implement some events here - rider assault ready", questid); + } } break; default: @@ -208,7 +238,9 @@ void BattleGroundAV::HandleQuestComplete(uint32 questid, Player* player) break; } if (reputation) - { RewardReputationToTeam((player->GetTeam() == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, reputation, player->GetTeam()); } + { + RewardReputationToTeam((player->GetTeam() == ALLIANCE) ? BG_AV_FACTION_A : BG_AV_FACTION_H, reputation, player->GetTeam()); + } } void BattleGroundAV::UpdateScore(PvpTeamIndex teamIdx, int32 points) @@ -241,7 +273,9 @@ void BattleGroundAV::Update(uint32 diff) BattleGround::Update(diff); if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } // add points from mine owning, and look if the neutral team can reclaim the mine for (uint8 mine = 0; mine < BG_AV_MAX_MINES; ++mine) @@ -256,7 +290,9 @@ void BattleGroundAV::Update(uint32 diff) } if (m_Mine_Reclaim_Timer[mine] > diff) - { m_Mine_Reclaim_Timer[mine] -= diff; } + { + m_Mine_Reclaim_Timer[mine] -= diff; + } else { ChangeMineOwner(mine, BG_AV_TEAM_NEUTRAL); } } @@ -268,7 +304,9 @@ void BattleGroundAV::Update(uint32 diff) if (m_Nodes[i].State == POINT_ASSAULTED) { if (m_Nodes[i].Timer > diff) - { m_Nodes[i].Timer -= diff; } + { + m_Nodes[i].Timer -= diff; + } else { EventPlayerDestroyedPoint(i); } } @@ -303,20 +341,28 @@ void BattleGroundAV::EndBattleGround(Team winner) for (BG_AV_Nodes i = BG_AV_NODES_DUNBALDAR_SOUTH; i <= BG_AV_NODES_STONEHEART_BUNKER; ++i) if (m_Nodes[i].State == POINT_CONTROLLED) if (m_Nodes[i].TotalOwner == BG_AV_TEAM_ALLIANCE) - { ++tower_survived[TEAM_INDEX_ALLIANCE]; } + { + ++tower_survived[TEAM_INDEX_ALLIANCE]; + } for (BG_AV_Nodes i = BG_AV_NODES_ICEBLOOD_TOWER; i <= BG_AV_NODES_FROSTWOLF_WTOWER; ++i) if (m_Nodes[i].State == POINT_CONTROLLED) if (m_Nodes[i].TotalOwner == BG_AV_TEAM_HORDE) - { ++tower_survived[TEAM_INDEX_HORDE]; } + { + ++tower_survived[TEAM_INDEX_HORDE]; + } // graves all controlled for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) if (m_Nodes[i].State == POINT_CONTROLLED && m_Nodes[i].Owner != BG_AV_TEAM_NEUTRAL) - { ++graves_owned[m_Nodes[i].Owner]; } + { + ++graves_owned[m_Nodes[i].Owner]; + } for (uint8 i = 0; i < BG_AV_MAX_MINES; ++i) if (m_Mine_Owner[i] != BG_AV_TEAM_NEUTRAL) - { ++mines_owned[m_Mine_Owner[i]]; } + { + ++mines_owned[m_Mine_Owner[i]]; + } // now we have the values give the honor/reputation to the teams: Team team[PVP_TEAM_COUNT] = { ALLIANCE, HORDE }; @@ -330,9 +376,13 @@ void BattleGroundAV::EndBattleGround(Team winner) } DEBUG_LOG("BattleGroundAV: EndbattleGround: bgteam: %u towers:%u honor:%u rep:%u", i, tower_survived[i], GetBonusHonorFromKill(tower_survived[i] * BG_AV_KILL_SURVIVING_TOWER), tower_survived[i] * BG_AV_REP_SURVIVING_TOWER); if (graves_owned[i]) - { RewardReputationToTeam(faction[i], graves_owned[i] * m_RepOwnedGrave, team[i]); } + { + RewardReputationToTeam(faction[i], graves_owned[i] * m_RepOwnedGrave, team[i]); + } if (mines_owned[i]) - { RewardReputationToTeam(faction[i], mines_owned[i] * m_RepOwnedMine, team[i]); } + { + RewardReputationToTeam(faction[i], mines_owned[i] * m_RepOwnedMine, team[i]); + } // captain survived?: if (!IsActiveEvent(BG_AV_NodeEventCaptainDead_A + GetTeamIndexByTeamId(team[i]), 0)) { @@ -358,13 +408,17 @@ bool BattleGroundAV::HandleAreaTrigger(Player* source, uint32 trigger) case 95: case 2608: if (source->GetTeam() != ALLIANCE) - { source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); } + { + source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_ALLIANCE_USE); + } else { source->LeaveBattleground(); } break; case 2606: if (source->GetTeam() != HORDE) - { source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); } + { + source->GetSession()->SendNotification(LANG_BATTLEGROUND_ONLY_HORDE_USE); + } else { source->LeaveBattleground(); } break; @@ -378,7 +432,9 @@ void BattleGroundAV::UpdatePlayerScore(Player* source, uint32 type, uint32 value { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid()); if (itr == m_PlayerScores.end()) // player not found... - { return; } + { + return; + } switch (type) { @@ -441,7 +497,9 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx // TODO changing the owner should result in setting respawntime to infinite for current creatures (they should fight the new ones), spawning new mine owners creatures and changing the chest - objects so that the current owning team can use them MANGOS_ASSERT(mine == BG_AV_NORTH_MINE || mine == BG_AV_SOUTH_MINE); if (m_Mine_Owner[mine] == teamIdx) - { return; } + { + return; + } m_Mine_PrevOwner[mine] = m_Mine_Owner[mine]; m_Mine_Owner[mine] = teamIdx; @@ -464,9 +522,13 @@ void BattleGroundAV::ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx bool BattleGroundAV::PlayerCanDoMineQuest(int32 GOId, Team team) { if (GOId == BG_AV_OBJECTID_MINE_N) - { return (m_Mine_Owner[BG_AV_NORTH_MINE] == GetAVTeamIndexByTeamId(team)); } + { + return (m_Mine_Owner[BG_AV_NORTH_MINE] == GetAVTeamIndexByTeamId(team)); + } if (GOId == BG_AV_OBJECTID_MINE_S) - { return (m_Mine_Owner[BG_AV_SOUTH_MINE] == GetAVTeamIndexByTeamId(team)); } + { + return (m_Mine_Owner[BG_AV_SOUTH_MINE] == GetAVTeamIndexByTeamId(team)); + } return true; // cause it's no mine'object it is ok if this is true } @@ -479,7 +541,9 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node) { uint32 graveDefenderType; if (m_Team_QuestStatus[teamIdx][0] < 500) - { graveDefenderType = 0; } + { + graveDefenderType = 0; + } else if (m_Team_QuestStatus[teamIdx][0] < 1000) { graveDefenderType = 1; } else if (m_Team_QuestStatus[teamIdx][0] < 1500) @@ -488,7 +552,9 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node) { 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); } + { + 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); } } @@ -499,11 +565,15 @@ void BattleGroundAV::PopulateNode(BG_AV_Nodes node) void BattleGroundAV::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } DEBUG_LOG("BattleGroundAV: using gameobject %i", target_obj->GetEntry()); uint8 event = (sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event1; if (event >= BG_AV_NODES_MAX) // not a node - { return; } + { + return; + } BG_AV_Nodes node = BG_AV_Nodes(event); switch ((sBattleGroundMgr.GetGameObjectEventIndex(target_obj->GetGUIDLow())).event2 % BG_AV_MAX_STATES) { @@ -525,7 +595,9 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node) PvpTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam()); if (m_Nodes[node].Owner == BattleGroundAVTeamIndex(teamIdx) || m_Nodes[node].State != POINT_ASSAULTED) - { return; } + { + return; + } if (m_Nodes[node].TotalOwner == BG_AV_TEAM_NEUTRAL) // initial snowfall capture { // until snowfall doesn't belong to anyone it is better handled in assault - code (best would be to have a special function @@ -571,7 +643,9 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node) PvpTeamIndex teamIdx = GetTeamIndexByTeamId(player->GetTeam()); DEBUG_LOG("BattleGroundAV: player assaults node %i", node); if (m_Nodes[node].Owner == BattleGroundAVTeamIndex(teamIdx) || BattleGroundAVTeamIndex(teamIdx) == m_Nodes[node].TotalOwner) - { return; } + { + return; + } AssaultNode(node, teamIdx); // update nodeinfo variables UpdateNodeWorldState(node); // send mapicon @@ -612,7 +686,9 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count) } if (m_Nodes[BG_AV_NODES_SNOWFALL_GRAVE].Owner == BG_AV_TEAM_NEUTRAL) // cause neutral teams aren't handled generic - { FillInitialWorldState(data, count, AV_SNOWFALL_N, WORLD_STATE_ADD); } + { + FillInitialWorldState(data, count, AV_SNOWFALL_N, WORLD_STATE_ADD); + } FillInitialWorldState(data, count, BG_AV_Alliance_Score, m_TeamScores[TEAM_INDEX_ALLIANCE]); FillInitialWorldState(data, count, BG_AV_Horde_Score, m_TeamScores[TEAM_INDEX_HORDE]); @@ -629,18 +705,24 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count) FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_NORTH_MINE][m_Mine_Owner[BG_AV_NORTH_MINE]], WORLD_STATE_ADD); if (m_Mine_Owner[BG_AV_NORTH_MINE] != m_Mine_PrevOwner[BG_AV_NORTH_MINE]) - { FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_NORTH_MINE][m_Mine_PrevOwner[BG_AV_NORTH_MINE]], WORLD_STATE_REMOVE); } + { + FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_NORTH_MINE][m_Mine_PrevOwner[BG_AV_NORTH_MINE]], WORLD_STATE_REMOVE); + } FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_SOUTH_MINE][m_Mine_Owner[BG_AV_SOUTH_MINE]], WORLD_STATE_ADD); if (m_Mine_Owner[BG_AV_SOUTH_MINE] != m_Mine_PrevOwner[BG_AV_SOUTH_MINE]) - { FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_SOUTH_MINE][m_Mine_PrevOwner[BG_AV_SOUTH_MINE]], WORLD_STATE_REMOVE); } + { + FillInitialWorldState(data, count, BG_AV_MineWorldStates[BG_AV_SOUTH_MINE][m_Mine_PrevOwner[BG_AV_SOUTH_MINE]], WORLD_STATE_REMOVE); + } } void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node) { UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].State, m_Nodes[node].Owner)], WORLD_STATE_ADD); if (m_Nodes[node].PrevOwner == BG_AV_TEAM_NEUTRAL) // currently only snowfall is supported as neutral node - { UpdateWorldState(AV_SNOWFALL_N, WORLD_STATE_REMOVE); } + { + 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); } } @@ -651,7 +733,9 @@ void BattleGroundAV::SendMineWorldStates(uint32 mine) UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_Owner[mine]], WORLD_STATE_ADD); if (m_Mine_Owner[mine] != m_Mine_PrevOwner[mine]) - { UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_PrevOwner[mine]], WORLD_STATE_REMOVE); } + { + UpdateWorldState(BG_AV_MineWorldStates[mine][m_Mine_PrevOwner[mine]], WORLD_STATE_REMOVE); + } } WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* plr) @@ -667,10 +751,14 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* plr) for (uint8 i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i) { if (m_Nodes[i].Owner != teamIdx || m_Nodes[i].State != POINT_CONTROLLED) - { continue; } + { + continue; + } WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[i]); if (!entry) - { continue; } + { + continue; + } float dist = (entry->x - x) * (entry->x - x) + (entry->y - y) * (entry->y - y); if (mindist > dist) { @@ -681,7 +769,9 @@ WorldSafeLocsEntry const* BattleGroundAV::GetClosestGraveYard(Player* plr) } // If not, place ghost in the starting-cave if (!good_entry) - { good_entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[teamIdx + 7]); } + { + good_entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[teamIdx + 7]); + } return good_entry; } @@ -746,7 +836,9 @@ void BattleGroundAV::InitNode(BG_AV_Nodes node, BattleGroundAVTeamIndex teamIdx, m_Nodes[node].Tower = tower; m_ActiveEvents[node] = teamIdx * BG_AV_MAX_STATES + m_Nodes[node].State; if (IsGrave(node)) // grave-creatures are special cause of a quest - { m_ActiveEvents[node + BG_AV_NODES_MAX] = teamIdx * BG_AV_MAX_GRAVETYPES; } + { + m_ActiveEvents[node + BG_AV_NODES_MAX] = teamIdx * BG_AV_MAX_GRAVETYPES; + } } void BattleGroundAV::DefendNode(BG_AV_Nodes node, PvpTeamIndex teamIdx) @@ -821,9 +913,13 @@ Team BattleGroundAV::GetPrematureWinner() int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE]; if (hordeScore > allianceScore) - { return HORDE; } + { + return HORDE; + } if (allianceScore > hordeScore) - { return ALLIANCE; } + { + 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 aeebdcaea..d4bf28fcc 100644 --- a/src/game/BattleGround/BattleGroundHandler.cpp +++ b/src/game/BattleGround/BattleGroundHandler.cpp @@ -51,10 +51,14 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recv_data) Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid); if (!pCreature) - { return; } + { + return; + } if (!pCreature->IsBattleMaster()) // it's not battlemaster - { return; } + { + return; + } // Stop the npc if moving pCreature->StopMoving(); @@ -62,7 +66,9 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recv_data) BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(pCreature->GetEntry()); if (bgTypeId == BATTLEGROUND_TYPE_NONE) - { return; } + { + return; + } if (!_player->GetBGAccessByLevel(bgTypeId)) { @@ -121,12 +127,16 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) // ignore if player is already in BG if (_player->InBattleGround()) - { return; } + { + return; + } // get bg instance or bg template if instance not found BattleGround* bg = NULL; if (instanceId) - { bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId); } + { + bg = sBattleGroundMgr.GetBattleGroundThroughClientInstance(instanceId, bgTypeId); + } if (!bg && !(bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId))) { @@ -158,16 +168,22 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) { return; } // check if has free queue slots if (!_player->HasFreeBattleGroundQueueId()) - { return; } + { + return; + } } else { grp = _player->GetGroup(); // no group found, error if (!grp) - { return; } + { + return; + } if (grp->GetLeaderGuid() != _player->GetObjectGuid()) - { return; } + { + return; + } err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0); isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) && (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam()); @@ -230,7 +246,9 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket & /*recv_ BattleGround* bg = _player->GetBattleGround(); if (!bg) // can't be received if player not in battleground - { return; } + { + return; + } Player* flagCarrierA = NULL; Player* flagCarrierH = NULL; @@ -295,7 +313,9 @@ void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/) BattleGround* bg = _player->GetBattleGround(); if (!bg) - { return; } + { + return; + } // arena finish version will send in BattleGround::EndBattleGround directly if (bg->isArena()) @@ -388,7 +408,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data) // bg template might and must be used in case of leaving queue, when instance is not created yet if (!bg && action == 0) - { bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); } + { + bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); + } if (!bg) { sLog.outError("BattlegroundHandler: bg_template not found for instance id %u type id %u.", ginfo.IsInvitedToBGInstanceGUID, bgTypeId); @@ -454,7 +476,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data) // this is still needed here if battleground "jumping" shouldn't add deserter debuff // also this is required to prevent stuck at old battleground after SetBattleGroundId set to new if (BattleGround* currentBg = _player->GetBattleGround()) - { currentBg->RemovePlayerAtLeave(_player->GetObjectGuid(), false, true); } + { + currentBg->RemovePlayerAtLeave(_player->GetObjectGuid(), false, true); + } // set the destination instance id _player->SetBattleGroundId(bg->GetInstanceID(), bgTypeId); @@ -501,7 +525,9 @@ void WorldSession::HandleLeaveBattlefieldOpcode(WorldPacket& recv_data) if (_player->IsInCombat()) if (BattleGround* bg = _player->GetBattleGround()) if (bg->GetStatus() != STATUS_WAIT_LEAVE) - { return; } + { + return; + } _player->LeaveBattleground(); } @@ -518,7 +544,9 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recv_data*/) { BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i); if (!bgQueueTypeId) - { continue; } + { + continue; + } BattleGroundTypeId bgTypeId = BattleGroundMgr::BGTemplateId(bgQueueTypeId); ArenaType arenaType = BattleGroundMgr::BGArenaType(bgQueueTypeId); @@ -541,12 +569,16 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recv_data*/) BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; GroupQueueInfo ginfo; if (!bgQueue.GetPlayerGroupInfoData(_player->GetObjectGuid(), &ginfo)) - { continue; } + { + continue; + } if (ginfo.IsInvitedToBGInstanceGUID) { bg = sBattleGroundMgr.GetBattleGround(ginfo.IsInvitedToBGInstanceGUID, bgTypeId); if (!bg) - { continue; } + { + continue; + } uint32 remainingTime = WorldTimer::getMSTimeDiff(WorldTimer::getMSTime(), ginfo.RemoveInviteTime); // send status invited to BattleGround sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, _player, i, STATUS_WAIT_JOIN, remainingTime, 0, arenaType); @@ -556,7 +588,9 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recv_data*/) { bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); if (!bg) - { continue; } + { + continue; + } // expected bracket entry PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); @@ -577,17 +611,23 @@ void WorldSession::HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data) BattleGround* bg = _player->GetBattleGround(); if (!bg) - { return; } + { + return; + } ObjectGuid guid; recv_data >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) - { return; } + { + return; + } if (!unit->IsSpiritService()) // it's not spirit service - { return; } + { + return; + } unit->SendAreaSpiritHealerQueryOpcode(GetPlayer()); } @@ -598,17 +638,23 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data) BattleGround* bg = _player->GetBattleGround(); if (!bg) - { return; } + { + return; + } ObjectGuid guid; recv_data >> guid; Creature* unit = GetPlayer()->GetMap()->GetCreature(guid); if (!unit) - { return; } + { + return; + } if (!unit->IsSpiritService()) // it's not spirit service - { return; } + { + return; + } sScriptMgr.OnGossipHello(GetPlayer(), unit); } @@ -800,4 +846,4 @@ void WorldSession::HandleRequestRatedBgInfo(WorldPacket & recvData) data << uint32(0); SendPacket(&data); -} \ No newline at end of file +} diff --git a/src/game/BattleGround/BattleGroundMgr.cpp b/src/game/BattleGround/BattleGroundMgr.cpp index 495588757..91e55ac7c 100644 --- a/src/game/BattleGround/BattleGroundMgr.cpp +++ b/src/game/BattleGround/BattleGroundMgr.cpp @@ -128,7 +128,9 @@ bool BattleGroundQueue::SelectionPool::KickGroup(uint32 size) PlayerCount -= ginfo->Players.size(); // return false if we kicked smaller group or there are enough players in selection pool if (ginfo->Players.size() <= size + 1) - { return false; } + { + return false; + } } return true; } @@ -148,7 +150,9 @@ bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo* ginfo, uint32 de return true; } if (PlayerCount < desiredCount) - { return true; } + { + return true; + } return false; } @@ -236,10 +240,14 @@ GroupQueueInfo* BattleGroundQueue::AddGroup(Player* leader, Group* grp, BattleGr GroupsQueueType::const_iterator itr; for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr) if (!(*itr)->IsInvitedToBGInstanceGUID) - { qAlliance += (*itr)->Players.size(); } + { + qAlliance += (*itr)->Players.size(); + } for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr) if (!(*itr)->IsInvitedToBGInstanceGUID) - { qHorde += (*itr)->Players.size(); } + { + qHorde += (*itr)->Players.size(); + } // Show queue status to player only (when joining queue) if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_QUEUE_ANNOUNCER_JOIN) == 1) @@ -304,7 +312,9 @@ uint32 BattleGroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleG } // check if there is enought values(we always add values > 0) if (m_WaitTimes[team_index][bracket_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1]) - { return (m_SumOfWaitTimes[team_index][bracket_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME); } + { + return (m_SumOfWaitTimes[team_index][bracket_id] / COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME); + } else // if there aren't enough values return 0 - not available { return 0; } @@ -369,14 +379,18 @@ void BattleGroundQueue::RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount) // remove player queue info from group queue info GroupQueueInfoPlayers::iterator pitr = group->Players.find(guid); if (pitr != group->Players.end()) - { group->Players.erase(pitr); } + { + group->Players.erase(pitr); + } // if invited to bg, and should decrease invited count, then do it if (decreaseInvitedCount && group->IsInvitedToBGInstanceGUID) { BattleGround* bg = sBattleGroundMgr.GetBattleGround(group->IsInvitedToBGInstanceGUID, group->BgTypeId); if (bg) - { bg->DecreaseInvitedCount(group->GroupTeam); } + { + bg->DecreaseInvitedCount(group->GroupTeam); + } } // remove player queue info @@ -446,7 +460,9 @@ bool BattleGroundQueue::GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* // ACE_Guard g(m_Lock); QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(guid); if (qItr == m_QueuedPlayers.end()) - { return false; } + { + return false; + } *ginfo = *(qItr->second.GroupInfo); return true; } @@ -455,7 +471,9 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg, { // set side if needed if (side) - { ginfo->GroupTeam = side; } + { + ginfo->GroupTeam = side; + } if (!ginfo->IsInvitedToBGInstanceGUID) { @@ -479,7 +497,9 @@ bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg, Player* plr = sObjectMgr.GetPlayer(itr->first); // if offline, skip him, this should not happen - player is removed from queue when he logs out if (!plr) - { continue; } + { + continue; + } // invite the player PlayerInvitedToBGUpdateAverageWaitTime(ginfo, bracket_id); @@ -541,7 +561,9 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId // if ofc like BG queue invitation is set in config, then we are happy if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE) == 0) - { return; } + { + return; + } /* if we reached this code, then we have to solve NP - complete problem called Subset sum problem @@ -569,7 +591,9 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId if (!m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount()) { if (aliFree <= diffHorde + 1) - { break; } + { + break; + } m_SelectionPools[TEAM_INDEX_HORDE].KickGroup(diffHorde - diffAli); } } @@ -584,7 +608,9 @@ void BattleGroundQueue::FillPlayersToBG(BattleGround* bg, BattleGroundBracketId if (!m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount()) { if (hordeFree <= diffAli + 1) - { break; } + { + break; + } m_SelectionPools[TEAM_INDEX_ALLIANCE].KickGroup(diffAli - diffHorde); } } @@ -607,10 +633,14 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint GroupsQueueType::const_iterator ali_group, horde_group; for (ali_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].begin(); ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end(); ++ali_group) if (!(*ali_group)->IsInvitedToBGInstanceGUID) - { break; } + { + break; + } for (horde_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].begin(); horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end(); ++horde_group) if (!(*horde_group)->IsInvitedToBGInstanceGUID) - { break; } + { + break; + } if (ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end() && horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end()) { @@ -625,7 +655,9 @@ bool BattleGroundQueue::CheckPremadeMatch(BattleGroundBracketId bracket_id, uint { // if itr can join BG and player count is less that maxPlayers, then add group to selectionpool if (!(*itr)->IsInvitedToBGInstanceGUID && !m_SelectionPools[i].AddGroup((*itr), maxPlayers)) - { break; } + { + break; + } } } // premade selection pools are set @@ -667,14 +699,18 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGround { m_SelectionPools[i].AddGroup(*(itr_team[i]), maxPlayers); if (m_SelectionPools[i].GetPlayerCount() >= minPlayers) - { break; } + { + break; + } } } } // try to invite same number of players - this cycle may cause longer wait time even if there are enough players in queue, but we want ballanced bg uint32 j = TEAM_INDEX_ALLIANCE; if (m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount()) - { j = TEAM_INDEX_HORDE; } + { + j = TEAM_INDEX_HORDE; + } if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE) != 0 && m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() >= minPlayers) { @@ -684,15 +720,21 @@ bool BattleGroundQueue::CheckNormalMatch(BattleGround* bg_template, BattleGround { if (!(*(itr_team[j]))->IsInvitedToBGInstanceGUID) if (!m_SelectionPools[j].AddGroup(*(itr_team[j]), m_SelectionPools[(j + 1) % PVP_TEAM_COUNT].GetPlayerCount())) - { break; } + { + break; + } } // do not allow to start bg with more than 2 players more on 1 faction if (abs((int32)(m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() - m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount())) > 2) - { return false; } + { + return false; + } } // allow 1v0 if debug bg if (sBattleGroundMgr.isTesting() && bg_template->isBattleGround() && (m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount())) - { return true; } + { + return true; + } // return true if there are enough players in selection pools - enable to work .debug bg command correctly return m_SelectionPools[TEAM_INDEX_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_INDEX_HORDE].GetPlayerCount() >= minPlayers; } @@ -826,7 +868,9 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI uint32 MinPlayersPerTeam = bg_template->GetMinPlayersPerTeam(); uint32 MaxPlayersPerTeam = bg_template->GetMaxPlayersPerTeam(); if (sBattleGroundMgr.isTesting()) - { MinPlayersPerTeam = 1; } + { + MinPlayersPerTeam = 1; + } if (bg_template->isArena()) { if (sBattleGroundMgr.isArenaTesting()) @@ -1052,12 +1096,16 @@ bool BGQueueInviteEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) Player* plr = sObjectMgr.GetPlayer(m_PlayerGuid); // player logged off (we should do nothing, he is correctly removed from queue in another procedure) if (!plr) - { return true; } + { + return true; + } BattleGround* bg = sBattleGroundMgr.GetBattleGround(m_BgInstanceGUID, m_BgTypeId); // if battleground ended and its instance deleted - do nothing if (!bg) - { return true; } + { + return true; + } BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bg->GetTypeID(), bg->GetArenaType()); uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId); @@ -1671,7 +1719,9 @@ BattleGround* BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 insta // SMSG_BATTLEFIELD_LIST we need to find the battleground with this clientinstance-id BattleGround* bg = GetBattleGroundTemplate(bgTypeId); if (!bg) - { return NULL; } + { + return NULL; + } if (bg->isArena()) return GetBattleGround(instanceId, bgTypeId); @@ -1679,7 +1729,9 @@ BattleGround* BattleGroundMgr::GetBattleGroundThroughClientInstance(uint32 insta for (BattleGroundSet::iterator itr = m_BattleGrounds[bgTypeId].begin(); itr != m_BattleGrounds[bgTypeId].end(); ++itr) { if (itr->second->GetClientInstanceID() == instanceId) - { return itr->second; } + { + return itr->second; + } } return NULL; } @@ -1694,7 +1746,9 @@ BattleGround* BattleGroundMgr::GetBattleGround(uint32 InstanceID, BattleGroundTy { itr = m_BattleGrounds[i].find(InstanceID); if (itr != m_BattleGrounds[i].end()) - { return itr->second; } + { + return itr->second; + } } return NULL; } @@ -1724,7 +1778,9 @@ uint32 BattleGroundMgr::CreateClientVisibleInstanceId(BattleGroundTypeId bgTypeI for (ClientBattleGroundIdSet::const_iterator itr = ids.begin(); itr != ids.end();) { if ((++lastId) != *itr) // if there is a gap between the ids, we will break.. - { break; } + { + break; + } lastId = *itr; } ids.insert(lastId + 1); @@ -1975,7 +2031,9 @@ void BattleGroundMgr::CreateInitialBattleGrounds() // sLog.outDetail("Creating battleground %s, %u-%u", bl->name[sWorld.GetDBClang()], MinLvl, MaxLvl); if (!CreateBattleGround(bgTypeID, IsArena, MinPlayersPerTeam, MaxPlayersPerTeam, bl->minLevel, bl->maxLevel, bl->name[sWorld.GetDefaultDbcLocale()], bl->mapid[0], AStartLoc[0], AStartLoc[1], AStartLoc[2], AStartLoc[3], HStartLoc[0], HStartLoc[1], HStartLoc[2], HStartLoc[3])) - { continue; } + { + continue; + } ++count; } @@ -2064,7 +2122,9 @@ void BattleGroundMgr::DistributeArenaPoints() void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket* data, ObjectGuid guid, Player* plr, BattleGroundTypeId bgTypeId) { if (!plr) - { return; } + { + return; + } BattleGround* bgTemplate = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); @@ -2121,7 +2181,9 @@ void BattleGroundMgr::SendToBattleGround(Player* pl, uint32 instanceId, BattleGr float x, y, z, O; Team team = pl->GetBGTeam(); if (team == 0) - { team = pl->GetTeam(); } + { + team = pl->GetTeam(); + } bg->GetTeamStartLoc(team, x, y, z, O); DETAIL_LOG("BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", pl->GetName(), mapid, x, y, z, O); @@ -2241,7 +2303,9 @@ void BattleGroundMgr::ToggleTesting() { m_Testing = !m_Testing; if (m_Testing) - { sWorld.SendWorldText(LANG_DEBUG_BG_ON); } + { + sWorld.SendWorldText(LANG_DEBUG_BG_ON); + } else { sWorld.SendWorldText(LANG_DEBUG_BG_OFF); } } @@ -2270,7 +2334,9 @@ void BattleGroundMgr::ScheduleQueueUpdate(uint32 arenaRating, ArenaType arenaTyp } } if (!found) - { m_QueueUpdateScheduler.push_back(schedule_id); } + { + m_QueueUpdateScheduler.push_back(schedule_id); + } } uint32 BattleGroundMgr::GetMaxRatingDifference() const @@ -2473,7 +2539,9 @@ void BattleGroundMgr::LoadBattleEventIndexes() } if (gameobject) - { m_GameObjectBattleEventIndexMap[dbTableGuidLow] = events; } + { + m_GameObjectBattleEventIndexMap[dbTableGuidLow] = events; + } else { m_CreatureBattleEventIndexMap[dbTableGuidLow] = events; } diff --git a/src/game/BattleGround/BattleGroundMgr.h b/src/game/BattleGround/BattleGroundMgr.h index a42ff859c..3e97c724e 100644 --- a/src/game/BattleGround/BattleGroundMgr.h +++ b/src/game/BattleGround/BattleGroundMgr.h @@ -572,7 +572,9 @@ class BattleGroundMgr { BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry); if (itr != mBattleMastersMap.end()) - { return itr->second; } + { + return itr->second; + } return BATTLEGROUND_TYPE_NONE; } @@ -591,7 +593,9 @@ class BattleGroundMgr { CreatureBattleEventIndexesMap::const_iterator itr = m_CreatureBattleEventIndexMap.find(dbTableGuidLow); if (itr != m_CreatureBattleEventIndexMap.end()) - { return itr->second; } + { + return itr->second; + } return m_CreatureBattleEventIndexMap.find(-1)->second; } /** @@ -604,7 +608,9 @@ class BattleGroundMgr { GameObjectBattleEventIndexesMap::const_iterator itr = m_GameObjectBattleEventIndexMap.find(dbTableGuidLow); if (itr != m_GameObjectBattleEventIndexMap.end()) - { return itr->second; } + { + return itr->second; + } return m_GameObjectBattleEventIndexMap.find(-1)->second; } diff --git a/src/game/BattleGround/BattleGroundWS.cpp b/src/game/BattleGround/BattleGroundWS.cpp index efb3c7c18..a89241cde 100644 --- a/src/game/BattleGround/BattleGroundWS.cpp +++ b/src/game/BattleGround/BattleGroundWS.cpp @@ -162,11 +162,15 @@ void BattleGroundWS::RespawnFlag(Team team, bool captured) void BattleGroundWS::RespawnDroppedFlag(Team team) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } RespawnFlag(team, false); if (team == ALLIANCE) - { SendMessageToAll(LANG_BG_WS_ALLIANCE_FLAG_RESPAWNED, CHAT_MSG_BG_SYSTEM_NEUTRAL); } + { + 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); } @@ -174,7 +178,9 @@ void BattleGroundWS::RespawnDroppedFlag(Team team) GameObject* obj = GetBgMap()->GetGameObject(GetDroppedFlagGuid(team)); if (obj) - { obj->Delete(); } + { + obj->Delete(); + } else { sLog.outError("Unknown dropped flag bg: %s", GetDroppedFlagGuid(team).GetString().c_str()); } @@ -184,7 +190,9 @@ void BattleGroundWS::RespawnDroppedFlag(Team team) void BattleGroundWS::EventPlayerCapturedFlag(Player* source) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } m_LastCapturedFlagTeam = source->GetTeam(); @@ -192,28 +200,36 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source) if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) - { return; } + { + return; + } ClearHordeFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time // horde flag in base (but not respawned yet) m_FlagState[TEAM_INDEX_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; // Drop Horde Flag from Player source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG); if (m_TeamScores[TEAM_INDEX_ALLIANCE] < BG_WS_MAX_TEAM_SCORE) - { m_TeamScores[TEAM_INDEX_ALLIANCE] += 1; } + { + m_TeamScores[TEAM_INDEX_ALLIANCE] += 1; + } PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE); RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE); } else { if (!IsAllianceFlagPickedUp()) - { return; } + { + return; + } ClearAllianceFlagCarrier(); // must be before aura remove to prevent 2 events (drop+capture) at the same time // alliance flag in base (but not respawned yet) m_FlagState[TEAM_INDEX_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN; // Drop Alliance Flag from Player source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG); if (m_TeamScores[TEAM_INDEX_HORDE] < BG_WS_MAX_TEAM_SCORE) - { m_TeamScores[TEAM_INDEX_HORDE] += 1; } + { + m_TeamScores[TEAM_INDEX_HORDE] += 1; + } PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE); RewardReputationToTeam(889, m_ReputationCapture, HORDE); } @@ -225,7 +241,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source) SpawnEvent(WS_EVENT_FLAG_H, 0, false); if (source->GetTeam() == ALLIANCE) - { SendMessageToAll(LANG_BG_WS_CAPTURED_HF, CHAT_MSG_BG_SYSTEM_ALLIANCE, 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); } @@ -236,7 +254,9 @@ void BattleGroundWS::EventPlayerCapturedFlag(Player* source) Team winner = TEAM_NONE; if (m_TeamScores[TEAM_INDEX_ALLIANCE] == BG_WS_MAX_TEAM_SCORE) - { winner = ALLIANCE; } + { + winner = ALLIANCE; + } else if (m_TeamScores[TEAM_INDEX_HORDE] == BG_WS_MAX_TEAM_SCORE) { winner = HORDE; } @@ -264,7 +284,9 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source) if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) - { return; } + { + return; + } if (GetHordeFlagCarrierGuid() == source->GetObjectGuid()) { ClearHordeFlagCarrier(); @@ -274,7 +296,9 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source) else { if (!IsAllianceFlagPickedUp()) - { return; } + { + return; + } if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid()) { ClearAllianceFlagCarrier(); @@ -289,7 +313,9 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source) if (source->GetTeam() == ALLIANCE) { if (!IsHordeFlagPickedUp()) - { return; } + { + return; + } if (GetHordeFlagCarrierGuid() == source->GetObjectGuid()) { ClearHordeFlagCarrier(); @@ -302,7 +328,9 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source) else { if (!IsAllianceFlagPickedUp()) - { return; } + { + return; + } if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid()) { ClearAllianceFlagCarrier(); @@ -336,7 +364,9 @@ void BattleGroundWS::EventPlayerDroppedFlag(Player* source) void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } int32 message_id = 0; ChatMsg type; @@ -432,7 +462,9 @@ void BattleGroundWS::EventPlayerClickedOnFlag(Player* source, GameObject* target } if (!message_id) - { return; } + { + return; + } SendMessageToAll(message_id, type, source); source->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); @@ -468,7 +500,9 @@ void BattleGroundWS::RemovePlayer(Player* plr, ObjectGuid guid) void BattleGroundWS::UpdateFlagState(Team team, uint32 value) { if (team == ALLIANCE) - { UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, value); } + { + UpdateWorldState(BG_WS_FLAG_STATE_ALLIANCE, value); + } else { UpdateWorldState(BG_WS_FLAG_STATE_HORDE, value); } } @@ -485,19 +519,25 @@ bool BattleGroundWS::HandleAreaTrigger(Player* source, uint32 trigger) { // this is wrong way to implement these things. On official it done by gameobject spell cast. if (GetStatus() != STATUS_IN_PROGRESS) - { return false; } + { + return false; + } switch (trigger) { case 3646: // Alliance Flag spawn if (m_FlagState[TEAM_INDEX_HORDE] && !m_FlagState[TEAM_INDEX_ALLIANCE]) if (GetHordeFlagCarrierGuid() == source->GetObjectGuid()) - { EventPlayerCapturedFlag(source); } + { + EventPlayerCapturedFlag(source); + } break; case 3647: // Horde Flag spawn if (m_FlagState[TEAM_INDEX_ALLIANCE] && !m_FlagState[TEAM_INDEX_HORDE]) if (GetAllianceFlagCarrierGuid() == source->GetObjectGuid()) - { EventPlayerCapturedFlag(source); } + { + EventPlayerCapturedFlag(source); + } break; default: return false; @@ -551,7 +591,9 @@ void BattleGroundWS::EndBattleGround(Team winner) void BattleGroundWS::HandleKillPlayer(Player* player, Player* killer) { if (GetStatus() != STATUS_IN_PROGRESS) - { return; } + { + return; + } EventPlayerDroppedFlag(player); @@ -562,7 +604,9 @@ void BattleGroundWS::UpdatePlayerScore(Player* source, uint32 type, uint32 value { BattleGroundScoreMap::iterator itr = m_PlayerScores.find(source->GetObjectGuid()); if (itr == m_PlayerScores.end()) // player not found - { return; } + { + return; + } switch (type) { @@ -588,14 +632,18 @@ WorldSafeLocsEntry const* BattleGroundWS::GetClosestGraveYard(Player* player) if (player->GetTeam() == ALLIANCE) { if (GetStatus() == STATUS_IN_PROGRESS) - { return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE); } + { + return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE); + } else { return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_ALLIANCE); } } else { if (GetStatus() == STATUS_IN_PROGRESS) - { return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_HORDE); } + { + return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_HORDE); + } else { return sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_FLAGROOM_HORDE); } } @@ -607,14 +655,18 @@ void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count) FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_HORDE, m_TeamScores[TEAM_INDEX_HORDE]); if (m_FlagState[TEAM_INDEX_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND) - { FillInitialWorldState(data, count, BG_WS_FLAG_UNK_ALLIANCE, -1); } + { + 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); } else { 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); } + { + 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); } else @@ -623,12 +675,16 @@ void BattleGroundWS::FillInitialWorldStates(WorldPacket& data, uint32& count) FillInitialWorldState(data, count, BG_WS_FLAG_CAPTURES_MAX, BG_WS_MAX_TEAM_SCORE); if (m_FlagState[TEAM_INDEX_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER) - { FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 2); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_STATE_HORDE, 2); + } else { 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); } + { + FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 2); + } else { FillInitialWorldState(data, count, BG_WS_FLAG_STATE_ALLIANCE, 1); } @@ -642,9 +698,13 @@ Team BattleGroundWS::GetPrematureWinner() int32 allianceScore = m_TeamScores[TEAM_INDEX_ALLIANCE]; if (hordeScore > allianceScore) - { return HORDE; } + { + return HORDE; + } if (allianceScore > hordeScore) - { return ALLIANCE; } + { + return ALLIANCE; + } // If the values are equal, fall back to number of players on each team return BattleGround::GetPrematureWinner(); diff --git a/src/game/ChatCommands/Level0.cpp b/src/game/ChatCommands/Level0.cpp index ae2323b7a..151feb42b 100644 --- a/src/game/ChatCommands/Level0.cpp +++ b/src/game/ChatCommands/Level0.cpp @@ -46,7 +46,9 @@ bool ChatHandler::HandleHelpCommand(char* args) else { if (!ShowHelpForCommand(getCommandTable(), args)) - { SendSysMessage(LANG_NO_CMD); } + { + SendSysMessage(LANG_NO_CMD); + } } return true; @@ -62,7 +64,9 @@ bool ChatHandler::HandleAccountCommand(char* args) { // let show subcommands at unexpected data in args if (*args) - { return false; } + { + return false; + } AccountTypes gmlevel = GetAccessLevel(); PSendSysMessage(LANG_ACCOUNT_LEVEL, uint32(gmlevel)); @@ -108,7 +112,9 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/) { char const* ver = sScriptMgr.GetScriptLibraryVersion(); if (ver && *ver) - { PSendSysMessage(LANG_USING_SCRIPT_LIB, ver); } + { + PSendSysMessage(LANG_USING_SCRIPT_LIB, ver); + } else { SendSysMessage(LANG_USING_SCRIPT_LIB_UNKNOWN); } } @@ -161,7 +167,9 @@ bool ChatHandler::HandleSaveCommand(char* /*args*/) // save or plan save after 20 sec (logout delay) if current next save time more this value and _not_ output any messages to prevent cheat planning uint32 save_interval = sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE); if (save_interval == 0 || (save_interval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20 * IN_MILLISECONDS)) - { player->SaveToDB(); } + { + player->SaveToDB(); + } return true; } @@ -214,7 +222,9 @@ bool ChatHandler::HandleAccountPasswordCommand(char* args) char* new_pass_c = ExtractQuotedOrLiteralArg(&args); if (!old_pass || !new_pass || !new_pass_c) - { return false; } + { + return false; + } std::string password_old = old_pass; std::string password_new = new_pass; diff --git a/src/game/ChatCommands/Level1.cpp b/src/game/ChatCommands/Level1.cpp index e08099e5a..7fe53a1e1 100644 --- a/src/game/ChatCommands/Level1.cpp +++ b/src/game/ChatCommands/Level1.cpp @@ -48,7 +48,9 @@ bool ChatHandler::HandleNpcSayCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Creature* pCreature = getSelectedCreature(); if (!pCreature) @@ -66,7 +68,9 @@ bool ChatHandler::HandleNpcSayCommand(char* args) bool ChatHandler::HandleNpcYellCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Creature* pCreature = getSelectedCreature(); if (!pCreature) @@ -85,7 +89,9 @@ bool ChatHandler::HandleNpcYellCommand(char* args) bool ChatHandler::HandleNpcTextEmoteCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Creature* pCreature = getSelectedCreature(); @@ -106,20 +112,28 @@ bool ChatHandler::HandleNpcWhisperCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } ObjectGuid guid = m_session->GetPlayer()->GetSelectionGuid(); if (!guid) - { return false; } + { + return false; + } Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(guid); if (!pCreature || !target || !*args) - { return false; } + { + return false; + } // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } pCreature->MonsterWhisper(args, target); @@ -131,7 +145,9 @@ bool ChatHandler::HandleNpcWhisperCommand(char* args) bool ChatHandler::HandleAnnounceCommand(char* args) { if (!*args) - { return false; } + { + return false; + } sWorld.SendWorldText(LANG_SYSTEMMESSAGE, args); return true; @@ -141,7 +157,9 @@ bool ChatHandler::HandleAnnounceCommand(char* args) bool ChatHandler::HandleNotifyCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string str = GetMangosString(LANG_GLOBAL_NOTIFY); str += args; @@ -199,7 +217,9 @@ bool ChatHandler::HandleGMChatCommand(char* args) if (!*args) { if (m_session->GetPlayer()->isGMChat()) - { m_session->SendNotification(LANG_GM_CHAT_ON); } + { + m_session->SendNotification(LANG_GM_CHAT_ON); + } else { m_session->SendNotification(LANG_GM_CHAT_OFF); } return true; @@ -247,21 +267,27 @@ bool ChatHandler::HandleGMVisibleCommand(char* args) Player* player = m_session->GetPlayer(); SpellEntry const* invisibleAuraInfo = sSpellStore.LookupEntry(sWorld.getConfig(CONFIG_UINT32_GM_INVISIBLE_AURA)); if (!invisibleAuraInfo || !IsSpellAppliesAura(invisibleAuraInfo)) - { invisibleAuraInfo = NULL; } + { + invisibleAuraInfo = NULL; + } if (value) { player->SetGMVisible(true); m_session->SendNotification(LANG_INVISIBLE_VISIBLE); if (invisibleAuraInfo) - { player->RemoveAurasDueToSpell(invisibleAuraInfo->Id); } + { + player->RemoveAurasDueToSpell(invisibleAuraInfo->Id); + } } else { m_session->SendNotification(LANG_INVISIBLE_INVISIBLE); player->SetGMVisible(false); if (invisibleAuraInfo) - { player->CastSpell(player, invisibleAuraInfo, true); } + { + player->CastSpell(player, invisibleAuraInfo, true); + } } return true; @@ -273,7 +299,9 @@ bool ChatHandler::HandleGPSCommand(char* args) if (*args) { if (ObjectGuid guid = ExtractGuidFromLink(&args)) - { obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); } + { + obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); + } if (!obj) { @@ -329,7 +357,9 @@ bool ChatHandler::HandleGPSCommand(char* args) if (have_vmap) { if (terrain->IsOutdoors(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ())) - { PSendSysMessage("You are OUTdoor"); } + { + PSendSysMessage("You are OUTdoor"); + } else { PSendSysMessage("You are INdoor"); } } @@ -370,7 +400,9 @@ bool ChatHandler::HandleGPSCommand(char* args) PSendSysMessage("Static terrain height (maps only): %f", obj->GetTerrain()->GetHeightStatic(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), false)); if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager()) - { PSendSysMessage("Vmap Terrain Height %f", vmgr->getHeight(obj->GetMapId(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ() + 2.0f, 10000.0f)); } + { + PSendSysMessage("Vmap Terrain Height %f", vmgr->getHeight(obj->GetMapId(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ() + 2.0f, 10000.0f)); + } PSendSysMessage("Static map height (maps and vmaps): %f", obj->GetTerrain()->GetHeightStatic(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ())); #endif @@ -385,7 +417,9 @@ bool ChatHandler::HandleSummonCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } Player* player = m_session->GetPlayer(); if (target == player || target_guid == player->GetObjectGuid()) @@ -400,7 +434,9 @@ bool ChatHandler::HandleSummonCommand(char* args) std::string nameLink = playerLink(target_name); // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } if (target->IsBeingTeleported()) { @@ -432,7 +468,9 @@ bool ChatHandler::HandleSummonCommand(char* args) target->SetBattleGroundId(m_session->GetPlayer()->GetBattleGroundId(), m_session->GetPlayer()->GetBattleGroundTypeId()); // remember current position as entry point for return at bg end teleportation if (!target->GetMap()->IsBattleGroundOrArena()) - { target->SetBattleGroundEntryPoint(); } + { + target->SetBattleGroundEntryPoint(); + } } else if (pMap->IsDungeon()) { @@ -459,7 +497,9 @@ bool ChatHandler::HandleSummonCommand(char* args) PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), ""); if (needReportToTarget(target)) - { ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, playerLink(player->GetName()).c_str()); } + { + ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, playerLink(player->GetName()).c_str()); + } // stop flight if need if (target->IsTaxiFlying()) @@ -480,7 +520,9 @@ bool ChatHandler::HandleSummonCommand(char* args) { // check offline security if (HasLowerSecurity(NULL, target_guid)) - { return false; } + { + return false; + } std::string nameLink = playerLink(target_name); @@ -505,7 +547,9 @@ bool ChatHandler::HandleAppearCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } Player* _player = m_session->GetPlayer(); if (target == _player || target_guid == _player->GetObjectGuid()) @@ -520,7 +564,9 @@ bool ChatHandler::HandleAppearCommand(char* args) { // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } std::string chrNameLink = playerLink(target_name); @@ -546,7 +592,9 @@ bool ChatHandler::HandleAppearCommand(char* args) _player->SetBattleGroundId(target->GetBattleGroundId(), target->GetBattleGroundTypeId()); // remember current position as entry point for return at bg end teleportation if (!_player->GetMap()->IsBattleGroundOrArena()) - { _player->SetBattleGroundEntryPoint(); } + { + _player->SetBattleGroundEntryPoint(); + } } else if (cMap->IsDungeon()) { @@ -589,7 +637,9 @@ bool ChatHandler::HandleAppearCommand(char* args) // if player is group leader then we need add group bind if (group && group->IsLeader(_player->GetObjectGuid())) - { group->BindToInstance(save, !save->CanReset()); } + { + group->BindToInstance(save, !save->CanReset()); + } else { _player->BindToInstance(save, !save->CanReset()); } } @@ -603,7 +653,9 @@ bool ChatHandler::HandleAppearCommand(char* args) PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str()); if (needReportToTarget(target)) - { ChatHandler(target).PSendSysMessage(LANG_APPEARING_TO, GetNameLink().c_str()); } + { + ChatHandler(target).PSendSysMessage(LANG_APPEARING_TO, GetNameLink().c_str()); + } // stop flight if need if (_player->IsTaxiFlying()) @@ -625,7 +677,9 @@ bool ChatHandler::HandleAppearCommand(char* args) { // check offline security if (HasLowerSecurity(NULL, target_guid)) - { return false; } + { + return false; + } std::string nameLink = playerLink(target_name); @@ -636,7 +690,9 @@ bool ChatHandler::HandleAppearCommand(char* args) uint32 map; bool in_flight; if (!Player::LoadPositionFromDB(target_guid, map, x, y, z, o, in_flight)) - { return false; } + { + return false; + } return HandleGoHelper(_player, map, x, y, &z); } @@ -649,11 +705,15 @@ bool ChatHandler::HandleRecallCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } if (target->IsBeingTeleported()) { @@ -712,7 +772,9 @@ bool ChatHandler::HandleModifyHolyPowerCommand(char* args) bool ChatHandler::HandleModifyHPCommand(char* args) { if (!*args) - { return false; } + { + return false; + } int32 hp = atoi(args); int32 hpm = atoi(args); @@ -734,11 +796,15 @@ bool ChatHandler::HandleModifyHPCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_CHANGE_HP, GetNameLink(chr).c_str(), hp, hpm); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetNameLink().c_str(), hp, hpm); + } chr->SetMaxHealth(hpm); chr->SetHealth(hp); @@ -750,7 +816,9 @@ bool ChatHandler::HandleModifyHPCommand(char* args) bool ChatHandler::HandleModifyManaCommand(char* args) { if (!*args) - { return false; } + { + return false; + } int32 mana = atoi(args); int32 manam = atoi(args); @@ -772,11 +840,15 @@ bool ChatHandler::HandleModifyManaCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_CHANGE_MANA, GetNameLink(chr).c_str(), mana, manam); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam); + } chr->SetMaxPower(POWER_MANA, manam); chr->SetPower(POWER_MANA, mana); @@ -788,7 +860,9 @@ bool ChatHandler::HandleModifyManaCommand(char* args) bool ChatHandler::HandleModifyEnergyCommand(char* args) { if (!*args) - { return false; } + { + return false; + } int32 energy = atoi(args) * 10; int32 energym = atoi(args) * 10; @@ -810,11 +884,15 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_CHANGE_ENERGY, GetNameLink(chr).c_str(), energy / 10, energym / 10); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy / 10, energym / 10); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetNameLink().c_str(), energy / 10, energym / 10); + } chr->SetMaxPower(POWER_ENERGY, energym); chr->SetPower(POWER_ENERGY, energy); @@ -828,7 +906,9 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args) bool ChatHandler::HandleModifyRageCommand(char* args) { if (!*args) - { return false; } + { + return false; + } int32 rage = atoi(args) * 10; int32 ragem = atoi(args) * 10; @@ -850,11 +930,15 @@ bool ChatHandler::HandleModifyRageCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_CHANGE_RAGE, GetNameLink(chr).c_str(), rage / 10, ragem / 10); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage / 10, ragem / 10); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetNameLink().c_str(), rage / 10, ragem / 10); + } chr->SetMaxPower(POWER_RAGE, ragem); chr->SetPower(POWER_RAGE, rage); @@ -929,7 +1013,9 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) uint32 factionid; if (!ExtractUint32KeyFromLink(&args, "Hfaction", factionid)) - { return false; } + { + return false; + } if (!sFactionTemplateStore.LookupEntry(factionid)) { @@ -940,15 +1026,21 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) uint32 flag; if (!ExtractOptUInt32(&args, flag, chr->GetUInt32Value(UNIT_FIELD_FLAGS))) - { return false; } + { + return false; + } uint32 npcflag; if (!ExtractOptUInt32(&args, npcflag, chr->GetUInt32Value(UNIT_NPC_FLAGS))) - { return false; } + { + return false; + } uint32 dyflag; if (!ExtractOptUInt32(&args, dyflag, chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS))) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(), factionid, flag, npcflag, dyflag); @@ -964,11 +1056,15 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) bool ChatHandler::HandleModifyTalentCommand(char* args) { if (!*args) - { return false; } + { + return false; + } int tp = atoi(args); if (tp < 0) - { return false; } + { + return false; + } Unit* target = getSelectedUnit(); if (!target) @@ -982,7 +1078,9 @@ bool ChatHandler::HandleModifyTalentCommand(char* args) { // check online security if (HasLowerSecurity((Player*)target)) - { return false; } + { + return false; + } ((Player*)target)->SetFreeTalentPoints(tp); ((Player*)target)->SendTalentsInfoData(false); @@ -1021,7 +1119,9 @@ bool ChatHandler::HandleTaxiCheatCommand(char* args) Player* chr = getSelectedPlayer(); if (!chr) - { chr = m_session->GetPlayer(); } + { + chr = m_session->GetPlayer(); + } // check online security else if (HasLowerSecurity(chr)) { return false; } @@ -1031,14 +1131,18 @@ bool ChatHandler::HandleTaxiCheatCommand(char* args) chr->SetTaxiCheater(true); PSendSysMessage(LANG_YOU_GIVE_TAXIS, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetNameLink().c_str()); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetNameLink().c_str()); + } } else { chr->SetTaxiCheater(false); PSendSysMessage(LANG_YOU_REMOVE_TAXIS, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetNameLink().c_str()); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetNameLink().c_str()); + } } return true; @@ -1048,7 +1152,9 @@ bool ChatHandler::HandleTaxiCheatCommand(char* args) bool ChatHandler::HandleModifyASpeedCommand(char* args) { if (!*args) - { return false; } + { + return false; + } float modSpeed = (float)atof(args); @@ -1069,7 +1175,9 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } std::string chrNameLink = GetNameLink(chr); @@ -1082,7 +1190,9 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args) PSendSysMessage(LANG_YOU_CHANGE_ASPEED, modSpeed, chrNameLink.c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetNameLink().c_str(), modSpeed); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetNameLink().c_str(), modSpeed); + } chr->UpdateSpeed(MOVE_WALK, true, modSpeed, true); chr->UpdateSpeed(MOVE_RUN, true, modSpeed, true); @@ -1096,7 +1206,9 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args) bool ChatHandler::HandleModifySpeedCommand(char* args) { if (!*args) - { return false; } + { + return false; + } float modSpeed = (float)atof(args); @@ -1117,7 +1229,9 @@ bool ChatHandler::HandleModifySpeedCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } std::string chrNameLink = GetNameLink(chr); @@ -1130,7 +1244,9 @@ bool ChatHandler::HandleModifySpeedCommand(char* args) PSendSysMessage(LANG_YOU_CHANGE_SPEED, modSpeed, chrNameLink.c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); + } chr->UpdateSpeed(MOVE_RUN, true, modSpeed, true); @@ -1141,7 +1257,9 @@ bool ChatHandler::HandleModifySpeedCommand(char* args) bool ChatHandler::HandleModifySwimCommand(char* args) { if (!*args) - { return false; } + { + return false; + } float modSpeed = (float)atof(args); @@ -1162,7 +1280,9 @@ bool ChatHandler::HandleModifySwimCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } std::string chrNameLink = GetNameLink(chr); @@ -1175,7 +1295,9 @@ bool ChatHandler::HandleModifySwimCommand(char* args) PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, modSpeed, chrNameLink.c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); + } chr->UpdateSpeed(MOVE_SWIM, true, modSpeed, true); @@ -1186,7 +1308,9 @@ bool ChatHandler::HandleModifySwimCommand(char* args) bool ChatHandler::HandleModifyBWalkCommand(char* args) { if (!*args) - { return false; } + { + return false; + } float modSpeed = (float)atof(args); @@ -1207,7 +1331,9 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } std::string chrNameLink = GetNameLink(chr); @@ -1220,7 +1346,9 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args) PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, modSpeed, chrNameLink.c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); + } chr->UpdateSpeed(MOVE_RUN_BACK, true, modSpeed, true); @@ -1267,7 +1395,9 @@ bool ChatHandler::HandleModifyFlyCommand(char* args) bool ChatHandler::HandleModifyScaleCommand(char* args) { if (!*args) - { return false; } + { + return false; + } float Scale = (float)atof(args); if (Scale > 10.0f || Scale <= 0.0f) @@ -1289,11 +1419,15 @@ bool ChatHandler::HandleModifyScaleCommand(char* args) { // check online security if (HasLowerSecurity((Player*)target)) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, GetNameLink((Player*)target).c_str()); if (needReportToTarget((Player*)target)) - { ChatHandler((Player*)target).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetNameLink().c_str(), Scale); } + { + ChatHandler((Player*)target).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetNameLink().c_str(), Scale); + } } target->SetObjectScale(Scale); @@ -1306,7 +1440,9 @@ bool ChatHandler::HandleModifyScaleCommand(char* args) bool ChatHandler::HandleModifyMountCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint16 mId = 1147; float speed = (float)15; @@ -1536,11 +1672,15 @@ bool ChatHandler::HandleModifyMountCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_GIVE_MOUNT, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetNameLink().c_str()); } + { + ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetNameLink().c_str()); + } chr->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); chr->Mount(mId); @@ -1571,7 +1711,9 @@ bool ChatHandler::HandleModifyMountCommand(char* args) bool ChatHandler::HandleModifyMoneyCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* chr = getSelectedPlayer(); if (chr == NULL) @@ -1583,7 +1725,9 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } int64 addmoney; if (!ExtractInt64(&args, addmoney)) @@ -1603,14 +1747,18 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) { PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetNameLink().c_str()); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetNameLink().c_str()); + } chr->SetMoney(0); } else { if (newmoney > MAX_MONEY_AMOUNT) - { newmoney = MAX_MONEY_AMOUNT; } + { + newmoney = MAX_MONEY_AMOUNT; + } PSendSysMessage(LANG_YOU_TAKE_MONEY, MoneyToString(abs(addmoney)).c_str(), GetNameLink(chr).c_str()); if (needReportToTarget(chr)) @@ -1625,7 +1773,9 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetNameLink().c_str(), MoneyToString(addmoney).c_str()); if (addmoney >= MAX_MONEY_AMOUNT) - { chr->SetMoney(MAX_MONEY_AMOUNT); } + { + chr->SetMoney(MAX_MONEY_AMOUNT); + } else { chr->ModifyMoney(addmoney); } } @@ -1639,7 +1789,9 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) bool ChatHandler::HandleTeleCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* _player = m_session->GetPlayer(); @@ -1659,13 +1811,17 @@ bool ChatHandler::HandleTeleCommand(char* args) bool ChatHandler::HandleLookupAreaCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } uint32 counter = 0; // Counter for figure out that we found smth. @@ -1681,7 +1837,9 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) int loc = GetSessionDbcLocale(); std::string name = areaEntry->area_name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (!Utf8FitTo(name, wnamepart)) { @@ -1689,14 +1847,20 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) - { continue; } + { + continue; + } name = areaEntry->area_name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) - { break; } + { + break; + } } } @@ -1705,7 +1869,9 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) // send area in "id - [name]" format std::ostringstream ss; if (m_session) - { ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc] << "]|h|r"; } + { + ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc] << "]|h|r"; + } else { ss << areaEntry->ID << " - " << name << " " << localeNames[loc]; } @@ -1717,7 +1883,9 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_NOAREAFOUND); } + { + SendSysMessage(LANG_COMMAND_NOAREAFOUND); + } return true; } @@ -1736,7 +1904,9 @@ bool ChatHandler::HandleLookupTeleCommand(char* args) std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -1749,16 +1919,22 @@ bool ChatHandler::HandleLookupTeleCommand(char* args) GameTele const* tele = &itr->second; if (tele->wnameLow.find(wnamepart) == std::wstring::npos) - { continue; } + { + continue; + } if (m_session) - { reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n"; } + { + reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n"; + } else { reply << " " << itr->first << " " << tele->name << "\n"; } } if (reply.str().empty()) - { SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); } + { + SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); + } else { PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str()); } @@ -1814,13 +1990,17 @@ bool ChatHandler::HandleSendMailCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } MailDraft draft; // fill draft if (!HandleSendMailHelper(draft, args)) - { return false; } + { + return false; + } // from console show nonexistent sender MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM); @@ -1841,7 +2021,9 @@ bool ChatHandler::HandleTeleNameCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r GameTele const* tele = ExtractGameTeleFromLink(&args); @@ -1856,7 +2038,9 @@ bool ChatHandler::HandleTeleNameCommand(char* args) { // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } std::string chrNameLink = playerLink(target_name); @@ -1869,7 +2053,9 @@ bool ChatHandler::HandleTeleNameCommand(char* args) PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(), "", tele->name.c_str()); if (needReportToTarget(target)) - { ChatHandler(target).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str()); } + { + ChatHandler(target).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str()); + } return HandleGoHelper(target, tele->mapId, tele->position_x, tele->position_y, &tele->position_z, &tele->orientation); } @@ -1877,7 +2063,9 @@ bool ChatHandler::HandleTeleNameCommand(char* args) { // check offline security if (HasLowerSecurity(NULL, target_guid)) - { return false; } + { + return false; + } std::string nameLink = playerLink(target_name); @@ -1894,7 +2082,9 @@ bool ChatHandler::HandleTeleNameCommand(char* args) bool ChatHandler::HandleTeleGroupCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* player = getSelectedPlayer(); if (!player) @@ -1906,7 +2096,9 @@ bool ChatHandler::HandleTeleGroupCommand(char* args) // check online security if (HasLowerSecurity(player)) - { return false; } + { + return false; + } // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r GameTele const* tele = ExtractGameTeleFromLink(&args); @@ -1932,11 +2124,15 @@ bool ChatHandler::HandleTeleGroupCommand(char* args) Player* pl = itr->getSource(); if (!pl || !pl->GetSession()) - { continue; } + { + continue; + } // check online security if (HasLowerSecurity(pl)) - { return false; } + { + return false; + } std::string plNameLink = GetNameLink(pl); @@ -1948,7 +2144,9 @@ bool ChatHandler::HandleTeleGroupCommand(char* args) PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str()); if (needReportToTarget(pl)) - { ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); } + { + ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); + } // stop flight if need if (pl->IsTaxiFlying()) @@ -1971,11 +2169,15 @@ bool ChatHandler::HandleGroupgoCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } Group* grp = target->GetGroup(); @@ -2008,11 +2210,15 @@ bool ChatHandler::HandleGroupgoCommand(char* args) Player* pl = itr->getSource(); if (!pl || pl == m_session->GetPlayer() || !pl->GetSession()) - { continue; } + { + continue; + } // check online security if (HasLowerSecurity(pl)) - { return false; } + { + return false; + } std::string plNameLink = GetNameLink(pl); @@ -2038,7 +2244,9 @@ bool ChatHandler::HandleGroupgoCommand(char* args) PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), ""); if (needReportToTarget(pl)) - { ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str()); } + { + ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str()); + } // stop flight if need if (pl->IsTaxiFlying()) @@ -2069,7 +2277,9 @@ bool ChatHandler::HandleGoHelper(Player* player, uint32 mapid, float x, float y, z = *zPtr; if (ortPtr) - { ort = *ortPtr; } + { + ort = *ortPtr; + } // check full provided coordinates if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort)) @@ -2114,7 +2324,9 @@ bool ChatHandler::HandleGoTaxinodeCommand(char* args) uint32 nodeId; if (!ExtractUint32KeyFromLink(&args, "Htaxinode", nodeId)) - { return false; } + { + return false; + } TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId); if (!node) @@ -2137,7 +2349,9 @@ bool ChatHandler::HandleGoTaxinodeCommand(char* args) bool ChatHandler::HandleGoCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* _player = m_session->GetPlayer(); @@ -2148,13 +2362,19 @@ bool ChatHandler::HandleGoCommand(char* args) if (ExtractFloat(&args, x)) { if (!ExtractFloat(&args, y)) - { return false; } + { + return false; + } if (!ExtractFloat(&args, z)) - { return false; } + { + return false; + } if (!ExtractOptUInt32(&args, mapid, _player->GetMapId())) - { return false; } + { + return false; + } } // link case else if (!ExtractLocationFromLink(&args, mapid, x, y, z)) @@ -2172,15 +2392,21 @@ bool ChatHandler::HandleGoXYCommand(char* args) float x; if (!ExtractFloat(&args, x)) - { return false; } + { + return false; + } float y; if (!ExtractFloat(&args, y)) - { return false; } + { + return false; + } uint32 mapid; if (!ExtractOptUInt32(&args, mapid, _player->GetMapId())) - { return false; } + { + return false; + } return HandleGoHelper(_player, mapid, x, y); } @@ -2192,19 +2418,27 @@ bool ChatHandler::HandleGoXYZCommand(char* args) float x; if (!ExtractFloat(&args, x)) - { return false; } + { + return false; + } float y; if (!ExtractFloat(&args, y)) - { return false; } + { + return false; + } float z; if (!ExtractFloat(&args, z)) - { return false; } + { + return false; + } uint32 mapid; if (!ExtractOptUInt32(&args, mapid, _player->GetMapId())) - { return false; } + { + return false; + } return HandleGoHelper(_player, mapid, x, y, &z); } @@ -2216,17 +2450,23 @@ bool ChatHandler::HandleGoZoneXYCommand(char* args) float x; if (!ExtractFloat(&args, x)) - { return false; } + { + return false; + } float y; if (!ExtractFloat(&args, y)) - { return false; } + { + return false; + } uint32 areaid; if (*args) { if (!ExtractUint32KeyFromLink(&args, "Harea", areaid)) - { return false; } + { + return false; + } } else { areaid = _player->GetZoneId(); } @@ -2271,15 +2511,21 @@ bool ChatHandler::HandleGoGridCommand(char* args) float grid_x; if (!ExtractFloat(&args, grid_x)) - { return false; } + { + return false; + } float grid_y; if (!ExtractFloat(&args, grid_y)) - { return false; } + { + return false; + } uint32 mapid; if (!ExtractOptUInt32(&args, mapid, _player->GetMapId())) - { return false; } + { + return false; + } // center of grid float x = (grid_x - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS; @@ -2306,7 +2552,9 @@ bool ChatHandler::HandleModifyDrunkCommand(char* args) bool ChatHandler::HandleSetViewCommand(char* /*args*/) { if (Unit* unit = getSelectedUnit()) - { m_session->GetPlayer()->GetCamera().SetView(unit); } + { + m_session->GetPlayer()->GetCamera().SetView(unit); + } else { PSendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); diff --git a/src/game/ChatCommands/Level2.cpp b/src/game/ChatCommands/Level2.cpp index 00d3a2bb0..447ca8fb5 100644 --- a/src/game/ChatCommands/Level2.cpp +++ b/src/game/ChatCommands/Level2.cpp @@ -78,11 +78,15 @@ bool ChatHandler::HandleMuteCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } uint32 notspeaktime; if (!ExtractUInt32(&args, notspeaktime)) - { return false; } + { + return false; + } uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); @@ -90,22 +94,30 @@ bool ChatHandler::HandleMuteCommand(char* args) if (!target) { if (WorldSession* session = sWorld.FindSession(account_id)) - { target = session->GetPlayer(); } + { + target = session->GetPlayer(); + } } // must have strong lesser security level if (HasLowerSecurity(target, target_guid, true)) - { return false; } + { + return false; + } time_t mutetime = time(NULL) + notspeaktime * 60; if (target) - { target->GetSession()->m_muteTime = mutetime; } + { + target->GetSession()->m_muteTime = mutetime; + } LoginDatabase.PExecute("UPDATE account SET mutetime = " UI64FMTD " WHERE id = '%u'", uint64(mutetime), account_id); if (target) - { ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime); } + { + ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notspeaktime); + } std::string nameLink = playerLink(target_name); @@ -120,7 +132,9 @@ bool ChatHandler::HandleUnmuteCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } uint32 account_id = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); @@ -128,12 +142,16 @@ bool ChatHandler::HandleUnmuteCommand(char* args) if (!target) { if (WorldSession* session = sWorld.FindSession(account_id)) - { target = session->GetPlayer(); } + { + target = session->GetPlayer(); + } } // must have strong lesser security level if (HasLowerSecurity(target, target_guid, true)) - { return false; } + { + return false; + } if (target) { @@ -150,7 +168,9 @@ bool ChatHandler::HandleUnmuteCommand(char* args) LoginDatabase.PExecute("UPDATE account SET mutetime = '0' WHERE id = '%u'", account_id); if (target) - { ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); } + { + ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); + } std::string nameLink = playerLink(target_name); @@ -199,7 +219,9 @@ void ChatHandler::ShowTriggerListHelper(AreaTriggerEntry const* atEntry) atEntry->id, atEntry->mapid, atEntry->x, atEntry->y, atEntry->z, tavern, quest); if (AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id)) - { ShowTriggerTargetListHelper(atEntry->id, at, true); } + { + ShowTriggerTargetListHelper(atEntry->id, at, true); + } } bool ChatHandler::HandleTriggerCommand(char* args) @@ -213,10 +235,14 @@ bool ChatHandler::HandleTriggerCommand(char* args) { uint32 atId; if (!ExtractUint32KeyFromLink(&args, "Hareatrigger", atId)) - { return false; } + { + return false; + } if (!atId) - { return false; } + { + return false; + } atEntry = sAreaTriggerStore.LookupEntry(atId); @@ -231,7 +257,9 @@ bool ChatHandler::HandleTriggerCommand(char* args) else { if (!m_session) - { return false; } + { + return false; + } float dist2 = MAP_SIZE * MAP_SIZE; @@ -240,10 +268,14 @@ bool ChatHandler::HandleTriggerCommand(char* args) { AreaTriggerEntry const* atTestEntry = sAreaTriggerStore.LookupEntry(id); if (!atTestEntry) - { continue; } + { + continue; + } if (atTestEntry->mapid != m_session->GetPlayer()->GetMapId()) - { continue; } + { + continue; + } float dx = atTestEntry->x - pl->GetPositionX(); float dy = atTestEntry->y - pl->GetPositionY(); @@ -251,7 +283,9 @@ bool ChatHandler::HandleTriggerCommand(char* args) float test_dist2 = dx * dx + dy * dy; if (test_dist2 >= dist2) - { continue; } + { + continue; + } dist2 = test_dist2; atEntry = atTestEntry; @@ -271,7 +305,9 @@ bool ChatHandler::HandleTriggerCommand(char* args) AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id); if (at) - { PSendSysMessage(LANG_TRIGGER_REQ_LEVEL, at->requiredLevel); } + { + PSendSysMessage(LANG_TRIGGER_REQ_LEVEL, at->requiredLevel); + } if (uint32 quest_id = sObjectMgr.GetQuestForAreaTrigger(atEntry->id)) { @@ -286,9 +322,13 @@ bool ChatHandler::HandleTriggerCommand(char* args) SendSysMessage(LANG_TRIGGER_REQ_ITEMS); if (at->requiredItem) - { ShowItemListHelper(at->requiredItem, loc_idx, pl); } + { + ShowItemListHelper(at->requiredItem, loc_idx, pl); + } if (at->requiredItem2) - { ShowItemListHelper(at->requiredItem2, loc_idx, pl); } + { + ShowItemListHelper(at->requiredItem2, loc_idx, pl); + } } if (at->requiredQuest) @@ -328,10 +368,14 @@ bool ChatHandler::HandleTriggerActiveCommand(char* /*args*/) { AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id); if (!atEntry) - { continue; } + { + continue; + } if (!IsPointInAreaTriggerZone(atEntry, pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ())) - { continue; } + { + continue; + } ShowTriggerListHelper(atEntry); @@ -339,7 +383,9 @@ bool ChatHandler::HandleTriggerActiveCommand(char* /*args*/) } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_NOTRIGGERFOUND); } + { + SendSysMessage(LANG_COMMAND_NOTRIGGERFOUND); + } return true; } @@ -357,16 +403,22 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) { AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id); if (!atEntry) - { continue; } + { + continue; + } if (atEntry->mapid != m_session->GetPlayer()->GetMapId()) - { continue; } + { + continue; + } float dx = atEntry->x - pl->GetPositionX(); float dy = atEntry->y - pl->GetPositionY(); if (dx * dx + dy * dy > dist2) - { continue; } + { + continue; + } ShowTriggerListHelper(atEntry); @@ -378,20 +430,28 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) { AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(id); if (!atEntry) - { continue; } + { + continue; + } AreaTrigger const* at = sObjectMgr.GetAreaTrigger(atEntry->id); if (!at) - { continue; } + { + continue; + } if (at->target_mapId != m_session->GetPlayer()->GetMapId()) - { continue; } + { + continue; + } float dx = at->target_X - pl->GetPositionX(); float dy = at->target_Y - pl->GetPositionY(); if (dx * dx + dy * dy > dist2) - { continue; } + { + continue; + } ShowTriggerTargetListHelper(atEntry->id, at); @@ -399,7 +459,9 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_NOTRIGGERFOUND); } + { + SendSysMessage(LANG_COMMAND_NOTRIGGERFOUND); + } return true; } @@ -416,18 +478,26 @@ bool ChatHandler::HandleGoTriggerCommand(char* args) Player* _player = m_session->GetPlayer(); if (!*args) - { return false; } + { + return false; + } char* atIdStr = ExtractKeyFromLink(&args, areatriggerKeys); if (!atIdStr) - { return false; } + { + return false; + } uint32 atId; if (!ExtractUInt32(&atIdStr, atId)) - { return false; } + { + return false; + } if (!atId) - { return false; } + { + return false; + } AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(atId); if (!atEntry) @@ -439,7 +509,9 @@ bool ChatHandler::HandleGoTriggerCommand(char* args) bool to_target = ExtractLiteralArg(&args, "target"); if (!to_target && *args) // can be fail also at syntax error - { return false; } + { + return false; + } if (to_target) { @@ -463,7 +535,9 @@ bool ChatHandler::HandleGoGraveyardCommand(char* args) uint32 gyId; if (!ExtractUInt32(&args, gyId)) - { return false; } + { + return false; + } WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(gyId); if (!gy) @@ -504,7 +578,9 @@ static char const* const creatureKeys[] = bool ChatHandler::HandleGoCreatureCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* _player = m_session->GetPlayer(); @@ -512,7 +588,9 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) int crType; char* pParam1 = ExtractKeyFromLink(&args, creatureKeys, &crType); if (!pParam1) - { return false; } + { + return false; + } // User wants to teleport to the NPC's template entry if (crType == CREATURE_LINK_RAW && strcmp(pParam1, "id") == 0) @@ -520,7 +598,9 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r pParam1 = ExtractKeyFromLink(&args, "Hcreature_entry"); if (!pParam1) - { return false; } + { + return false; + } crType = CREATURE_LINK_ENTRY; } @@ -533,10 +613,14 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) { uint32 tEntry; if (!ExtractUInt32(&pParam1, tEntry)) - { return false; } + { + return false; + } if (!tEntry) - { return false; } + { + return false; + } if (!ObjectMgr::GetCreatureTemplate(tEntry)) { @@ -564,7 +648,9 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) { uint32 lowguid; if (!ExtractUInt32(&pParam1, lowguid)) - { return false; } + { + return false; + } data = sObjectMgr.GetCreatureData(lowguid); if (!data) @@ -610,7 +696,9 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) CreatureDataPair const* cr_data = sObjectMgr.GetCreatureDataPair(guid); if (!cr_data) - { continue; } + { + continue; + } worker(*cr_data); } @@ -658,7 +746,9 @@ bool ChatHandler::HandleGoObjectCommand(char* args) int goType; char* pParam1 = ExtractKeyFromLink(&args, gameobjectKeys, &goType); if (!pParam1) - { return false; } + { + return false; + } // User wants to teleport to the GO's template entry if (goType == GAMEOBJECT_LINK_RAW && strcmp(pParam1, "id") == 0) @@ -666,7 +756,9 @@ bool ChatHandler::HandleGoObjectCommand(char* args) // number or [name] Shift-click form |color|Hgameobject_entry:creature_id|h[name]|h|r pParam1 = ExtractKeyFromLink(&args, "Hgameobject_entry"); if (!pParam1) - { return false; } + { + return false; + } goType = GAMEOBJECT_LINK_ENTRY; } @@ -679,10 +771,14 @@ bool ChatHandler::HandleGoObjectCommand(char* args) { uint32 tEntry; if (!ExtractUInt32(&pParam1, tEntry)) - { return false; } + { + return false; + } if (!tEntry) - { return false; } + { + return false; + } if (!ObjectMgr::GetGameObjectInfo(tEntry)) { @@ -711,7 +807,9 @@ bool ChatHandler::HandleGoObjectCommand(char* args) { uint32 lowguid; if (!ExtractUInt32(&pParam1, lowguid)) - { return false; } + { + return false; + } // by DB guid data = sObjectMgr.GetGOData(lowguid); @@ -758,7 +856,9 @@ bool ChatHandler::HandleGoObjectCommand(char* args) GameObjectDataPair const* go_data = sObjectMgr.GetGODataPair(guid); if (!go_data) - { continue; } + { + continue; + } worker(*go_data); } @@ -793,7 +893,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r char* cId = ExtractKeyFromLink(&args, "Hgameobject_entry"); if (!cId) - { return false; } + { + return false; + } uint32 id; if (ExtractUInt32(&cId, id)) @@ -829,7 +931,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) } if (!initString) - { eventFilter << "))"; } + { + eventFilter << "))"; + } else { eventFilter << ")"; } @@ -862,7 +966,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) mapid = fields[6].GetUInt16(); pool_id = sPoolMgr.IsPartOfAPool(lowguid); if (!pool_id || pl->GetMap()->GetPersistentState()->IsSpawnedPoolObject(lowguid)) - { found = true; } + { + found = true; + } } while (result->NextRow() && (!found)); @@ -890,7 +996,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) { time_t curRespawnDelay = target->GetRespawnTimeEx() - time(NULL); if (curRespawnDelay < 0) - { curRespawnDelay = 0; } + { + curRespawnDelay = 0; + } std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay, true); std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true); @@ -900,7 +1008,9 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) ShowNpcOrGoSpawnInformation(target->GetGUIDLow()); if (target->GetGoType() == GAMEOBJECT_TYPE_DOOR) - { PSendSysMessage(LANG_COMMAND_GO_STATUS_DOOR, target->GetGoState(), target->getLootState(), GetOnOffStr(target->IsCollisionEnabled()), goI->door.startOpen ? "open" : "closed"); } + { + 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())); } } @@ -913,16 +1023,22 @@ bool ChatHandler::HandleGameObjectDeleteCommand(char* args) // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r uint32 lowguid; if (!ExtractUint32KeyFromLink(&args, "Hgameobject", lowguid)) - { return false; } + { + return false; + } if (!lowguid) - { return false; } + { + return false; + } GameObject* obj = NULL; // by DB guid if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - { obj = GetGameObjectWithGuid(lowguid, go_data->id); } + { + obj = GetGameObjectWithGuid(lowguid, go_data->id); + } if (!obj) { @@ -959,16 +1075,22 @@ bool ChatHandler::HandleGameObjectTurnCommand(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; } + { + return false; + } if (!lowguid) - { return false; } + { + return false; + } GameObject* obj = NULL; // by DB guid if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - { obj = GetGameObjectWithGuid(lowguid, go_data->id); } + { + obj = GetGameObjectWithGuid(lowguid, go_data->id); + } if (!obj) { @@ -979,7 +1101,9 @@ bool ChatHandler::HandleGameObjectTurnCommand(char* args) float z_rot, y_rot, x_rot; if (!ExtractFloat(&args, z_rot) || !ExtractOptFloat(&args, y_rot, 0) || !ExtractOptFloat(&args, x_rot, 0)) - { return false; } + { + return false; + } obj->SetWorldRotationAngles(z_rot, y_rot, x_rot); obj->SaveToDB(); @@ -994,16 +1118,22 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args) // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r uint32 lowguid; if (!ExtractUint32KeyFromLink(&args, "Hgameobject", lowguid)) - { return false; } + { + return false; + } if (!lowguid) - { return false; } + { + return false; + } GameObject* obj = NULL; // by DB guid if (GameObjectData const* go_data = sObjectMgr.GetGOData(lowguid)) - { obj = GetGameObjectWithGuid(lowguid, go_data->id); } + { + obj = GetGameObjectWithGuid(lowguid, go_data->id); + } if (!obj) { @@ -1027,15 +1157,21 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args) { float x; if (!ExtractFloat(&args, x)) - { return false; } + { + return false; + } float y; if (!ExtractFloat(&args, y)) - { return false; } + { + return false; + } float z; if (!ExtractFloat(&args, z)) - { return false; } + { + return false; + } if (!MapManager::IsValidMapCoord(obj->GetMapId(), x, y, z)) { @@ -1066,14 +1202,20 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args) // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r uint32 id; if (!ExtractUint32KeyFromLink(&args, "Hgameobject_entry", id)) - { return false; } + { + return false; + } if (!id) - { return false; } + { + return false; + } int32 spawntimeSecs; if (!ExtractOptInt32(&args, spawntimeSecs, 0)) - { return false; } + { + return false; + } const GameObjectInfo* gInfo = ObjectMgr::GetGameObjectInfo(id); if (!gInfo) @@ -1116,7 +1258,9 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args) } if (spawntimeSecs) - { pGameObj->SetRespawnTime(spawntimeSecs); } + { + pGameObj->SetRespawnTime(spawntimeSecs); + } // fill the gameobject data and save to the db pGameObj->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), plr->GetPhaseMaskForSpawn()); @@ -1179,7 +1323,9 @@ bool ChatHandler::HandleGameObjectNearCommand(char* args) { float distance; if (!ExtractOptFloat(&args, distance, 10.0f)) - { return false; } + { + return false; + } uint32 count = 0; @@ -1205,7 +1351,9 @@ bool ChatHandler::HandleGameObjectNearCommand(char* args) GameObjectInfo const* gInfo = ObjectMgr::GetGameObjectInfo(entry); if (!gInfo) - { continue; } + { + continue; + } PSendSysMessage(LANG_GO_MIXED_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), entry, guid, gInfo->name, x, y, z, mapid); @@ -1374,7 +1522,9 @@ void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, Locale // or "id - [faction] [no reputation]" format std::ostringstream ss; if (m_session) - { ss << factionEntry->ID << " - |cffffffff|Hfaction:" << factionEntry->ID << "|h[" << name << " " << localeNames[loc] << "]|h|r"; } + { + ss << factionEntry->ID << " - |cffffffff|Hfaction:" << factionEntry->ID << "|h[" << name << " " << localeNames[loc] << "]|h|r"; + } else { ss << factionEntry->ID << " - " << name << " " << localeNames[loc]; } @@ -1386,17 +1536,29 @@ void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, Locale ss << " " << rankName << "|h|r (" << target->GetReputationMgr().GetReputation(factionEntry) << ")"; if (repState->Flags & FACTION_FLAG_VISIBLE) - { ss << GetMangosString(LANG_FACTION_VISIBLE); } + { + ss << GetMangosString(LANG_FACTION_VISIBLE); + } if (repState->Flags & FACTION_FLAG_AT_WAR) - { ss << GetMangosString(LANG_FACTION_ATWAR); } + { + ss << GetMangosString(LANG_FACTION_ATWAR); + } if (repState->Flags & FACTION_FLAG_PEACE_FORCED) - { ss << GetMangosString(LANG_FACTION_PEACE_FORCED); } + { + ss << GetMangosString(LANG_FACTION_PEACE_FORCED); + } if (repState->Flags & FACTION_FLAG_HIDDEN) - { ss << GetMangosString(LANG_FACTION_HIDDEN); } + { + ss << GetMangosString(LANG_FACTION_HIDDEN); + } if (repState->Flags & FACTION_FLAG_INVISIBLE_FORCED) - { ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED); } + { + ss << GetMangosString(LANG_FACTION_INVISIBLE_FORCED); + } if (repState->Flags & FACTION_FLAG_INACTIVE) - { ss << GetMangosString(LANG_FACTION_INACTIVE); } + { + ss << GetMangosString(LANG_FACTION_INACTIVE); + } } else if (target) { ss << GetMangosString(LANG_FACTION_NOREPUTATION); } @@ -1407,7 +1569,9 @@ void ChatHandler::ShowFactionListHelper(FactionEntry const* factionEntry, Locale bool ChatHandler::HandleLookupFactionCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // Can be NULL at console call Player* target = getSelectedPlayer(); @@ -1416,7 +1580,9 @@ bool ChatHandler::HandleLookupFactionCommand(char* args) std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -1431,7 +1597,9 @@ bool ChatHandler::HandleLookupFactionCommand(char* args) int loc = GetSessionDbcLocale(); std::string name = factionEntry->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (!Utf8FitTo(name, wnamepart)) { @@ -1439,14 +1607,20 @@ bool ChatHandler::HandleLookupFactionCommand(char* args) for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) - { continue; } + { + continue; + } name = factionEntry->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) - { break; } + { + break; + } } } @@ -1460,14 +1634,18 @@ bool ChatHandler::HandleLookupFactionCommand(char* args) } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND); } + { + SendSysMessage(LANG_COMMAND_FACTION_NOTFOUND); + } return true; } bool ChatHandler::HandleModifyRepCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* target = getSelectedPlayer(); @@ -1480,26 +1658,36 @@ bool ChatHandler::HandleModifyRepCommand(char* args) // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } uint32 factionId; if (!ExtractUint32KeyFromLink(&args, "Hfaction", factionId)) - { return false; } + { + return false; + } if (!factionId) - { return false; } + { + return false; + } int32 amount = 0; if (!ExtractInt32(&args, amount)) { char* rankTxt = ExtractLiteralArg(&args); if (!rankTxt) - { return false; } + { + return false; + } std::string rankStr = rankTxt; std::wstring wrankStr; if (!Utf8toWStr(rankStr, wrankStr)) - { return false; } + { + return false; + } wstrToLower(wrankStr); int r = 0; @@ -1508,11 +1696,15 @@ bool ChatHandler::HandleModifyRepCommand(char* args) { std::string rank = GetMangosString(ReputationRankStrIndex[r]); if (rank.empty()) - { continue; } + { + continue; + } std::wstring wrank; if (!Utf8toWStr(rank, wrank)) - { continue; } + { + continue; + } wstrToLower(wrank); @@ -1565,11 +1757,15 @@ bool ChatHandler::HandleModifyRepCommand(char* args) bool ChatHandler::HandleNpcAddCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint32 id; if (!ExtractUint32KeyFromLink(&args, "Hcreature_entry", id)) - { return false; } + { + return false; + } CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(id); if (!cinfo) @@ -1666,11 +1862,15 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(char* args) uint32 maxcount; if (!ExtractOptUInt32(&args, maxcount, 0)) - { return false; } + { + return false; + } uint32 incrtime; if (!ExtractOptUInt32(&args, incrtime, 0)) - { return false; } + { + return false; + } uint32 extendedcost; if (!ExtractOptUInt32(&args, extendedcost, 0)) @@ -1733,7 +1933,9 @@ bool ChatHandler::HandleNpcDelVendorCurrencyCommand(char* args) bool ChatHandler::HandleNpcDelVendorItemCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Creature* vendor = getSelectedCreature(); if (!vendor || !vendor->IsVendor()) @@ -1788,7 +1990,9 @@ bool ChatHandler::HandleNpcAIInfoCommand(char* /*args*/) strScript.empty() ? " - " : strScript.c_str()); if (pTarget->AI()) - { pTarget->AI()->GetAIInformation(*this); } + { + pTarget->AI()->GetAIInformation(*this); + } return true; } @@ -1797,7 +2001,9 @@ bool ChatHandler::HandleNpcAIInfoCommand(char* /*args*/) bool ChatHandler::HandleNpcChangeLevelCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint8 lvl = (uint8) atoi(args); if (lvl < 1 || lvl > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) + 3) @@ -1816,7 +2022,9 @@ bool ChatHandler::HandleNpcChangeLevelCommand(char* args) } if (pCreature->IsPet()) - { ((Pet*)pCreature)->GivePetLevel(lvl); } + { + ((Pet*)pCreature)->GivePetLevel(lvl); + } else { pCreature->SetMaxHealth(100 + 30 * lvl); @@ -1824,7 +2032,9 @@ bool ChatHandler::HandleNpcChangeLevelCommand(char* args) pCreature->SetLevel(lvl); if (pCreature->HasStaticDBSpawnData()) - { pCreature->SaveToDB(); } + { + pCreature->SaveToDB(); + } } return true; @@ -1834,7 +2044,9 @@ bool ChatHandler::HandleNpcChangeLevelCommand(char* args) bool ChatHandler::HandleNpcFlagCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint32 npcFlags = (uint32) atoi(args); @@ -1865,13 +2077,19 @@ bool ChatHandler::HandleNpcDeleteCommand(char* args) // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r uint32 lowguid; if (!ExtractUint32KeyFromLink(&args, "Hcreature", lowguid)) - { return false; } + { + return false; + } if (!lowguid) - { return false; } + { + return false; + } if (CreatureData const* data = sObjectMgr.GetCreatureData(lowguid)) - { unit = m_session->GetPlayer()->GetMap()->GetCreature(data->GetObjectGuid(lowguid)); } + { + unit = m_session->GetPlayer()->GetMap()->GetCreature(data->GetObjectGuid(lowguid)); + } } else { unit = getSelectedCreature(); } @@ -1927,7 +2145,9 @@ bool ChatHandler::HandleNpcMoveCommand(char* args) { // number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r if (!ExtractUint32KeyFromLink(&args, "Hcreature", lowguid)) - { return false; } + { + return false; + } CreatureData const* data = sObjectMgr.GetCreatureData(lowguid); if (!data) @@ -2005,7 +2225,9 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args) { pCreature = getSelectedCreature(); if (!pCreature || !pCreature->HasStaticDBSpawnData()) - { return false; } + { + return false; + } lowguid = pCreature->GetGUIDLow(); } else // case .setmovetype #creature_guid $move_type (with guid) @@ -2033,10 +2255,14 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args) MovementGeneratorType move_type; char* type_str = ExtractLiteralArg(&args); if (!type_str) - { return false; } + { + return false; + } if (strncmp(type_str, "stay", strlen(type_str)) == 0) - { move_type = IDLE_MOTION_TYPE; } + { + move_type = IDLE_MOTION_TYPE; + } else if (strncmp(type_str, "random", strlen(type_str)) == 0) { move_type = RANDOM_MOTION_TYPE; } else if (strncmp(type_str, "way", strlen(type_str)) == 0) @@ -2046,14 +2272,18 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args) bool doNotDelete = ExtractLiteralArg(&args, "NODEL") != NULL; if (!doNotDelete && *args) // need fail if false in result wrong literal - { return false; } + { + return false; + } // now lowguid is low guid really existing creature // and pCreature point (maybe) to this creature or NULL // update movement type if (!doNotDelete) - { sWaypointMgr.DeletePath(lowguid); } + { + sWaypointMgr.DeletePath(lowguid); + } if (pCreature) { @@ -2068,7 +2298,9 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args) } if (doNotDelete) - { PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL, type_str); } + { + PSendSysMessage(LANG_MOVE_TYPE_SET_NODEL, type_str); + } else { PSendSysMessage(LANG_MOVE_TYPE_SET, type_str); } @@ -2079,7 +2311,9 @@ bool ChatHandler::HandleNpcSetMoveTypeCommand(char* args) bool ChatHandler::HandleNpcSetModelCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint32 displayId = (uint32) atoi(args); @@ -2096,7 +2330,9 @@ bool ChatHandler::HandleNpcSetModelCommand(char* args) pCreature->SetNativeDisplayId(displayId); if (pCreature->HasStaticDBSpawnData()) - { pCreature->SaveToDB(); } + { + pCreature->SaveToDB(); + } return true; } @@ -2104,7 +2340,9 @@ bool ChatHandler::HandleNpcSetModelCommand(char* args) bool ChatHandler::HandleNpcFactionIdCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint32 factionId = (uint32) atoi(args); @@ -2144,7 +2382,9 @@ bool ChatHandler::HandleNpcFactionIdCommand(char* args) bool ChatHandler::HandleNpcSpawnDistCommand(char* args) { if (!*args) - { return false; } + { + return false; + } float option = (float)atof(args); if (option < 0.0f) @@ -2155,13 +2395,17 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args) MovementGeneratorType mtype = IDLE_MOTION_TYPE; if (option > 0.0f) - { mtype = RANDOM_MOTION_TYPE; } + { + mtype = RANDOM_MOTION_TYPE; + } Creature* pCreature = getSelectedCreature(); uint32 u_guidlow = 0; if (pCreature) - { u_guidlow = pCreature->GetGUIDLow(); } + { + u_guidlow = pCreature->GetGUIDLow(); + } else { return false; } @@ -2183,7 +2427,9 @@ bool ChatHandler::HandleNpcSpawnTimeCommand(char* args) { uint32 stime; if (!ExtractUInt32(&args, stime)) - { return false; } + { + return false; + } Creature* pCreature = getSelectedCreature(); if (!pCreature) @@ -2331,7 +2577,9 @@ bool ChatHandler::HandleNpcSetDeathStateCommand(char* args) } if (value) - { pCreature->SetDeadByDefault(true); } + { + pCreature->SetDeadByDefault(true); + } else { pCreature->SetDeadByDefault(false); } @@ -2438,30 +2686,42 @@ bool ChatHandler::HandleNpcSubNameCommand(char* /*args*/) bool ChatHandler::HandleItemMoveCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint8 srcslot, dstslot; char* pParam1 = strtok(args, " "); if (!pParam1) - { return false; } + { + return false; + } char* pParam2 = strtok(NULL, " "); if (!pParam2) - { return false; } + { + return false; + } srcslot = (uint8)atoi(pParam1); dstslot = (uint8)atoi(pParam2); if (srcslot == dstslot) - { return true; } + { + return true; + } Player* player = m_session->GetPlayer(); if (!player->IsValidPos(INVENTORY_SLOT_BAG_0, srcslot, true)) - { return false; } + { + return false; + } // can be autostore pos if (!player->IsValidPos(INVENTORY_SLOT_BAG_0, dstslot, false)) - { return false; } + { + return false; + } uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcslot); uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstslot); @@ -2476,7 +2736,9 @@ bool ChatHandler::HandleDeMorphCommand(char* /*args*/) { Unit* target = getSelectedUnit(); if (!target) - { target = m_session->GetPlayer(); } + { + target = m_session->GetPlayer(); + } // check online security else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) @@ -2491,7 +2753,9 @@ bool ChatHandler::HandleDeMorphCommand(char* /*args*/) bool ChatHandler::HandleModifyMorphCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint32 display_id = (uint32)atoi(args); @@ -2505,7 +2769,9 @@ bool ChatHandler::HandleModifyMorphCommand(char* args) Unit* target = getSelectedUnit(); if (!target) - { target = m_session->GetPlayer(); } + { + target = m_session->GetPlayer(); + } // check online security else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) @@ -2521,7 +2787,9 @@ bool ChatHandler::HandleKickPlayerCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } if (m_session && target == m_session->GetPlayer()) { @@ -2532,7 +2800,9 @@ bool ChatHandler::HandleKickPlayerCommand(char* args) // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } // send before target pointer invalidate PSendSysMessage(LANG_COMMAND_KICKMESSAGE, GetNameLink(target).c_str()); @@ -2568,7 +2838,9 @@ bool ChatHandler::HandlePInfoCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } uint32 accId = 0; uint64 money = 0; @@ -2581,7 +2853,9 @@ bool ChatHandler::HandlePInfoCommand(char* args) { // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } accId = target->GetSession()->GetAccountId(); money = target->GetMoney(); @@ -2594,12 +2868,16 @@ bool ChatHandler::HandlePInfoCommand(char* args) { // check offline security if (HasLowerSecurity(NULL, target_guid)) - { return false; } + { + return false; + } // 0 1 2 3 QueryResult* result = CharacterDatabase.PQuery("SELECT totaltime, level, money, account FROM characters WHERE guid = '%u'", target_guid.GetCounter()); if (!result) - { return false; } + { + return false; + } Field* fields = result->Fetch(); total_player_time = fields[0].GetUInt32(); @@ -2652,7 +2930,9 @@ void ChatHandler::ShowTicket(GMTicket const* ticket) std::string name; if (!sObjectMgr.GetPlayerNameByGUID(ticket->GetPlayerGuid(), name)) - { name = GetMangosString(LANG_UNKNOWN); } + { + name = GetMangosString(LANG_UNKNOWN); + } std::string nameLink = playerLink(name); @@ -2660,7 +2940,9 @@ void ChatHandler::ShowTicket(GMTicket const* ticket) PSendSysMessage(LANG_COMMAND_TICKETVIEW, nameLink.c_str(), lastupdated.c_str(), ticket->GetText()); if (strlen(response)) - { PSendSysMessage(LANG_COMMAND_TICKETRESPONSE, ticket->GetResponse()); } + { + PSendSysMessage(LANG_COMMAND_TICKETRESPONSE, ticket->GetResponse()); + } } // ticket commands @@ -2725,7 +3007,9 @@ bool ChatHandler::HandleTicketCommand(char* args) if (ExtractUInt32(&args, num)) { if (num == 0) - { return false; } + { + return false; + } // mgr numbering tickets start from 0 ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1); @@ -2742,7 +3026,9 @@ bool ChatHandler::HandleTicketCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, NULL, &target_guid, &target_name)) - { return false; } + { + return false; + } // ticket respond $char_name ticket = sTicketMgr.GetGMTicket(target_guid); @@ -2757,7 +3043,9 @@ bool ChatHandler::HandleTicketCommand(char* args) // no response text? if (!*args) - { return false; } + { + return false; + } ticket->SetResponseText(args); @@ -2772,7 +3060,9 @@ bool ChatHandler::HandleTicketCommand(char* args) if (ExtractUInt32(&px, num)) { if (num == 0) - { return false; } + { + return false; + } // mgr numbering tickets start from 0 GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1); @@ -2790,7 +3080,9 @@ bool ChatHandler::HandleTicketCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&px, NULL, &target_guid, &target_name)) - { return false; } + { + return false; + } // ticket $char_name GMTicket* ticket = sTicketMgr.GetGMTicket(target_guid); @@ -2811,7 +3103,9 @@ bool ChatHandler::HandleDelTicketCommand(char* args) { char* px = ExtractLiteralArg(&args); if (!px) - { return false; } + { + return false; + } // ticket delete all if (strncmp(px, "all", 4) == 0) @@ -2827,7 +3121,9 @@ bool ChatHandler::HandleDelTicketCommand(char* args) if (ExtractUInt32(&px, num)) { if (num == 0) - { return false; } + { + return false; + } // mgr numbering tickets start from 0 GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1); @@ -2859,14 +3155,18 @@ bool ChatHandler::HandleDelTicketCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&px, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } // ticket delete $charName sTicketMgr.Delete(target_guid); // notify players about ticket deleting if (target) - { target->GetSession()->SendGMTicketGetTicket(0x0A); } + { + target->GetSession()->SendGMTicketGetTicket(0x0A); + } std::string nameLink = playerLink(target_name); @@ -3115,7 +3415,9 @@ bool ChatHandler::HandleWpModifyCommand(char* args) DEBUG_LOG("DEBUG: HandleWpModifyCommand"); if (!*args) - { return false; } + { + return false; + } CreatureInfo const* waypointInfo = ObjectMgr::GetCreatureTemplate(VISUAL_WAYPOINT); if (!waypointInfo || waypointInfo->GetHighGuid() != HIGHGUID_UNIT) @@ -3335,7 +3637,9 @@ bool ChatHandler::HandleWpShowCommand(char* args) DEBUG_LOG("DEBUG: HandleWpShowCommand"); if (!*args) - { return false; } + { + return false; + } CreatureInfo const* waypointInfo = ObjectMgr::GetCreatureTemplate(VISUAL_WAYPOINT); if (!waypointInfo || waypointInfo->GetHighGuid() != HIGHGUID_UNIT) @@ -3703,13 +4007,17 @@ bool ChatHandler::HandleCharacterRenameCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } if (target) { // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } PSendSysMessage(LANG_RENAME_PLAYER, GetNameLink(target).c_str()); target->SetAtLoginFlag(AT_LOGIN_RENAME); @@ -3719,7 +4027,9 @@ bool ChatHandler::HandleCharacterRenameCommand(char* args) { // check offline security if (HasLowerSecurity(NULL, target_guid)) - { return false; } + { + return false; + } std::string oldNameLink = playerLink(target_name); @@ -3760,7 +4070,9 @@ bool ChatHandler::HandleCharacterReputationCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } LocaleConstant loc = GetSessionDbcLocale(); @@ -3779,10 +4091,14 @@ bool ChatHandler::HandleModifyStandStateCommand(char* args) { uint32 anim_id; if (!ExtractUInt32(&args, anim_id)) - { return false; } + { + return false; + } if (!sEmotesStore.LookupEntry(anim_id)) - { return false; } + { + return false; + } m_session->GetPlayer()->HandleEmoteState(anim_id); @@ -3792,7 +4108,9 @@ bool ChatHandler::HandleModifyStandStateCommand(char* args) bool ChatHandler::HandleHonorAddCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* target = getSelectedPlayer(); if (!target) @@ -3804,7 +4122,9 @@ bool ChatHandler::HandleHonorAddCommand(char* args) // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } float amount = (float)atof(args); target->RewardHonor(NULL, 1, amount); @@ -3823,7 +4143,9 @@ bool ChatHandler::HandleHonorAddKillCommand(char* /*args*/) // check online security if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) - { return false; } + { + return false; + } m_session->GetPlayer()->RewardHonor(target, 1); return true; @@ -3850,14 +4172,18 @@ bool ChatHandler::HandleHonorKillsUpdateCommand(char* /*args*/) bool ChatHandler::HandleLookupEventCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; std::wstring wnamepart; // converting string that we try to find to lower case if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } wstrToLower(wnamepart); @@ -3868,20 +4194,26 @@ bool ChatHandler::HandleLookupEventCommand(char* args) for (uint32 id = 1; id < events.size(); ++id) { if (!sGameEventMgr.IsValidEvent(id)) - { continue; } + { + continue; + } GameEventData const& eventData = events[id]; std::string descr = eventData.description; if (descr.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(descr, wnamepart)) { char const* active = sGameEventMgr.IsActiveEvent(id) ? GetMangosString(LANG_ACTIVE) : ""; if (m_session) - { PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description.c_str(), active); } + { + 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); } @@ -3890,7 +4222,9 @@ bool ChatHandler::HandleLookupEventCommand(char* args) } if (counter == 0) - { SendSysMessage(LANG_NOEVENTFOUND); } + { + SendSysMessage(LANG_NOEVENTFOUND); + } return true; } @@ -3901,7 +4235,9 @@ bool ChatHandler::HandleEventListCommand(char* args) bool all = false; std::string arg = args; if (arg == "all") - { all = true; } + { + all = true; + } GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); @@ -3912,12 +4248,16 @@ bool ChatHandler::HandleEventListCommand(char* args) for (uint32 event_id = 0; event_id < events.size(); ++event_id) { if (!sGameEventMgr.IsValidEvent(event_id)) - { continue; } + { + continue; + } if (!sGameEventMgr.IsActiveEvent(event_id)) { if (!all) - { continue; } + { + continue; + } state = inactive; } else @@ -3926,7 +4266,9 @@ bool ChatHandler::HandleEventListCommand(char* args) GameEventData const& eventData = events[event_id]; if (m_session) - { PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, event_id, event_id, eventData.description.c_str(), state); } + { + 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); } @@ -3934,7 +4276,9 @@ bool ChatHandler::HandleEventListCommand(char* args) } if (counter == 0) - { SendSysMessage(LANG_NOEVENTFOUND); } + { + SendSysMessage(LANG_NOEVENTFOUND); + } return true; } @@ -3942,12 +4286,16 @@ bool ChatHandler::HandleEventListCommand(char* args) bool ChatHandler::HandleEventInfoCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r uint32 event_id; if (!ExtractUint32KeyFromLink(&args, "Hgameevent", event_id)) - { return false; } + { + return false; + } GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); @@ -3981,12 +4329,16 @@ bool ChatHandler::HandleEventInfoCommand(char* args) bool ChatHandler::HandleEventStartCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r uint32 event_id; if (!ExtractUint32KeyFromLink(&args, "Hgameevent", event_id)) - { return false; } + { + return false; + } GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); @@ -4020,12 +4372,16 @@ bool ChatHandler::HandleEventStartCommand(char* args) bool ChatHandler::HandleEventStopCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // id or [name] Shift-click form |color|Hgameevent:id|h[name]|h|r uint32 event_id; if (!ExtractUint32KeyFromLink(&args, "Hgameevent", event_id)) - { return false; } + { + return false; + } GameEventMgr::GameEventDataMap const& events = sGameEventMgr.GetEventMap(); @@ -4060,11 +4416,15 @@ bool ChatHandler::HandleCombatStopCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } target->CombatStop(); target->GetHostileRefManager().deleteReferences(); @@ -4079,27 +4439,39 @@ void ChatHandler::HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id) { SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j); if (!skillLine) - { continue; } + { + continue; + } // wrong skill if (skillLine->skillId != skill_id) - { continue; } + { + continue; + } // not high rank if (skillLine->forward_spellid) - { continue; } + { + continue; + } // skip racial skills if (skillLine->racemask != 0) - { continue; } + { + continue; + } // skip wrong class skills if (skillLine->classmask && (skillLine->classmask & classmask) == 0) - { continue; } + { + continue; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player, false)) - { continue; } + { + continue; + } player->learnSpell(skillLine->spellId, false); } @@ -4111,7 +4483,9 @@ bool ChatHandler::HandleLearnAllCraftsCommand(char* /*args*/) { SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); if (!skillInfo) - { continue; } + { + continue; + } if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && skillInfo->canLink) // only prof. with recipes have @@ -4137,12 +4511,16 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) } if (!*args) - { return false; } + { + return false; + } std::wstring wnamepart; if (!Utf8toWStr(args, wnamepart)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -4154,7 +4532,9 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) { SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(i); if (!skillInfo) - { continue; } + { + continue; + } if ((skillInfo->categoryId != SKILL_CATEGORY_PROFESSION && skillInfo->categoryId != SKILL_CATEGORY_SECONDARY) || @@ -4164,7 +4544,9 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) int loc = GetSessionDbcLocale(); name = skillInfo->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (!Utf8FitTo(name, wnamepart)) { @@ -4172,14 +4554,20 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) - { continue; } + { + continue; + } name = skillInfo->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) - { break; } + { + break; + } } } @@ -4191,7 +4579,9 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) } if (!targetSkillInfo) - { return false; } + { + return false; + } HandleLearnSkillRecipesHelper(target, targetSkillInfo->id); @@ -4205,11 +4595,15 @@ bool ChatHandler::HandleLookupAccountEmailCommand(char* args) { char* emailStr = ExtractQuotedOrLiteralArg(&args); if (!emailStr) - { return false; } + { + return false; + } uint32 limit; if (!ExtractOptUInt32(&args, limit, 100)) - { return false; } + { + return false; + } std::string email = emailStr; LoginDatabase.escape_string(email); @@ -4223,11 +4617,15 @@ bool ChatHandler::HandleLookupAccountIpCommand(char* args) { char* ipStr = ExtractQuotedOrLiteralArg(&args); if (!ipStr) - { return false; } + { + return false; + } uint32 limit; if (!ExtractOptUInt32(&args, limit, 100)) - { return false; } + { + return false; + } std::string ip = ipStr; LoginDatabase.escape_string(ip); @@ -4242,15 +4640,21 @@ bool ChatHandler::HandleLookupAccountNameCommand(char* args) { char* accountStr = ExtractQuotedOrLiteralArg(&args); if (!accountStr) - { return false; } + { + return false; + } uint32 limit; if (!ExtractOptUInt32(&args, limit, 100)) - { return false; } + { + return false; + } std::string account = accountStr; if (!AccountMgr::normalizeString(account)) - { return false; } + { + return false; + } LoginDatabase.escape_string(account); // 0 1 2 3 4 @@ -4264,7 +4668,9 @@ bool ChatHandler::ShowAccountListHelper(QueryResult* result, uint32* limit, bool if (!result) { if (error) - { SendSysMessage(LANG_ACCOUNT_LIST_EMPTY); } + { + SendSysMessage(LANG_ACCOUNT_LIST_EMPTY); + } return true; } @@ -4283,7 +4689,9 @@ bool ChatHandler::ShowAccountListHelper(QueryResult* result, uint32* limit, bool if (limit) { if (*limit == 0) - { break; } + { + break; + } --*limit; } @@ -4306,7 +4714,9 @@ bool ChatHandler::ShowAccountListHelper(QueryResult* result, uint32* limit, bool delete result; if (!m_session) // not output header for online case - { SendSysMessage(LANG_ACCOUNT_LIST_BAR); } + { + SendSysMessage(LANG_ACCOUNT_LIST_BAR); + } return true; } @@ -4315,11 +4725,15 @@ bool ChatHandler::HandleLookupPlayerIpCommand(char* args) { char* ipStr = ExtractQuotedOrLiteralArg(&args); if (!ipStr) - { return false; } + { + return false; + } uint32 limit; if (!ExtractOptUInt32(&args, limit, 100)) - { return false; } + { + return false; + } std::string ip = ipStr; LoginDatabase.escape_string(ip); @@ -4333,15 +4747,21 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(char* args) { char* accountStr = ExtractQuotedOrLiteralArg(&args); if (!accountStr) - { return false; } + { + return false; + } uint32 limit; if (!ExtractOptUInt32(&args, limit, 100)) - { return false; } + { + return false; + } std::string account = accountStr; if (!AccountMgr::normalizeString(account)) - { return false; } + { + return false; + } LoginDatabase.escape_string(account); @@ -4354,11 +4774,15 @@ bool ChatHandler::HandleLookupPlayerEmailCommand(char* args) { char* emailStr = ExtractQuotedOrLiteralArg(&args); if (!emailStr) - { return false; } + { + return false; + } uint32 limit; if (!ExtractOptUInt32(&args, limit, 100)) - { return false; } + { + return false; + } std::string email = emailStr; LoginDatabase.escape_string(email); @@ -4382,12 +4806,16 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, uint32* limit) uint32 limit_local = limit_original; if (!limit) - { limit = &limit_local; } + { + limit = &limit_local; + } do { if (limit && *limit == 0) - { break; } + { + break; + } Field* fields = result->Fetch(); uint32 acc_id = fields[0].GetUInt32(); @@ -4436,7 +4864,9 @@ void ChatHandler::ShowPoolListHelper(uint16 pool_id) bool ChatHandler::HandleLookupPoolCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; strToLower(namepart); @@ -4452,14 +4882,18 @@ bool ChatHandler::HandleLookupPoolCommand(char* args) strToLower(desc); if (desc.find(namepart) == std::wstring::npos) - { continue; } + { + continue; + } ShowPoolListHelper(pool_id); ++counter; } if (counter == 0) - { SendSysMessage(LANG_NO_POOL); } + { + SendSysMessage(LANG_NO_POOL); + } return true; } @@ -4490,7 +4924,9 @@ bool ChatHandler::HandlePoolListCommand(char* /*args*/) } if (counter == 0) - { PSendSysMessage(LANG_NO_POOL_FOR_MAP, mapState->GetMapEntry()->name[GetSessionDbcLocale()], mapState->GetMapId()); } + { + PSendSysMessage(LANG_NO_POOL_FOR_MAP, mapState->GetMapEntry()->name[GetSessionDbcLocale()], mapState->GetMapId()); + } return true; } @@ -4536,7 +4972,9 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) // id or [name] Shift-click form |color|Hpool:id|h[name]|h|r uint32 pool_id; if (!ExtractUint32KeyFromLink(&args, "Hpool", pool_id)) - { return false; } + { + return false; + } if (pool_id > sPoolMgr.GetMaxPoolId()) { @@ -4554,7 +4992,9 @@ bool ChatHandler::HandlePoolInfoCommand(char* args) PoolTemplateData const& pool_template = sPoolMgr.GetPoolTemplate(pool_id); uint32 mother_pool_id = sPoolMgr.IsPartOfAPool(pool_id); if (!mother_pool_id) - { PSendSysMessage(LANG_POOL_INFO_HEADER, pool_id, pool_template.AutoSpawn, pool_template.MaxLimit); } + { + PSendSysMessage(LANG_POOL_INFO_HEADER, pool_id, pool_template.AutoSpawn, pool_template.MaxLimit); + } else { PoolTemplateData const& mother_template = sPoolMgr.GetPoolTemplate(mother_pool_id); @@ -4718,18 +5158,24 @@ bool ChatHandler::HandleRepairitemsCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } // check online security if (HasLowerSecurity(target)) - { return false; } + { + return false; + } // Repair items target->DurabilityRepairAll(false, 0, false); PSendSysMessage(LANG_YOU_REPAIR_ITEMS, GetNameLink(target).c_str()); if (needReportToTarget(target)) - { ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, GetNameLink().c_str()); } + { + ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, GetNameLink().c_str()); + } return true; } @@ -4754,7 +5200,9 @@ bool ChatHandler::HandleWaterwalkCommand(char* args) // check online security if (HasLowerSecurity(player)) - { return false; } + { + return false; + } if (value) { player->SetWaterWalk(true); } // ON @@ -4763,7 +5211,9 @@ bool ChatHandler::HandleWaterwalkCommand(char* args) PSendSysMessage(LANG_YOU_SET_WATERWALK, args, GetNameLink(player).c_str()); if (needReportToTarget(player)) - { ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, GetNameLink().c_str()); } + { + ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, GetNameLink().c_str()); + } return true; } @@ -5146,7 +5596,9 @@ bool ChatHandler::HandleMmapPathCommand(char* args) PSendSysMessage("actual end (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z); if (!player->isGameMaster()) - { PSendSysMessage("Enable GM mode to see the path points."); } + { + PSendSysMessage("Enable GM mode to see the path points."); + } for (uint32 i = 0; i < pointPath.size(); ++i) { @@ -5204,14 +5656,18 @@ bool ChatHandler::HandleMmapLocCommand(char* /*args*/) navmeshquery->findNearestPoly(location, extents, &filter, &polyRef, NULL); if (polyRef == INVALID_POLYREF) - { PSendSysMessage("Dt [??,??] (invalid poly, probably no tile loaded)"); } + { + PSendSysMessage("Dt [??,??] (invalid poly, probably no tile loaded)"); + } else { const dtMeshTile* tile; const dtPoly* poly; navmesh->getTileAndPolyByRef(polyRef, &tile, &poly); if (tile) - { PSendSysMessage("Dt [%02i,%02i]", tile->header->x, tile->header->y); } + { + PSendSysMessage("Dt [%02i,%02i]", tile->header->x, tile->header->y); + } else { PSendSysMessage("Dt [??,??] (no tile loaded)"); } } @@ -5237,7 +5693,9 @@ bool ChatHandler::HandleMmapLoadedTilesCommand(char* /*args*/) { const dtMeshTile* tile = navmesh->getTile(i); if (!tile || !tile->header) - { continue; } + { + continue; + } PSendSysMessage("[%02i,%02i]", tile->header->x, tile->header->y); } @@ -5271,7 +5729,9 @@ bool ChatHandler::HandleMmapStatsCommand(char* /*args*/) { const dtMeshTile* tile = navmesh->getTile(i); if (!tile || !tile->header) - { continue; } + { + continue; + } tileCount ++; nodeCount += tile->header->bvNodeCount; diff --git a/src/game/ChatCommands/Level3.cpp b/src/game/ChatCommands/Level3.cpp index a5bfdd815..d1ce035ba 100644 --- a/src/game/ChatCommands/Level3.cpp +++ b/src/game/ChatCommands/Level3.cpp @@ -78,7 +78,9 @@ bool ChatHandler::HandleAHBotItemsAmountCommand(char* args) uint32 qVals[MAX_AUCTION_QUALITY]; for (int i = 0; i < MAX_AUCTION_QUALITY; ++i) if (!ExtractUInt32(&args, qVals[i])) - { return false; } + { + return false; + } sAuctionBot.SetItemsAmount(qVals); @@ -93,7 +95,9 @@ bool ChatHandler::HandleAHBotItemsAmountQualityCommand(char* args) { uint32 qVal; if (!ExtractUInt32(&args, qVal)) - { return false; } + { + return false; + } sAuctionBot.SetItemsAmountForQuality(AuctionQuality(Q), qVal); PSendSysMessage(LANG_AHBOT_ITEMS_AMOUNT, GetMangosString(ahbotQualityIds[Q]), sAuctionBotConfig.getConfigItemQualityAmount(AuctionQuality(Q))); @@ -113,7 +117,9 @@ bool ChatHandler::HandleAHBotItemsRatioCommand(char* args) uint32 rVal[MAX_AUCTION_HOUSE_TYPE]; for (int i = 0; i < MAX_AUCTION_HOUSE_TYPE; ++i) if (!ExtractUInt32(&args, rVal[i])) - { return false; } + { + return false; + } sAuctionBot.SetItemsRatio(rVal[0], rVal[1], rVal[2]); @@ -127,7 +133,9 @@ bool ChatHandler::HandleAHBotItemsRatioHouseCommand(char* args) { uint32 rVal; if (!ExtractUInt32(&args, rVal)) - { return false; } + { + return false; + } sAuctionBot.SetItemsRatioForHouse(AuctionHouseType(H), rVal); PSendSysMessage(LANG_AHBOT_ITEMS_RATIO, AuctionBotConfig::GetHouseTypeName(AuctionHouseType(H)), sAuctionBotConfig.getConfigItemAmountRatio(AuctionHouseType(H))); return true; @@ -143,7 +151,9 @@ bool ChatHandler::HandleAHBotRebuildCommand(char* args) if (*args) { if (!ExtractLiteralArg(&args, "all")) - { return false; } + { + return false; + } all = true; } @@ -172,7 +182,9 @@ bool ChatHandler::HandleAHBotStatusCommand(char* args) if (*args) { if (!ExtractLiteralArg(&args, "all")) - { return false; } + { + return false; + } all = true; } @@ -226,7 +238,9 @@ bool ChatHandler::HandleAHBotStatusCommand(char* args) } if (!m_session) - { SendSysMessage(LANG_AHBOT_STATUS_BAR_CONSOLE); } + { + SendSysMessage(LANG_AHBOT_STATUS_BAR_CONSOLE); + } return true; } @@ -352,7 +366,9 @@ bool ChatHandler::HandleReloadAllSpellCommand(char* /*args*/) bool ChatHandler::HandleReloadAllGossipsCommand(char* args) { if (*args != 'a') // already reload from all_scripts - { HandleReloadDBScriptsOnGossipCommand((char*)"a"); } + { + HandleReloadDBScriptsOnGossipCommand((char*)"a"); + } HandleReloadGossipMenuCommand((char*)"a"); HandleReloadPointsOfInterestCommand((char*)"a"); return true; @@ -904,7 +920,9 @@ bool ChatHandler::HandleReloadDBScriptsOnGossipCommand(char* args) } if (*args != 'a') - { sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_GOSSIP]`..."); } + { + sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_GOSSIP]`..."); + } sScriptMgr.LoadDbScripts(DBS_ON_GOSSIP); @@ -924,7 +942,9 @@ bool ChatHandler::HandleReloadDBScriptsOnSpellCommand(char* args) } if (*args != 'a') - { sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_SPELL]`..."); } + { + sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_SPELL]`..."); + } sScriptMgr.LoadDbScripts(DBS_ON_SPELL); @@ -944,7 +964,9 @@ bool ChatHandler::HandleReloadDBScriptsOnQuestStartCommand(char* args) } if (*args != 'a') - { sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_QUEST_START]`..."); } + { + sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_QUEST_START]`..."); + } sScriptMgr.LoadDbScripts(DBS_ON_QUEST_START); @@ -964,7 +986,9 @@ bool ChatHandler::HandleReloadDBScriptsOnQuestEndCommand(char* args) } if (*args != 'a') - { sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_QUEST_END]`..."); } + { + sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_QUEST_END]`..."); + } sScriptMgr.LoadDbScripts(DBS_ON_QUEST_END); @@ -984,7 +1008,9 @@ bool ChatHandler::HandleReloadDBScriptsOnEventCommand(char* args) } if (*args != 'a') - { sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_EVENT]`..."); } + { + sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_EVENT]`..."); + } sScriptMgr.LoadDbScripts(DBS_ON_EVENT); @@ -1004,7 +1030,9 @@ bool ChatHandler::HandleReloadDBScriptsOnGoUseCommand(char* args) } if (*args != 'a') - { sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_GO[_TEMPLATE]_USE]`..."); } + { + sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_GO[_TEMPLATE]_USE]`..."); + } sScriptMgr.LoadDbScripts(DBS_ON_GO_USE); sScriptMgr.LoadDbScripts(DBS_ON_GOT_USE); @@ -1025,7 +1053,9 @@ bool ChatHandler::HandleReloadDBScriptsOnCreatureDeathCommand(char* args) } if (*args != 'a') - { sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_CREATURE_DEATH]`..."); } + { + sLog.outString("Re-Loading Scripts from `db_scripts [type = DBS_ON_CREATURE_DEATH]`..."); + } sScriptMgr.LoadDbScripts(DBS_ON_CREATURE_DEATH); @@ -1157,7 +1187,9 @@ bool ChatHandler::HandleReloadDisablesCommand(char * /*args*/) bool ChatHandler::HandleLoadScriptsCommand(char* args) { if (!*args) - { return false; } + { + return false; + } switch (sScriptMgr.LoadScriptLibrary(args)) { @@ -1187,15 +1219,21 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args) Player* targetPlayer = NULL; uint32 targetAccountId = ExtractAccountId(&accountStr, &targetAccountName, &targetPlayer); if (!targetAccountId) - { return false; } + { + return false; + } /// only target player different from self allowed if (GetAccountId() == targetAccountId) - { return false; } + { + return false; + } int32 gm; if (!ExtractInt32(&args, gm)) - { return false; } + { + return false; + } if (gm < SEC_PLAYER || gm > SEC_ADMINISTRATOR) { @@ -1207,7 +1245,9 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args) /// can set security level only for target with less security and to less security that we have /// This will reject self apply by specify account name if (HasLowerSecurityAccount(NULL, targetAccountId, true)) - { return false; } + { + return false; + } /// account can't set security to same or grater level, need more power GM or console AccountTypes plSecurity = GetAccessLevel(); @@ -1237,18 +1277,24 @@ bool ChatHandler::HandleAccountSetPasswordCommand(char* args) std::string account_name; uint32 targetAccountId = ExtractAccountId(&args, &account_name); if (!targetAccountId) - { return false; } + { + return false; + } // allow or quoted string with possible spaces or literal without spaces char* szPassword1 = ExtractQuotedOrLiteralArg(&args); char* szPassword2 = ExtractQuotedOrLiteralArg(&args); if (!szPassword1 || !szPassword2) - { return false; } + { + return false; + } /// can set password only for target with less security /// This is also reject self apply in fact if (HasLowerSecurityAccount(NULL, targetAccountId, true)) - { return false; } + { + return false; + } if (strcmp(szPassword1, szPassword2)) { @@ -1582,19 +1628,27 @@ bool ChatHandler::HandleSetSkillCommand(char* args) // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r char* skill_p = ExtractKeyFromLink(&args, "Hskill"); if (!skill_p) - { return false; } + { + return false; + } int32 skill; if (!ExtractInt32(&skill_p, skill)) - { return false; } + { + return false; + } int32 level; if (!ExtractInt32(&args, level)) - { return false; } + { + return false; + } int32 maxskill; if (!ExtractOptInt32(&args, maxskill, target->GetPureMaxSkillValue(skill))) - { return false; } + { + return false; + } if (skill <= 0) { @@ -1621,7 +1675,9 @@ bool ChatHandler::HandleSetSkillCommand(char* args) } if (level <= 0 || level > maxskill || maxskill <= 0) - { return false; } + { + return false; + } target->SetSkill(skill, level, maxskill, target->GetSkillStep(skill)); PSendSysMessage(LANG_SET_SKILL, skill, sl->name[GetSessionDbcLocale()], tNameLink.c_str(), level, maxskill); @@ -1632,16 +1688,22 @@ bool ChatHandler::HandleSetSkillCommand(char* args) bool ChatHandler::HandleUnLearnCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r uint32 spell_id = ExtractSpellIdFromLink(&args); if (!spell_id) - { return false; } + { + return false; + } bool allRanks = ExtractLiteralArg(&args, "all") != NULL; if (!allRanks && *args) // can be fail also at syntax error - { return false; } + { + return false; + } Player* target = getSelectedPlayer(); if (!target) @@ -1652,10 +1714,14 @@ bool ChatHandler::HandleUnLearnCommand(char* args) } if (allRanks) - { spell_id = sSpellMgr.GetFirstSpellInChain(spell_id); } + { + spell_id = sSpellMgr.GetFirstSpellInChain(spell_id); + } if (target->HasSpell(spell_id)) - { target->removeSpell(spell_id, false, !allRanks); } + { + target->removeSpell(spell_id, false, !allRanks); + } else { SendSysMessage(LANG_FORGET_SPELL); } @@ -1687,7 +1753,9 @@ bool ChatHandler::HandleCooldownCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell_id = ExtractSpellIdFromLink(&args); if (!spell_id) - { return false; } + { + return false; + } if (!sSpellStore.LookupEntry(spell_id)) { @@ -2314,7 +2382,9 @@ bool ChatHandler::HandleLearnAllCommand(char* /*args*/) uint32 spell = std::stoul((char*)allSpellList[loop++]); if (m_session->GetPlayer()->HasSpell(spell)) - { continue; } + { + continue; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) @@ -2382,39 +2452,55 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(char* /*args*/) Player* player = m_session->GetPlayer(); ChrClassesEntry const* clsEntry = sChrClassesStore.LookupEntry(player->getClass()); if (!clsEntry) - { return true; } + { + return true; + } uint32 family = clsEntry->spellfamily; for (uint32 i = 0; i < sSkillLineAbilityStore.GetNumRows(); ++i) { SkillLineAbilityEntry const* entry = sSkillLineAbilityStore.LookupEntry(i); if (!entry) - { continue; } + { + continue; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(entry->spellId); if (!spellInfo) - { continue; } + { + continue; + } // skip server-side/triggered spells if(spellInfo->GetSpellLevel()==0) - { continue; } + { + continue; + } // skip wrong class/race skills if (!player->IsSpellFitByClassAndRace(spellInfo->Id)) - { continue; } + { + continue; + } // skip other spell families if( spellInfo->GetSpellFamilyName() != family) - { continue; } + { + continue; + } // skip spells with first rank learned as talent (and all talents then also) uint32 first_rank = sSpellMgr.GetFirstSpellInChain(spellInfo->Id); if (GetTalentSpellCost(first_rank) > 0) - { continue; } + { + continue; + } // skip broken spells if (!SpellMgr::IsSpellValid(spellInfo, player, false)) - { continue; } + { + continue; + } player->learnSpell(spellInfo->Id, false); } @@ -2432,14 +2518,20 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(char* /*args*/) { TalentEntry const* talentInfo = sTalentStore.LookupEntry(i); if (!talentInfo) - { continue; } + { + continue; + } TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab); if (!talentTabInfo) - { continue; } + { + continue; + } if ((classMask & talentTabInfo->ClassMask) == 0) - { continue; } + { + continue; + } // search highest talent rank uint32 spellid = 0; @@ -2454,11 +2546,15 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(char* /*args*/) } if (!spellid) // ??? none spells in talent - { continue; } + { + continue; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player, false)) - { continue; } + { + continue; + } // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) player->learnSpellHighRank(spellid); @@ -2564,7 +2660,9 @@ bool ChatHandler::HandleLearnAllDefaultCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } target->learnDefaultSpells(); target->learnQuestRewardedSpells(); @@ -2588,11 +2686,15 @@ bool ChatHandler::HandleLearnCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell = ExtractSpellIdFromLink(&args); if (!spell || !sSpellStore.LookupEntry(spell)) - { return false; } + { + return false; + } bool allRanks = ExtractLiteralArg(&args, "all") != NULL; if (!allRanks && *args) // can be fail also at syntax error - { return false; } + { + return false; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player)) @@ -2605,7 +2707,9 @@ bool ChatHandler::HandleLearnCommand(char* args) if (!allRanks && targetPlayer->HasSpell(spell)) { if (targetPlayer == player) - { SendSysMessage(LANG_YOU_KNOWN_SPELL); } + { + SendSysMessage(LANG_YOU_KNOWN_SPELL); + } else PSendSysMessage(LANG_TARGET_KNOWN_SPELL, GetNameLink(targetPlayer).c_str()); SetSentErrorMessage(true); @@ -2613,7 +2717,9 @@ bool ChatHandler::HandleLearnCommand(char* args) } if (allRanks) - { targetPlayer->learnSpellHighRank(spell); } + { + targetPlayer->learnSpellHighRank(spell); + } else { targetPlayer->learnSpell(spell, false); } @@ -2628,7 +2734,9 @@ bool ChatHandler::HandleAddItemCommand(char* args) { char* cId = ExtractKeyFromLink(&args, "Hitem"); if (!cId) - { return false; } + { + return false; + } uint32 itemId = 0; if (!ExtractUInt32(&cId, itemId)) // [name] manual form @@ -2648,12 +2756,16 @@ bool ChatHandler::HandleAddItemCommand(char* args) int32 count; if (!ExtractOptInt32(&args, count, 1)) - { return false; } + { + return false; + } Player* pl = m_session->GetPlayer(); Player* plTarget = getSelectedPlayer(); if (!plTarget) - { plTarget = pl; } + { + plTarget = pl; + } DETAIL_LOG(GetMangosString(LANG_ADDITEM), itemId, count); @@ -2680,7 +2792,9 @@ bool ChatHandler::HandleAddItemCommand(char* args) ItemPosCountVec dest; uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) // convert to possible store amount - { count -= noSpaceForCount; } + { + count -= noSpaceForCount; + } if (count == 0 || dest.empty()) // can't add any { @@ -2695,17 +2809,23 @@ bool ChatHandler::HandleAddItemCommand(char* args) if (pl == plTarget) for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) if (Item* item1 = pl->GetItemByPos(itr->pos)) - { item1->SetBinding(false); } + { + item1->SetBinding(false); + } if (count > 0 && item) { pl->SendNewItem(item, count, false, true); if (pl != plTarget) - { plTarget->SendNewItem(item, count, true, false); } + { + plTarget->SendNewItem(item, count, true, false); + } } if (noSpaceForCount > 0) - { PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); } + { + PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount); + } return true; } @@ -2714,7 +2834,9 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) { uint32 itemsetId; if (!ExtractUint32KeyFromLink(&args, "Hitemset", itemsetId)) - { return false; } + { + return false; + } // prevent generation all items with itemset field value '0' if (itemsetId == 0) @@ -2727,7 +2849,9 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) Player* pl = m_session->GetPlayer(); Player* plTarget = getSelectedPlayer(); if (!plTarget) - { plTarget = pl; } + { + plTarget = pl; + } DETAIL_LOG(GetMangosString(LANG_ADDITEMSET), itemsetId); @@ -2736,7 +2860,9 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) { ItemPrototype const* pProto = sItemStorage.LookupEntry(id); if (!pProto) - { continue; } + { + continue; + } if (pProto->ItemSet == itemsetId) { @@ -2749,11 +2875,15 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) // remove binding (let GM give it to another player later) if (pl == plTarget) - { item->SetBinding(false); } + { + item->SetBinding(false); + } pl->SendNewItem(item, 1, false, true); if (pl != plTarget) - { plTarget->SendNewItem(item, 1, true, false); } + { + plTarget->SendNewItem(item, 1, true, false); + } } else { @@ -2778,7 +2908,9 @@ bool ChatHandler::HandleListItemCommand(char* args) { uint32 item_id; if (!ExtractUint32KeyFromLink(&args, "Hitem", item_id)) - { return false; } + { + return false; + } if (!item_id) { @@ -2797,7 +2929,9 @@ bool ChatHandler::HandleListItemCommand(char* args) uint32 count; if (!ExtractOptUInt32(&args, count, 10)) - { return false; } + { + return false; + } QueryResult* result; @@ -2831,7 +2965,9 @@ bool ChatHandler::HandleListItemCommand(char* args) char const* item_pos = 0; if (Player::IsEquipmentPos(item_bag, item_slot)) - { item_pos = "[equipped]"; } + { + item_pos = "[equipped]"; + } else if (Player::IsInventoryPos(item_bag, item_slot)) { item_pos = "[in inventory]"; } else if (Player::IsBankPos(item_bag, item_slot)) @@ -2849,7 +2985,9 @@ bool ChatHandler::HandleListItemCommand(char* args) delete result; if (count > res_count) - { count -= res_count; } + { + count -= res_count; + } else if (count) { count = 0; } } @@ -2900,7 +3038,9 @@ bool ChatHandler::HandleListItemCommand(char* args) delete result; if (count > res_count) - { count -= res_count; } + { + count -= res_count; + } else if (count) { count = 0; } } @@ -3001,7 +3141,9 @@ bool ChatHandler::HandleListObjectCommand(char* args) // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r uint32 go_id; if (!ExtractUint32KeyFromLink(&args, "Hgameobject_entry", go_id)) - { return false; } + { + return false; + } if (!go_id) { @@ -3020,7 +3162,9 @@ bool ChatHandler::HandleListObjectCommand(char* args) uint32 count; if (!ExtractOptUInt32(&args, count, 10)) - { return false; } + { + return false; + } QueryResult* result; @@ -3054,7 +3198,9 @@ bool ChatHandler::HandleListObjectCommand(char* args) int mapid = fields[4].GetUInt16(); if (m_session) - { PSendSysMessage(LANG_GO_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), guid, gInfo->name, x, y, z, mapid); } + { + 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); } } @@ -3072,7 +3218,9 @@ bool ChatHandler::HandleListCreatureCommand(char* args) // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r uint32 cr_id; if (!ExtractUint32KeyFromLink(&args, "Hcreature_entry", cr_id)) - { return false; } + { + return false; + } if (!cr_id) { @@ -3091,7 +3239,9 @@ bool ChatHandler::HandleListCreatureCommand(char* args) uint32 count; if (!ExtractOptUInt32(&args, count, 10)) - { return false; } + { + return false; + } QueryResult* result; @@ -3125,7 +3275,9 @@ bool ChatHandler::HandleListCreatureCommand(char* args) int mapid = fields[4].GetUInt16(); if (m_session) - { PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, PrepareStringNpcOrGoSpawnInformation(guid).c_str(), guid, cInfo->Name, x, y, z, mapid); } + { + 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); } } @@ -3143,7 +3295,9 @@ void ChatHandler::ShowItemListHelper(uint32 itemId, int loc_idx, Player* target { ItemPrototype const* itemProto = sItemStorage.LookupEntry(itemId); if (!itemProto) - { return; } + { + return; + } std::string name = itemProto->Name1; sObjectMgr.GetItemLocaleStrings(itemProto->ItemId, loc_idx, &name); @@ -3153,11 +3307,15 @@ void ChatHandler::ShowItemListHelper(uint32 itemId, int loc_idx, Player* target if (target) { if (target->CanUseItem(itemProto)) - { usableStr = GetMangosString(LANG_COMMAND_ITEM_USABLE); } + { + usableStr = GetMangosString(LANG_COMMAND_ITEM_USABLE); + } } if (m_session) - { PSendSysMessage(LANG_ITEM_LIST_CHAT, itemId, itemId, name.c_str(), usableStr); } + { + PSendSysMessage(LANG_ITEM_LIST_CHAT, itemId, itemId, name.c_str(), usableStr); + } else { PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemId, name.c_str(), usableStr); } } @@ -3165,14 +3323,18 @@ void ChatHandler::ShowItemListHelper(uint32 itemId, int loc_idx, Player* target bool ChatHandler::HandleLookupItemCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; std::wstring wnamepart; // converting string that we try to find to lower case if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } wstrToLower(wnamepart); @@ -3185,21 +3347,27 @@ bool ChatHandler::HandleLookupItemCommand(char* args) { ItemPrototype const* pProto = sItemStorage.LookupEntry(id); if (!pProto) - { continue; } + { + continue; + } int loc_idx = GetSessionDbLocaleIndex(); std::string name; // "" for let later only single time check default locale name directly sObjectMgr.GetItemLocaleStrings(id, loc_idx, &name); if ((name.empty() || !Utf8FitTo(name, wnamepart)) && !Utf8FitTo(pProto->Name1, wnamepart)) - { continue; } + { + continue; + } ShowItemListHelper(id, loc_idx, pl); ++counter; } if (counter == 0) - { SendSysMessage(LANG_COMMAND_NOITEMFOUND); } + { + SendSysMessage(LANG_COMMAND_NOITEMFOUND); + } return true; } @@ -3207,13 +3375,17 @@ bool ChatHandler::HandleLookupItemCommand(char* args) bool ChatHandler::HandleLookupItemSetCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -3229,7 +3401,9 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) int loc = GetSessionDbcLocale(); std::string name = set->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (!Utf8FitTo(name, wnamepart)) { @@ -3237,14 +3411,20 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) - { continue; } + { + continue; + } name = set->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) - { break; } + { + break; + } } } @@ -3252,7 +3432,9 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) { // send item set in "id - [namedlink locale]" format if (m_session) - { PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name.c_str(), localeNames[loc]); } + { + PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name.c_str(), localeNames[loc]); + } else { PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), localeNames[loc]); } ++counter; @@ -3260,14 +3442,18 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) } } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_NOITEMSETFOUND); } + { + SendSysMessage(LANG_COMMAND_NOITEMSETFOUND); + } return true; } bool ChatHandler::HandleLookupSkillCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // can be NULL in console call Player* target = getSelectedPlayer(); @@ -3276,7 +3462,9 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -3292,7 +3480,9 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) int loc = GetSessionDbcLocale(); std::string name = skillInfo->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (!Utf8FitTo(name, wnamepart)) { @@ -3300,14 +3490,20 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) - { continue; } + { + continue; + } name = skillInfo->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) - { break; } + { + break; + } } } @@ -3329,7 +3525,9 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) // send skill in "id - [namedlink locale]" format if (m_session) - { PSendSysMessage(LANG_SKILL_LIST_CHAT, id, id, name.c_str(), localeNames[loc], knownStr, valStr); } + { + 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); } @@ -3338,7 +3536,9 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) } } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_NOSKILLFOUND); } + { + SendSysMessage(LANG_COMMAND_NOSKILLFOUND); + } return true; } @@ -3389,29 +3589,45 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format std::ostringstream ss; if (m_session) - { ss << id << " - |cffffffff|Hspell:" << id << "|h[" << spellInfo->SpellName[loc]; } + { + ss << id << " - |cffffffff|Hspell:" << id << "|h[" << spellInfo->SpellName[loc]; + } else { ss << id << " - " << spellInfo->SpellName[loc]; } // include rank in link name if (rank) - { ss << GetMangosString(LANG_SPELL_RANK) << rank; } + { + ss << GetMangosString(LANG_SPELL_RANK) << rank; + } if (m_session) - { ss << " " << localeNames[loc] << "]|h|r"; } + { + ss << " " << localeNames[loc] << "]|h|r"; + } else { ss << " " << localeNames[loc]; } if (talent) - { ss << GetMangosString(LANG_TALENT); } + { + ss << GetMangosString(LANG_TALENT); + } if (passive) - { ss << GetMangosString(LANG_PASSIVE); } + { + ss << GetMangosString(LANG_PASSIVE); + } if (learn) - { ss << GetMangosString(LANG_LEARN); } + { + ss << GetMangosString(LANG_LEARN); + } if (known) - { ss << GetMangosString(LANG_KNOWN); } + { + ss << GetMangosString(LANG_KNOWN); + } if (active) - { ss << GetMangosString(LANG_ACTIVE); } + { + ss << GetMangosString(LANG_ACTIVE); + } SendSysMessage(ss.str().c_str()); } @@ -3478,7 +3694,9 @@ bool ChatHandler::HandleLookupCurrencyCommand(char* args) bool ChatHandler::HandleLookupSpellCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // can be NULL at console call Player* target = getSelectedPlayer(); @@ -3487,7 +3705,9 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -3504,7 +3724,9 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) DEBUG_LOG("Spellid %u locale %u", id, loc); std::string name = spellInfo->SpellName[loc]; if (name.empty()) - { continue; } + { + continue; + } if (!Utf8FitTo(name, wnamepart)) { @@ -3512,14 +3734,20 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) - { continue; } + { + continue; + } name = spellInfo->SpellName[loc]; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) - { break; } + { + break; + } } } @@ -3533,7 +3761,9 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) } } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_NOSPELLFOUND); } + { + SendSysMessage(LANG_COMMAND_NOSPELLFOUND); + } return true; } @@ -3542,7 +3772,9 @@ void ChatHandler::ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* tar { Quest const* qinfo = sObjectMgr.GetQuestTemplate(questId); if (!qinfo) - { return; } + { + return; + } std::string title = qinfo->GetTitle(); sObjectMgr.GetQuestLocaleStrings(questId, loc_idx, &title); @@ -3556,7 +3788,9 @@ void ChatHandler::ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* tar if (status == QUEST_STATUS_COMPLETE) { if (target->GetQuestRewardStatus(qinfo->GetQuestId())) - { statusStr = GetMangosString(LANG_COMMAND_QUEST_REWARDED); } + { + statusStr = GetMangosString(LANG_COMMAND_QUEST_REWARDED); + } else { statusStr = GetMangosString(LANG_COMMAND_QUEST_COMPLETE); } } @@ -3565,7 +3799,9 @@ void ChatHandler::ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* tar } if (m_session) - { PSendSysMessage(LANG_QUEST_LIST_CHAT, qinfo->GetQuestId(), qinfo->GetQuestId(), qinfo->GetQuestLevel(), title.c_str(), statusStr); } + { + 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); } } @@ -3573,7 +3809,9 @@ void ChatHandler::ShowQuestListHelper(uint32 questId, int32 loc_idx, Player* tar bool ChatHandler::HandleLookupQuestCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // can be NULL at console call Player* target = getSelectedPlayer(); @@ -3583,7 +3821,9 @@ bool ChatHandler::HandleLookupQuestCommand(char* args) // converting string that we try to find to lower case if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } wstrToLower(wnamepart); @@ -3600,14 +3840,18 @@ bool ChatHandler::HandleLookupQuestCommand(char* args) sObjectMgr.GetQuestLocaleStrings(qinfo->GetQuestId(), loc_idx, &title); if ((title.empty() || !Utf8FitTo(title, wnamepart)) && !Utf8FitTo(qinfo->GetTitle(), wnamepart)) - { continue; } + { + continue; + } ShowQuestListHelper(qinfo->GetQuestId(), loc_idx, target); ++counter; } if (counter == 0) - { SendSysMessage(LANG_COMMAND_NOQUESTFOUND); } + { + SendSysMessage(LANG_COMMAND_NOQUESTFOUND); + } return true; } @@ -3615,14 +3859,18 @@ bool ChatHandler::HandleLookupQuestCommand(char* args) bool ChatHandler::HandleLookupCreatureCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; std::wstring wnamepart; // converting string that we try to find to lower case if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } wstrToLower(wnamepart); @@ -3632,7 +3880,9 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) { CreatureInfo const* cInfo = sCreatureStorage.LookupEntry (id); if (!cInfo) - { continue; } + { + continue; + } int loc_idx = GetSessionDbLocaleIndex(); @@ -3642,11 +3892,15 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) { name = cInfo->Name; if (!Utf8FitTo(name, wnamepart)) - { continue; } + { + continue; + } } if (m_session) - { PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); } + { + PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); + } else { PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name); } @@ -3654,7 +3908,9 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) } if (counter == 0) - { SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); } + { + SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); + } return true; } @@ -3662,14 +3918,18 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) bool ChatHandler::HandleLookupObjectCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; std::wstring wnamepart; // converting string that we try to find to lower case if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } wstrToLower(wnamepart); @@ -3690,7 +3950,9 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) if (Utf8FitTo(name, wnamepart)) { if (m_session) - { PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->id, itr->id, name.c_str()); } + { + 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()); } ++counter; @@ -3702,12 +3964,16 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) std::string name = itr->name; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) { if (m_session) - { PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->id, itr->id, name.c_str()); } + { + 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()); } ++counter; @@ -3715,7 +3981,9 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) } if (counter == 0) - { SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); } + { + SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); + } return true; } @@ -3723,13 +3991,17 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string namepart = args; std::wstring wnamepart; if (!Utf8toWStr(namepart, wnamepart)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wnamepart); @@ -3745,7 +4017,9 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) int loc = GetSessionDbcLocale(); std::string name = nodeEntry->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (!Utf8FitTo(name, wnamepart)) { @@ -3753,14 +4027,20 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) for (; loc < MAX_LOCALE; ++loc) { if (loc == GetSessionDbcLocale()) - { continue; } + { + continue; + } name = nodeEntry->name[loc]; if (name.empty()) - { continue; } + { + continue; + } if (Utf8FitTo(name, wnamepart)) - { break; } + { + break; + } } } @@ -3778,7 +4058,9 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) } } if (counter == 0) // if counter == 0 then we found nth - { SendSysMessage(LANG_COMMAND_NOTAXINODEFOUND); } + { + SendSysMessage(LANG_COMMAND_NOTAXINODEFOUND); + } return true; } @@ -3797,11 +4079,15 @@ bool ChatHandler::HandleGuildCreateCommand(char* args) Player* target; if (!ExtractPlayerTarget(&guildMasterStr, &target)) - { return false; } + { + return false; + } char* guildStr = ExtractQuotedArg(&args); if (!guildStr) - { return false; } + { + return false; + } std::string guildname = guildStr; @@ -3832,20 +4118,28 @@ bool ChatHandler::HandleGuildInviteCommand(char* args) // if not guild name only (in "") then player name ObjectGuid target_guid; if (!ExtractPlayerTarget(&nameStr, NULL, &target_guid)) - { return false; } + { + return false; + } char* guildStr = ExtractQuotedArg(&args); if (!guildStr) - { return false; } + { + return false; + } std::string glName = guildStr; Guild* targetGuild = sGuildMgr.GetGuildByName(glName); if (!targetGuild) - { return false; } + { + return false; + } // player's guild membership checked in AddMember before add if (!targetGuild->AddMember(target_guid, targetGuild->GetLowestRank())) - { return false; } + { + return false; + } return true; } @@ -3855,15 +4149,21 @@ bool ChatHandler::HandleGuildUninviteCommand(char* args) Player* target; ObjectGuid target_guid; if (!ExtractPlayerTarget(&args, &target, &target_guid)) - { return false; } + { + return false; + } uint32 glId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(target_guid); if (!glId) - { return false; } + { + return false; + } Guild* targetGuild = sGuildMgr.GetGuildById(glId); if (!targetGuild) - { return false; } + { + return false; + } if (targetGuild->DelMember(target_guid)) { @@ -3882,26 +4182,38 @@ bool ChatHandler::HandleGuildRankCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } uint32 glId = target ? target->GetGuildId() : Player::GetGuildIdFromDB(target_guid); if (!glId) - { return false; } + { + return false; + } Guild* targetGuild = sGuildMgr.GetGuildById(glId); if (!targetGuild) - { return false; } + { + return false; + } uint32 newrank; if (!ExtractUInt32(&args, newrank)) - { return false; } + { + return false; + } if (newrank > targetGuild->GetLowestRank()) - { return false; } + { + return false; + } MemberSlot* slot = targetGuild->GetMemberSlot(target_guid); if (!slot) - { return false; } + { + return false; + } slot->ChangeRank(newrank); return true; @@ -3910,17 +4222,23 @@ bool ChatHandler::HandleGuildRankCommand(char* args) bool ChatHandler::HandleGuildDeleteCommand(char* args) { if (!*args) - { return false; } + { + return false; + } char* guildStr = ExtractQuotedArg(&args); if (!guildStr) - { return false; } + { + return false; + } std::string gld = guildStr; Guild* targetGuild = sGuildMgr.GetGuildByName(gld); if (!targetGuild) - { return false; } + { + return false; + } targetGuild->Disband(); delete targetGuild; @@ -3935,7 +4253,9 @@ bool ChatHandler::HandleGetDistanceCommand(char* args) if (*args) { if (ObjectGuid guid = ExtractGuidFromLink(&args)) - { obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); } + { + obj = (WorldObject*)m_session->GetPlayer()->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); + } if (!obj) { @@ -3983,7 +4303,9 @@ bool ChatHandler::HandleDieCommand(char* /*args*/) if (target->GetTypeId() == TYPEID_PLAYER) { if (HasLowerSecurity((Player*)target, ObjectGuid(), false)) - { return false; } + { + return false; + } } if (target->IsAlive()) @@ -3997,7 +4319,9 @@ bool ChatHandler::HandleDieCommand(char* /*args*/) bool ChatHandler::HandleDamageCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Unit* target = getSelectedUnit(); Player* player = m_session->GetPlayer(); @@ -4010,14 +4334,20 @@ bool ChatHandler::HandleDamageCommand(char* args) } if (!target->IsAlive()) - { return true; } + { + return true; + } int32 damage_int; if (!ExtractInt32(&args, damage_int)) - { return false; } + { + return false; + } if (damage_int <= 0) - { return true; } + { + return true; + } uint32 damage = damage_int; @@ -4026,21 +4356,29 @@ bool ChatHandler::HandleDamageCommand(char* args) { player->DealDamage(target, damage, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); if (target != player) - { player->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); } + { + player->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_NORMAL, 0); + } return true; } uint32 school; if (!ExtractUInt32(&args, school)) - { return false; } + { + return false; + } if (school >= MAX_SPELL_SCHOOL) - { return false; } + { + return false; + } SpellSchoolMask schoolmask = SpellSchoolMask(1 << school); if (schoolmask & SPELL_SCHOOL_MASK_NORMAL) - { damage = player->CalcArmorReducedDamage(target, damage); } + { + damage = player->CalcArmorReducedDamage(target, damage); + } // melee damage by specific school if (!*args) @@ -4051,7 +4389,9 @@ bool ChatHandler::HandleDamageCommand(char* args) target->CalculateDamageAbsorbAndResist(player, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); if (damage <= absorb + resist) - { return true; } + { + return true; + } damage -= absorb + resist; @@ -4066,7 +4406,9 @@ bool ChatHandler::HandleDamageCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellid = ExtractSpellIdFromLink(&args); if (!spellid || !sSpellStore.LookupEntry(spellid)) - { return false; } + { + return false; + } player->SpellNonMeleeDamageLog(target, spellid, damage); return true; @@ -4109,7 +4451,9 @@ bool ChatHandler::HandleReviveCommand(char* args) Player* target; ObjectGuid target_guid; if (!ExtractPlayerTarget(&args, &target, &target_guid)) - { return false; } + { + return false; + } if (target) { @@ -4138,7 +4482,9 @@ bool ChatHandler::HandleAuraCommand(char* args) SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID); if (!spellInfo) - { return false; } + { + return false; + } if (!IsSpellAppliesAura(spellInfo) && !IsSpellHaveEffect(spellInfo, SPELL_EFFECT_PERSISTENT_AREA_AURA)) @@ -4158,7 +4504,9 @@ bool ChatHandler::HandleAuraCommand(char* args) uint8 eff = spellEffect->Effect; if (eff >= TOTAL_SPELL_EFFECTS) - { continue; } + { + continue; + } if (IsAreaAuraEffect(eff) || eff == SPELL_EFFECT_APPLY_AURA || eff == SPELL_EFFECT_PERSISTENT_AREA_AURA) @@ -4192,7 +4540,9 @@ bool ChatHandler::HandleUnAuraCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spellID = ExtractSpellIdFromLink(&args); if (!spellID) - { return false; } + { + return false; + } target->RemoveAurasDueToSpell(spellID); @@ -4203,13 +4553,17 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) { uint32 g_id; if (!ExtractUInt32(&args, g_id)) - { return false; } + { + return false; + } char* teamStr = ExtractLiteralArg(&args); Team g_team; if (!teamStr) - { g_team = TEAM_BOTH_ALLOWED; } + { + g_team = TEAM_BOTH_ALLOWED; + } else if (strncmp(teamStr, "horde", strlen(teamStr)) == 0) { g_team = HORDE; } else if (strncmp(teamStr, "alliance", strlen(teamStr)) == 0) @@ -4238,7 +4592,9 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) } if (sObjectMgr.AddGraveYardLink(g_id, zoneId, g_team)) - { PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id, zoneId); } + { + PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, g_id, zoneId); + } else { PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, g_id, zoneId); } @@ -4252,7 +4608,9 @@ bool ChatHandler::HandleNearGraveCommand(char* args) size_t argslen = strlen(args); if (!*args) - { g_team = TEAM_BOTH_ALLOWED; } + { + g_team = TEAM_BOTH_ALLOWED; + } else if (strncmp(args, "horde", argslen) == 0) { g_team = HORDE; } else if (strncmp(args, "alliance", argslen) == 0) @@ -4280,7 +4638,9 @@ bool ChatHandler::HandleNearGraveCommand(char* args) std::string team_name; if (data->team == TEAM_BOTH_ALLOWED) - { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); } + { + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); + } else if (data->team == HORDE) { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); } else if (data->team == ALLIANCE) @@ -4295,14 +4655,18 @@ bool ChatHandler::HandleNearGraveCommand(char* args) std::string team_name; if (g_team == TEAM_BOTH_ALLOWED) - { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); } + { + team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ANY); + } else if (g_team == HORDE) { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE); } else if (g_team == ALLIANCE) { team_name = GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE); } if (g_team == TEAM_BOTH_ALLOWED) - { PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id); } + { + PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id); + } else { PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str()); } } @@ -4329,11 +4693,15 @@ bool ChatHandler::HandleNpcAllowMovementCommand(char* /*args*/) bool ChatHandler::HandleNpcChangeEntryCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint32 newEntryNum = atoi(args); if (!newEntryNum) - { return false; } + { + return false; + } Unit* unit = getSelectedUnit(); if (!unit || unit->GetTypeId() != TYPEID_UNIT) @@ -4344,7 +4712,9 @@ bool ChatHandler::HandleNpcChangeEntryCommand(char* args) } Creature* creature = (Creature*)unit; if (creature->UpdateEntry(newEntryNum)) - { SendSysMessage(LANG_DONE); } + { + SendSysMessage(LANG_DONE); + } else { SendSysMessage(LANG_ERROR); } return true; @@ -4370,7 +4740,9 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/) time_t curRespawnDelay = target->GetRespawnTimeEx() - time(NULL); if (curRespawnDelay < 0) - { curRespawnDelay = 0; } + { + curRespawnDelay = 0; + } std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay, true); std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true); @@ -4501,7 +4873,9 @@ bool ChatHandler::HandleNpcAddWeaponCommand(char* /*args*/) bool ChatHandler::HandleExploreCheatCommand(char* args) { if (!*args) - { return false; } + { + return false; + } int flag = atoi(args); @@ -4517,13 +4891,17 @@ bool ChatHandler::HandleExploreCheatCommand(char* args) { PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, GetNameLink().c_str()); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, GetNameLink().c_str()); + } } else { PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, GetNameLink(chr).c_str()); if (needReportToTarget(chr)) - { ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, GetNameLink().c_str()); } + { + ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, GetNameLink().c_str()); + } } for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) @@ -4552,7 +4930,9 @@ void ChatHandler::HandleCharacterLevel(Player* player, ObjectGuid player_guid, u if (needReportToTarget(player)) { if (oldlevel == newlevel) - { ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, GetNameLink().c_str()); } + { + 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); } else // if(oldlevel > newlevel) @@ -4579,7 +4959,9 @@ bool ChatHandler::HandleCharacterLevelCommand(char* args) { nameStr = ExtractArg(&args); if (!nameStr) - { return false; } + { + return false; + } nolevel = true; } @@ -4591,17 +4973,23 @@ bool ChatHandler::HandleCharacterLevelCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(target_guid); if (nolevel) - { newlevel = oldlevel; } + { + newlevel = oldlevel; + } if (newlevel < 1) { return false; } // invalid level if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level - { newlevel = STRONG_MAX_LEVEL; } + { + newlevel = STRONG_MAX_LEVEL; + } HandleCharacterLevel(target, target_guid, oldlevel, newlevel); @@ -4627,7 +5015,9 @@ bool ChatHandler::HandleLevelUpCommand(char* args) if (!ExtractInt32(&args, addlevel)) { if (!nameStr) - { nameStr = ExtractArg(&args); } + { + nameStr = ExtractArg(&args); + } else { return false; } } @@ -4664,16 +5054,22 @@ bool ChatHandler::HandleLevelUpCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } int32 oldlevel = target ? target->getLevel() : Player::GetLevelFromDB(target_guid); int32 newlevel = oldlevel + addlevel; if (newlevel < 1) - { newlevel = 1; } + { + newlevel = 1; + } if (newlevel > STRONG_MAX_LEVEL) // hardcoded maximum level - { newlevel = STRONG_MAX_LEVEL; } + { + newlevel = STRONG_MAX_LEVEL; + } HandleCharacterLevel(target, target_guid, oldlevel, newlevel); @@ -4689,7 +5085,9 @@ bool ChatHandler::HandleLevelUpCommand(char* args) bool ChatHandler::HandleShowAreaCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* chr = getSelectedPlayer(); if (chr == NULL) @@ -4720,7 +5118,9 @@ bool ChatHandler::HandleShowAreaCommand(char* args) bool ChatHandler::HandleHideAreaCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* chr = getSelectedPlayer(); if (chr == NULL) @@ -4782,11 +5182,15 @@ bool ChatHandler::HandleAuctionItemCommand(char* args) // format: (alliance|horde|goblin) item[:count] price [buyout] [short|long|verylong] char* typeStr = ExtractLiteralArg(&args); if (!typeStr) - { return false; } + { + return false; + } uint32 houseid; if (strncmp(typeStr, "alliance", strlen(typeStr)) == 0) - { houseid = 1; } + { + houseid = 1; + } else if (strncmp(typeStr, "horde", strlen(typeStr)) == 0) { houseid = 6; } else if (strncmp(typeStr, "goblin", strlen(typeStr)) == 0) @@ -4797,27 +5201,37 @@ bool ChatHandler::HandleAuctionItemCommand(char* args) // parse item str char* itemStr = ExtractArg(&args); if (!itemStr) - { return false; } + { + return false; + } uint32 item_id = 0; uint32 item_count = 1; if (sscanf(itemStr, "%u:%u", &item_id, &item_count) != 2) if (sscanf(itemStr, "%u", &item_id) != 1) - { return false; } + { + return false; + } uint32 price; if (!ExtractUInt32(&args, price)) - { return false; } + { + return false; + } uint32 buyout; if (!ExtractOptUInt32(&args, buyout, 0)) - { return false; } + { + return false; + } uint32 etime = 4 * MIN_AUCTION_TIME; if (char* timeStr = ExtractLiteralArg(&args)) { if (strncmp(timeStr, "short", strlen(timeStr)) == 0) - { etime = 1 * MIN_AUCTION_TIME; } + { + etime = 1 * MIN_AUCTION_TIME; + } else if (strncmp(timeStr, "long", strlen(timeStr)) == 0) { etime = 2 * MIN_AUCTION_TIME; } else if (strncmp(timeStr, "verylong", strlen(timeStr)) == 0) @@ -4898,15 +5312,21 @@ bool ChatHandler::HandleChangeWeatherCommand(char* args) uint32 type; if (!ExtractUInt32(&args, type)) - { return false; } + { + return false; + } // see enum WeatherType if (!Weather::IsValidWeatherType(type)) - { return false; } + { + return false; + } float grade; if (!ExtractFloat(&args, grade)) - { return false; } + { + return false; + } // clamp grade from 0 to 1 if (grade < 0.0f) @@ -4929,11 +5349,15 @@ bool ChatHandler::HandleChangeWeatherCommand(char* args) bool ChatHandler::HandleTeleAddCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* player = m_session->GetPlayer(); if (!player) - { return false; } + { + return false; + } std::string name = args; @@ -4969,7 +5393,9 @@ bool ChatHandler::HandleTeleAddCommand(char* args) bool ChatHandler::HandleTeleDelCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string name = args; @@ -5010,7 +5436,9 @@ bool ChatHandler::HandleListAurasCommand(char* /*args*/) { Aura* aur = holder->GetAuraByEffectIndex(SpellEffectIndex(i)); if (!aur) - { continue; } + { + continue; + } if (m_session) { @@ -5081,16 +5509,22 @@ bool ChatHandler::HandleListTalentsCommand(char* /*args*/) for (PlayerSpellMap::const_iterator itr = uSpells.begin(); itr != uSpells.end(); ++itr) { if (itr->second.state == PLAYERSPELL_REMOVED || itr->second.disabled) - { continue; } + { + continue; + } uint32 cost_itr = GetTalentSpellCost(itr->first); if (cost_itr == 0) - { continue; } + { + continue; + } SpellEntry const* spellEntry = sSpellStore.LookupEntry(itr->first); if (!spellEntry) - { continue; } + { + continue; + } ShowSpellListHelper(player, spellEntry, GetSessionDbcLocale()); ++count; @@ -5120,7 +5554,9 @@ bool ChatHandler::HandleResetHonorCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } target->SetCurrencyCount(CURRENCY_HONOR_POINTS, 0); target->SetUInt32Value(PLAYER_FIELD_KILLS, 0); @@ -5143,7 +5579,9 @@ static bool HandleResetStatsOrLevelHelper(Player* player) // reset m_form if no aura if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) - { player->SetShapeshiftForm(FORM_NONE); } + { + player->SetShapeshiftForm(FORM_NONE); + } player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE); player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f); @@ -5154,7 +5592,9 @@ static bool HandleResetStatsOrLevelHelper(Player* player) // reset only if player not in some form; if (player->GetShapeshiftForm() == FORM_NONE) - { player->InitDisplayIds(); } + { + player->InitDisplayIds(); + } player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); @@ -5171,10 +5611,14 @@ bool ChatHandler::HandleResetLevelCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } if (!HandleResetStatsOrLevelHelper(target)) - { return false; } + { + return false; + } // set starting level uint32 start_level = target->getClass() != CLASS_DEATH_KNIGHT @@ -5195,7 +5639,9 @@ bool ChatHandler::HandleResetLevelCommand(char* args) // reset level for pet if (Pet* pet = target->GetPet()) - { pet->SynchronizeLevelWithOwner(); } + { + pet->SynchronizeLevelWithOwner(); + } return true; } @@ -5204,10 +5650,14 @@ bool ChatHandler::HandleResetStatsCommand(char* args) { Player* target; if (!ExtractPlayerTarget(&args, &target)) - { return false; } + { + return false; + } if (!HandleResetStatsOrLevelHelper(target)) - { return false; } + { + return false; + } target->InitRunes(); target->InitStatsForLevel(true); @@ -5224,7 +5674,9 @@ bool ChatHandler::HandleResetSpellsCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } if (target) { @@ -5232,7 +5684,9 @@ bool ChatHandler::HandleResetSpellsCommand(char* args) ChatHandler(target).SendSysMessage(LANG_RESET_SPELLS); if (!m_session || m_session->GetPlayer() != target) - { PSendSysMessage(LANG_RESET_SPELLS_ONLINE, GetNameLink(target).c_str()); } + { + PSendSysMessage(LANG_RESET_SPELLS_ONLINE, GetNameLink(target).c_str()); + } } else { @@ -5249,7 +5703,9 @@ bool ChatHandler::HandleResetSpecsCommand(char* args) ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&args, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } if (target) { @@ -5258,7 +5714,9 @@ bool ChatHandler::HandleResetSpecsCommand(char* args) ChatHandler(target).SendSysMessage(LANG_RESET_TALENTS); if (!m_session || m_session->GetPlayer() != target) - { PSendSysMessage(LANG_RESET_TALENTS_ONLINE, GetNameLink(target).c_str()); } + { + PSendSysMessage(LANG_RESET_TALENTS_ONLINE, GetNameLink(target).c_str()); + } Pet* pet = target->GetPet(); Pet::resetTalentsForAllPetsOf(target, pet); @@ -5331,7 +5789,9 @@ bool ChatHandler::HandleResetTalentsCommand(char* args) bool ChatHandler::HandleResetAllCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string casename = args; @@ -5343,14 +5803,18 @@ bool ChatHandler::HandleResetAllCommand(char* args) atLogin = AT_LOGIN_RESET_SPELLS; sWorld.SendWorldText(LANG_RESETALL_SPELLS); if (!m_session) - { SendSysMessage(LANG_RESETALL_SPELLS); } + { + SendSysMessage(LANG_RESETALL_SPELLS); + } } else if (casename == "talents") { atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS); sWorld.SendWorldText(LANG_RESETALL_TALENTS); if (!m_session) - { SendSysMessage(LANG_RESETALL_TALENTS); } + { + SendSysMessage(LANG_RESETALL_TALENTS); + } } else { @@ -5489,7 +5953,9 @@ bool ChatHandler::HandleQuestAddCommand(char* args) // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r uint32 entry; if (!ExtractUint32KeyFromLink(&args, "Hquest", entry)) - { return false; } + { + return false; + } Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); if (!pQuest) @@ -5504,7 +5970,9 @@ bool ChatHandler::HandleQuestAddCommand(char* args) { ItemPrototype const* pProto = sItemStorage.LookupEntry(id); if (!pProto) - { continue; } + { + continue; + } if (pProto->StartQuest == entry) { @@ -5520,7 +5988,9 @@ bool ChatHandler::HandleQuestAddCommand(char* args) player->AddQuest(pQuest, NULL); if (player->CanCompleteQuest(entry)) - { player->CompleteQuest(entry); } + { + player->CompleteQuest(entry); + } } return true; @@ -5540,7 +6010,9 @@ bool ChatHandler::HandleQuestRemoveCommand(char* args) // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r uint32 entry; if (!ExtractUint32KeyFromLink(&args, "Hquest", entry)) - { return false; } + { + return false; + } Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); @@ -5588,7 +6060,9 @@ bool ChatHandler::HandleQuestCompleteCommand(char* args) // number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r uint32 entry; if (!ExtractUint32KeyFromLink(&args, "Hquest", entry)) - { return false; } + { + return false; + } Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); @@ -5606,7 +6080,9 @@ bool ChatHandler::HandleQuestCompleteCommand(char* args) uint32 id = pQuest->ReqItemId[x]; uint32 count = pQuest->ReqItemCount[x]; if (!id || !count) - { continue; } + { + continue; + } uint32 curItemCount = player->GetItemCount(id, true); @@ -5650,13 +6126,17 @@ bool ChatHandler::HandleQuestCompleteCommand(char* args) uint32 curRep = player->GetReputationMgr().GetReputation(repFaction); if (curRep < repValue) if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(repFaction)) - { player->GetReputationMgr().SetReputation(factionEntry, repValue); } + { + player->GetReputationMgr().SetReputation(factionEntry, repValue); + } } // If the quest requires money int32 ReqOrRewMoney = pQuest->GetRewOrReqMoney(); if (ReqOrRewMoney < 0) - { player->ModifyMoney(-ReqOrRewMoney); } + { + player->ModifyMoney(-ReqOrRewMoney); + } for (int i = 0; i < QUEST_REQUIRED_CURRENCY_COUNT; ++i) { @@ -5689,23 +6169,31 @@ bool ChatHandler::HandleBanIPCommand(char* args) bool ChatHandler::HandleBanHelper(BanMode mode, char* args) { if (!*args) - { return false; } + { + return false; + } char* cnameOrIP = ExtractArg(&args); if (!cnameOrIP) - { return false; } + { + return false; + } std::string nameOrIP = cnameOrIP; char* duration = ExtractArg(&args); // time string if (!duration) - { return false; } + { + return false; + } uint32 duration_secs = TimeStringToSecs(duration); char* reason = ExtractArg(&args); if (!reason) - { return false; } + { + return false; + } switch (mode) { @@ -5727,7 +6215,9 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) break; case BAN_IP: if (!IsIPAddress(nameOrIP.c_str())) - { return false; } + { + return false; + } break; } @@ -5735,7 +6225,9 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) { case BAN_SUCCESS: if (duration_secs > 0) - { PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(duration_secs, true).c_str(), reason); } + { + PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(duration_secs, true).c_str(), reason); + } else { PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reason); } break; @@ -5779,11 +6271,15 @@ bool ChatHandler::HandleUnBanIPCommand(char* args) bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) { if (!*args) - { return false; } + { + return false; + } char* cnameOrIP = ExtractArg(&args); if (!cnameOrIP) - { return false; } + { + return false; + } std::string nameOrIP = cnameOrIP; @@ -5807,12 +6303,16 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) break; case BAN_IP: if (!IsIPAddress(nameOrIP.c_str())) - { return false; } + { + return false; + } break; } if (sWorld.RemoveBanAccount(mode, nameOrIP)) - { PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str()); } + { + PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str()); + } else { PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str()); } @@ -5822,12 +6322,16 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) bool ChatHandler::HandleBanInfoAccountCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string account_name; uint32 accountid = ExtractAccountId(&args, &account_name); if (!accountid) - { return false; } + { + return false; + } return HandleBanInfoHelper(accountid, account_name.c_str()); } @@ -5837,7 +6341,9 @@ bool ChatHandler::HandleBanInfoCharacterCommand(char* args) Player* target; ObjectGuid target_guid; if (!ExtractPlayerTarget(&args, &target, &target_guid)) - { return false; } + { + return false; + } uint32 accountid = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); @@ -5868,7 +6374,9 @@ bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) time_t unbandate = time_t(fields[3].GetUInt64()); bool active = false; if (fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 || unbandate >= time(NULL))) - { active = true; } + { + active = true; + } bool permanent = (fields[1].GetUInt64() == (uint64)0); std::string bantime = permanent ? GetMangosString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true); PSendSysMessage(LANG_BANINFO_HISTORYENTRY, @@ -5883,14 +6391,20 @@ bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) bool ChatHandler::HandleBanInfoIPCommand(char* args) { if (!*args) - { return false; } + { + return false; + } char* cIP = ExtractQuotedOrLiteralArg(&args); if (!cIP) - { return false; } + { + return false; + } if (!IsIPAddress(cIP)) - { return false; } + { + return false; + } std::string IP = cIP; @@ -5917,7 +6431,9 @@ bool ChatHandler::HandleBanListCharacterCommand(char* args) char* cFilter = ExtractLiteralArg(&args); if (!cFilter) - { return false; } + { + return false; + } std::string filter = cFilter; LoginDatabase.escape_string(filter); @@ -6000,7 +6516,9 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) // "account" case, name can be get in same query if (result->GetFieldCount() > 1) - { account_name = fields[1].GetCppString(); } + { + account_name = fields[1].GetCppString(); + } // "character" case, name need extract from another DB else { sAccountMgr.GetName(account_id, account_name); } @@ -6135,7 +6653,9 @@ bool ChatHandler::HandleRespawnCommand(char* /*args*/) } if (target->IsDead()) - { ((Creature*)target)->Respawn(); } + { + ((Creature*)target)->Respawn(); + } return true; } @@ -6157,7 +6677,9 @@ bool ChatHandler::HandleGMFlyCommand(char* args) Player* target = getSelectedPlayer(); if (!target) - { target = m_session->GetPlayer(); } + { + target = m_session->GetPlayer(); + } target->SetCanFly(value); PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, GetNameLink(target).c_str(), args); @@ -6168,12 +6690,16 @@ bool ChatHandler::HandlePDumpLoadCommand(char* args) { char* file = ExtractQuotedOrLiteralArg(&args); if (!file) - { return false; } + { + return false; + } std::string account_name; uint32 account_id = ExtractAccountId(&args, &account_name); if (!account_id) - { return false; } + { + return false; + } char* name_str = ExtractLiteralArg(&args); @@ -6201,7 +6727,9 @@ bool ChatHandler::HandlePDumpLoadCommand(char* args) if (*args) { if (!ExtractUInt32(&args, lowguid)) - { return false; } + { + return false; + } if (!lowguid) { @@ -6250,11 +6778,15 @@ bool ChatHandler::HandlePDumpLoadCommand(char* args) bool ChatHandler::HandlePDumpWriteCommand(char* args) { if (!*args) - { return false; } + { + return false; + } char* file = ExtractQuotedOrLiteralArg(&args); if (!file) - { return false; } + { + return false; + } char* p2 = ExtractLiteralArg(&args); @@ -6337,12 +6869,16 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) { Unit* target = NULL; if (unit->GetTypeId() == TYPEID_PLAYER) - { target = static_cast const*>(*itr)->GetTarget(); } + { + target = static_cast const*>(*itr)->GetTarget(); + } else { target = static_cast const*>(*itr)->GetTarget(); } if (!target) - { SendSysMessage(LANG_MOVEGENS_CHASE_NULL); } + { + SendSysMessage(LANG_MOVEGENS_CHASE_NULL); + } else if (target->GetTypeId() == TYPEID_PLAYER) { PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); } else @@ -6353,12 +6889,16 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) { Unit* target = NULL; if (unit->GetTypeId() == TYPEID_PLAYER) - { target = static_cast const*>(*itr)->GetTarget(); } + { + target = static_cast const*>(*itr)->GetTarget(); + } else { target = static_cast const*>(*itr)->GetTarget(); } if (!target) - { SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); } + { + SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); + } else if (target->GetTypeId() == TYPEID_PLAYER) { PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); } else @@ -6396,13 +6936,17 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) { char* param = ExtractLiteralArg(&args); if (!param) - { return false; } + { + return false; + } int l = strlen(param); int val; if (strncmp(param, "player", l) == 0) - { sWorld.SetPlayerLimit(-SEC_PLAYER); } + { + sWorld.SetPlayerLimit(-SEC_PLAYER); + } else if (strncmp(param, "moderator", l) == 0) { sWorld.SetPlayerLimit(-SEC_MODERATOR); } else if (strncmp(param, "gamemaster", l) == 0) @@ -6414,7 +6958,9 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) else if (ExtractInt32(¶m, val)) { if (val < -SEC_ADMINISTRATOR) - { val = -SEC_ADMINISTRATOR; } + { + val = -SEC_ADMINISTRATOR; + } sWorld.SetPlayerLimit(val); } @@ -6423,7 +6969,9 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) // kick all low security level players if (sWorld.GetPlayerAmountLimit() > SEC_PLAYER) - { sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); } + { + sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); + } } uint32 pLimit = sWorld.GetPlayerAmountLimit(); @@ -6446,7 +6994,9 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) bool ChatHandler::HandleCastCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Unit* target = getSelectedUnit(); @@ -6460,11 +7010,15 @@ bool ChatHandler::HandleCastCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell = ExtractSpellIdFromLink(&args); if (!spell) - { return false; } + { + return false; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); if (!spellInfo) - { return false; } + { + return false; + } if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { @@ -6475,7 +7029,9 @@ bool ChatHandler::HandleCastCommand(char* args) bool triggered = ExtractLiteralArg(&args, "triggered") != NULL; if (!triggered && *args) // can be fail also at syntax error - { return false; } + { + return false; + } m_session->GetPlayer()->CastSpell(target, spell, triggered); @@ -6497,11 +7053,15 @@ bool ChatHandler::HandleCastBackCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell = ExtractSpellIdFromLink(&args); if (!spell || !sSpellStore.LookupEntry(spell)) - { return false; } + { + return false; + } bool triggered = ExtractLiteralArg(&args, "triggered") != NULL; if (!triggered && *args) // can be fail also at syntax error - { return false; } + { + return false; + } caster->SetFacingToObject(m_session->GetPlayer()); @@ -6513,16 +7073,22 @@ bool ChatHandler::HandleCastBackCommand(char* args) bool ChatHandler::HandleCastDistCommand(char* args) { if (!*args) - { return false; } + { + return false; + } // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell = ExtractSpellIdFromLink(&args); if (!spell) - { return false; } + { + return false; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); if (!spellInfo) - { return false; } + { + return false; + } if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { @@ -6533,11 +7099,15 @@ bool ChatHandler::HandleCastDistCommand(char* args) float dist; if (!ExtractFloat(&args, dist)) - { return false; } + { + return false; + } bool triggered = ExtractLiteralArg(&args, "triggered") != NULL; if (!triggered && *args) // can be fail also at syntax error - { return false; } + { + return false; + } float x, y, z; m_session->GetPlayer()->GetClosePoint(x, y, z, dist); @@ -6567,11 +7137,15 @@ bool ChatHandler::HandleCastTargetCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell = ExtractSpellIdFromLink(&args); if (!spell || !sSpellStore.LookupEntry(spell)) - { return false; } + { + return false; + } bool triggered = ExtractLiteralArg(&args, "triggered") != NULL; if (!triggered && *args) // can be fail also at syntax error - { return false; } + { + return false; + } caster->SetFacingToObject(m_session->GetPlayer()); @@ -6605,7 +7179,9 @@ bool ChatHandler::HandleComeToMeCommand(char* /*args*/) bool ChatHandler::HandleCastSelfCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Unit* target = getSelectedUnit(); @@ -6619,11 +7195,15 @@ bool ChatHandler::HandleCastSelfCommand(char* args) // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form uint32 spell = ExtractSpellIdFromLink(&args); if (!spell) - { return false; } + { + return false; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); if (!spellInfo) - { return false; } + { + return false; + } if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { @@ -6634,7 +7214,9 @@ bool ChatHandler::HandleCastSelfCommand(char* args) bool triggered = ExtractLiteralArg(&args, "triggered") != NULL; if (!triggered && *args) // can be fail also at syntax error - { return false; } + { + return false; + } target->CastSpell(target, spell, triggered); @@ -6696,11 +7278,15 @@ bool ChatHandler::HandleInstanceListBindsCommand(char* /*args*/) bool ChatHandler::HandleInstanceUnbindCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* player = getSelectedPlayer(); if (!player) - { player = m_session->GetPlayer(); } + { + player = m_session->GetPlayer(); + } uint32 counter = 0; uint32 mapid = 0; bool got_map = false; @@ -6708,7 +7294,9 @@ bool ChatHandler::HandleInstanceUnbindCommand(char* args) if (strncmp(args, "all", strlen(args)) != 0) { if (!isNumeric(args[0])) - { return false; } + { + return false; + } got_map = true; mapid = atoi(args); @@ -6844,7 +7432,9 @@ bool ChatHandler::ShowPlayerListHelper(QueryResult* result, uint32* limit, bool if (limit) { if (*limit == 0) - { break; } + { + break; + } --*limit; } @@ -6862,7 +7452,9 @@ bool ChatHandler::ShowPlayerListHelper(QueryResult* result, uint32* limit, bool char const* class_name = classEntry ? classEntry->name[GetSessionDbcLocale()] : ""; if (!m_session) - { PSendSysMessage(LANG_CHARACTERS_LIST_LINE_CONSOLE, guid, name.c_str(), race_name, class_name, level); } + { + 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); } } @@ -6872,7 +7464,9 @@ bool ChatHandler::ShowPlayerListHelper(QueryResult* result, uint32* limit, bool } if (!m_session) - { SendSysMessage(LANG_CHARACTERS_LIST_BAR); } + { + SendSysMessage(LANG_CHARACTERS_LIST_BAR); + } return true; } @@ -6886,7 +7480,9 @@ bool ChatHandler::HandleAccountCharactersCommand(char* args) Player* target = NULL; // only for triggering use targeted player account uint32 account_id = ExtractAccountId(&args, &account_name, &target); if (!account_id) - { return false; } + { + return false; + } ///- Get the characters for account id QueryResult* result = CharacterDatabase.PQuery("SELECT guid, name, race, class, level FROM characters WHERE account = %u", account_id); @@ -6903,7 +7499,9 @@ bool ChatHandler::HandleAccountSetAddonCommand(char* args) std::string account_name; uint32 account_id = ExtractAccountId(&accountStr, &account_name); if (!account_id) - { return false; } + { + return false; + } // Let set addon state only for lesser (strong) security level // or to self account @@ -6913,7 +7511,9 @@ bool ChatHandler::HandleAccountSetAddonCommand(char* args) uint32 lev; if (!ExtractUInt32(&args, lev)) - { return false; } + { + return false; + } // No SQL injection LoginDatabase.PExecute("UPDATE account SET expansion = '%u' WHERE id = '%u'", lev, account_id); @@ -6926,11 +7526,15 @@ bool ChatHandler::HandleSendMailHelper(MailDraft& draft, char* args) // format: "subject text" "mail text" std::string msgSubject = ExtractQuotedArg(&args); if (msgSubject.empty()) - { return false; } + { + return false; + } std::string msgText = ExtractQuotedArg(&args); if (msgText.empty()) - { return false; } + { + return false; + } // msgSubject, msgText isn't NUL after prev. check draft.SetSubjectAndBody(msgSubject, msgText); @@ -6945,7 +7549,9 @@ bool ChatHandler::HandleSendMassMailCommand(char* args) char const* name = NULL; if (!ExtractRaceMask(&args, raceMask, &name)) - { return false; } + { + return false; + } // need dynamic object because it trasfered to mass mailer MailDraft* draft = new MailDraft; @@ -6973,11 +7579,15 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) // format: "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12] std::string msgSubject = ExtractQuotedArg(&args); if (msgSubject.empty()) - { return false; } + { + return false; + } std::string msgText = ExtractQuotedArg(&args); if (msgText.empty()) - { return false; } + { + return false; + } // extract items typedef std::pair ItemPair; @@ -6992,7 +7602,9 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) uint32 item_count = 1; if (sscanf(itemStr, "%u:%u", &item_id, &item_count) != 2) if (sscanf(itemStr, "%u", &item_id) != 1) - { return false; } + { + return false; + } if (!item_id) { @@ -7054,13 +7666,17 @@ bool ChatHandler::HandleSendItemsCommand(char* args) ObjectGuid receiver_guid; std::string receiver_name; if (!ExtractPlayerTarget(&args, &receiver, &receiver_guid, &receiver_name)) - { return false; } + { + return false; + } MailDraft draft; // fill mail if (!HandleSendItemsHelper(draft, args)) - { return false; } + { + return false; + } // from console show nonexistent sender MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM); @@ -7080,7 +7696,9 @@ bool ChatHandler::HandleSendMassItemsCommand(char* args) char const* name = NULL; if (!ExtractRaceMask(&args, raceMask, &name)) - { return false; } + { + return false; + } // need dynamic object because it trasfered to mass mailer MailDraft* draft = new MailDraft; @@ -7108,18 +7726,26 @@ bool ChatHandler::HandleSendMoneyHelper(MailDraft& draft, char* args) std::string msgSubject = ExtractQuotedArg(&args); if (msgSubject.empty()) - { return false; } + { + return false; + } char* msgText = ExtractQuotedArg(&args); if (!msgText) - { return false; } + { + return false; + } uint32 money; if (!ExtractUInt32(&args, money)) - { return false; } + { + return false; + } if (money <= 0) - { return false; } + { + return false; + } // msgSubject, msgText isn't NUL after prev. check draft.SetSubjectAndBody(msgSubject, msgText).SetMoney(money); @@ -7135,13 +7761,17 @@ bool ChatHandler::HandleSendMoneyCommand(char* args) ObjectGuid receiver_guid; std::string receiver_name; if (!ExtractPlayerTarget(&args, &receiver, &receiver_guid, &receiver_name)) - { return false; } + { + return false; + } MailDraft draft; // fill mail if (!HandleSendMoneyHelper(draft, args)) - { return false; } + { + return false; + } // from console show nonexistent sender MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM); @@ -7161,7 +7791,9 @@ bool ChatHandler::HandleSendMassMoneyCommand(char* args) char const* name = NULL; if (!ExtractRaceMask(&args, raceMask, &name)) - { return false; } + { + return false; + } // need dynamic object because it trasfered to mass mailer MailDraft* draft = new MailDraft; @@ -7188,11 +7820,15 @@ bool ChatHandler::HandleSendMessageCommand(char* args) ///- Find the player Player* rPlayer; if (!ExtractPlayerTarget(&args, &rPlayer)) - { return false; } + { + return false; + } ///- message if (!*args) - { return false; } + { + return false; + } WorldSession* rPlayerSession = rPlayer->GetSession(); @@ -7218,7 +7854,9 @@ bool ChatHandler::HandleSendMessageCommand(char* args) bool ChatHandler::HandleModifyGenderCommand(char* args) { if (!*args) - { return false; } + { + return false; + } Player* player = getSelectedPlayer(); @@ -7231,7 +7869,9 @@ bool ChatHandler::HandleModifyGenderCommand(char* args) PlayerInfo const* info = sObjectMgr.GetPlayerInfo(player->getRace(), player->getClass()); if (!info) - { return false; } + { + return false; + } char* gender_str = args; int gender_len = strlen(gender_str); @@ -7241,14 +7881,18 @@ bool ChatHandler::HandleModifyGenderCommand(char* args) if (!strncmp(gender_str, "male", gender_len)) // MALE { if (player->getGender() == GENDER_MALE) - { return true; } + { + return true; + } gender = GENDER_MALE; } else if (!strncmp(gender_str, "female", gender_len)) // FEMALE { if (player->getGender() == GENDER_FEMALE) - { return true; } + { + return true; + } gender = GENDER_FEMALE; } @@ -7271,7 +7915,9 @@ bool ChatHandler::HandleModifyGenderCommand(char* args) PSendSysMessage(LANG_YOU_CHANGE_GENDER, GetNameLink(player).c_str(), gender_full); if (needReportToTarget(player)) - { ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetNameLink().c_str()); } + { + ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetNameLink().c_str()); + } return true; } diff --git a/src/game/ChatCommands/Level4.cpp b/src/game/ChatCommands/Level4.cpp index 9ccf99673..d349c31d7 100644 --- a/src/game/ChatCommands/Level4.cpp +++ b/src/game/ChatCommands/Level4.cpp @@ -44,18 +44,24 @@ bool ChatHandler::HandleAccountDeleteCommand(char* args) { if (!*args) - { return false; } + { + return false; + } std::string account_name; uint32 account_id = ExtractAccountId(&args, &account_name); if (!account_id) - { return false; } + { + return false; + } /// Commands not recommended call from chat, but support anyway /// can delete only for account with less security /// This is also reject self apply in fact if (HasLowerSecurityAccount(NULL, account_id, true)) - { return false; } + { + return false; + } AccountOpResult result = sAccountMgr.DeleteAccount(account_id); switch (result) @@ -94,12 +100,16 @@ bool ChatHandler::GetDeletedCharacterInfoList(DeletedInfoList& foundList, std::s { // search by GUID if (isNumeric(searchString)) - { resultChar = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND guid = %u", uint32(atoi(searchString.c_str()))); } + { + resultChar = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND guid = %u", uint32(atoi(searchString.c_str()))); + } // search by name else { if (!normalizePlayerName(searchString)) - { return false; } + { + return false; + } resultChar = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Name, deleteInfos_Account, deleteDate FROM characters WHERE deleteDate IS NOT NULL AND deleteInfos_Name " _LIKE_ " " _CONCAT3_("'%%'", "'%s'", "'%%'"), searchString.c_str()); } @@ -157,7 +167,9 @@ std::string ChatHandler::GenerateDeletedCharacterGUIDsWhereStr(DeletedInfoList:: DeletedInfoList::const_iterator itr2 = itr; if (++itr2 != itr_end) - { wherestr << "','"; } + { + wherestr << "','"; + } } wherestr << "')"; return wherestr.str(); @@ -197,7 +209,9 @@ void ChatHandler::HandleCharacterDeletedListHelper(DeletedInfoList const& foundL } if (!m_session) - { SendSysMessage(LANG_CHARACTER_DELETED_LIST_BAR); } + { + SendSysMessage(LANG_CHARACTER_DELETED_LIST_BAR); + } } /** @@ -214,7 +228,9 @@ bool ChatHandler::HandleCharacterDeletedListCommand(char* args) { DeletedInfoList foundList; if (!GetDeletedCharacterInfoList(foundList, args)) - { return false; } + { + return false; + } // if no characters have been found, output a warning if (foundList.empty()) @@ -278,7 +294,9 @@ bool ChatHandler::HandleCharacterDeletedRestoreCommand(char* args) { // It is required to submit at least one argument if (!*args) - { return false; } + { + return false; + } std::string searchString; std::string newCharName; @@ -290,7 +308,9 @@ bool ChatHandler::HandleCharacterDeletedRestoreCommand(char* args) DeletedInfoList foundList; if (!GetDeletedCharacterInfoList(foundList, searchString)) - { return false; } + { + return false; + } if (foundList.empty()) { @@ -343,11 +363,15 @@ bool ChatHandler::HandleCharacterDeletedDeleteCommand(char* args) { // It is required to submit at least one argument if (!*args) - { return false; } + { + return false; + } DeletedInfoList foundList; if (!GetDeletedCharacterInfoList(foundList, args)) - { return false; } + { + return false; + } if (foundList.empty()) { @@ -381,10 +405,14 @@ bool ChatHandler::HandleCharacterDeletedOldCommand(char* args) int32 keepDays = sWorld.getConfig(CONFIG_UINT32_CHARDELETE_KEEP_DAYS); if (!ExtractOptInt32(&args, keepDays, sWorld.getConfig(CONFIG_UINT32_CHARDELETE_KEEP_DAYS))) - { return false; } + { + return false; + } if (keepDays < 0) - { return false; } + { + return false; + } Player::DeleteOldCharacters((uint32)keepDays); return true; @@ -394,13 +422,17 @@ bool ChatHandler::HandleCharacterEraseCommand(char* args) { char* nameStr = ExtractLiteralArg(&args); if (!nameStr) - { return false; } + { + return false; + } Player* target; ObjectGuid target_guid; std::string target_name; if (!ExtractPlayerTarget(&nameStr, &target, &target_guid, &target_name)) - { return false; } + { + return false; + } uint32 account_id; @@ -441,7 +473,9 @@ bool ChatHandler::HandleAccountOnlineListCommand(char* args) { uint32 limit; if (!ExtractOptUInt32(&args, limit, 100)) - { return false; } + { + return false; + } ///- Get the list of accounts ID logged to the realm // 0 1 2 3 4 @@ -457,7 +491,9 @@ bool ChatHandler::HandleAccountCreateCommand(char* args) char* szAcc = ExtractQuotedOrLiteralArg(&args); char* szPassword = ExtractQuotedOrLiteralArg(&args); if (!szAcc || !szPassword) - { return false; } + { + return false; + } // normalized in accmgr.CreateAccount std::string account_name = szAcc; @@ -503,13 +539,17 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args) SendSysMessage(LANG_LOG_FILTERS_STATE_HEADER); for (int i = 0; i < LOG_FILTER_COUNT; ++i) if (*logFilterData[i].name) - { PSendSysMessage(" %-20s = %s", logFilterData[i].name, GetOnOffStr(sLog.HasLogFilter(1 << i))); } + { + PSendSysMessage(" %-20s = %s", logFilterData[i].name, GetOnOffStr(sLog.HasLogFilter(1 << i))); + } return true; } char* filtername = ExtractLiteralArg(&args); if (!filtername) - { return false; } + { + return false; + } bool value; if (!ExtractOnOff(&args, value)) @@ -529,7 +569,9 @@ bool ChatHandler::HandleServerLogFilterCommand(char* args) for (int i = 0; i < LOG_FILTER_COUNT; ++i) { if (!*logFilterData[i].name) - { continue; } + { + continue; + } if (!strncmp(filtername, logFilterData[i].name, strlen(filtername))) { diff --git a/src/game/ChatCommands/debugcmds.cpp b/src/game/ChatCommands/debugcmds.cpp index eac7828c5..f9a905dfe 100644 --- a/src/game/ChatCommands/debugcmds.cpp +++ b/src/game/ChatCommands/debugcmds.cpp @@ -41,28 +41,40 @@ bool ChatHandler::HandleDebugSendSpellFailCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint32 failnum; if (!ExtractUInt32(&args, failnum) || failnum > 255) - { return false; } + { + return false; + } uint32 failarg1; if (!ExtractOptUInt32(&args, failarg1, 0)) - { return false; } + { + return false; + } uint32 failarg2; if (!ExtractOptUInt32(&args, failarg2, 0)) - { return false; } + { + return false; + } WorldPacket data(SMSG_CAST_FAILED, 5); data << uint8(0); data << uint32(133); data << uint8(failnum); if (failarg1 || failarg2) - { data << uint32(failarg1); } + { + data << uint32(failarg1); + } if (failarg2) - { data << uint32(failarg2); } + { + data << uint32(failarg2); + } m_session->SendPacket(&data); @@ -81,11 +93,15 @@ bool ChatHandler::HandleDebugSendPoiCommand(char* args) uint32 icon; if (!ExtractUInt32(&args, icon)) - { return false; } + { + return false; + } uint32 flags; if (!ExtractUInt32(&args, flags)) - { return false; } + { + return false; + } DETAIL_LOG("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon, flags); pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI"); @@ -95,7 +111,9 @@ bool ChatHandler::HandleDebugSendPoiCommand(char* args) bool ChatHandler::HandleDebugSendEquipErrorCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint8 msg = atoi(args); m_session->GetPlayer()->SendEquipError(InventoryResult(msg), NULL, NULL); @@ -105,7 +123,9 @@ bool ChatHandler::HandleDebugSendEquipErrorCommand(char* args) bool ChatHandler::HandleDebugSendSellErrorCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint8 msg = atoi(args); m_session->GetPlayer()->SendSellError(SellResult(msg), 0, ObjectGuid(), 0); @@ -115,7 +135,9 @@ bool ChatHandler::HandleDebugSendSellErrorCommand(char* args) bool ChatHandler::HandleDebugSendBuyErrorCommand(char* args) { if (!*args) - { return false; } + { + return false; + } uint8 msg = atoi(args); m_session->GetPlayer()->SendBuyError(BuyResult(msg), 0, 0, 0); @@ -126,11 +148,15 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/) { Unit* unit = getSelectedUnit(); if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) - { unit = m_session->GetPlayer(); } + { + unit = m_session->GetPlayer(); + } std::ifstream stream("opcode.txt"); if (!stream.is_open()) - { return false; } + { + return false; + } uint32 opcode = 0; if (!(stream >> opcode)) @@ -145,7 +171,9 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/) while (stream >> type) { if (type.empty()) - { break; } + { + break; + } if (type == "uint8") { @@ -209,11 +237,15 @@ bool ChatHandler::HandleDebugUpdateWorldStateCommand(char* args) { uint32 world; if (!ExtractUInt32(&args, world)) - { return false; } + { + return false; + } uint32 state; if (!ExtractUInt32(&args, state)) - { return false; } + { + return false; + } m_session->GetPlayer()->SendUpdateWorldState(world, state); return true; @@ -225,7 +257,9 @@ bool ChatHandler::HandleDebugPlayCinematicCommand(char* args) // #cinematicid - ID decimal number from CinemaicSequences.dbc (1st column) uint32 dwId; if (!ExtractUInt32(&args, dwId)) - { return false; } + { + return false; + } if (!sCinematicSequencesStore.LookupEntry(dwId)) { @@ -264,7 +298,9 @@ bool ChatHandler::HandleDebugPlaySoundCommand(char* args) // #soundid - ID decimal number from SoundEntries.dbc (1st column) uint32 dwSoundId; if (!ExtractUInt32(&args, dwSoundId)) - { return false; } + { + return false; + } if (!sSoundEntriesStore.LookupEntry(dwSoundId)) { @@ -282,7 +318,9 @@ bool ChatHandler::HandleDebugPlaySoundCommand(char* args) } if (m_session->GetPlayer()->GetSelectionGuid()) - { unit->PlayDistanceSound(dwSoundId, m_session->GetPlayer()); } + { + unit->PlayDistanceSound(dwSoundId, m_session->GetPlayer()); + } else { unit->PlayDirectSound(dwSoundId, m_session->GetPlayer()); } @@ -297,7 +335,9 @@ bool ChatHandler::HandleDebugSendChannelNotifyCommand(char* args) uint32 code; if (!ExtractUInt32(&args, code) || code > 255) - { return false; } + { + return false; + } WorldPacket data(SMSG_CHANNEL_NOTIFY, (1 + 10)); data << uint8(code); // notify type @@ -315,7 +355,9 @@ bool ChatHandler::HandleDebugSendChatMsgCommand(char* args) uint32 type; if (!ExtractUInt32(&args, type) || type > 255) - { return false; } + { + return false; + } WorldPacket data; ChatHandler::BuildChatPacket(data, ChatMsg(type), msg, LANG_UNIVERSAL, CHAT_TAG_NONE, m_session->GetPlayer()->GetObjectGuid(), m_session->GetPlayerName()); @@ -327,7 +369,9 @@ bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(char* args) { uint32 msg; if (!ExtractUInt32(&args, msg)) - { return false; } + { + return false; + } m_session->GetPlayer()->SendPushToPartyResponse(m_session->GetPlayer(), msg); return true; @@ -337,10 +381,14 @@ bool ChatHandler::HandleDebugGetLootRecipientCommand(char* /*args*/) { Creature* target = getSelectedCreature(); if (!target) - { return false; } + { + return false; + } if (!target->HasLootRecipient()) - { SendSysMessage("loot recipient: no loot recipient"); } + { + SendSysMessage("loot recipient: no loot recipient"); + } else if (Player* recipient = target->GetLootRecipient()) PSendSysMessage("loot recipient: %s with raw data %s from group %u", recipient->GetGuidStr().c_str(), @@ -362,7 +410,9 @@ bool ChatHandler::HandleDebugSendQuestInvalidMsgCommand(char* args) bool ChatHandler::HandleDebugGetItemStateCommand(char* args) { if (!*args) - { return false; } + { + return false; + } ItemUpdateState state = ITEM_UNCHANGED; bool list_queue = false, check_all = false; @@ -406,7 +456,9 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args) for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) - { continue; } + { + continue; + } Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (!item) { continue; } @@ -455,7 +507,9 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args) item->GetGuidStr().c_str(), bag_slot, item->GetSlot(), st.c_str()); } if (updateQueue.empty()) - { PSendSysMessage("updatequeue empty"); } + { + PSendSysMessage("updatequeue empty"); + } } if (check_all) @@ -465,7 +519,9 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args) for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) - { continue; } + { + continue; + } Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (!item) { continue; } @@ -638,7 +694,9 @@ bool ChatHandler::HandleDebugGetItemStateCommand(char* args) } } if (!error) - { SendSysMessage("All OK!"); } + { + SendSysMessage("All OK!"); + } } return true; @@ -691,7 +749,9 @@ bool ChatHandler::HandleDebugPhaseCommand(char* args) { uint32 emote_id; if (!ExtractUInt32(&args, emote_id)) - { return false; } + { + return false; + } m_session->GetPlayer()->HandleEmoteCommand(emote_id); return true; @@ -702,7 +762,9 @@ bool ChatHandler::HandleDebugAnimCommand(char* args) { uint32 emote_id; if (!ExtractUInt32(&args, emote_id)) - { return false; } + { + return false; + } m_session->GetPlayer()->HandleEmoteCommand(emote_id); return true; @@ -712,7 +774,9 @@ bool ChatHandler::HandleDebugSetAuraStateCommand(char* args) { int32 state; if (!ExtractInt32(&args, state)) - { return false; } + { + return false; + } Unit* unit = getSelectedUnit(); if (!unit) @@ -747,7 +811,9 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS uint32 base; // 0 -> float if (!typeStr) - { base = 10; } + { + base = 10; + } else if (strncmp(typeStr, "int", strlen(typeStr)) == 0) { base = 10; } else if (strncmp(typeStr, "hex", strlen(typeStr)) == 0) @@ -763,7 +829,9 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS { uint32 iValue; if (!ExtractUInt32Base(&valStr, iValue, base)) - { return false; } + { + return false; + } DEBUG_LOG(GetMangosString(LANG_SET_UINT), guid.GetString().c_str(), field, iValue); target->SetUInt32Value(field , iValue); @@ -773,7 +841,9 @@ bool ChatHandler::HandleSetValueHelper(Object* target, uint32 field, char* typeS { float fValue; if (!ExtractFloat(&valStr, fValue)) - { return false; } + { + return false; + } DEBUG_LOG(GetMangosString(LANG_SET_FLOAT), guid.GetString().c_str(), field, fValue); target->SetFloatValue(field , fValue); @@ -787,23 +857,33 @@ bool ChatHandler::HandleDebugSetItemValueCommand(char* args) { uint32 guid; if (!ExtractUInt32(&args, guid)) - { return false; } + { + return false; + } uint32 field; if (!ExtractUInt32(&args, field)) - { return false; } + { + return false; + } char* typeStr = ExtractOptNotLastArg(&args); if (!typeStr) - { return false; } + { + return false; + } char* valStr = ExtractLiteralArg(&args); if (!valStr) - { return false; } + { + return false; + } Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid)); if (!item) - { return false; } + { + return false; + } return HandleSetValueHelper(item, field, typeStr, valStr); } @@ -820,15 +900,21 @@ bool ChatHandler::HandleDebugSetValueCommand(char* args) uint32 field; if (!ExtractUInt32(&args, field)) - { return false; } + { + return false; + } char* typeStr = ExtractOptNotLastArg(&args); if (!typeStr) - { return false; } + { + return false; + } char* valStr = ExtractLiteralArg(&args); if (!valStr) - { return false; } + { + return false; + } return HandleSetValueHelper(target, field, typeStr, valStr); } @@ -845,7 +931,9 @@ bool ChatHandler::HandleGetValueHelper(Object* target, uint32 field, char* typeS uint32 base; // 0 -> float if (!typeStr) - { base = 10; } + { + base = 10; + } else if (strncmp(typeStr, "int", strlen(typeStr)) == 0) { base = 10; } else if (strncmp(typeStr, "hex", strlen(typeStr)) == 0) @@ -899,19 +987,27 @@ bool ChatHandler::HandleDebugGetItemValueCommand(char* args) { uint32 guid; if (!ExtractUInt32(&args, guid)) - { return false; } + { + return false; + } uint32 field; if (!ExtractUInt32(&args, field)) - { return false; } + { + return false; + } char* typeStr = ExtractLiteralArg(&args); if (!typeStr && *args) // optional arg but check format fail case - { return false; } + { + return false; + } Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid)); if (!item) - { return false; } + { + return false; + } return HandleGetValueHelper(item, field, typeStr); } @@ -928,11 +1024,15 @@ bool ChatHandler::HandleDebugGetValueCommand(char* args) uint32 field; if (!ExtractUInt32(&args, field)) - { return false; } + { + return false; + } char* typeStr = ExtractLiteralArg(&args); if (!typeStr && *args) // optional arg but check format fail case - { return false; } + { + return false; + } return HandleGetValueHelper(target, field, typeStr); } @@ -950,7 +1050,9 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char* uint32 type; // 0 -> float 1 -> int add 2-> bit or 3 -> bit and 4 -> bit and not if (strncmp(typeStr, "int", strlen(typeStr)) == 0) - { type = 1; } + { + type = 1; + } else if (strncmp(typeStr, "float", strlen(typeStr)) == 0) { type = 0; } else if (strncmp(typeStr, "|=", strlen("|=") + 1) == 0) // exactly copy @@ -966,7 +1068,9 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char* { uint32 iValue; if (!ExtractUInt32Base(&valStr, iValue, type == 1 ? 10 : 16)) - { return false; } + { + return false; + } uint32 value = target->GetUInt32Value(field); const char* guidString = guid.GetString().c_str(); @@ -1002,7 +1106,9 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char* { float fValue; if (!ExtractFloat(&valStr, fValue)) - { return false; } + { + return false; + } float value = target->GetFloatValue(field); @@ -1021,23 +1127,33 @@ bool ChatHandler::HandleDebugModItemValueCommand(char* args) { uint32 guid; if (!ExtractUInt32(&args, guid)) - { return false; } + { + return false; + } uint32 field; if (!ExtractUInt32(&args, field)) - { return false; } + { + return false; + } char* typeStr = ExtractLiteralArg(&args); if (!typeStr) - { return false; } + { + return false; + } char* valStr = ExtractLiteralArg(&args); if (!valStr) - { return false; } + { + return false; + } Item* item = m_session->GetPlayer()->GetItemByGuid(ObjectGuid(HIGHGUID_ITEM, guid)); if (!item) - { return false; } + { + return false; + } return HandlerDebugModValueHelper(item, field, typeStr, valStr); } @@ -1054,15 +1170,21 @@ bool ChatHandler::HandleDebugModValueCommand(char* args) uint32 field; if (!ExtractUInt32(&args, field)) - { return false; } + { + return false; + } char* typeStr = ExtractLiteralArg(&args); if (!typeStr && *args) // optional arg but check format fail case - { return false; } + { + return false; + } char* valStr = ExtractLiteralArg(&args); if (!valStr) - { return false; } + { + return false; + } return HandlerDebugModValueHelper(target, field, typeStr, valStr); } @@ -1071,11 +1193,15 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args) { uint32 spellid = ExtractSpellIdFromLink(&args); if (!spellid) - { return false; } + { + return false; + } SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellid); if (!spellEntry) - { return false; } + { + return false; + } SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellid); @@ -1128,11 +1254,15 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args) { char* typeStr = ExtractLiteralArg(&args); if (!typeStr) - { return false; } + { + return false; + } Opcodes opcode; if (strncmp(typeStr, "flat", strlen(typeStr)) == 0) - { opcode = SMSG_SET_FLAT_SPELL_MODIFIER; } + { + opcode = SMSG_SET_FLAT_SPELL_MODIFIER; + } else if (strncmp(typeStr, "pct", strlen(typeStr)) == 0) { opcode = SMSG_SET_PCT_SPELL_MODIFIER; } else @@ -1140,15 +1270,21 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args) uint32 effidx; if (!ExtractUInt32(&args, effidx) || effidx >= 64 + 32) - { return false; } + { + return false; + } uint32 spellmodop; if (!ExtractUInt32(&args, spellmodop) || spellmodop >= MAX_SPELLMOD) - { return false; } + { + return false; + } int32 value; if (!ExtractInt32(&args, value)) - { return false; } + { + return false; + } Player* chr = getSelectedPlayer(); if (chr == NULL) @@ -1160,7 +1296,9 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args) // check online security if (HasLowerSecurity(chr)) - { return false; } + { + return false; + } PSendSysMessage(LANG_YOU_CHANGE_SPELLMODS, opcode == SMSG_SET_FLAT_SPELL_MODIFIER ? "flat" : "pct", spellmodop, value, effidx, GetNameLink(chr).c_str()); diff --git a/src/game/MotionGenerators/ConfusedMovementGenerator.cpp b/src/game/MotionGenerators/ConfusedMovementGenerator.cpp index 2fce61ebe..d33c2c2c9 100644 --- a/src/game/MotionGenerators/ConfusedMovementGenerator.cpp +++ b/src/game/MotionGenerators/ConfusedMovementGenerator.cpp @@ -37,7 +37,9 @@ void ConfusedMovementGenerator::Initialize(T& unit) unit.GetPosition(i_x, i_y, i_z); if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } unit.StopMoving(); unit.addUnitState(UNIT_STAT_CONFUSED_MOVE); @@ -57,7 +59,9 @@ void ConfusedMovementGenerator::Reset(T& unit) i_nextMoveTime.Reset(0); if (!unit.IsAlive() || unit.hasUnitState(UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } unit.StopMoving(); unit.addUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE); @@ -68,7 +72,9 @@ bool ConfusedMovementGenerator::Update(T& unit, const uint32& diff) { // ignore in case other no reaction state if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT & ~UNIT_STAT_CONFUSED)) - { return true; } + { + return true; + } if (i_nextMoveTime.Passed()) { @@ -76,7 +82,9 @@ bool ConfusedMovementGenerator::Update(T& unit, const uint32& diff) unit.addUnitState(UNIT_STAT_CONFUSED_MOVE); if (unit.movespline->Finalized()) - { i_nextMoveTime.Reset(urand(800, 1500)); } + { + i_nextMoveTime.Reset(urand(800, 1500)); + } } else { diff --git a/src/game/MotionGenerators/FleeingMovementGenerator.cpp b/src/game/MotionGenerators/FleeingMovementGenerator.cpp index e226482e2..5ee7c0df6 100644 --- a/src/game/MotionGenerators/FleeingMovementGenerator.cpp +++ b/src/game/MotionGenerators/FleeingMovementGenerator.cpp @@ -39,7 +39,9 @@ void FleeingMovementGenerator::_setTargetLocation(T& owner) { // ignore in case other no reaction state if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING)) - { return; } + { + return; + } float x, y, z; if (!_getPoint(owner, x, y, z)) @@ -76,7 +78,9 @@ bool FleeingMovementGenerator::_getPoint(T& owner, float& x, float& y, float& { dist_from_caster = fright->GetDistance(&owner); if (dist_from_caster > 0.2f) - { angle_to_caster = fright->GetAngle(&owner); } + { + angle_to_caster = fright->GetAngle(&owner); + } else { angle_to_caster = frand(0, 2 * M_PI_F); } } @@ -172,7 +176,9 @@ template bool FleeingMovementGenerator::Update(T& owner, const uint32& time_diff) { if (!owner.IsAlive()) - { return false; } + { + return false; + } // ignore in case other no reaction state if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING)) @@ -183,7 +189,9 @@ bool FleeingMovementGenerator::Update(T& owner, const uint32& time_diff) i_nextCheckTime.Update(time_diff); if (i_nextCheckTime.Passed() && owner.movespline->Finalized()) - { _setTargetLocation(owner); } + { + _setTargetLocation(owner); + } return true; } @@ -217,7 +225,9 @@ void TimedFleeingMovementGenerator::Finalize(Unit& owner) bool TimedFleeingMovementGenerator::Update(Unit& owner, const uint32& time_diff) { if (!owner.IsAlive()) - { return false; } + { + return false; + } // ignore in case other no reaction state if (owner.hasUnitState((UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE) & ~UNIT_STAT_FLEEING)) @@ -228,7 +238,9 @@ bool TimedFleeingMovementGenerator::Update(Unit& owner, const uint32& time_diff) i_totalFleeTime.Update(time_diff); if (i_totalFleeTime.Passed()) - { return false; } + { + return false; + } // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, const uint32 &) version // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly diff --git a/src/game/MotionGenerators/HomeMovementGenerator.cpp b/src/game/MotionGenerators/HomeMovementGenerator.cpp index 4893a513d..ea3490ab3 100644 --- a/src/game/MotionGenerators/HomeMovementGenerator.cpp +++ b/src/game/MotionGenerators/HomeMovementGenerator.cpp @@ -42,7 +42,9 @@ void HomeMovementGenerator::Reset(Creature&) void HomeMovementGenerator::_setTargetLocation(Creature& owner) { if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } Movement::MoveSplineInit init(owner); float x, y, z, o; @@ -71,7 +73,9 @@ void HomeMovementGenerator::Finalize(Creature& owner) if (arrived) { if (owner.GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_REACH_HOME) - { owner.ClearTemporaryFaction(); } + { + owner.ClearTemporaryFaction(); + } owner.SetWalk(!owner.hasUnitState(UNIT_STAT_RUNNING_STATE) && !owner.IsLevitating(), false); owner.LoadCreatureAddon(true); diff --git a/src/game/MotionGenerators/IdleMovementGenerator.cpp b/src/game/MotionGenerators/IdleMovementGenerator.cpp index 0140f83eb..e1e5ec7ab 100644 --- a/src/game/MotionGenerators/IdleMovementGenerator.cpp +++ b/src/game/MotionGenerators/IdleMovementGenerator.cpp @@ -60,7 +60,9 @@ bool DistractMovementGenerator::Update(Unit& /*owner*/, const uint32& time_diff) { if (time_diff > m_timer) - { return false; } + { + return false; + } m_timer -= time_diff; return true; diff --git a/src/game/MotionGenerators/MotionMaster.cpp b/src/game/MotionGenerators/MotionMaster.cpp index c23937543..4fde108b4 100644 --- a/src/game/MotionGenerators/MotionMaster.cpp +++ b/src/game/MotionGenerators/MotionMaster.cpp @@ -76,14 +76,18 @@ MotionMaster::~MotionMaster() MovementGenerator* m = top(); pop(); if (!isStatic(m)) - { delete m; } + { + delete m; + } } } void MotionMaster::UpdateMotion(uint32 diff) { if (m_owner->hasUnitState(UNIT_STAT_CAN_NOT_MOVE)) - { return; } + { + return; + } MANGOS_ASSERT(!empty()); m_cleanFlag |= MMCF_UPDATE; @@ -102,14 +106,18 @@ void MotionMaster::UpdateMotion(uint32 diff) { MovementGenerator* mg = (*m_expList)[i]; if (!isStatic(mg)) - { delete mg; } + { + delete mg; + } } delete m_expList; m_expList = NULL; if (empty()) - { Initialize(); } + { + Initialize(); + } if (m_cleanFlag & MMCF_RESET) { @@ -128,7 +136,9 @@ void MotionMaster::DirectClean(bool reset, bool all) curr->Finalize(*m_owner); if (!isStatic(curr)) - { delete curr; } + { + delete curr; + } } if (!all && reset) @@ -141,15 +151,21 @@ void MotionMaster::DirectClean(bool reset, bool all) void MotionMaster::DelayedClean(bool reset, bool all) { if (reset) - { m_cleanFlag |= MMCF_RESET; } + { + m_cleanFlag |= MMCF_RESET; + } else { m_cleanFlag &= ~MMCF_RESET; } if (empty() || (!all && size() == 1)) - { return; } + { + return; + } if (!m_expList) - { m_expList = new ExpireList(); } + { + m_expList = new ExpireList(); + } while (all ? !empty() : size() > 1) { @@ -158,14 +174,18 @@ void MotionMaster::DelayedClean(bool reset, bool all) curr->Finalize(*m_owner); if (!isStatic(curr)) - { m_expList->push_back(curr); } + { + m_expList->push_back(curr); + } } } void MotionMaster::DirectExpire(bool reset) { if (empty() || size() == 1) - { return; } + { + return; + } MovementGenerator* curr = top(); pop(); @@ -185,31 +205,43 @@ void MotionMaster::DirectExpire(bool reset) curr->Finalize(*m_owner); if (!isStatic(curr)) - { delete curr; } + { + delete curr; + } if (empty()) - { Initialize(); } + { + Initialize(); + } // Prevent reseting possible new pushed MMGen if (reset && top() == nowTop) - { top()->Reset(*m_owner); } + { + top()->Reset(*m_owner); + } } void MotionMaster::DelayedExpire(bool reset) { if (reset) - { m_cleanFlag |= MMCF_RESET; } + { + m_cleanFlag |= MMCF_RESET; + } else { m_cleanFlag &= ~MMCF_RESET; } if (empty() || size() == 1) - { return; } + { + return; + } MovementGenerator* curr = top(); pop(); if (!m_expList) - { m_expList = new ExpireList(); } + { + m_expList = new ExpireList(); + } // also drop stored under top() targeted motions while (!empty() && (top()->GetMovementGeneratorType() == CHASE_MOTION_TYPE || top()->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)) @@ -223,13 +255,17 @@ void MotionMaster::DelayedExpire(bool reset) curr->Finalize(*m_owner); if (!isStatic(curr)) - { m_expList->push_back(curr); } + { + m_expList->push_back(curr); + } } void MotionMaster::MoveIdle() { if (empty() || !isStatic(top())) - { push(&si_idleMovement); } + { + push(&si_idleMovement); + } } void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius, float verticalZ) @@ -248,7 +284,9 @@ void MotionMaster::MoveRandomAroundPoint(float x, float y, float z, float radius void MotionMaster::MoveTargetedHome() { if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) - { return; } + { + return; + } Clear(false); @@ -256,7 +294,9 @@ void MotionMaster::MoveTargetedHome() { // Manual exception for linked mobs if (m_owner->IsLinkingEventTrigger() && m_owner->GetMap()->GetCreatureLinkingHolder()->TryFollowMaster((Creature*)m_owner)) - { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s refollowed linked master", m_owner->GetGuidStr().c_str()); } + { + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s refollowed linked master", m_owner->GetGuidStr().c_str()); + } else { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted home", m_owner->GetGuidStr().c_str()); @@ -284,7 +324,9 @@ void MotionMaster::MoveConfused() DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s move confused", m_owner->GetGuidStr().c_str()); if (m_owner->GetTypeId() == TYPEID_PLAYER) - { Mutate(new ConfusedMovementGenerator()); } + { + Mutate(new ConfusedMovementGenerator()); + } else { Mutate(new ConfusedMovementGenerator()); } } @@ -293,12 +335,16 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle) { // ignore movement request if target not exist if (!target) - { return; } + { + return; + } DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s chase to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str()); if (m_owner->GetTypeId() == TYPEID_PLAYER) - { Mutate(new ChaseMovementGenerator(*target, dist, angle)); } + { + Mutate(new ChaseMovementGenerator(*target, dist, angle)); + } else { Mutate(new ChaseMovementGenerator(*target, dist, angle)); } } @@ -306,18 +352,24 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle) void MotionMaster::MoveFollow(Unit* target, float dist, float angle) { if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL)) - { return; } + { + return; + } Clear(); // ignore movement request if target not exist if (!target) - { return; } + { + return; + } DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str()); if (m_owner->GetTypeId() == TYPEID_PLAYER) - { Mutate(new FollowMovementGenerator(*target, dist, angle)); } + { + Mutate(new FollowMovementGenerator(*target, dist, angle)); + } else { Mutate(new FollowMovementGenerator(*target, dist, angle)); } } @@ -327,7 +379,9 @@ void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generate DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), id, x, y, z); if (m_owner->GetTypeId() == TYPEID_PLAYER) - { Mutate(new PointMovementGenerator(id, x, y, z, generatePath)); } + { + Mutate(new PointMovementGenerator(id, x, y, z, generatePath)); + } else { Mutate(new PointMovementGenerator(id, x, y, z, generatePath)); } } @@ -363,16 +417,22 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time) void MotionMaster::MoveFleeing(Unit* enemy, uint32 time) { if (!enemy) - { return; } + { + return; + } DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s flee from %s", m_owner->GetGuidStr().c_str(), enemy->GetGuidStr().c_str()); if (m_owner->GetTypeId() == TYPEID_PLAYER) - { Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); } + { + Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); + } else { if (time) - { Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); } + { + Mutate(new TimedFleeingMovementGenerator(enemy->GetObjectGuid(), time)); + } else { Mutate(new FleeingMovementGenerator(enemy->GetObjectGuid())); } } @@ -434,7 +494,9 @@ void MotionMaster::MoveDistract(uint32 timer) void MotionMaster::MoveFlyOrLand(uint32 id, float x, float y, float z, bool liftOff) { if (m_owner->GetTypeId() != TYPEID_UNIT) - { return; } + { + return; + } DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s targeted point for %s (Id: %u X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), liftOff ? "liftoff" : "landing", id, x, y, z); Mutate(new FlyOrLandMovementGenerator(id, x, y, z, liftOff)); @@ -457,7 +519,9 @@ void MotionMaster::Mutate(MovementGenerator* m) } if (!empty()) - { top()->Interrupt(*m_owner); } + { + top()->Interrupt(*m_owner); + } } m->Initialize(*m_owner); @@ -488,7 +552,9 @@ uint32 MotionMaster::getLastReachedWaypoint() const for (Impl::container_type::const_reverse_iterator rItr = Impl::c.rbegin(); rItr != Impl::c.rend(); ++rItr) { if ((*rItr)->GetMovementGeneratorType() == WAYPOINT_MOTION_TYPE) - { return (static_cast*>(*rItr))->getLastReachedWaypoint(); } + { + return (static_cast*>(*rItr))->getLastReachedWaypoint(); + } } return 0; } @@ -496,7 +562,9 @@ uint32 MotionMaster::getLastReachedWaypoint() const MovementGeneratorType MotionMaster::GetCurrentMovementGeneratorType() const { if (empty()) - { return IDLE_MOTION_TYPE; } + { + return IDLE_MOTION_TYPE; + } return top()->GetMovementGeneratorType(); } @@ -516,7 +584,9 @@ void MotionMaster::GetWaypointPathInformation(std::ostringstream& oss) const bool MotionMaster::GetDestination(float& x, float& y, float& z) { if (m_owner->movespline->Finalized()) - { return false; } + { + return false; + } const G3D::Vector3& dest = m_owner->movespline->FinalDestination(); x = dest.x; @@ -558,7 +628,9 @@ void MotionMaster::MoveFall() // Abort too if the ground is very near if (fabs(m_owner->GetPositionZ() - tz) < 0.1f) - { return; } + { + return; + } Movement::MoveSplineInit init(*m_owner); init.MoveTo(m_owner->GetPositionX(), m_owner->GetPositionY(), tz); diff --git a/src/game/MotionGenerators/MotionMaster.h b/src/game/MotionGenerators/MotionMaster.h index 38a991d47..6aaeddfaf 100644 --- a/src/game/MotionGenerators/MotionMaster.h +++ b/src/game/MotionGenerators/MotionMaster.h @@ -95,14 +95,18 @@ class MotionMaster : private std::stack void Clear(bool reset = true, bool all = false) { if (m_cleanFlag & MMCF_UPDATE) - { DelayedClean(reset, all); } + { + DelayedClean(reset, all); + } else { DirectClean(reset, all); } } void MovementExpired(bool reset = true) { if (m_cleanFlag & MMCF_UPDATE) - { DelayedExpire(reset); } + { + DelayedExpire(reset); + } else { DirectExpire(reset); } } diff --git a/src/game/MotionGenerators/PathFinder.cpp b/src/game/MotionGenerators/PathFinder.cpp index 834a8649f..01e36e1f3 100644 --- a/src/game/MotionGenerators/PathFinder.cpp +++ b/src/game/MotionGenerators/PathFinder.cpp @@ -88,7 +88,9 @@ bool PathFinder::calculate(float destX, float destY, float destZ, bool forceDest dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef* polyPath, uint32 polyPathSize, const float* point, float* distance) const { if (!polyPath || !polyPathSize) - { return INVALID_POLYREF; } + { + return INVALID_POLYREF; + } dtPolyRef nearestPoly = INVALID_POLYREF; float minDist2d = FLT_MAX; @@ -110,11 +112,15 @@ dtPolyRef PathFinder::getPathPolyByPosition(const dtPolyRef* polyPath, uint32 po } if (minDist2d < 1.0f) // shortcut out - close enough for us - { break; } + { + break; + } } if (distance) - { *distance = dtSqrt(minDist3d); } + { + *distance = dtSqrt(minDist3d); + } return (minDist2d < 3.0f) ? nearestPoly : INVALID_POLYREF; } @@ -126,7 +132,9 @@ dtPolyRef PathFinder::getPolyByLocation(const float* point, float* distance) con // we need to use the expensive navMesh.findNearestPoly dtPolyRef polyRef = getPathPolyByPosition(m_pathPolyRefs, m_polyLength, point, distance); if (polyRef != INVALID_POLYREF) - { return polyRef; } + { + return polyRef; + } // we don't have it in our old path // try to get it by findNearestPoly() @@ -205,13 +213,17 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) { DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: underWater case\n"); if (owner->CanSwim()) - { buildShotrcut = true; } + { + buildShotrcut = true; + } } else { DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ BuildPolyPath :: flying case\n"); if (owner->CanFly()) - { buildShotrcut = true; } + { + buildShotrcut = true; + } } } @@ -391,7 +403,9 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) // by now we know what type of path we can get if (m_pathPolyRefs[m_polyLength - 1] == endPoly && !(m_type & PATHFIND_INCOMPLETE)) - { m_type = PATHFIND_NORMAL; } + { + m_type = PATHFIND_NORMAL; + } else { m_type = PATHFIND_INCOMPLETE; } @@ -576,12 +590,16 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath, } } if (found) - { break; } + { + break; + } } // If no intersection found just return current path. if (furthestPath == -1 || furthestVisited == -1) - { return npath; } + { + return npath; + } // Concatenate paths. @@ -590,10 +608,14 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath, uint32 orig = uint32(furthestPath + 1) < npath ? furthestPath + 1 : npath; uint32 size = npath > orig ? npath - orig : 0; if (req + size > maxPath) - { size = maxPath - req; } + { + size = maxPath - req; + } if (size) - { memmove(path + req, path + orig, size * sizeof(dtPolyRef)); } + { + memmove(path + req, path + orig, size * sizeof(dtPolyRef)); + } // Store visited for (uint32 i = 0; i < req; ++i) @@ -615,7 +637,9 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos, dtStatus dtResult = m_navMeshQuery->findStraightPath(startPos, endPos, path, pathSize, steerPath, steerPathFlags, steerPathPolys, (int*)&nsteerPath, MAX_STEER_POINTS); if (!nsteerPath || dtStatusFailed(dtResult)) - { return false; } + { + return false; + } // Find vertex far enough to steer to. uint32 ns = 0; @@ -629,7 +653,9 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos, } // Failed to find good point to steer to. if (ns >= nsteerPath) - { return false; } + { + return false; + } dtVcopy(steerPos, &steerPath[ns * VERTEX_SIZE]); steerPos[1] = startPos[1]; // keep Z value @@ -653,11 +679,15 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, float iterPos[VERTEX_SIZE], targetPos[VERTEX_SIZE]; dtStatus dtResult = m_navMeshQuery->closestPointOnPolyBoundary(polys[0], startPos, iterPos); if (dtStatusFailed(dtResult)) - { return DT_FAILURE; } + { + return DT_FAILURE; + } dtResult = m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys - 1], endPos, targetPos); if (dtStatusFailed(dtResult)) - { return DT_FAILURE; } + { + return DT_FAILURE; + } dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos); ++nsmoothPath; @@ -672,7 +702,9 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, dtPolyRef steerPosRef = INVALID_POLYREF; if (!getSteerTarget(iterPos, targetPos, SMOOTH_PATH_SLOP, polys, npolys, steerPos, steerPosFlag, steerPosRef)) - { break; } + { + break; + } bool endOfPath = (steerPosFlag & DT_STRAIGHTPATH_END); bool offMeshConnection = (steerPosFlag & DT_STRAIGHTPATH_OFFMESH_CONNECTION); @@ -683,7 +715,9 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, float len = dtSqrt(dtVdot(delta, delta)); // If the steer target is end of path or off-mesh link, do not move past the location. if ((endOfPath || offMeshConnection) && len < SMOOTH_PATH_STEP_SIZE) - { len = 1.0f; } + { + len = 1.0f; + } else { len = SMOOTH_PATH_STEP_SIZE / len; } diff --git a/src/game/MotionGenerators/PointMovementGenerator.cpp b/src/game/MotionGenerators/PointMovementGenerator.cpp index e16e04a82..8f1146307 100644 --- a/src/game/MotionGenerators/PointMovementGenerator.cpp +++ b/src/game/MotionGenerators/PointMovementGenerator.cpp @@ -36,7 +36,9 @@ template void PointMovementGenerator::Initialize(T& unit) { if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } unit.StopMoving(); @@ -52,7 +54,9 @@ void PointMovementGenerator::Finalize(T& unit) unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); if (unit.movespline->Finalized()) - { MovementInform(unit); } + { + MovementInform(unit); + } } template @@ -79,7 +83,9 @@ bool PointMovementGenerator::Update(T& unit, const uint32& diff) } if (!unit.hasUnitState(UNIT_STAT_ROAMING_MOVE) && unit.movespline->Finalized()) - { Initialize(unit); } + { + Initialize(unit); + } return !unit.movespline->Finalized(); } @@ -93,7 +99,9 @@ template <> void PointMovementGenerator::MovementInform(Creature& unit) { if (unit.AI()) - { unit.AI()->MovementInform(POINT_MOTION_TYPE, id); } + { + unit.AI()->MovementInform(POINT_MOTION_TYPE, id); + } if (unit.IsTemporarySummon()) { @@ -101,7 +109,9 @@ void PointMovementGenerator::MovementInform(Creature& unit) if (pSummon->GetSummonerGuid().IsCreatureOrVehicle()) if (Creature* pSummoner = unit.GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) - { pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); } + { + pSummoner->AI()->SummonedMovementInform(&unit, POINT_MOTION_TYPE, id); + } } } @@ -123,7 +133,9 @@ void AssistanceMovementGenerator::Finalize(Unit& unit) ((Creature*)&unit)->SetNoCallAssistance(false); ((Creature*)&unit)->CallAssistance(); if (unit.IsAlive()) - { unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)); } + { + unit.GetMotionMaster()->MoveSeekAssistanceDistract(sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_ASSISTANCE_DELAY)); + } } bool EffectMovementGenerator::Update(Unit& unit, const uint32&) @@ -134,15 +146,21 @@ bool EffectMovementGenerator::Update(Unit& unit, const uint32&) void EffectMovementGenerator::Finalize(Unit& unit) { if (unit.GetTypeId() != TYPEID_UNIT) - { return; } + { + return; + } if (((Creature&)unit).AI() && unit.movespline->Finalized()) - { ((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); } + { + ((Creature&)unit).AI()->MovementInform(EFFECT_MOTION_TYPE, m_Id); + } // Need restore previous movement since we have no proper states system if (unit.IsAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING | UNIT_STAT_NO_COMBAT_MOVEMENT)) { if (Unit* victim = unit.getVictim()) - { unit.GetMotionMaster()->MoveChase(victim); } + { + unit.GetMotionMaster()->MoveChase(victim); + } else { unit.GetMotionMaster()->Initialize(); } } @@ -151,7 +169,9 @@ void EffectMovementGenerator::Finalize(Unit& unit) void FlyOrLandMovementGenerator::Initialize(Unit& unit) { if (unit.hasUnitState(UNIT_STAT_CAN_NOT_REACT | UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } unit.StopMoving(); diff --git a/src/game/MotionGenerators/RandomMovementGenerator.cpp b/src/game/MotionGenerators/RandomMovementGenerator.cpp index fc88fff9c..2a2759812 100644 --- a/src/game/MotionGenerators/RandomMovementGenerator.cpp +++ b/src/game/MotionGenerators/RandomMovementGenerator.cpp @@ -76,7 +76,9 @@ void RandomMovementGenerator::Initialize(Creature& creature) creature.addUnitState(UNIT_STAT_ROAMING); // _MOVE set in _setRandomLocation if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } _setRandomLocation(creature); } @@ -116,7 +118,9 @@ bool RandomMovementGenerator::Update(Creature& creature, const uint32& { i_nextMoveTime.Update(diff); if (i_nextMoveTime.Passed()) - { _setRandomLocation(creature); } + { + _setRandomLocation(creature); + } } return true; } diff --git a/src/game/MotionGenerators/TargetedMovementGenerator.cpp b/src/game/MotionGenerators/TargetedMovementGenerator.cpp index 1a85db9d5..9983d36b4 100644 --- a/src/game/MotionGenerators/TargetedMovementGenerator.cpp +++ b/src/game/MotionGenerators/TargetedMovementGenerator.cpp @@ -38,10 +38,14 @@ template void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner, bool updateDestination) { if (!i_target.isValid() || !i_target->IsInWorld()) - { return; } + { + return; + } if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } float x, y, z; @@ -55,7 +59,9 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner, bool up if (!RequiresNewPosition(owner, x, y, z)) { if (!owner.movespline->Finalized()) - { return; } + { + return; + } } // Chase Movement and angle == 0 case: Chase to current angle else if (this->GetMovementGeneratorType() == CHASE_MOTION_TYPE && i_angle == 0.0f) @@ -78,14 +84,18 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner, bool up } if (!i_path) - { i_path = new PathFinder(&owner); } + { + i_path = new PathFinder(&owner); + } // allow pets following their master to cheat while generating paths bool forceDest = (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->IsPet() && owner.hasUnitState(UNIT_STAT_FOLLOW)); i_path->calculate(x, y, z, forceDest); if (i_path->getPathType() & PATHFIND_NOPATH) - { return; } + { + return; + } D::_addUnitStateMove(owner); i_targetReached = false; @@ -101,10 +111,14 @@ template bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_diff) { if (!i_target.isValid() || !i_target->IsInWorld()) - { return false; } + { + return false; + } if (!owner.IsAlive()) - { return true; } + { + return true; + } if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) { @@ -122,7 +136,9 @@ bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_ if (owner.IsNonMeleeSpellCasted(false, false, true)) { if (!owner.IsStopped()) - { owner.StopMoving(); } + { + owner.StopMoving(); + } return true; } @@ -143,12 +159,16 @@ bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_ } if (m_speedChanged || targetMoved) - { _setTargetLocation(owner, targetMoved); } + { + _setTargetLocation(owner, targetMoved); + } if (owner.movespline->Finalized()) { if (i_angle == 0.f && !owner.HasInArc(0.01f, i_target.getTarget())) - { owner.SetInFront(i_target.getTarget()); } + { + owner.SetInFront(i_target.getTarget()); + } if (!i_targetReached) { @@ -170,7 +190,9 @@ bool TargetedMovementGeneratorMedium::RequiresNewPosition(T& owner, float { // More distance let have better performance, less distance let have more sensitive reaction at target move. if (owner.GetTypeId() == TYPEID_UNIT && ((Creature*)&owner)->CanFly()) - { return !i_target->IsWithinDist3d(x, y, z, this->GetDynamicTargetDistance(owner, true)); } + { + return !i_target->IsWithinDist3d(x, y, z, this->GetDynamicTargetDistance(owner, true)); + } else { return !i_target->IsWithinDist2d(x, y, this->GetDynamicTargetDistance(owner, true)); } } @@ -191,7 +213,9 @@ template void ChaseMovementGenerator::_reachTarget(T& owner) { if (owner.CanReachWithMeleeAttack(this->i_target.getTarget())) - { owner.Attack(this->i_target.getTarget(), true); } + { + owner.Attack(this->i_target.getTarget(), true); + } } template<> @@ -236,7 +260,9 @@ template float ChaseMovementGenerator::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const { if (!forRangeCheck) - { return this->i_offset + CHASE_DEFAULT_RANGE_FACTOR * this->i_target->GetCombatReach(&owner); } + { + return this->i_offset + CHASE_DEFAULT_RANGE_FACTOR * this->i_target->GetCombatReach(&owner); + } return CHASE_RECHASE_RANGE_FACTOR * this->i_target->GetCombatReach(&owner) - this->i_target->GetObjectBoundingRadius(); } @@ -270,7 +296,9 @@ void FollowMovementGenerator::_updateSpeed(Creature& u) { // pet only sync speed with owner if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid()) - { return; } + { + return; + } u.UpdateSpeed(MOVE_RUN, true); u.UpdateSpeed(MOVE_WALK, true); @@ -326,12 +354,16 @@ template float FollowMovementGenerator::GetDynamicTargetDistance(T& owner, bool forRangeCheck) const { if (!forRangeCheck) - { return this->i_offset + owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius(); } + { + return this->i_offset + owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius(); + } float allowed_dist = sWorld.getConfig(CONFIG_FLOAT_RATE_TARGET_POS_RECALCULATION_RANGE) - this->i_target->GetObjectBoundingRadius(); allowed_dist += FOLLOW_RECALCULATE_FACTOR * (owner.GetObjectBoundingRadius() + this->i_target->GetObjectBoundingRadius()); if (this->i_offset > FOLLOW_DIST_GAP_FOR_DIST_FACTOR) - { allowed_dist += FOLLOW_DIST_RECALCULATE_FACTOR * this->i_offset; } + { + allowed_dist += FOLLOW_DIST_RECALCULATE_FACTOR * this->i_offset; + } return allowed_dist; } diff --git a/src/game/MotionGenerators/WaypointMovementGenerator.cpp b/src/game/MotionGenerators/WaypointMovementGenerator.cpp index 30202d03c..a1a7887f9 100644 --- a/src/game/MotionGenerators/WaypointMovementGenerator.cpp +++ b/src/game/MotionGenerators/WaypointMovementGenerator.cpp @@ -65,7 +65,9 @@ void WaypointMovementGenerator::LoadPath(Creature& creature, int32 pat } if (i_path->empty()) - { return; } + { + return; + } // Initialize the i_currentNode to point to the first node i_currentNode = i_path->begin()->first; m_lastReachedWaypoint = 0; @@ -107,12 +109,16 @@ void WaypointMovementGenerator::Reset(Creature& creature) void WaypointMovementGenerator::OnArrived(Creature& creature) { if (!i_path || i_path->empty()) - { return; } + { + return; + } m_lastReachedWaypoint = i_currentNode; if (m_isArrivalDone) - { return; } + { + return; + } creature.clearUnitState(UNIT_STAT_ROAMING_MOVE); m_isArrivalDone = true; @@ -131,13 +137,19 @@ void WaypointMovementGenerator::OnArrived(Creature& creature) if (WaypointBehavior* behavior = node.behavior) { if (behavior->emote != 0) - { creature.HandleEmote(behavior->emote); } + { + creature.HandleEmote(behavior->emote); + } if (behavior->spell != 0) - { creature.CastSpell(&creature, behavior->spell, false); } + { + creature.CastSpell(&creature, behavior->spell, false); + } if (behavior->model1 != 0) - { creature.SetDisplayId(behavior->model1); } + { + creature.SetDisplayId(behavior->model1); + } if (behavior->textid[0]) { @@ -150,14 +162,18 @@ void WaypointMovementGenerator::OnArrived(Creature& creature) for (; i < MAX_WAYPOINT_TEXT; ++i) { if (!behavior->textid[i]) - { break; } + { + break; + } } textId = behavior->textid[urand(0, i - 1)]; } if (MangosStringLocale const* textData = sObjectMgr.GetMangosStringLocale(textId)) - { creature.MonsterText(textData, NULL); } + { + 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); } } @@ -179,13 +195,19 @@ void WaypointMovementGenerator::OnArrived(Creature& creature) void WaypointMovementGenerator::StartMove(Creature& creature) { if (!i_path || i_path->empty()) - { return; } + { + return; + } if (Stopped(creature)) - { return; } + { + return; + } if (!creature.IsAlive() || creature.hasUnitState(UNIT_STAT_NOT_MOVE)) - { return; } + { + return; + } WaypointPath::const_iterator currPoint = i_path->find(i_currentNode); MANGOS_ASSERT(currPoint != i_path->end()); @@ -193,7 +215,9 @@ void WaypointMovementGenerator::StartMove(Creature& creature) if (WaypointBehavior* behavior = currPoint->second.behavior) { if (behavior->model2 != 0) - { creature.SetDisplayId(behavior->model2); } + { + creature.SetDisplayId(behavior->model2); + } creature.SetUInt32Value(UNIT_NPC_EMOTESTATE, 0); } @@ -231,7 +255,9 @@ void WaypointMovementGenerator::StartMove(Creature& creature) init.MoveTo(nextNode.x, nextNode.y, nextNode.z, true); if (nextNode.orientation != 100 && nextNode.delay != 0) - { init.SetFacing(nextNode.orientation); } + { + init.SetFacing(nextNode.orientation); + } creature.SetWalk(!creature.hasUnitState(UNIT_STAT_RUNNING_STATE) && !creature.IsLevitating(), false); init.Launch(); } @@ -256,12 +282,16 @@ bool WaypointMovementGenerator::Update(Creature& creature, const uint3 if (Stopped(creature)) { if (CanMove(diff, creature)) - { StartMove(creature); } + { + StartMove(creature); + } } else { if (creature.IsStopped()) - { Stop(STOP_TIME_FOR_PLAYER); } + { + Stop(STOP_TIME_FOR_PLAYER); + } else if (creature.movespline->Finalized()) { OnArrived(creature); @@ -291,12 +321,16 @@ bool WaypointMovementGenerator::GetResetPosition(Creature&, float& x, { // prevent a crash at empty waypoint path. if (!i_path || i_path->empty()) - { return false; } + { + return false; + } WaypointPath::const_iterator lastPoint = i_path->find(m_lastReachedWaypoint); // Special case: Before the first waypoint is reached, m_lastReachedWaypoint is set to 0 (which may not be contained in i_path) if (!m_lastReachedWaypoint && lastPoint == i_path->end()) - { return false; } + { + return false; + } MANGOS_ASSERT(lastPoint != i_path->end()); @@ -369,14 +403,18 @@ bool WaypointMovementGenerator::SetNextWaypoint(uint32 pointId) uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const { if (i_currentNode >= i_path->size()) - { return i_path->size(); } + { + return i_path->size(); + } uint32 curMapId = (*i_path)[i_currentNode].mapid; for (uint32 i = i_currentNode; i < i_path->size(); ++i) { if ((*i_path)[i].mapid != curMapId) - { return i; } + { + return i; + } } return i_path->size(); @@ -400,7 +438,9 @@ void FlightPathMovementGenerator::Finalize(Player& player) { player.GetHostileRefManager().setOnlineOfflineState(true); if (player.pvpInfo.inHostileArea) - { player.CastSpell(&player, 2479, true); } + { + player.CastSpell(&player, 2479, true); + } // update z position to ground and orientation for landing point // this prevent cheating with landing point at lags @@ -448,7 +488,9 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff) { DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent); if (pointId == i_currentNode) - { break; } + { + break; + } i_currentNode += (uint32)departureEvent; departureEvent = !departureEvent; } @@ -461,7 +503,9 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff) void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() { if (i_path->empty()) - { return; } + { + return; + } uint32 map0 = (*i_path)[0].mapid; diff --git a/src/game/Object/AggressorAI.cpp b/src/game/Object/AggressorAI.cpp index 5bd4f0a55..6fca4eff0 100644 --- a/src/game/Object/AggressorAI.cpp +++ b/src/game/Object/AggressorAI.cpp @@ -34,7 +34,9 @@ int AggressorAI::Permissible(const Creature* creature) { // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight if (!creature->IsCivilian() && !creature->IsNeutralToAll()) - { return PERMIT_BASE_PROACTIVE; } + { + return PERMIT_BASE_PROACTIVE; + } return PERMIT_BASE_NO; } @@ -47,7 +49,9 @@ void AggressorAI::MoveInLineOfSight(Unit* u) { // Ignore Z for flying creatures if (!m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE) - { return; } + { + return; + } if (m_creature->CanInitiateAttack() && u->IsTargetableForAttack() && m_creature->IsHostileTo(u) && u->isInAccessablePlaceFor(m_creature)) @@ -111,7 +115,9 @@ void AggressorAI::EnterEvadeMode() // Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) - { m_creature->GetMotionMaster()->MoveTargetedHome(); } + { + m_creature->GetMotionMaster()->MoveTargetedHome(); + } } m_creature->DeleteThreatList(); @@ -124,7 +130,9 @@ void AggressorAI::UpdateAI(const uint32 /*diff*/) { // update i_victimGuid if m_creature->getVictim() !=0 and changed if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) - { return; } + { + return; + } i_victimGuid = m_creature->getVictim()->GetObjectGuid(); @@ -140,7 +148,9 @@ bool AggressorAI::IsVisible(Unit* pl) const void AggressorAI::AttackStart(Unit* u) { if (!u || !m_creature->CanAttackByItself()) - { return; } + { + return; + } if (m_creature->Attack(u, true)) { diff --git a/src/game/Object/AuctionHouseMgr.cpp b/src/game/Object/AuctionHouseMgr.cpp index ae22f729f..dff698432 100644 --- a/src/game/Object/AuctionHouseMgr.cpp +++ b/src/game/Object/AuctionHouseMgr.cpp @@ -62,7 +62,9 @@ AuctionHouseMgr::~AuctionHouseMgr() AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house) { if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - { return &mAuctions[AUCTION_HOUSE_NEUTRAL]; } + { + return &mAuctions[AUCTION_HOUSE_NEUTRAL]; + } // team have linked auction houses switch (GetAuctionHouseTeam(house)) @@ -84,7 +86,9 @@ uint64 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32 float min_deposit = float(sWorld.getConfig(CONFIG_UINT32_AUCTION_DEPOSIT_MIN)); if (deposit < min_deposit) - { deposit = min_deposit; } + { + deposit = min_deposit; + } return uint64(deposit * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_DEPOSIT)); } @@ -94,7 +98,9 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) { Item* pItem = GetAItem(auction->itemGuidLow); if (!pItem) - { return; } + { + return; + } ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder); Player* bidder = sObjectMgr.GetPlayer(bidder_guid); @@ -123,7 +129,9 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) if (bidder_security > SEC_PLAYER) // not do redundant DB requests { if (!sObjectMgr.GetPlayerNameByGUID(bidder_guid, bidder_name)) - { bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); } + { + bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); + } } } @@ -196,7 +204,9 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction) uint32 owner_accId = 0; if (!owner) - { owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); } + { + owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); + } // owner exist if (owner || owner_accId) @@ -245,7 +255,9 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction) uint32 owner_accId = 0; if (!owner) - { owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); } + { + owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); + } // owner exist if (owner || owner_accId) @@ -561,7 +573,9 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit) { Player* player = (Player*)unit; if (player->GetAuctionAccessMode() > 0) - { houseid = 7; } + { + houseid = 7; + } else { switch (((Player*)unit)->GetTeam()) @@ -630,7 +644,9 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, if (Aentry->bidder == player->GetGUIDLow()) { if (itr->second->BuildAuctionInfo(data)) - { ++count; } + { + ++count; + } ++totalcount; } } @@ -646,7 +662,9 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, if (Aentry->owner == player->GetGUIDLow()) { if (Aentry->BuildAuctionInfo(data)) - { ++count; } + { + ++count; + } ++totalcount; } } @@ -818,7 +836,9 @@ void WorldSession::BuildListAuctionItems(std::vector const& aucti continue; Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow); if (!item) - { continue; } + { + continue; + } if (isFull) { @@ -830,19 +850,29 @@ void WorldSession::BuildListAuctionItems(std::vector const& aucti ItemPrototype const* proto = item->GetProto(); if (itemClass != 0xffffffff && proto->Class != itemClass) - { continue; } + { + continue; + } if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass) - { continue; } + { + continue; + } if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType) - { continue; } + { + continue; + } if (quality != 0xffffffff && proto->Quality < quality) - { continue; } + { + continue; + } if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax))) - { continue; } + { + continue; + } if (usable != 0x00) { @@ -867,7 +897,9 @@ void WorldSession::BuildListAuctionItems(std::vector const& aucti sObjectMgr.GetItemLocaleStrings(proto->ItemId, loc_idx, &name); if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname)) - { continue; } + { + continue; + } if (count < 50 && totalcount >= listfrom) { @@ -942,7 +974,9 @@ AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHou AH->SaveToDB(); if (pl) - { pl->SaveInventoryAndGoldToDB(); } + { + pl->SaveInventoryAndGoldToDB(); + } CharacterDatabase.CommitTransaction(); @@ -993,7 +1027,9 @@ uint64 AuctionEntry::GetAuctionOutBid() const { uint64 outbid = (bid / 100) * 5; if (!outbid) - { outbid = 1; } + { + outbid = 1; + } return outbid; } @@ -1018,7 +1054,9 @@ void AuctionEntry::AuctionBidWinning(Player* newbidder) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("UPDATE auction SET itemguid = 0, moneyTime = '" UI64FMTD "', buyguid = '%u', lastbid = '" UI64FMTD "' WHERE id = '%u'", (uint64)moneyDeliveryTime, bidder, bid, Id); if (newbidder) - { newbidder->SaveInventoryAndGoldToDB(); } + { + newbidder->SaveInventoryAndGoldToDB(); + } CharacterDatabase.CommitTransaction(); sAuctionMgr.SendAuctionWonMail(this); @@ -1030,7 +1068,9 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/) // bid can't be greater buyout if (buyout && newbid > buyout) - { newbid = buyout; } + { + newbid = buyout; + } if (newbidder && newbidder->GetGUIDLow() == bidder) { @@ -1042,7 +1082,9 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/) newbidder->ModifyMoney(-int64(newbid)); if (bidder) // return money to old bidder if present - { WorldSession::SendAuctionOutbiddedMail(this); } + { + WorldSession::SendAuctionOutbiddedMail(this); + } } bidder = newbidder ? newbidder->GetGUIDLow() : 0; @@ -1057,7 +1099,9 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/) CharacterDatabase.BeginTransaction(); CharacterDatabase.PExecute("UPDATE auction SET buyguid = '%u', lastbid = '" UI64FMTD "' WHERE id = '%u'", bidder, bid, Id); if (newbidder) - { newbidder->SaveInventoryAndGoldToDB(); } + { + newbidder->SaveInventoryAndGoldToDB(); + } CharacterDatabase.CommitTransaction(); return true; } diff --git a/src/game/Object/Bag.cpp b/src/game/Object/Bag.cpp index 9886b4e65..bb7b2386b 100644 --- a/src/game/Object/Bag.cpp +++ b/src/game/Object/Bag.cpp @@ -49,14 +49,18 @@ void Bag::AddToWorld() for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) - { m_bagslot[i]->AddToWorld(); } + { + m_bagslot[i]->AddToWorld(); + } } void Bag::RemoveFromWorld() { for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) - { m_bagslot[i]->RemoveFromWorld(); } + { + m_bagslot[i]->RemoveFromWorld(); + } Item::RemoveFromWorld(); } @@ -66,7 +70,9 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner) ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid); if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE) - { return false; } + { + return false; + } Object::_Create(guidlow, 0, HIGHGUID_CONTAINER); @@ -101,7 +107,9 @@ void Bag::SaveToDB() bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid) { if (!Item::LoadFromDB(guidLow, fields, ownerGuid)) - { return false; } + { + return false; + } // cleanup bag content related item value fields (its will be filled correctly from `character_inventory`) for (int i = 0; i < MAX_BAG_SIZE; ++i) @@ -119,7 +127,9 @@ void Bag::DeleteFromDB() { for (int i = 0; i < MAX_BAG_SIZE; ++i) if (m_bagslot[i]) - { m_bagslot[i]->DeleteFromDB(); } + { + m_bagslot[i]->DeleteFromDB(); + } Item::DeleteFromDB(); } @@ -129,7 +139,9 @@ uint32 Bag::GetFreeSlots() const uint32 slots = 0; for (uint32 i = 0; i < GetBagSize(); ++i) if (!m_bagslot[i]) - { ++slots; } + { + ++slots; + } return slots; } @@ -139,7 +151,9 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/) MANGOS_ASSERT(slot < MAX_BAG_SIZE); if (m_bagslot[slot]) - { m_bagslot[slot]->SetContainer(NULL); } + { + m_bagslot[slot]->SetContainer(NULL); + } m_bagslot[slot] = NULL; SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid()); @@ -166,7 +180,9 @@ void Bag::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) cons for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) - { m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target); } + { + m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target); + } } // If the bag is empty returns true @@ -174,7 +190,9 @@ bool Bag::IsEmpty() const { for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) - { return false; } + { + return false; + } return true; } @@ -183,7 +201,9 @@ Item* Bag::GetItemByEntry(uint32 item) const { for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i] && m_bagslot[i]->GetEntry() == item) - { return m_bagslot[i]; } + { + return m_bagslot[i]; + } return NULL; } @@ -204,7 +224,9 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i]) if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item) - { count += m_bagslot[i]->GetCount(); } + { + count += m_bagslot[i]->GetCount(); + } if (eItem && eItem->GetProto()->GemProperties) for (uint32 i = 0; i < GetBagSize(); ++i) @@ -232,7 +254,9 @@ uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const for (uint32 i = 0; i < GetBagSize(); ++i) if (m_bagslot[i] != 0) if (m_bagslot[i]->GetObjectGuid() == guid) - { return i; } + { + return i; + } return NULL_SLOT; } @@ -240,7 +264,9 @@ uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const Item* Bag::GetItemByPos(uint8 slot) const { if (slot < GetBagSize()) - { return m_bagslot[slot]; } + { + return m_bagslot[slot]; + } return NULL; } diff --git a/src/game/Object/Bag.h b/src/game/Object/Bag.h index 7430d10f7..efecf55cf 100644 --- a/src/game/Object/Bag.h +++ b/src/game/Object/Bag.h @@ -78,7 +78,9 @@ class Bag : public Item inline Item* NewItemOrBag(ItemPrototype const* proto) { if (proto->InventoryType == INVTYPE_BAG) - { return new Bag; } + { + return new Bag; + } return new Item; } diff --git a/src/game/Object/Camera.cpp b/src/game/Object/Camera.cpp index 227c5057d..2986def21 100644 --- a/src/game/Object/Camera.cpp +++ b/src/game/Object/Camera.cpp @@ -53,7 +53,9 @@ void Camera::UpdateForCurrentViewPoint() m_gridRef.unlink(); if (GridType* grid = m_source->GetViewPoint().m_grid) - { grid->AddWorldObject(this); } + { + grid->AddWorldObject(this); + } UpdateVisibilityForOwner(); } @@ -63,7 +65,9 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/) MANGOS_ASSERT(obj); if (m_source == obj) - { return; } + { + return; + } if (!m_owner.IsInMap(obj)) { @@ -80,17 +84,23 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/) // detach and deregister from active objects if there are no more reasons to be active m_source->GetViewPoint().Detach(this); if (!m_source->IsActiveObject()) - { m_source->GetMap()->RemoveFromActive(m_source); } + { + m_source->GetMap()->RemoveFromActive(m_source); + } m_source = obj; if (!m_source->IsActiveObject()) - { m_source->GetMap()->AddToActive(m_source); } + { + m_source->GetMap()->AddToActive(m_source); + } m_source->GetViewPoint().Attach(this); if (update_far_sight_field) - { m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid())); } + { + m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid())); + } UpdateForCurrentViewPoint(); } @@ -98,7 +108,9 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/) void Camera::Event_ViewPointVisibilityChanged() { if (!m_owner.HaveAtClient(m_source)) - { ResetView(); } + { + ResetView(); + } } void Camera::ResetView(bool update_far_sight_field /*= true*/) diff --git a/src/game/Object/Corpse.cpp b/src/game/Object/Corpse.cpp index 4afdc1d4f..f84f1b0eb 100644 --- a/src/game/Object/Corpse.cpp +++ b/src/game/Object/Corpse.cpp @@ -55,7 +55,9 @@ void Corpse::AddToWorld() { ///- Register the corpse for guid lookup if (!IsInWorld()) - { sObjectAccessor.AddObject(this); } + { + sObjectAccessor.AddObject(this); + } Object::AddToWorld(); } @@ -64,7 +66,9 @@ void Corpse::RemoveFromWorld() { ///- Remove the corpse from the accessor if (IsInWorld()) - { sObjectAccessor.RemoveObject(this); } + { + sObjectAccessor.RemoveObject(this); + } Object::RemoveFromWorld(); } @@ -232,9 +236,13 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields) uint32 flags = CORPSE_FLAG_UNK2; if (playerFlags & PLAYER_FLAGS_HIDE_HELM) - { flags |= CORPSE_FLAG_HIDE_HELM; } + { + flags |= CORPSE_FLAG_HIDE_HELM; + } if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK) - { flags |= CORPSE_FLAG_HIDE_CLOAK; } + { + flags |= CORPSE_FLAG_HIDE_CLOAK; + } SetUInt32Value(CORPSE_FIELD_FLAGS, flags); // no need to mark corpse as lootable, because corpses are not saved in battle grounds @@ -265,7 +273,9 @@ bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool Corpse::IsHostileTo(Unit const* unit) const { if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid())) - { return owner->IsHostileTo(unit); } + { + return owner->IsHostileTo(unit); + } else { return false; } } @@ -273,7 +283,9 @@ bool Corpse::IsHostileTo(Unit const* unit) const bool Corpse::IsFriendlyTo(Unit const* unit) const { if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid())) - { return owner->IsFriendlyTo(unit); } + { + return owner->IsFriendlyTo(unit); + } else { return true; } } @@ -281,7 +293,9 @@ bool Corpse::IsFriendlyTo(Unit const* unit) const bool Corpse::IsExpired(time_t t) const { if (m_type == CORPSE_BONES) - { return m_time < t - 60 * MINUTE; } + { + return m_time < t - 60 * MINUTE; + } else { return m_time < t - 3 * DAY; } } diff --git a/src/game/Object/Creature.cpp b/src/game/Object/Creature.cpp index 48bd5082d..d81b2ffeb 100644 --- a/src/game/Object/Creature.cpp +++ b/src/game/Object/Creature.cpp @@ -69,7 +69,9 @@ TrainerSpell const* TrainerSpellData::Find(uint32 spell_id) const { TrainerSpellMap::const_iterator itr = spellList.find(spell_id); if (itr != spellList.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -116,7 +118,9 @@ VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint8 type, u { // Skip checking for conditions, condition system is powerfull enough to not require additional entries only for the conditions if ((*i)->item == item_id && (*i)->ExtendedCost == extendedCost && (*i)->type == type) - { return *i; } + { + return *i; + } } return NULL; } @@ -201,13 +205,17 @@ void Creature::AddToWorld() ///- Register the creature for guid lookup if (!IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) - { GetMap()->GetObjectsStore().insert(GetObjectGuid(), (Creature*)this); } + { + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (Creature*)this); + } Unit::AddToWorld(); // Make active if required if (sWorld.isForceLoadMap(GetMapId()) || (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_ACTIVE)) - { SetActiveObjectState(true); } + { + SetActiveObjectState(true); + } #ifdef ENABLE_ELUNA if (!inWorld) @@ -224,7 +232,9 @@ void Creature::RemoveFromWorld() ///- Remove the creature from the accessor if (IsInWorld() && GetObjectGuid().IsCreatureOrVehicle()) - { GetMap()->GetObjectsStore().erase(GetObjectGuid(), (Creature*)NULL); } + { + GetMap()->GetObjectsStore().erase(GetObjectGuid(), (Creature*)NULL); + } Unit::RemoveFromWorld(); } @@ -233,13 +243,19 @@ void Creature::RemoveCorpse() { // since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless if (uint16 poolid = sPoolMgr.IsPartOfAPool(GetGUIDLow())) - { sPoolMgr.UpdatePool(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); } + { + sPoolMgr.UpdatePool(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); + } if (!IsInWorld()) // can be despawned by update pool - { return; } + { + return; + } if ((getDeathState() != CORPSE && !m_IsDeadByDefault) || (getDeathState() != ALIVE && m_IsDeadByDefault)) - { return; } + { + return; + } DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Removing corpse of %s ", GetGuidStr().c_str()); @@ -254,17 +270,23 @@ void Creature::RemoveCorpse() uint32 respawnDelay = 0; if (AI()) - { AI()->CorpseRemoved(respawnDelay); } + { + AI()->CorpseRemoved(respawnDelay); + } if (m_isCreatureLinkingTrigger) GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DESPAWN, this); if (InstanceData* mapInstance = GetInstanceData()) - { mapInstance->OnCreatureDespawn(this); } + { + mapInstance->OnCreatureDespawn(this); + } // script can set time (in seconds) explicit, override the original if (respawnDelay) - { m_respawnTime = time(NULL) + respawnDelay; } + { + m_respawnTime = time(NULL) + respawnDelay; + } float x, y, z, o; GetRespawnCoord(x, y, z, &o); @@ -285,7 +307,9 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE { // use game event entry if any instead default suggested if (eventData && eventData->entry_id) - { Entry = eventData->entry_id; } + { + Entry = eventData->entry_id; + } CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(Entry); if (!normalInfo) @@ -407,7 +431,9 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=NULL*/, GameE bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*=NULL*/, GameEventCreatureData const* eventData /*=NULL*/, bool preserveHPAndPower /*=true*/) { if (!InitEntry(Entry, data, eventData)) - { return false; } + { + return false; + } // creatures always have melee weapon ready if any SetSheath(SHEATH_STATE_MELEE); @@ -511,7 +537,9 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo* cinfo, const CreatureData* // Use creature model explicit, override template (creature.modelid) if (data && data->modelid_override) - { return data->modelid_override; } + { + return data->modelid_override; + } // use defaults from the template uint32 display_id = 0; @@ -555,7 +583,9 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo* cinfo, const CreatureData* sLog.outErrorDb("Call customer support, ChooseDisplayId can not select native model for creature entry %u, model from creature entry 1 will be used instead.", cinfo->Entry); if (const CreatureInfo* creatureDefault = ObjectMgr::GetCreatureTemplate(1)) - { display_id = creatureDefault->ModelId[0]; } + { + display_id = creatureDefault->ModelId[0]; + } } return display_id; @@ -612,10 +642,14 @@ void Creature::Update(uint32 update_diff, uint32 diff) // Call AI respawn virtual function if (AI()) - { AI()->JustRespawned(); } + { + AI()->JustRespawned(); + } if (m_isCreatureLinkingTrigger) - { GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, this); } + { + GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, this); + } GetMap()->Add(this); } @@ -626,7 +660,9 @@ void Creature::Update(uint32 update_diff, uint32 diff) Unit::Update(update_diff, diff); if (m_IsDeadByDefault) - { break; } + { + break; + } if (m_corpseDecayTimer <= update_diff) { @@ -639,7 +675,9 @@ void Creature::Update(uint32 update_diff, uint32 diff) if (m_groupLootId) // Loot is stopped already if corpse got removed. { if (m_groupLootTimer <= update_diff) - { StopGroupLoot(); } + { + StopGroupLoot(); + } else { m_groupLootTimer -= update_diff; } } @@ -669,7 +707,9 @@ void Creature::Update(uint32 update_diff, uint32 diff) // creature can be dead after Unit::Update call // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) if (!IsAlive()) - { break; } + { + break; + } if (!IsInEvadeMode()) { @@ -685,7 +725,9 @@ void Creature::Update(uint32 update_diff, uint32 diff) // creature can be dead after UpdateAI call // CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly) if (!IsAlive()) - { break; } + { + break; + } RegenerateAll(update_diff); break; } @@ -703,10 +745,14 @@ void Creature::StartGroupLoot(Group* group, uint32 timer) void Creature::StopGroupLoot() { if (!m_groupLootId) - { return; } + { + return; + } if (Group* group = sObjectMgr.GetGroupById(m_groupLootId)) - { group->EndRoll(); } + { + group->EndRoll(); + } m_groupLootTimer = 0; m_groupLootId = 0; @@ -717,15 +763,21 @@ void Creature::RegenerateAll(uint32 update_diff) if (m_regenTimer > 0) { if (update_diff >= m_regenTimer) - { m_regenTimer = 0; } + { + m_regenTimer = 0; + } else { m_regenTimer -= update_diff; } } if (m_regenTimer != 0) - { return; } + { + return; + } if (!IsInCombat() || IsPolymorphed()) - { RegenerateHealth(); } + { + RegenerateHealth(); + } RegeneratePower(); @@ -742,7 +794,9 @@ void Creature::RegeneratePower() uint32 maxValue = GetMaxPower(powerType); if (curValue >= maxValue) - { return; } + { + return; + } float addValue = 0.0f; @@ -798,13 +852,17 @@ void Creature::RegeneratePower() void Creature::RegenerateHealth() { if (!IsRegeneratingHealth()) - { return; } + { + return; + } uint32 curValue = GetHealth(); uint32 maxValue = GetMaxHealth(); if (curValue >= maxValue) - { return; } + { + return; + } uint32 addvalue = 0; @@ -815,7 +873,9 @@ void Creature::RegenerateHealth() float Spirit = GetStat(STAT_SPIRIT); if (GetPower(POWER_MANA) > 0) - { addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); } + { + addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); + } else { addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); } } @@ -828,7 +888,9 @@ void Creature::RegenerateHealth() void Creature::DoFleeToGetAssistance() { if (!getVictim()) - { return; } + { + return; + } float radius = sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS); if (radius > 0) @@ -843,7 +905,9 @@ void Creature::DoFleeToGetAssistance() UpdateSpeed(MOVE_RUN, false); if (!pCreature) - { SetFeared(true, getVictim()->GetObjectGuid(), 0 , sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_FLEE_DELAY)); } + { + SetFeared(true, getVictim()->GetObjectGuid(), 0 , sWorld.getConfig(CONFIG_UINT32_CREATURE_FAMILY_FLEE_DELAY)); + } else { GetMotionMaster()->MoveSeekAssistance(pCreature->GetPositionX(), pCreature->GetPositionY(), pCreature->GetPositionZ()); @@ -876,22 +940,30 @@ bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo cons SetPhaseMask(cPos.GetPhaseMask(), false); if (!CreateFromProto(guidlow, cinfo, team, data, eventData)) - { return false; } + { + return false; + } cPos.SelectFinalPoint(this); if (!cPos.Relocate(this)) - { return false; } + { + return false; + } // Notify the outdoor pvp script if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) - { outdoorPvP->HandleCreatureCreate(this); } + { + outdoorPvP->HandleCreatureCreate(this); + } // Notify the map's instance data. // Only works if you create the object in it, not if it is moves to that map. // Normally non-players do not teleport to other maps. if (InstanceData* iData = GetMap()->GetInstanceData()) - { iData->OnCreatureCreate(this); } + { + iData->OnCreatureCreate(this); + } switch (GetCreatureInfo()->Rank) { @@ -914,7 +986,9 @@ bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo cons // Add to CreatureLinkingHolder if needed if (sCreatureLinkingMgr.GetLinkedTriggerInformation(this)) - { cPos.GetMap()->GetCreatureLinkingHolder()->AddSlaveToHolder(this); } + { + cPos.GetMap()->GetCreatureLinkingHolder()->AddSlaveToHolder(this); + } if (sCreatureLinkingMgr.IsLinkedEventTrigger(this)) { m_isCreatureLinkingTrigger = true; @@ -929,7 +1003,9 @@ bool Creature::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo cons bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const { if (!IsTrainer()) - { return false; } + { + return false; + } // pet trainers not have spells in fact now if (GetCreatureInfo()->TrainerType != TRAINER_TYPE_PETS) @@ -988,7 +1064,9 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const if (FactionTemplateEntry const* faction_template = getFactionTemplateEntry()) { if (pPlayer->GetReputationRank(faction_template->faction) == REP_EXALTED) - { return true; } + { + return true; + } } if (msg) @@ -1031,14 +1109,20 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const bool Creature::CanInteractWithBattleMaster(Player* pPlayer, bool msg) const { if (!IsBattleMaster()) - { return false; } + { + return false; + } BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry()); if (bgTypeId == BATTLEGROUND_TYPE_NONE) - { return false; } + { + return false; + } if (!msg) - { return pPlayer->GetBGAccessByLevel(bgTypeId); } + { + return pPlayer->GetBGAccessByLevel(bgTypeId); + } if (!pPlayer->GetBGAccessByLevel(bgTypeId)) { @@ -1135,18 +1219,24 @@ Player* Creature::GetLootRecipient() const // if group not set or disbanded return original recipient player if any if (!group) - { return player; } + { + return player; + } // group case // return player if it still be in original recipient group if (player && player->GetGroup() == group) - { return player; } + { + return player; + } // find any in group for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) if (Player* p = itr->getSource()) - { return p; } + { + return p; + } return NULL; } @@ -1171,14 +1261,18 @@ void Creature::SetLootRecipient(Unit* unit) Player* player = unit->GetCharmerOrOwnerPlayerOrPlayerItself(); if (!player) // normal creature, no player involved - { return; } + { + return; + } // set player for non group case or if group will disbanded m_lootRecipientGuid = player->GetObjectGuid(); // set group for group existing case including if player will leave group at loot time if (Group* group = player->GetGroup()) - { m_lootGroupRecipientId = group->GetId(); } + { + m_lootGroupRecipientId = group->GetId(); + } SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED); SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED_BY_PLAYER); @@ -1219,7 +1313,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) if (cinfo->ModelId[i]) if (CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelInfo(cinfo->ModelId[i])) if (displayId == minfo->modelid_other_gender) - { displayId = 0; } + { + displayId = 0; + } } else { displayId = 0; } @@ -1455,7 +1551,9 @@ void Creature::SelectLevel(const CreatureInfo* cinfo, float percentHealth /*= 10 SetMaxHealth(health); if (percentHealth == 100.0f) - { SetHealth(health); } + { + SetHealth(health); + } else { SetHealthPercent(percentHealth); } @@ -1570,7 +1668,9 @@ bool Creature::CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team t Object::_Create(guidlow, cinfo->Entry, cinfo->GetHighGuid()); if (!UpdateEntry(cinfo->Entry, team, data, eventData, false)) - { return false; } + { + return false; + } return true; } @@ -1596,12 +1696,16 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map) // Creature can be loaded already in map if grid has been unloaded while creature walk to another grid if (map->GetCreature(cinfo->GetObjectGuid(guidlow))) - { return false; } + { + return false; + } CreatureCreatePos pos(map, data->posX, data->posY, data->posZ, data->orientation, data->phaseMask); if (!Create(guidlow, pos, cinfo, TEAM_NONE, data, eventData)) - { return false; } + { + return false; + } SetRespawnCoord(pos); m_respawnradius = data->spawndist; @@ -1620,7 +1724,9 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map) { float tz = GetTerrain()->GetHeightStatic(data->posX, data->posY, data->posZ, false); if (data->posZ - tz > 0.1) - { Relocate(data->posX, data->posY, tz); } + { + Relocate(data->posX, data->posY, tz); + } } } else if (m_respawnTime) // respawn time set but expired @@ -1635,7 +1741,9 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map) { curhealth = uint32(curhealth * _GetHealthMod(GetCreatureInfo()->Rank)); if (curhealth < 1) - { curhealth = 1; } + { + curhealth = 1; + } } if (sCreatureLinkingMgr.IsSpawnedByLinkedMob(this)) @@ -1650,7 +1758,9 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map) { float tz = GetTerrain()->GetHeightStatic(data->posX, data->posY, data->posZ, false); if (data->posZ - tz > 0.1) - { Relocate(data->posX, data->posY, tz); } + { + Relocate(data->posX, data->posY, tz); + } } } } @@ -1667,7 +1777,9 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map) // Creature Linking, Initial load is handled like respawn if (m_isCreatureLinkingTrigger && IsAlive()) - { GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, this); } + { + GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, this); + } // check if it is rabbit day if (IsAlive() && sWorld.getConfig(CONFIG_UINT32_RABBIT_DAY)) @@ -1677,7 +1789,9 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map) tm now_tm = *localtime(&sWorld.GetGameTime()); if (now_tm.tm_mon == rabbit_day_tm.tm_mon && now_tm.tm_mday == rabbit_day_tm.tm_mday) - { CastSpell(this, 10710 + urand(0, 2), true); } + { + CastSpell(this, 10710 + urand(0, 2), true); + } } return true; @@ -1711,7 +1825,9 @@ bool Creature::HasQuest(uint32 quest_id) const for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (itr->second == quest_id) - { return true; } + { + return true; + } } return false; } @@ -1722,7 +1838,9 @@ bool Creature::HasInvolvedQuest(uint32 quest_id) const for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (itr->second == quest_id) - { return true; } + { + return true; + } } return false; } @@ -1774,7 +1892,9 @@ float Creature::GetAttackDistance(Unit const* pl) const { float aggroRate = sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); if (aggroRate == 0) - { return 0.0f; } + { + return 0.0f; + } uint32 playerlevel = pl->GetLevelForTarget(this); uint32 creaturelevel = GetLevelForTarget(pl); @@ -1783,7 +1903,9 @@ float Creature::GetAttackDistance(Unit const* pl) const // "The maximum Aggro Radius has a cap of 25 levels under. Example: A level 30 char has the same Aggro Radius of a level 5 char on a level 60 mob." if (leveldif < - 25) - { leveldif = -25; } + { + leveldif = -25; + } // "The aggro radius of a mob having the same level as the player is roughly 20 yards" float RetDistance = 20; @@ -1803,7 +1925,9 @@ float Creature::GetAttackDistance(Unit const* pl) const // "Minimum Aggro Radius for a mob seems to be combat range (5 yards)" if (RetDistance < 5) - { RetDistance = 5; } + { + RetDistance = 5; + } return (RetDistance * aggroRate); } @@ -1817,7 +1941,9 @@ void Creature::SetDeathState(DeathState s) // always save boss respawn time at death to prevent crash cheating if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY) || IsWorldBoss()) - { SaveRespawnTime(); } + { + SaveRespawnTime(); + } } Unit::SetDeathState(s); @@ -1834,7 +1960,9 @@ void Creature::SetDeathState(DeathState s) } if (CanFly()) - { i_motionMaster.MoveFall(); } + { + i_motionMaster.MoveFall(); + } Unit::SetDeathState(CORPSE); } @@ -1848,7 +1976,9 @@ void Creature::SetDeathState(DeathState s) SetHealth(GetMaxHealth()); SetLootRecipient(NULL); if (GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_RESPAWN) - { ClearTemporaryFaction(); } + { + ClearTemporaryFaction(); + } SetMeleeDamageSchool(SpellSchools(GetCreatureInfo()->DamageSchool)); @@ -1870,14 +2000,18 @@ void Creature::SetDeathState(DeathState s) void Creature::Respawn() { if (!IsInWorld()) // Could be removed as part of a pool (in which case respawn-time is handled with pool-system) - { return; } + { + return; + } RemoveCorpse(); if (IsDespawned()) { if (HasStaticDBSpawnData()) - { GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), 0); } + { + GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), 0); + } m_respawnTime = time(NULL); // respawn at next tick } } @@ -1893,10 +2027,14 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn) } if (IsDespawned()) - { return; } + { + return; + } if (IsAlive()) - { SetDeathState(JUST_DIED); } + { + SetDeathState(JUST_DIED); + } RemoveCorpse(); @@ -1906,10 +2044,14 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn) bool Creature::IsImmuneToSpell(SpellEntry const* spellInfo, bool castOnSelf) { if (!spellInfo) - { return false; } + { + return false; + } if (!castOnSelf && GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->GetMechanic() - 1))) - { return true; } + { + return true; + } return Unit::IsImmuneToSpell(spellInfo, castOnSelf); } @@ -1921,7 +2063,9 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd return false; if (!castOnSelf && GetCreatureInfo()->MechanicImmuneMask & (1 << (spellEffect->EffectMechanic - 1))) - { return true; } + { + return true; + } // Taunt immunity special flag check if (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_NOT_TAUNTABLE) @@ -1930,7 +2074,9 @@ bool Creature::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectInd if (spellEffect->Effect == SPELL_EFFECT_APPLY_AURA) { if (spellEffect->EffectApplyAuraName == SPELL_AURA_MOD_TAUNT) - { return true; } + { + return true; + } } // Spell effect taunt check else if (spellEffect->Effect == SPELL_EFFECT_ATTACK_ME) @@ -1994,12 +2140,16 @@ bool Creature::IsTappedBy(Player* plr) const SpellEntry const* Creature::ReachWithSpellAttack(Unit* pVictim) { if (!pVictim) - { return NULL; } + { + return NULL; + } for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) { if (!m_spells[i]) - { continue; } + { + continue; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]); if (!spellInfo) { @@ -2026,7 +2176,9 @@ SpellEntry const* Creature::ReachWithSpellAttack(Unit* pVictim) if (bcontinue) { continue; } if(spellInfo->GetManaCost() > GetPower(POWER_MANA)) - { continue; } + { + continue; + } SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); float range = GetSpellMaxRange(srange); float minrange = GetSpellMinRange(srange); @@ -2036,11 +2188,17 @@ SpellEntry const* Creature::ReachWithSpellAttack(Unit* pVictim) // if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) // continue; if (dist > range || dist < minrange) - { continue; } + { + continue; + } if(spellInfo->GetPreventionType() == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - { continue; } + { + continue; + } if(spellInfo->GetPreventionType() == SPELL_PREVENTION_TYPE_PACIFY && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) - { continue; } + { + continue; + } return spellInfo; } return NULL; @@ -2049,12 +2207,16 @@ SpellEntry const* Creature::ReachWithSpellAttack(Unit* pVictim) SpellEntry const* Creature::ReachWithSpellCure(Unit* pVictim) { if (!pVictim) - { return NULL; } + { + return NULL; + } for (uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) { if (!m_spells[i]) - { continue; } + { + continue; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(m_spells[i]); if (!spellInfo) { @@ -2073,10 +2235,14 @@ SpellEntry const* Creature::ReachWithSpellCure(Unit* pVictim) } } if (bcontinue) - { continue; } + { + continue; + } if(spellInfo->GetManaCost() > GetPower(POWER_MANA)) - { continue; } + { + continue; + } SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(spellInfo->rangeIndex); float range = GetSpellMaxRange(srange); float minrange = GetSpellMinRange(srange); @@ -2086,11 +2252,17 @@ SpellEntry const* Creature::ReachWithSpellCure(Unit* pVictim) // if(!isInFront( pVictim, range ) && spellInfo->AttributesEx ) // continue; if (dist > range || dist < minrange) - { continue; } + { + continue; + } if(spellInfo->GetPreventionType() == SPELL_PREVENTION_TYPE_SILENCE && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - { continue; } + { + continue; + } if(spellInfo->GetPreventionType() == SPELL_PREVENTION_TYPE_PACIFY && HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) - { continue; } + { + continue; + } return spellInfo; } return NULL; @@ -2100,10 +2272,14 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const { // gamemaster in GM mode see all, including ghosts if (pl->isGameMaster()) - { return true; } + { + return true; + } if (GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_INVISIBLE) - { return false; } + { + return false; + } // Live player (or with not release body see live creatures or death creatures with corpse disappearing time > 0 if (pl->IsAlive() || pl->GetDeathTimer() > 0) @@ -2119,13 +2295,17 @@ bool Creature::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; } + { + return true; + } } } // Dead player can see ghosts if (GetCreatureInfo()->CreatureTypeFlags & CREATURE_TYPEFLAGS_GHOST_VISIBLE) - { return true; } + { + return true; + } // and not see any other return false; @@ -2160,7 +2340,9 @@ void Creature::CallAssistance() void Creature::CallForHelp(float fRadius) { if (fRadius <= 0.0f || !getVictim() || IsPet() || IsCharmed()) - { return; } + { + return; + } MaNGOS::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius); MaNGOS::CreatureWorker worker(this, u_do); @@ -2172,38 +2354,54 @@ bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction / { // we don't need help from zombies :) if (!IsAlive()) - { return false; } + { + return false; + } // we don't need help from non-combatant ;) if (IsCivilian()) - { return false; } + { + return false; + } if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PASSIVE)) - { return false; } + { + return false; + } // skip fighting creature if (enemy && IsInCombat()) - { return false; } + { + return false; + } // only free creature if (GetCharmerOrOwnerGuid()) - { return false; } + { + return false; + } // only from same creature faction if (checkfaction) { if (getFaction() != u->getFaction()) - { return false; } + { + return false; + } } else { if (!IsFriendlyTo(u)) - { return false; } + { + return false; + } } // skip non hostile to caster enemy creatures if (enemy && !IsHostileTo(enemy)) - { return false; } + { + return false; + } return true; } @@ -2241,10 +2439,14 @@ bool Creature::CanInitiateAttack() void Creature::SaveRespawnTime() { if (IsPet() || !HasStaticDBSpawnData()) - { return; } + { + return; + } if (m_respawnTime > time(NULL)) // dead (no corpse) - { GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), m_respawnTime); } + { + GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), m_respawnTime); + } else if (m_corpseDecayTimer > 0) // dead (corpse) GetMap()->GetPersistentState()->SaveCreatureRespawnTime(GetGUIDLow(), time(NULL) + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS); } @@ -2252,22 +2454,34 @@ void Creature::SaveRespawnTime() bool Creature::IsOutOfThreatArea(Unit* pVictim) const { if (!pVictim) - { return true; } + { + return true; + } if (!pVictim->IsInMap(this)) - { return true; } + { + return true; + } if (!pVictim->IsTargetableForAttack()) - { return true; } + { + return true; + } if (!pVictim->isInAccessablePlaceFor(this)) - { return true; } + { + return true; + } if (!pVictim->IsVisibleForOrDetect(this, this, false)) - { return true; } + { + return true; + } if (sMapStore.LookupEntry(GetMapId())->IsDungeon()) - { return false; } + { + return false; + } float AttackDist = GetAttackDistance(pVictim); float ThreatRadius = sWorld.getConfig(CONFIG_FLOAT_THREAT_RADIUS); @@ -2281,7 +2495,9 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const { if (!(GetObjectGuid().GetHigh() == HIGHGUID_PET)) // pets have guidlow that is conflicting with normal guidlows hence GetGUIDLow() gives wrong info if (CreatureDataAddon const* addon = ObjectMgr::GetCreatureAddon(GetGUIDLow())) - { return addon; } + { + return addon; + } // dependent from difficulty mode entry if (GetEntry() != GetCreatureInfo()->Entry) @@ -2300,10 +2516,14 @@ bool Creature::LoadCreatureAddon(bool reload) { CreatureDataAddon const* cainfo = GetCreatureAddon(); if (!cainfo) - { return false; } + { + return false; + } if (cainfo->mount != 0) - { Mount(cainfo->mount); } + { + Mount(cainfo->mount); + } if (cainfo->bytes1 != 0) { @@ -2333,7 +2553,9 @@ bool Creature::LoadCreatureAddon(bool reload) // SetByteValue(UNIT_FIELD_BYTES_2, 3, 0); if (cainfo->emote != 0) - { SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote); } + { + SetUInt32Value(UNIT_NPC_EMOTESTATE, cainfo->emote); + } if (cainfo->splineFlags & SPLINEFLAG_FLYING) SetLevitate(true); @@ -2345,7 +2567,9 @@ bool Creature::LoadCreatureAddon(bool reload) if (HasAuraOfDifficulty(*cAura)) { if (!reload) - { sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u) has spell %u in `auras` field, but aura is already applied.", GetGUIDLow(), GetEntry(), *cAura); } + { + sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u) has spell %u in `auras` field, but aura is already applied.", GetGUIDLow(), GetEntry(), *cAura); + } continue; } @@ -2388,14 +2612,18 @@ void Creature::SetInCombatWithZone() Map::PlayerList const& PlList = pMap->GetPlayers(); if (PlList.isEmpty()) - { return; } + { + return; + } for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) { if (Player* pPlayer = i->getSource()) { if (pPlayer->isGameMaster()) - { continue; } + { + continue; + } if (pPlayer->IsAlive() && !IsFriendlyTo(pPlayer)) { @@ -2409,10 +2637,14 @@ void Creature::SetInCombatWithZone() bool Creature::MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* pSpellInfo, uint32 selectFlags) const { if (selectFlags & SELECT_FLAG_PLAYER && pTarget->GetTypeId() != TYPEID_PLAYER) - { return false; } + { + return false; + } if (selectFlags & SELECT_FLAG_POWER_MANA && pTarget->GetPowerType() != POWER_MANA) - { return false; } + { + return false; + } else if (selectFlags & SELECT_FLAG_POWER_RAGE && pTarget->GetPowerType() != POWER_RAGE) { return false; } else if (selectFlags & SELECT_FLAG_POWER_ENERGY && pTarget->GetPowerType() != POWER_ENERGY) @@ -2421,12 +2653,18 @@ bool Creature::MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* { return false; } if (selectFlags & SELECT_FLAG_IN_MELEE_RANGE && !CanReachWithMeleeAttack(pTarget)) - { return false; } + { + return false; + } if (selectFlags & SELECT_FLAG_NOT_IN_MELEE_RANGE && CanReachWithMeleeAttack(pTarget)) - { return false; } + { + return false; + } if (selectFlags & SELECT_FLAG_IN_LOS && !IsWithinLOSInMap(pTarget)) - { return false; } + { + return false; + } if (pSpellInfo) { @@ -2456,7 +2694,9 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, u Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, SpellEntry const* pSpellInfo /*= NULL*/, uint32 selectFlags/*= 0*/) const { if (!CanHaveThreatList()) - { return NULL; } + { + return NULL; + } // ThreatList m_threatlist; ThreatList const& threatlist = GetThreatManager().getThreatList(); @@ -2464,7 +2704,9 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, S ThreatList::const_reverse_iterator ritr = threatlist.rbegin(); if (position >= threatlist.size() || !threatlist.size()) - { return NULL; } + { + return NULL; + } switch (target) { @@ -2476,10 +2718,14 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, S for (; itr != threatlist.end(); ++itr) if (Unit* pTarget = GetMap()->GetUnit((*itr)->getUnitGuid())) if (!selectFlags || MeetsSelectAttackingRequirement(pTarget, pSpellInfo, selectFlags)) - { suitableUnits.push_back(pTarget); } + { + suitableUnits.push_back(pTarget); + } if (!suitableUnits.empty()) - { return suitableUnits[urand(0, suitableUnits.size() - 1)]; } + { + return suitableUnits[urand(0, suitableUnits.size() - 1)]; + } break; } @@ -2489,7 +2735,9 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, S for (; itr != threatlist.end(); ++itr) if (Unit* pTarget = GetMap()->GetUnit((*itr)->getUnitGuid())) if (!selectFlags || MeetsSelectAttackingRequirement(pTarget, pSpellInfo, selectFlags)) - { return pTarget; } + { + return pTarget; + } break; } @@ -2499,7 +2747,9 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, S for (; ritr != threatlist.rend(); ++ritr) if (Unit* pTarget = GetMap()->GetUnit((*itr)->getUnitGuid())) if (!selectFlags || MeetsSelectAttackingRequirement(pTarget, pSpellInfo, selectFlags)) - { return pTarget; } + { + return pTarget; + } break; } @@ -2522,11 +2772,15 @@ void Creature::AddCreatureSpellCooldown(uint32 spellid) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); if (!spellInfo) - { return; } + { + return; + } uint32 cooldown = GetSpellRecoveryTime(spellInfo); if (cooldown) - { _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown / IN_MILLISECONDS); } + { + _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown / IN_MILLISECONDS); + } if(uint32 category = spellInfo->GetCategory()) _AddCreatureCategoryCooldown(category, time(NULL)); @@ -2573,7 +2827,9 @@ bool Creature::HasSpell(uint32 spellID) const uint8 i; for (i = 0; i < CREATURE_MAX_SPELLS; ++i) if (spellID == m_spells[i]) - { break; } + { + break; + } return i < CREATURE_MAX_SPELLS; // break before end of iteration of known spells } @@ -2581,7 +2837,9 @@ time_t Creature::GetRespawnTimeEx() const { time_t now = time(NULL); if (m_respawnTime > now) // dead (no corpse) - { return m_respawnTime; } + { + return m_respawnTime; + } else if (m_corpseDecayTimer > 0) // dead (corpse) return now + m_respawnDelay + m_corpseDecayTimer / IN_MILLISECONDS; else @@ -2595,10 +2853,14 @@ void Creature::GetRespawnCoord(float& x, float& y, float& z, float* ori, float* z = m_respawnPos.z; if (ori) - { *ori = m_respawnPos.o; } + { + *ori = m_respawnPos.o; + } if (dist) - { *dist = GetRespawnRadius(); } + { + *dist = GetRespawnRadius(); + } // lets check if our creatures have valid spawn coordinates MANGOS_ASSERT(MaNGOS::IsValidMapCoord(x, y, z) || PrintCoordinatesError(x, y, z, "respawn")); @@ -2667,13 +2929,19 @@ void Creature::AllLootRemovedFromCorpse() uint32 Creature::GetLevelForTarget(Unit const* target) const { if (!IsWorldBoss()) - { return Unit::GetLevelForTarget(target); } + { + return Unit::GetLevelForTarget(target); + } uint32 level = target->getLevel() + sWorld.getConfig(CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF); if (level < 1) - { return 1; } + { + return 1; + } if (level > 255) - { return 255; } + { + return 255; + } return level; } @@ -2707,15 +2975,21 @@ VendorItemData const* Creature::GetVendorTemplateItems() const uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) { if (!vItem->maxcount) - { return vItem->maxcount; } + { + return vItem->maxcount; + } VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); for (; itr != m_vendorItemCounts.end(); ++itr) if (itr->itemId == vItem->item) - { break; } + { + break; + } if (itr == m_vendorItemCounts.end()) - { return vItem->maxcount; } + { + return vItem->maxcount; + } VendorItemCount* vCount = &*itr; @@ -2742,12 +3016,16 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 used_count) { if (!vItem->maxcount) - { return 0; } + { + return 0; + } VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); for (; itr != m_vendorItemCounts.end(); ++itr) if (itr->itemId == vItem->item) - { break; } + { + break; + } if (itr == m_vendorItemCounts.end()) { @@ -2766,7 +3044,9 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime); if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount) - { vCount->count += diff * pProto->BuyCount; } + { + vCount->count += diff * pProto->BuyCount; + } else { vCount->count = vItem->maxcount; } } @@ -2801,15 +3081,25 @@ void Creature::SetFactionTemporary(uint32 factionId, uint32 tempFactionFlags) setFaction(factionId); if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NON_ATTACKABLE) - { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_OOC_NOT_ATTACK) - { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); } + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PASSIVE) - { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); } + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PACIFIED) - { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); } + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NOT_SELECTABLE) - { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } } void Creature::ClearTemporaryFaction() @@ -2818,21 +3108,33 @@ void Creature::ClearTemporaryFaction() // For later we may consider extend to restore to charmer faction where charmer is creature. // This can also be done by update any pet/charmed of creature at any faction change to charmer. if (IsCharmed()) - { return; } + { + return; + } // Reset to original faction setFaction(GetCreatureInfo()->FactionAlliance); // Reset UNIT_FLAG_NON_ATTACKABLE, UNIT_FLAG_OOC_NOT_ATTACKABLE, UNIT_FLAG_PASSIVE, UNIT_FLAG_PACIFIED or UNIT_FLAG_NOT_SELECTABLE flags if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NON_ATTACKABLE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_NON_ATTACKABLE) - { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_OOC_NOT_ATTACK && GetCreatureInfo()->UnitFlags & UNIT_FLAG_OOC_NOT_ATTACKABLE && !IsInCombat()) - { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); } + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PASSIVE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_PASSIVE) - { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); } + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_PACIFIED && GetCreatureInfo()->UnitFlags & UNIT_FLAG_PACIFIED) - { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); } + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); + } if (m_temporaryFactionFlags & TEMPFACTION_TOGGLE_NOT_SELECTABLE && GetCreatureInfo()->UnitFlags & UNIT_FLAG_NOT_SELECTABLE) - { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); } + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); + } m_temporaryFactionFlags = TEMPFACTION_NONE; } @@ -2841,7 +3143,9 @@ void Creature::SendAreaSpiritHealerQueryOpcode(Player* pl) { uint32 next_resurrect = 0; if (Spell* pcurSpell = GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - { next_resurrect = pcurSpell->GetCastedTime(); } + { + next_resurrect = pcurSpell->GetCastedTime(); + } WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 8 + 4); data << ObjectGuid(GetObjectGuid()); data << uint32(next_resurrect); @@ -2856,16 +3160,22 @@ void Creature::ApplyGameEventSpells(GameEventCreatureData const* eventData, bool if (remove_spell) if (SpellEntry const* spellEntry = sSpellStore.LookupEntry(remove_spell)) if (IsSpellAppliesAura(spellEntry)) - { RemoveAurasDueToSpell(remove_spell); } + { + RemoveAurasDueToSpell(remove_spell); + } if (cast_spell) - { CastSpell(this, cast_spell, true); } + { + CastSpell(this, cast_spell, true); + } } void Creature::FillGuidsListFromThreatList(GuidVector& guids, uint32 maxamount /*= 0*/) { if (!CanHaveThreatList()) - { return; } + { + return; + } ThreatList const& threats = GetThreatManager().getThreatList(); @@ -2884,7 +3194,9 @@ struct AddCreatureToRemoveListInMapsWorker void operator()(Map* map) { if (Creature* pCreature = map->GetCreature(i_guid)) - { pCreature->AddObjectToRemoveList(); } + { + pCreature->AddObjectToRemoveList(); + } } ObjectGuid i_guid; @@ -2939,17 +3251,23 @@ void Creature::SetWalk(bool enable, bool asDefault) if (asDefault) { if (enable) - { clearUnitState(UNIT_STAT_RUNNING); } + { + clearUnitState(UNIT_STAT_RUNNING); + } else { addUnitState(UNIT_STAT_RUNNING); } } // Nothing changed? if (enable == m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE)) - { return; } + { + return; + } if (enable) - { m_movementInfo.AddMovementFlag(MOVEFLAG_WALK_MODE); } + { + m_movementInfo.AddMovementFlag(MOVEFLAG_WALK_MODE); + } else { m_movementInfo.RemoveMovementFlag(MOVEFLAG_WALK_MODE); } @@ -2974,7 +3292,9 @@ void Creature::SetWalk(bool enable, bool asDefault) void Creature::SetLevitate(bool enable) { if (enable) - { m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING); } + { + m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING); + } else { m_movementInfo.RemoveMovementFlag(MOVEFLAG_LEVITATING); } @@ -3047,7 +3367,9 @@ void Creature::SetHover(bool enable) void Creature::SetRoot(bool enable) { if (enable) - { m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT); } + { + m_movementInfo.AddMovementFlag(MOVEFLAG_ROOT); + } else { m_movementInfo.RemoveMovementFlag(MOVEFLAG_ROOT); } diff --git a/src/game/Object/Creature.h b/src/game/Object/Creature.h index 07e2566f3..cff7b2077 100644 --- a/src/game/Object/Creature.h +++ b/src/game/Object/Creature.h @@ -166,7 +166,9 @@ struct CreatureInfo SkillType GetRequiredLootSkill() const { if (CreatureTypeFlags & CREATURE_TYPEFLAGS_HERBLOOT) - { return SKILL_HERBALISM; } + { + return SKILL_HERBALISM; + } else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT) { return SKILL_MINING; } else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT) @@ -565,7 +567,9 @@ class Creature : public Unit bool IsElite() const { if (IsPet()) - { return false; } + { + return false; + } uint32 Rank = GetCreatureInfo()->Rank; return Rank != CREATURE_ELITE_NORMAL && Rank != CREATURE_ELITE_RARE; @@ -574,7 +578,9 @@ class Creature : public Unit bool IsWorldBoss() const { if (IsPet()) - { return false; } + { + return false; + } return GetCreatureInfo()->Rank == CREATURE_ELITE_WORLDBOSS; } @@ -785,7 +791,9 @@ class Creature : public Unit virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const { if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED) - { return 0; } + { + return 0; + } else { return m_charmInfo->GetCharmSpell(pos)->GetAction(); } } diff --git a/src/game/Object/CreatureAI.cpp b/src/game/Object/CreatureAI.cpp index 50a41db52..3a1dd8d3a 100644 --- a/src/game/Object/CreatureAI.cpp +++ b/src/game/Object/CreatureAI.cpp @@ -40,7 +40,9 @@ CreatureAI::~CreatureAI() void CreatureAI::AttackedBy(Unit* attacker) { if (!m_creature->getVictim()) - { AttackStart(attacker); } + { + AttackStart(attacker); + } } CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, bool isTriggered) @@ -50,17 +52,25 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, { // State does not allow if (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL)) - { return CAST_FAIL_STATE; } + { + return CAST_FAIL_STATE; + } if (pSpell->GetPreventionType() == SPELL_PREVENTION_TYPE_SILENCE && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) - { return CAST_FAIL_STATE; } + { + return CAST_FAIL_STATE; + } if (pSpell->GetPreventionType() == SPELL_PREVENTION_TYPE_PACIFY && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) - { return CAST_FAIL_STATE; } + { + return CAST_FAIL_STATE; + } // Check for power (also done by Spell::CheckCast()) if (m_creature->GetPower((Powers)pSpell->powerType) < Spell::CalculatePowerCost(pSpell, m_creature)) - { return CAST_FAIL_POWER; } + { + return CAST_FAIL_POWER; + } if (!pSpell->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !m_creature->IsWithinLOSInMap(pTarget) && m_creature != pTarget) return CAST_FAIL_NOT_IN_LOS; @@ -74,12 +84,16 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, float fDistance = m_creature->GetCombatDistance(pTarget, pSpell->rangeIndex == SPELL_RANGE_IDX_COMBAT); if (fDistance > (m_creature->IsHostileTo(pTarget) ? pSpellRange->maxRange : pSpellRange->maxRangeFriendly)) - { return CAST_FAIL_TOO_FAR; } + { + return CAST_FAIL_TOO_FAR; + } float fMinRange = m_creature->IsHostileTo(pTarget) ? pSpellRange->minRange : pSpellRange->minRangeFriendly; if (fMinRange && fDistance < fMinRange) - { return CAST_FAIL_TOO_CLOSE; } + { + return CAST_FAIL_TOO_CLOSE; + } } return CAST_OK; @@ -93,7 +107,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 Unit* pCaster = m_creature; if (uiCastFlags & CAST_FORCE_TARGET_SELF) - { pCaster = pTarget; } + { + pCaster = pTarget; + } // Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered if (!pCaster->IsNonMeleeSpellCasted(false) || (uiCastFlags & (CAST_TRIGGERED | CAST_INTERRUPT_PREVIOUS))) @@ -104,7 +120,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 if (uiCastFlags & CAST_AURA_NOT_PRESENT) { if (pTarget->HasAura(uiSpell)) - { return CAST_FAIL_TARGET_AURA; } + { + return CAST_FAIL_TARGET_AURA; + } } // Check if can not cast spell @@ -120,7 +138,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 // Interrupt any previous spell if ((uiCastFlags & CAST_INTERRUPT_PREVIOUS) && pCaster->IsNonMeleeSpellCasted(false)) - { pCaster->InterruptNonMeleeSpells(false); } + { + pCaster->InterruptNonMeleeSpells(false); + } // Creature should always stop before it will cast a non-instant spell if (GetSpellCastTime(pSpell)) @@ -155,14 +175,18 @@ void CreatureAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=fals m_isCombatMovement = enable; if (enable) - { m_creature->clearUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); } + { + m_creature->clearUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); + } else { m_creature->addUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); } if (stopOrStartMovement && m_creature->getVictim()) // Only change current movement while in combat { if (enable) - { m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle); } + { + m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle); + } else if (!enable && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) { m_creature->StopMoving(); } } diff --git a/src/game/Object/CreatureAISelector.cpp b/src/game/Object/CreatureAISelector.cpp index 18bf6b4d6..175d21e84 100644 --- a/src/game/Object/CreatureAISelector.cpp +++ b/src/game/Object/CreatureAISelector.cpp @@ -48,7 +48,9 @@ namespace FactorySelector // Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets) if (!creature->IsPet() || !static_cast(creature)->isControlled()) - { return scriptedAI; } + { + return scriptedAI; + } } CreatureAIRegistry& ai_registry(CreatureAIRepository::Instance()); @@ -64,17 +66,23 @@ namespace FactorySelector { Unit* controler = creature->GetOwner() ? creature->GetOwner() : creature->GetCharmer(); if (controler && controler->GetTypeId() == TYPEID_PLAYER && controler->IsAlive()) - { ai_factory = ai_registry.GetRegistryItem("PetAI"); } + { + ai_factory = ai_registry.GetRegistryItem("PetAI"); + } } else if (creature->IsTotem()) { ai_factory = ai_registry.GetRegistryItem("TotemAI"); } // select by script name if (!ai_factory && !ainame.empty()) - { ai_factory = ai_registry.GetRegistryItem(ainame.c_str()); } + { + ai_factory = ai_registry.GetRegistryItem(ainame.c_str()); + } if (!ai_factory && creature->IsGuard()) - { ai_factory = ai_registry.GetRegistryItem("GuardAI"); } + { + ai_factory = ai_registry.GetRegistryItem("GuardAI"); + } // select by permit check if (!ai_factory) diff --git a/src/game/Object/CreatureEventAI.cpp b/src/game/Object/CreatureEventAI.cpp index c1ceaadcf..00a5595af 100644 --- a/src/game/Object/CreatureEventAI.cpp +++ b/src/game/Object/CreatureEventAI.cpp @@ -40,7 +40,9 @@ bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatMin, uint32 repeatMax) { if (repeatMin == repeatMax) - { Time = repeatMin; } + { + Time = repeatMin; + } else if (repeatMax > repeatMin) { Time = urand(repeatMin, repeatMax); } else @@ -56,7 +58,9 @@ bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatM int CreatureEventAI::Permissible(const Creature* creature) { if (creature->GetAIName() == "EventAI") - { return PERMIT_BASE_SPECIAL; } + { + return PERMIT_BASE_SPECIAL; + } return PERMIT_BASE_NO; } @@ -67,13 +71,17 @@ void CreatureEventAI::GetAIInformation(ChatHandler& reader) reader.PSendSysMessage(LANG_NPC_EVENTAI_COMBAT, reader.GetOnOffStr(m_MeleeEnabled)); if (sLog.HasLogFilter(LOG_FILTER_EVENT_AI_DEV)) // Give some more details if in EventAI Dev Mode - { return; } + { + return; + } reader.PSendSysMessage("Current events of this creature:"); for (CreatureEventAIList::const_iterator itr = m_CreatureEventAIList.begin(); itr != m_CreatureEventAIList.end(); ++itr) { if (itr->Event.action[2].type != ACTION_T_NONE) - { 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); } + { + 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); } else @@ -104,7 +112,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c), { uint32 events_count = 0; - const CreatureEventAI_Event_Vec& creatureEvent = creatureEventsItr->second; + const CreatureEventAI_Event_Vec &creatureEvent = creatureEventsItr->second; for (CreatureEventAI_Event_Vec::const_iterator i = creatureEvent.begin(); i != creatureEvent.end(); ++i) { // Debug check @@ -126,7 +134,9 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c), } // EventMap had events but they were not added because they must be for instance if (events_count == 0) - { sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags (spawned in map %u, difficulty %u).", m_creature->GetEntry(), m_creature->GetMapId(), m_creature->GetMap()->GetDifficulty()); } + { + sLog.outErrorEventAI("Creature %u has events but no events added to list because of instance flags (spawned in map %u, difficulty %u).", m_creature->GetEntry(), m_creature->GetMapId(), m_creature->GetMap()->GetDifficulty()); + } else { m_CreatureEventAIList.reserve(events_count); @@ -135,13 +145,17 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c), // Debug check #ifndef MANGOS_DEBUG if (i->event_flags & EFLAG_DEBUG_ONLY) - { continue; } + { + continue; + } #endif bool storeEvent = false; if (m_creature->GetMap()->IsDungeon()) { if ((1 << (m_creature->GetMap()->GetSpawnMode() + 1)) & i->event_flags) - { storeEvent = true; } + { + storeEvent = true; + } } else if (IsEventFlagsFitForNormalMap(i->event_flags)) { storeEvent = true; } @@ -195,18 +209,24 @@ inline bool IsTimerBasedEvent(EventAI_Type type) bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker, Creature* pAIEventSender /*=NULL*/) { if (!pHolder.Enabled || pHolder.Time) - { return false; } + { + return false; + } // Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask) if (pHolder.Event.event_inverse_phase_mask & (1 << m_Phase)) { if (!IsTimerBasedEvent(pHolder.Event.event_type)) - { DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Event %u skipped because of phasemask %u. Current phase %u", pHolder.Event.event_id, pHolder.Event.event_inverse_phase_mask, m_Phase); } + { + DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Event %u skipped because of phasemask %u. Current phase %u", pHolder.Event.event_id, pHolder.Event.event_inverse_phase_mask, m_Phase); + } return false; } if (!IsTimerBasedEvent(pHolder.Event.event_type)) - { LOG_PROCESS_EVENT; } + { + LOG_PROCESS_EVENT; + } CreatureEventAI_Event const& event = pHolder.Event; @@ -215,7 +235,9 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction { case EVENT_T_TIMER_IN_COMBAT: if (!m_creature->IsInCombat()) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -223,7 +245,9 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction break; case EVENT_T_TIMER_OOC: if (m_creature->IsInCombat() || m_creature->IsInEvadeMode()) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -237,12 +261,16 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_HP: { if (!m_creature->IsInCombat() || !m_creature->GetMaxHealth()) - { return false; } + { + return false; + } uint32 perc = (m_creature->GetHealth() * 100) / m_creature->GetMaxHealth(); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -252,12 +280,16 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_MANA: { if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_MANA)) - { return false; } + { + return false; + } uint32 perc = (m_creature->GetPower(POWER_MANA) * 100) / m_creature->GetMaxPower(POWER_MANA); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -299,12 +331,16 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_TARGET_HP: { if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth()) - { return false; } + { + return false; + } uint32 perc = (m_creature->getVictim()->GetHealth() * 100) / m_creature->getVictim()->GetMaxHealth(); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -313,7 +349,9 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction } case EVENT_T_TARGET_CASTING: if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->IsNonMeleeSpellCasted(false, false, true)) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -322,11 +360,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_FRIENDLY_HP: { if (!m_creature->IsInCombat()) - { return false; } + { + return false; + } Unit* pUnit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit); if (!pUnit) - { return false; } + { + return false; + } pActionInvoker = pUnit; @@ -338,14 +380,18 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_FRIENDLY_IS_CC: { if (!m_creature->IsInCombat()) - { return false; } + { + return false; + } std::list pList; DoFindFriendlyCC(pList, (float)event.friendly_is_cc.radius); // List is empty if (pList.empty()) - { return false; } + { + return false; + } // We don't really care about the whole list, just return first available pActionInvoker = *(pList.begin()); @@ -362,7 +408,9 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction // List is empty if (pList.empty()) - { return false; } + { + return false; + } // We don't really care about the whole list, just return first available pActionInvoker = *(pList.begin()); @@ -377,11 +425,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction { // Prevent event from occuring on no unit or non creatures if (!pActionInvoker || pActionInvoker->GetTypeId() != TYPEID_UNIT) - { return false; } + { + return false; + } // Creature id doesn't match up if (((Creature*)pActionInvoker)->GetEntry() != event.summoned.creatureId) - { return false; } + { + return false; + } // Repeat Timers pHolder.UpdateRepeatTimer(m_creature, event.summoned.repeatMin, event.summoned.repeatMax); @@ -390,12 +442,16 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_TARGET_MANA: { if (!m_creature->IsInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA)) - { return false; } + { + return false; + } uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA) * 100) / m_creature->getVictim()->GetMaxPower(POWER_MANA); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - { return false; } + { + return false; + } // Repeat Timers pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax); @@ -407,11 +463,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_AURA: { if (!m_creature->IsInCombat()) - { return false; } + { + return false; + } SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId); if (!holder || holder->GetStackAmount() < event.buffed.amount) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -421,11 +481,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_TARGET_AURA: { if (!m_creature->IsInCombat() || !m_creature->getVictim()) - { return false; } + { + return false; + } SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId); if (!holder || holder->GetStackAmount() < event.buffed.amount) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -435,11 +499,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_MISSING_AURA: { if (!m_creature->IsInCombat()) - { return false; } + { + return false; + } SpellAuraHolder* holder = m_creature->GetSpellAuraHolder(event.buffed.spellId); if (holder && holder->GetStackAmount() >= event.buffed.amount) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -449,11 +517,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_TARGET_MISSING_AURA: { if (!m_creature->IsInCombat() || !m_creature->getVictim()) - { return false; } + { + return false; + } SpellAuraHolder* holder = m_creature->getVictim()->GetSpellAuraHolder(event.buffed.spellId); if (holder && holder->GetStackAmount() >= event.buffed.amount) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -465,12 +537,16 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_ENERGY: { if (!m_creature->IsInCombat() || !m_creature->GetMaxPower(POWER_ENERGY)) - { return false; } + { + return false; + } uint32 perc = (m_creature->GetPower(POWER_ENERGY) * 100) / m_creature->GetMaxPower(POWER_ENERGY); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) - { return false; } + { + return false; + } LOG_PROCESS_EVENT; // Repeat Timers @@ -484,14 +560,18 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction // Disable non-repeatable events if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE)) - { pHolder.Enabled = false; } + { + pHolder.Enabled = false; + } // Store random here so that all random actions match up uint32 rnd = rand(); // Return if chance for event is not met if (pHolder.Event.event_chance <= rnd % 100) - { return false; } + { + return false; + } // Process actions, normal case if (!(pHolder.Event.event_flags & EFLAG_RANDOM_ACTION)) @@ -506,7 +586,9 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction uint32 count = 0; for (uint32 j = 0; j < MAX_ACTIONS; ++j) if (pHolder.Event.action[j].type != ACTION_T_NONE) - { ++count; } + { + ++count; + } if (count) { @@ -520,7 +602,9 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (pHolder.Event.action[j].type != ACTION_T_NONE) { if (!idx) - { break; } + { + break; + } --idx; } } @@ -534,7 +618,9 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker, Creature* pAIEventSender) { if (action.type == ACTION_T_NONE) //0 - { return; } + { + return; + } DEBUG_FILTER_LOG(LOG_FILTER_EVENT_AI_DEV, "CreatureEventAI: Process action %u (script %u) triggered for %s (invoked by %s)", action.type, EventId, m_creature->GetGuidStr().c_str(), pActionInvoker ? pActionInvoker->GetGuidStr().c_str() : ""); @@ -546,14 +632,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_CHANCED_TEXT: //44 { if (!action.text.TextId[0]) - { return; } + { + return; + } int32 textId = 0; if (action.type == ACTION_T_TEXT) { if (action.text.TextId[1] && action.text.TextId[2]) - { textId = action.text.TextId[rnd % 3]; } + { + textId = action.text.TextId[rnd % 3]; + } else if (action.text.TextId[1] && (rnd % 2)) { textId = action.text.TextId[1]; } else @@ -563,7 +653,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 else if ((rnd % 100) < action.chanced_text.chance) { if (action.chanced_text.TextId[0] && action.chanced_text.TextId[1]) - { textId = action.chanced_text.TextId[rnd % 2]; } + { + textId = action.chanced_text.TextId[rnd % 2]; + } else { textId = action.chanced_text.TextId[0]; } } @@ -575,11 +667,15 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (pActionInvoker) { if (pActionInvoker->GetTypeId() == TYPEID_PLAYER) - { target = pActionInvoker; } + { + target = pActionInvoker; + } else if (Unit* owner = pActionInvoker->GetOwner()) { if (owner->GetTypeId() == TYPEID_PLAYER) - { target = owner; } + { + target = owner; + } } } else if ((target = m_creature->getVictim())) @@ -587,18 +683,24 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (target->GetTypeId() != TYPEID_PLAYER) if (Unit* owner = target->GetOwner()) if (owner->GetTypeId() == TYPEID_PLAYER) - { target = owner; } + { + target = owner; + } } if (!DoDisplayText(m_creature, textId, target)) - { sLog.outErrorEventAI("Error attempting to display text %i, used by script %u", textId, EventId); } + { + sLog.outErrorEventAI("Error attempting to display text %i, used by script %u", textId, EventId); + } } break; } case ACTION_T_SET_FACTION: //2 { if (action.set_faction.factionId) - { m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); } + { + m_creature->SetFactionTemporary(action.set_faction.factionId, action.set_faction.factionFlags); + } else // no id provided, assume reset and then use default { m_creature->ClearTemporaryFaction(); } @@ -635,14 +737,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { int32 temp = GetRandActionParam(rnd, action.random_sound.soundId1, action.random_sound.soundId2, action.random_sound.soundId3); if (temp >= 0) - { m_creature->PlayDirectSound(temp); } + { + m_creature->PlayDirectSound(temp); + } break; } case ACTION_T_RANDOM_EMOTE: //10 { int32 temp = GetRandActionParam(rnd, action.random_emote.emoteId1, action.random_emote.emoteId2, action.random_emote.emoteId3); if (temp >= 0) - { m_creature->HandleEmote(temp); } + { + m_creature->HandleEmote(temp); + } break; } case ACTION_T_CAST: //11 @@ -660,7 +766,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (!target) { if (reportTargetError) - { sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId); } + { + sLog.outErrorEventAI("NULL target for ACTION_T_CAST creature entry %u casting spell id %u", m_creature->GetEntry(), action.cast.spellId); + } return; } @@ -723,24 +831,32 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { Unit* target = GetTargetByType(action.summon.target, pActionInvoker, pAIEventSender, reportTargetError); if (!target && reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON(%u), target-type %u", EventId, action.type, action.summon.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON(%u), target-type %u", EventId, action.type, action.summon.target); + } Creature* pCreature = NULL; if (action.summon.duration) - { pCreature = m_creature->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN, action.summon.duration); } + { + 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); } if (!pCreature) - { sLog.outErrorEventAI("failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, m_creature->GetEntry()); } + { + 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); } break; } case ACTION_T_THREAT_SINGLE_PCT: //13 if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker, pAIEventSender, reportTargetError)) - { m_creature->GetThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); } + { + 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); } break; @@ -749,14 +865,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 ThreatList const& threatList = m_creature->GetThreatManager().getThreatList(); for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i) if (Unit* Temp = m_creature->GetMap()->GetUnit((*i)->getUnitGuid())) - { m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); } + { + m_creature->GetThreatManager().modifyThreatPercent(Temp, action.threat_all_pct.percent); + } break; } case ACTION_T_QUEST_EVENT: //15 if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker, pAIEventSender, reportTargetError)) { if (target->GetTypeId() == TYPEID_PLAYER) - { ((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId); } + { + ((Player*)target)->AreaExploredOrEventHappens(action.quest_event.questId); + } } 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); } @@ -765,7 +885,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER)) { if (target->GetTypeId() == TYPEID_PLAYER) - { ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId); } + { + ((Player*)target)->CastedCreatureOrGO(action.cast_event.creatureId, m_creature->GetObjectGuid(), action.cast_event.spellId); + } } 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); } @@ -776,7 +898,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 // not allow modify important for integrity object fields if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) - { return; } + { + return; + } 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); } @@ -785,13 +909,17 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } case ACTION_T_SET_UNIT_FLAG: //18 if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError)) - { target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); } + { + 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); } break; case ACTION_T_REMOVE_UNIT_FLAG: //19 if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker, pAIEventSender, reportTargetError)) - { target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); } + { + 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); } case ACTION_T_AUTO_ATTACK: //20 @@ -800,12 +928,16 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_COMBAT_MOVEMENT: //21 // ignore no affect case if (m_isCombatMovement == (action.combat_movement.state != 0) || m_creature->IsNonMeleeSpellCasted(false)) - { return; } + { + return; + } SetCombatMovement(action.combat_movement.state != 0, true); if (m_isCombatMovement && action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim()) - { m_creature->SendMeleeAttackStart(m_creature->getVictim()); } + { + m_creature->SendMeleeAttackStart(m_creature->getVictim()); + } else if (action.combat_movement.melee && m_creature->IsInCombat() && m_creature->getVictim()) { m_creature->SendMeleeAttackStop(m_creature->getVictim()); } break; @@ -854,12 +986,16 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 ThreatList const& threatList = m_creature->GetThreatManager().getThreatList(); for (ThreatList::const_iterator i = threatList.begin(); i != threatList.end(); ++i) if (Player* temp = m_creature->GetMap()->GetPlayer((*i)->getUnitGuid())) - { temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); } + { + temp->CastedCreatureOrGO(action.cast_event_all.creatureId, m_creature->GetObjectGuid(), action.cast_event_all.spellId); + } break; } case ACTION_T_REMOVEAURASFROMSPELL: //28 if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker, pAIEventSender, reportTargetError)) - { target->RemoveAurasDueToSpell(action.remove_aura.spellId); } + { + 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); } break; @@ -883,7 +1019,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_RANDOM_PHASE_RANGE: //31 if (action.random_phase_range.phaseMax > action.random_phase_range.phaseMin) - { m_Phase = action.random_phase_range.phaseMin + (rnd % (action.random_phase_range.phaseMax - action.random_phase_range.phaseMin)); } + { + 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()); } break; @@ -891,7 +1029,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker, pAIEventSender, reportTargetError); if (!target && reportTargetError) - { sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON_ID(%u), target-type %u", EventId, action.type, action.summon_id.target); } + { + sLog.outErrorEventAI("Event %u - NULL target for ACTION_T_SUMMON_ID(%u), target-type %u", EventId, action.type, action.summon_id.target); + } CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr.GetCreatureEventAISummonMap().find(action.summon_id.spawnId); if (i == sEventAIMgr.GetCreatureEventAISummonMap().end()) @@ -902,12 +1042,16 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 Creature* pCreature = NULL; if ((*i).second.SpawnTimeSecs) - { 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); } + { + 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); } if (!pCreature) - { sLog.outErrorEventAI("failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, m_creature->GetEntry()); } + { + 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); } @@ -916,14 +1060,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_KILLED_MONSTER: //33 // first attempt player/group who tapped creature if (Player* pPlayer = m_creature->GetLootRecipient()) - { pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); } + { + pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); + } else { // if not available, use pActionInvoker if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker, pAIEventSender, reportTargetError, 0, SELECT_FLAG_PLAYER)) { if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) - { pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); } + { + pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, m_creature); + } } 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); } @@ -947,7 +1095,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (!target) { if (reportTargetError) - { sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); } + { + sLog.outErrorEventAI("Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, m_creature->GetEntry()); + } return; } @@ -1001,7 +1151,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: //42 { if (action.invincibility_hp_level.is_percent) - { m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; } + { + m_InvinceabilityHpLevel = m_creature->GetMaxHealth() * action.invincibility_hp_level.hp_level / 100; + } else { m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level; } break; @@ -1084,7 +1236,9 @@ void CreatureEventAI::JustRespawned() // NOTE that this is if (i->Event.event_type == EVENT_T_TIMER_GENERIC) { if (i->UpdateRepeatTimer(m_creature, i->Event.timer.initialMin, i->Event.timer.initialMax)) - { i->Enabled = true; } + { + i->Enabled = true; + } } // Handle Spawned Events else if (SpawnedEventConditionsCheck((*i).Event)) @@ -1125,7 +1279,9 @@ void CreatureEventAI::JustReachedHome() for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if (i->Event.event_type == EVENT_T_REACHED_HOME) - { ProcessEvent(*i); } + { + ProcessEvent(*i); + } } Reset(); @@ -1139,7 +1295,9 @@ void CreatureEventAI::EnterEvadeMode() // only alive creatures that are not on transport can return to home position if (m_creature->IsAlive() && !m_creature->IsBoarded()) - { m_creature->GetMotionMaster()->MoveTargetedHome(); } + { + m_creature->GetMotionMaster()->MoveTargetedHome(); + } m_creature->SetLootRecipient(NULL); @@ -1147,7 +1305,9 @@ void CreatureEventAI::EnterEvadeMode() for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if (i->Event.event_type == EVENT_T_EVADE) - { ProcessEvent(*i); } + { + ProcessEvent(*i); + } } } @@ -1159,17 +1319,23 @@ void CreatureEventAI::JustDied(Unit* killer) { // Send Zone Under Attack message to the LocalDefense and WorldDefense Channels if (Player* pKiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) - { m_creature->SendZoneUnderAttackMessage(pKiller); } + { + m_creature->SendZoneUnderAttackMessage(pKiller); + } } if (m_throwAIEventMask & (1 << AI_EVENT_JUST_DIED)) - { SendAIEventAround(AI_EVENT_JUST_DIED, killer, 0, AIEVENT_DEFAULT_THROW_RADIUS); } + { + SendAIEventAround(AI_EVENT_JUST_DIED, killer, 0, AIEVENT_DEFAULT_THROW_RADIUS); + } // Handle On Death events for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if (i->Event.event_type == EVENT_T_DEATH) - { ProcessEvent(*i, killer); } + { + ProcessEvent(*i, killer); + } } // reset phase after any death state events @@ -1179,12 +1345,16 @@ void CreatureEventAI::JustDied(Unit* killer) void CreatureEventAI::KilledUnit(Unit* victim) { if (victim->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if (i->Event.event_type == EVENT_T_KILL) - { ProcessEvent(*i, victim); } + { + ProcessEvent(*i, victim); + } } } @@ -1193,7 +1363,9 @@ void CreatureEventAI::JustSummoned(Creature* pUnit) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if (i->Event.event_type == EVENT_T_SUMMONED_UNIT) - { ProcessEvent(*i, pUnit); } + { + ProcessEvent(*i, pUnit); + } } } @@ -1202,7 +1374,9 @@ void CreatureEventAI::SummonedCreatureJustDied(Creature* pUnit) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DIED) - { ProcessEvent(*i, pUnit); } + { + ProcessEvent(*i, pUnit); + } } } @@ -1211,7 +1385,9 @@ void CreatureEventAI::SummonedCreatureDespawn(Creature* pUnit) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if (i->Event.event_type == EVENT_T_SUMMONED_JUST_DESPAWN) - { ProcessEvent(*i, pUnit); } + { + ProcessEvent(*i, pUnit); + } } } @@ -1242,7 +1418,9 @@ void CreatureEventAI::EnterCombat(Unit* enemy) // Reset all in combat timers case EVENT_T_TIMER_IN_COMBAT: if (i->UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax)) - { i->Enabled = true; } + { + i->Enabled = true; + } break; // All normal events need to be re-enabled and their time set to 0 default: @@ -1259,7 +1437,9 @@ void CreatureEventAI::EnterCombat(Unit* enemy) void CreatureEventAI::AttackStart(Unit* who) { if (!who || !m_creature->CanAttackByItself()) - { return; } + { + return; + } if (m_creature->Attack(who, m_MeleeEnabled)) { @@ -1274,7 +1454,9 @@ void CreatureEventAI::AttackStart(Unit* who) void CreatureEventAI::MoveInLineOfSight(Unit* who) { if (!who) - { return; } + { + return; + } // Check for OOC LOS Event if (m_HasOOCLoSEvent && !m_creature->getVictim()) @@ -1292,20 +1474,26 @@ void CreatureEventAI::MoveInLineOfSight(Unit* who) { // if range is ok and we are actually in LOS if (m_creature->IsWithinDistInMap(who, fMaxAllowedRange) && m_creature->IsWithinLOSInMap(who)) - { ProcessEvent(*itr, who); } + { + ProcessEvent(*itr, who); + } } } } } if (m_creature->IsCivilian() || m_creature->IsNeutralToAll()) - { return; } + { + return; + } if (m_creature->CanInitiateAttack() && who->IsTargetableForAttack() && m_creature->IsHostileTo(who) && who->isInAccessablePlaceFor(m_creature)) { if (!m_creature->CanFly() && m_creature->GetDistanceZ(who) > CREATURE_Z_ATTACK_RANGE) - { return; } + { + return; + } float attackRadius = m_creature->GetAttackDistance(who); if (m_creature->IsWithinDistInMap(who, attackRadius) && m_creature->IsWithinLOSInMap(who)) @@ -1331,7 +1519,9 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellEntry* pSpell) // If spell id matches (or no spell id) & if spell school matches (or no spell school) if (!i->Event.spell_hit.spellId || pSpell->Id == i->Event.spell_hit.spellId) if (pSpell->SchoolMask & i->Event.spell_hit.schoolMask) - { ProcessEvent(*i, pUnit); } + { + ProcessEvent(*i, pUnit); + } } void CreatureEventAI::UpdateAI(const uint32 diff) @@ -1438,50 +1628,70 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke case TARGET_T_HOSTILE: resTarget = m_creature->getVictim(); if (!resTarget) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_HOSTILE_SECOND_AGGRO: resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 1, forSpellId, selectFlags); if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty())) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_HOSTILE_LAST_AGGRO: resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_BOTTOMAGGRO, 0, forSpellId, selectFlags); if (!resTarget && m_creature->GetThreatManager().getThreatList().empty()) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_HOSTILE_RANDOM: resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, selectFlags); if (!resTarget && m_creature->GetThreatManager().getThreatList().empty()) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_HOSTILE_RANDOM_NOT_TOP: resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, selectFlags); if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty())) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_HOSTILE_RANDOM_PLAYER: resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0, forSpellId, SELECT_FLAG_PLAYER | selectFlags); if (!resTarget) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_HOSTILE_RANDOM_NOT_TOP_PLAYER: resTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1, forSpellId, SELECT_FLAG_PLAYER | selectFlags); if (!resTarget && ((forSpellId == 0 && selectFlags == 0 && m_creature->GetThreatManager().getThreatList().size() > 1) || m_creature->GetThreatManager().getThreatList().empty())) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_ACTION_INVOKER: if (!pActionInvoker) - { isError = true; } + { + isError = true; + } return pActionInvoker; case TARGET_T_ACTION_INVOKER_OWNER: resTarget = pActionInvoker ? pActionInvoker->GetCharmerOrOwnerOrSelf() : NULL; if (!resTarget) - { isError = true; } + { + isError = true; + } return resTarget; case TARGET_T_EVENT_SENDER: if (!pAIEventSender) - { isError = true; } + { + isError = true; + } return pAIEventSender; default: isError = true; @@ -1528,7 +1738,9 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) if (itr->Event.event_type == EVENT_T_RECEIVE_EMOTE) { if (itr->Event.receive_emote.emoteId != text_emote) - { continue; } + { + continue; + } PlayerCondition pcon(0, itr->Event.receive_emote.condition, itr->Event.receive_emote.conditionValue1, itr->Event.receive_emote.conditionValue2); if (pcon.Meets(pPlayer, m_creature->GetMap(), m_creature, CONDITION_FROM_EVENTAI)) @@ -1547,7 +1759,9 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage) if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel + damage) { if (m_creature->GetHealth() <= m_InvinceabilityHpLevel) - { damage = 0; } + { + damage = 0; + } else { damage = m_creature->GetHealth() - m_InvinceabilityHpLevel; } } @@ -1574,7 +1788,9 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage) } if (m_throwAIEventMask & (1 << sendEvent[step])) - { SendAIEventAround(sendEvent[step], dealer, 0, AIEVENT_DEFAULT_THROW_RADIUS); } + { + SendAIEventAround(sendEvent[step], dealer, 0, AIEVENT_DEFAULT_THROW_RADIUS); + } m_throwAIEventStep = step + 1; } @@ -1583,12 +1799,16 @@ void CreatureEventAI::DamageTaken(Unit* dealer, uint32& damage) void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount) { if (m_throwAIEventStep == 100) - { return; } + { + return; + } if (m_creature->GetHealth() + healedAmount >= m_creature->GetMaxHealth()) { if (m_throwAIEventMask & (1 << AI_EVENT_GOT_FULL_HEALTH)) - { SendAIEventAround(AI_EVENT_GOT_FULL_HEALTH, healer, 0, AIEVENT_DEFAULT_THROW_RADIUS); } + { + SendAIEventAround(AI_EVENT_GOT_FULL_HEALTH, healer, 0, AIEVENT_DEFAULT_THROW_RADIUS); + } m_throwAIEventStep = 100; } } @@ -1596,7 +1816,9 @@ void CreatureEventAI::HealedBy(Unit* healer, uint32& healedAmount) bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& event) { if (event.event_type != EVENT_T_SPAWNED) - { return false; } + { + return false; + } switch (event.spawned.condition) { diff --git a/src/game/Object/CreatureEventAIMgr.cpp b/src/game/Object/CreatureEventAIMgr.cpp index 66850a582..67c1ba5fb 100644 --- a/src/game/Object/CreatureEventAIMgr.cpp +++ b/src/game/Object/CreatureEventAIMgr.cpp @@ -44,13 +44,17 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use) sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID, true); if (check_entry_use) - { CheckUnusedAITexts(); } + { + CheckUnusedAITexts(); + } } void CreatureEventAIMgr::CheckUnusedAITexts() { if (m_usedTextsAmount == sObjectMgr.GetLoadedStringsCount(MIN_CREATURE_AI_TEXT_STRING_ID)) - { return; } + { + return; + } sLog.outString("Checking EventAI for unused texts, this might take a while"); @@ -58,7 +62,9 @@ void CreatureEventAIMgr::CheckUnusedAITexts() // check not used strings this is negative range for (int32 i = MAX_CREATURE_AI_TEXT_STRING_ID + 1; i <= MIN_CREATURE_AI_TEXT_STRING_ID; ++i) if (sObjectMgr.GetMangosStringLocale(i)) - { idx_set.insert(i); } + { + idx_set.insert(i); + } for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr) { @@ -78,7 +84,9 @@ void CreatureEventAIMgr::CheckUnusedAITexts() int k = action.type == ACTION_T_TEXT ? 0 : 1; for (; k < 3; ++k) if (action.text.TextId[k]) - { idx_set.erase(action.text.TextId[k]); } + { + idx_set.erase(action.text.TextId[k]); + } break; } default: break; @@ -106,7 +114,9 @@ bool IsValidTargetType(EventAI_Type eventType, EventAI_ActionType actionType, ui case TARGET_T_HOSTILE_RANDOM: case TARGET_T_HOSTILE_RANDOM_NOT_TOP: if (actionType == ACTION_T_QUEST_EVENT || actionType == ACTION_T_CAST_EVENT || actionType == ACTION_T_QUEST_EVENT_ALL || actionType == ACTION_T_KILLED_MONSTER) - { sLog.outErrorEventAI("Event %u Action%u uses LIKELY bad Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType); } + { + sLog.outErrorEventAI("Event %u Action%u uses LIKELY bad Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType); + } // no break, check if valid at all case TARGET_T_HOSTILE: case TARGET_T_HOSTILE_SECOND_AGGRO: @@ -305,7 +315,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() // No chance of this event occuring if (temp.event_chance == 0) - { sLog.outErrorEventAI("Event %u has 0 percent chance. Event will never trigger!", i); } + { + sLog.outErrorEventAI("Event %u has 0 percent chance. Event will never trigger!", i); + } // Chance above 100, force it to be 100 else if (temp.event_chance > 100) { @@ -320,9 +332,13 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_TIMER_OOC: case EVENT_T_TIMER_GENERIC: if (temp.timer.initialMax < temp.timer.initialMin) - { sLog.outErrorEventAI("Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); + } if (temp.timer.repeatMax < temp.timer.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_HP: case EVENT_T_MANA: @@ -330,10 +346,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_TARGET_MANA: case EVENT_T_ENERGY: if (temp.percent_range.percentMax > 100) - { sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); + } if (temp.percent_range.percentMax <= temp.percent_range.percentMin) - { sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); + } if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax) { @@ -352,24 +372,36 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() } if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask) - { sLog.outErrorEventAI("Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i); } + { + sLog.outErrorEventAI("Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i); + } } if (!temp.spell_hit.schoolMask) - { sLog.outErrorEventAI("Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i); } + { + sLog.outErrorEventAI("Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i); + } if (temp.spell_hit.repeatMax < temp.spell_hit.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_RANGE: if (temp.range.maxDist < temp.range.minDist) - { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i); + } if (temp.range.repeatMax < temp.range.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_OOC_LOS: if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_SPAWNED: switch (temp.spawned.condition) @@ -378,11 +410,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case SPAWNED_EVENT_MAP: if (!sMapStore.LookupEntry(temp.spawned.conditionValue1)) - { sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); } + { + sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); + } break; case SPAWNED_EVENT_ZONE: if (!GetAreaEntryByAreaID(temp.spawned.conditionValue1)) - { sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); } + { + sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); + } break; default: sLog.outErrorEventAI("Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition); @@ -391,11 +427,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case EVENT_T_FRIENDLY_HP: if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_FRIENDLY_IS_CC: if (temp.friendly_is_cc.repeatMax < temp.friendly_is_cc.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_FRIENDLY_MISSING_BUFF: { @@ -411,29 +451,41 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() continue; } if (temp.friendly_buff.repeatMax < temp.friendly_buff.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; } case EVENT_T_KILL: if (temp.kill.repeatMax < temp.kill.repeatMin) - { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_TARGET_CASTING: if (temp.target_casting.repeatMax < temp.target_casting.repeatMin) - { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_SUMMONED_UNIT: case EVENT_T_SUMMONED_JUST_DIED: case EVENT_T_SUMMONED_JUST_DESPAWN: if (!sCreatureStorage.LookupEntry(temp.summoned.creatureId)) - { sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summoned.creatureId); } + { + sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summoned.creatureId); + } if (temp.summoned.repeatMax < temp.summoned.repeatMin) - { sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; case EVENT_T_QUEST_ACCEPT: case EVENT_T_QUEST_COMPLETE: if (!sObjectMgr.GetQuestTemplate(temp.quest.questId)) - { sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent quest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId); } + { + sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent quest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId); + } sLog.outErrorEventAI("Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i); continue; @@ -491,7 +543,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() continue; } if (temp.buffed.repeatMax < temp.buffed.repeatMin) - { sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); } + { + sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); + } break; } case EVENT_T_RECEIVE_AI_EVENT: @@ -540,7 +594,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case ACTION_T_CHANCED_TEXT: // Check first param as chance if (!action.chanced_text.chance) - { sLog.outErrorEventAI("Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1); } + { + 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); } // no break here to check texts @@ -553,10 +609,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (action.text.TextId[k]) { if (k > firstTextParam && not_set) - { sLog.outErrorEventAI("Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1); } + { + sLog.outErrorEventAI("Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1); + } if (!action.text.TextId[k]) - { not_set = true; } + { + not_set = true; + } // range negative else if (action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID) { @@ -607,33 +667,51 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_SOUND: if (!sSoundEntriesStore.LookupEntry(action.sound.soundId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SoundID %u.", i, j + 1, action.sound.soundId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent SoundID %u.", i, j + 1, action.sound.soundId); + } break; case ACTION_T_EMOTE: if (!sEmotesStore.LookupEntry(action.emote.emoteId)) - { sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.emote.emoteId); } + { + sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.emote.emoteId); + } break; case ACTION_T_RANDOM_SOUND: if (!sSoundEntriesStore.LookupEntry(action.random_sound.soundId1)) - { sLog.outErrorEventAI("Event %u Action %u param1 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId1); } + { + sLog.outErrorEventAI("Event %u Action %u param1 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId1); + } if (action.random_sound.soundId2 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId2)) - { sLog.outErrorEventAI("Event %u Action %u param2 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId2); } + { + sLog.outErrorEventAI("Event %u Action %u param2 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId2); + } if (action.random_sound.soundId3 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId3)) - { sLog.outErrorEventAI("Event %u Action %u param3 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId3); } + { + sLog.outErrorEventAI("Event %u Action %u param3 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId3); + } break; case ACTION_T_RANDOM_EMOTE: if (!sEmotesStore.LookupEntry(action.random_emote.emoteId1)) - { sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId1); } + { + sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId1); + } if (action.random_emote.emoteId2 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId2)) - { sLog.outErrorEventAI("Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId2); } + { + sLog.outErrorEventAI("Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId2); + } if (action.random_emote.emoteId3 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId3)) - { sLog.outErrorEventAI("Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId3); } + { + sLog.outErrorEventAI("Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId3); + } break; case ACTION_T_CAST: { const SpellEntry* spell = sSpellStore.LookupEntry(action.cast.spellId); if (!spell) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast.spellId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast.spellId); + } /* FIXME: temp.raw.param3 not have event tipes with recovery time in it.... else { @@ -648,7 +726,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() // Cast is always triggered if target is forced to cast on self if (action.cast.castFlags & CAST_FORCE_TARGET_SELF) - { action.cast.castFlags |= CAST_TRIGGERED; } + { + action.cast.castFlags |= CAST_TRIGGERED; + } IsValidTargetType(temp.event_type, action.type, action.cast.target, i, j + 1); @@ -657,7 +737,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { // spell must be cast on self, but is not if ((IsOnlySelfTargeting(spell) || spell->rangeIndex == SPELL_RANGE_IDX_SELF_ONLY) && action.cast.target != TARGET_T_SELF && !(action.cast.castFlags & CAST_FORCE_TARGET_SELF)) - { sLog.outErrorEventAI("Event %u Action %u uses SpellID %u that must be self cast (target is %u)", i, j + 1, action.cast.spellId, action.cast.target); } + { + sLog.outErrorEventAI("Event %u Action %u uses SpellID %u that must be self cast (target is %u)", i, j + 1, action.cast.spellId, action.cast.target); + } // TODO: spell must be cast on enemy, but is not @@ -676,24 +758,32 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() } case ACTION_T_SUMMON: if (!sCreatureStorage.LookupEntry(action.summon.creatureId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId); + } IsValidTargetType(temp.event_type, action.type, action.summon.target, i, j + 1); break; case ACTION_T_THREAT_SINGLE_PCT: if (std::abs(action.threat_single_pct.percent) > 100) - { sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent); } + { + sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent); + } IsValidTargetType(temp.event_type, action.type, action.threat_single_pct.target, i, j + 1); break; case ACTION_T_THREAT_ALL_PCT: if (std::abs(action.threat_all_pct.percent) > 100) - { sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_all_pct.percent); } + { + sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_all_pct.percent); + } break; case ACTION_T_QUEST_EVENT: if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event.questId)) { if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT)) - { sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event.questId); } + { + sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event.questId); + } } else { sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId); } @@ -702,14 +792,20 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_CAST_EVENT: if (!sCreatureStorage.LookupEntry(action.cast_event.creatureId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId); + } if (!sSpellStore.LookupEntry(action.cast_event.spellId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId); + } IsValidTargetType(temp.event_type, action.type, action.cast_event.target, i, j + 1); break; case ACTION_T_SET_UNIT_FIELD: if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) - { sLog.outErrorEventAI("Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1); } + { + sLog.outErrorEventAI("Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1); + } IsValidTargetType(temp.event_type, action.type, action.set_unit_field.target, i, j + 1); break; case ACTION_T_SET_UNIT_FLAG: @@ -718,11 +814,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_SET_PHASE: if (action.set_phase.phase >= MAX_PHASE) - { sLog.outErrorEventAI("Event %u Action %u attempts to set phase >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); } + { + sLog.outErrorEventAI("Event %u Action %u attempts to set phase >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); + } break; case ACTION_T_INC_PHASE: if (action.set_inc_phase.step == 0) - { sLog.outErrorEventAI("Event %u Action %u is incrementing phase by 0. Was this intended?", i, j + 1); } + { + 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); } break; @@ -730,35 +830,53 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event_all.questId)) { if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT)) - { sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event_all.questId); } + { + sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event_all.questId); + } } else { 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)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event_all.creatureId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event_all.creatureId); + } if (!sSpellStore.LookupEntry(action.cast_event_all.spellId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event_all.spellId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event_all.spellId); + } break; case ACTION_T_REMOVEAURASFROMSPELL: if (!sSpellStore.LookupEntry(action.remove_aura.spellId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId); + } IsValidTargetType(temp.event_type, action.type, action.remove_aura.target, i, j + 1); break; case ACTION_T_RANDOM_PHASE: // PhaseId1, PhaseId2, PhaseId3 if (action.random_phase.phase1 >= MAX_PHASE) - { sLog.outErrorEventAI("Event %u Action %u attempts to set phase1 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); } + { + sLog.outErrorEventAI("Event %u Action %u attempts to set phase1 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); + } if (action.random_phase.phase2 >= MAX_PHASE) - { sLog.outErrorEventAI("Event %u Action %u attempts to set phase2 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); } + { + sLog.outErrorEventAI("Event %u Action %u attempts to set phase2 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); + } if (action.random_phase.phase3 >= MAX_PHASE) - { sLog.outErrorEventAI("Event %u Action %u attempts to set phase3 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); } + { + sLog.outErrorEventAI("Event %u Action %u attempts to set phase3 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); + } break; case ACTION_T_RANDOM_PHASE_RANGE: // PhaseMin, PhaseMax if (action.random_phase_range.phaseMin >= MAX_PHASE) - { sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMin >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); } + { + sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMin >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); + } if (action.random_phase_range.phaseMin >= MAX_PHASE) - { sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); } + { + sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); + } if (action.random_phase_range.phaseMin >= action.random_phase_range.phaseMax) { sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j + 1); @@ -768,21 +886,29 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_SUMMON_ID: if (!sCreatureStorage.LookupEntry(action.summon_id.creatureId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId); + } IsValidTargetType(temp.event_type, action.type, action.summon_id.target, i, j + 1); if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end()) - { sLog.outErrorEventAI("Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j + 1, action.summon_id.spawnId); } + { + sLog.outErrorEventAI("Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j + 1, action.summon_id.spawnId); + } break; case ACTION_T_KILLED_MONSTER: if (!sCreatureStorage.LookupEntry(action.killed_monster.creatureId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId); + } IsValidTargetType(temp.event_type, action.type, action.killed_monster.target, i, j + 1); break; case ACTION_T_SET_INST_DATA: if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) sLog.outErrorEventAI("Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1); if (action.set_inst_data.value > 4/*SPECIAL*/) - { sLog.outErrorEventAI("Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j + 1); } + { + sLog.outErrorEventAI("Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j + 1); + } break; case ACTION_T_SET_INST_DATA64: if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) @@ -791,7 +917,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_UPDATE_TEMPLATE: if (!sCreatureStorage.LookupEntry(action.update_template.creatureId)) - { sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.update_template.creatureId); } + { + sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.update_template.creatureId); + } break; case ACTION_T_SET_SHEATH: if (action.set_sheath.sheath >= MAX_SHEATH_STATE) @@ -859,7 +987,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() continue; } if (action.throwEvent.radius > SIZE_OF_GRIDS) - { sLog.outErrorEventAI("Event %u Action %u uses unexpectedly huge radius %u (expected to be less than %f)", i, j + 1, action.throwEvent.radius, SIZE_OF_GRIDS); } + { + sLog.outErrorEventAI("Event %u Action %u uses unexpectedly huge radius %u (expected to be less than %f)", i, j + 1, action.throwEvent.radius, SIZE_OF_GRIDS); + } if (action.throwEvent.radius == 0) { @@ -913,7 +1043,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() bool ainame = strcmp(cInfo->AIName, "EventAI") == 0; bool hasevent = m_CreatureEventAI_Event_Map.find(i) != m_CreatureEventAI_Event_Map.end(); if (ainame && !hasevent) - { sLog.outErrorEventAI("EventAI not has script for creature entry (%u), but AIName = '%s'.", i, cInfo->AIName); } + { + 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); } } diff --git a/src/game/Object/DynamicObject.cpp b/src/game/Object/DynamicObject.cpp index 251324870..8f3e42f34 100644 --- a/src/game/Object/DynamicObject.cpp +++ b/src/game/Object/DynamicObject.cpp @@ -48,7 +48,9 @@ void DynamicObject::AddToWorld() { ///- Register the dynamicObject for guid lookup if (!IsInWorld()) - { GetMap()->GetObjectsStore().insert(GetObjectGuid(), (DynamicObject*)this); } + { + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (DynamicObject*)this); + } Object::AddToWorld(); } @@ -134,7 +136,9 @@ void DynamicObject::Update(uint32 /*update_diff*/, uint32 p_time) bool deleteThis = false; if (m_aliveDuration > int32(p_time)) - { m_aliveDuration -= p_time; } + { + m_aliveDuration -= p_time; + } else { deleteThis = true; } @@ -204,11 +208,15 @@ void DynamicObject::Delay(int32 delaytime) bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const { if (!IsInWorld() || !u->IsInWorld()) - { return false; } + { + return false; + } // always seen by owner if (GetCasterGuid() == u->GetObjectGuid()) - { return true; } + { + return true; + } // normal case return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false); @@ -217,7 +225,9 @@ bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* view bool DynamicObject::IsHostileTo(Unit const* unit) const { if (Unit* owner = GetCaster()) - { return owner->IsHostileTo(unit); } + { + return owner->IsHostileTo(unit); + } else { return false; } } @@ -225,7 +235,9 @@ bool DynamicObject::IsHostileTo(Unit const* unit) const bool DynamicObject::IsFriendlyTo(Unit const* unit) const { if (Unit* owner = GetCaster()) - { return owner->IsFriendlyTo(unit); } + { + return owner->IsFriendlyTo(unit); + } else { return true; } } diff --git a/src/game/Object/Formulas.h b/src/game/Object/Formulas.h index 6772a2f96..1bb788d58 100644 --- a/src/game/Object/Formulas.h +++ b/src/game/Object/Formulas.h @@ -45,7 +45,9 @@ namespace MaNGOS inline uint32 GetGrayLevel(uint32 pl_level) { if (pl_level <= 5) - { return 0; } + { + return 0; + } else if (pl_level <= 39) { return pl_level - 5 - pl_level / 10; } else if (pl_level <= 59) @@ -57,7 +59,9 @@ namespace MaNGOS inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level) { if (mob_level >= pl_level + 5) - { return RED; } + { + return RED; + } else if (mob_level >= pl_level + 3) { return ORANGE; } else if (mob_level >= pl_level - 2) @@ -102,7 +106,9 @@ namespace MaNGOS { uint32 nLevelDiff = mob_level - pl_level; if (nLevelDiff > 4) - { nLevelDiff = 4; } + { + nLevelDiff = 4; + } return ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2; } else @@ -126,10 +132,14 @@ namespace MaNGOS uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(), pl->GetZoneId())); if (xp_gain == 0) - { return 0; } + { + return 0; + } if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsElite()) - { xp_gain *= 2; } + { + xp_gain *= 2; + } return (uint32)(xp_gain * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL)); } diff --git a/src/game/Object/GMTicketMgr.cpp b/src/game/Object/GMTicketMgr.cpp index cbce70a47..1e0c231f6 100644 --- a/src/game/Object/GMTicketMgr.cpp +++ b/src/game/Object/GMTicketMgr.cpp @@ -63,7 +63,9 @@ void GMTicketMgr::LoadGMTickets() uint32 guidlow = fields[0].GetUInt32(); if (!guidlow) - { continue; } + { + continue; + } ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, guidlow); GMTicket& ticket = m_GMTicketMap[guid]; @@ -89,7 +91,9 @@ void GMTicketMgr::DeleteAll() for (GMTicketMap::const_iterator itr = m_GMTicketMap.begin(); itr != m_GMTicketMap.end(); ++itr) { if (Player* owner = sObjectMgr.GetPlayer(itr->first)) - { owner->GetSession()->SendGMTicketGetTicket(0x0A); } + { + owner->GetSession()->SendGMTicketGetTicket(0x0A); + } } CharacterDatabase.Execute("DELETE FROM character_ticket"); m_GMTicketListByCreatingOrder.clear(); diff --git a/src/game/Object/GMTicketMgr.h b/src/game/Object/GMTicketMgr.h index 6f9ef0ac3..5e2d39cc8 100644 --- a/src/game/Object/GMTicketMgr.h +++ b/src/game/Object/GMTicketMgr.h @@ -187,7 +187,9 @@ class GMTicketMgr { GMTicketMap::iterator itr = m_GMTicketMap.find(guid); if (itr == m_GMTicketMap.end()) - { return NULL; } + { + return NULL; + } return &(itr->second); } @@ -199,12 +201,16 @@ class GMTicketMgr GMTicket* GetGMTicketByOrderPos(uint32 pos) { if (pos >= GetTicketCount()) - { return NULL; } + { + return NULL; + } GMTicketList::iterator itr = m_GMTicketListByCreatingOrder.begin(); std::advance(itr, pos); if (itr == m_GMTicketListByCreatingOrder.end()) - { return NULL; } + { + return NULL; + } return *itr; } @@ -220,7 +226,9 @@ class GMTicketMgr { GMTicketMap::iterator itr = m_GMTicketMap.find(guid); if (itr == m_GMTicketMap.end()) - { return; } + { + return; + } itr->second.DeleteFromDB(); m_GMTicketListByCreatingOrder.remove(&itr->second); m_GMTicketMap.erase(itr); diff --git a/src/game/Object/GameObject.cpp b/src/game/Object/GameObject.cpp index 00ceaaabf..78a38c357 100644 --- a/src/game/Object/GameObject.cpp +++ b/src/game/Object/GameObject.cpp @@ -98,10 +98,14 @@ void GameObject::AddToWorld() ///- Register the gameobject for guid lookup if (!IsInWorld()) - { GetMap()->GetObjectsStore().insert(GetObjectGuid(), (GameObject*)this); } + { + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (GameObject*)this); + } if (m_model) - { GetMap()->InsertGameObjectModel(*m_model); } + { + GetMap()->InsertGameObjectModel(*m_model); + } Object::AddToWorld(); @@ -125,13 +129,17 @@ void GameObject::RemoveFromWorld() // Notify the outdoor pvp script if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) - { outdoorPvP->HandleGameObjectRemove(this); } + { + outdoorPvP->HandleGameObjectRemove(this); + } // Remove GO from owner if (ObjectGuid owner_guid = GetOwnerGuid()) { if (Unit* owner = ObjectAccessor::GetUnit(*this, owner_guid)) - { owner->RemoveGameObject(this, false); } + { + owner->RemoveGameObject(this, false); + } else { sLog.outError("Delete %s with SpellId %u LinkedGO %u that lost references to owner %s GO list. Crash possible later.", @@ -140,7 +148,9 @@ void GameObject::RemoveFromWorld() } if (m_model && GetMap()->ContainsGameObjectModel(*m_model)) - { GetMap()->RemoveGameObjectModel(*m_model); } + { + GetMap()->RemoveGameObjectModel(*m_model); + } GetMap()->GetObjectsStore().erase(GetObjectGuid(), (GameObject*)NULL); } @@ -203,7 +213,9 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); if (goinfo->type == GAMEOBJECT_TYPE_TRANSPORT) - { SetFlag(GAMEOBJECT_FLAGS, (GO_FLAG_TRANSPORT | GO_FLAG_NODESPAWN)); } + { + SetFlag(GAMEOBJECT_FLAGS, (GO_FLAG_TRANSPORT | GO_FLAG_NODESPAWN)); + } SetEntry(goinfo->id); SetDisplayId(goinfo->displayId); @@ -237,7 +249,9 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa // Notify the battleground or outdoor pvp script if (map->IsBattleGroundOrArena()) - { ((BattleGroundMap*)map)->GetBG()->HandleGameObjectCreate(this); } + { + ((BattleGroundMap*)map)->GetBG()->HandleGameObjectCreate(this); + } else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) { outdoorPvP->HandleGameObjectCreate(this); } @@ -245,7 +259,9 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa // Only works if you create the object in it, not if it is moves to that map. // Normally non-players do not teleport to other maps. if (InstanceData* iData = map->GetInstanceData()) - { iData->OnObjectCreate(this); } + { + iData->OnObjectCreate(this); + } return true; } @@ -274,7 +290,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) // Arming Time for GAMEOBJECT_TYPE_TRAP (6) Unit* owner = GetOwner(); if (owner && owner->IsInCombat()) - { m_cooldownTime = time(NULL) + GetGOInfo()->trap.startDelay; } + { + m_cooldownTime = time(NULL) + GetGOInfo()->trap.startDelay; + } m_lootState = GO_READY; break; } @@ -333,7 +351,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) case GAMEOBJECT_TYPE_BUTTON: // we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds) if (GetGoState() != GO_STATE_READY) - { ResetDoorOrButton(); } + { + ResetDoorOrButton(); + } // flags in AB are type_button and we need to add them here so no break! default: if (!m_spawnedByDefault) // despawn timer @@ -344,7 +364,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) if (!HasStaticDBSpawnData()) { if (Unit* owner = GetOwner()) - { owner->RemoveGameObject(this, false); } + { + owner->RemoveGameObject(this, false); + } Delete(); } return; @@ -364,7 +386,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) if (goInfo->type == GAMEOBJECT_TYPE_TRAP) // traps { if (m_cooldownTime >= time(NULL)) - { return; } + { + return; + } // FIXME: this is activation radius (in different casting radius that must be selected from spell data) // TODO: move activated state code (cast itself) to GO_ACTIVATED, in this place only check activating and set state @@ -372,11 +396,15 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) if (!radius) { if (goInfo->trap.cooldown != 3) // cast in other case (at some triggering/linked go/etc explicit call) - { return; } + { + return; + } else { if (m_respawnTime > 0) - { break; } + { + break; + } // battlegrounds gameobjects has data2 == 0 && data5 == 3 radius = float(goInfo->trap.cooldown); @@ -389,7 +417,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) MaNGOS::UnitSearcher checker(enemy, u_check); Cell::VisitAllObjects(this, checker, radius); if (enemy) - { Use(enemy); } + { + Use(enemy); + } } if (uint32 max_charges = goInfo->GetCharges()) @@ -410,7 +440,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) case GAMEOBJECT_TYPE_DOOR: case GAMEOBJECT_TYPE_BUTTON: if (GetGOInfo()->GetAutoCloseTime() && (m_cooldownTime < time(NULL))) - { ResetDoorOrButton(); } + { + ResetDoorOrButton(); + } break; case GAMEOBJECT_TYPE_CHEST: if (m_groupLootId) @@ -454,7 +486,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) for (GuidSet::const_iterator itr = m_UniqueUsers.begin(); itr != m_UniqueUsers.end(); ++itr) { if (Player* owner = GetMap()->GetPlayer(*itr)) - { owner->CastSpell(owner, spellId, false, NULL, NULL, GetObjectGuid()); } + { + owner->CastSpell(owner, spellId, false, NULL, NULL, GetObjectGuid()); + } } ClearAllUsesData(); @@ -470,7 +504,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) for (GuidSet::const_iterator itr = m_UniqueUsers.begin(); itr != m_UniqueUsers.end(); ++itr) { if (Player* owner = GetMap()->GetPlayer(*itr)) - { owner->SendUpdateWorldState(GetGOInfo()->capturePoint.worldState1, WORLD_STATE_REMOVE); } + { + owner->SendUpdateWorldState(GetGOInfo()->capturePoint.worldState1, WORLD_STATE_REMOVE); + } } m_UniqueUsers.clear(); @@ -484,7 +520,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) if (!HasStaticDBSpawnData() && (!GetSpellId() || GetGOInfo()->GetDespawnPossibility())) { if (Unit* owner = GetOwner()) - { owner->RemoveGameObject(this, false); } + { + owner->RemoveGameObject(this, false); + } Delete(); return; } @@ -509,22 +547,30 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) SetLootState(GO_READY); if (!m_respawnDelayTime) - { return; } + { + return; + } // since pool system can fail to roll unspawned object, this one can remain spawned, so must set respawn nevertheless m_respawnTime = m_spawnedByDefault ? time(NULL) + m_respawnDelayTime : 0; // if option not set then object will be saved at grid unload if (sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) - { SaveRespawnTime(); } + { + SaveRespawnTime(); + } // if part of pool, let pool system schedule new spawn instead of just scheduling respawn if (uint16 poolid = sPoolMgr.IsPartOfAPool(GetGUIDLow())) - { sPoolMgr.UpdatePool(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); } + { + sPoolMgr.UpdatePool(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); + } // can be not in world at pool despawn if (IsInWorld()) - { UpdateObjectVisibility(); } + { + UpdateObjectVisibility(); + } break; } @@ -535,10 +581,14 @@ void GameObject::Refresh() { // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway) if (m_respawnTime > 0 && m_spawnedByDefault) - { return; } + { + return; + } if (isSpawned()) - { GetMap()->Add(this); } + { + GetMap()->Add(this); + } } void GameObject::AddUniqueUse(Player* player) @@ -546,7 +596,9 @@ void GameObject::AddUniqueUse(Player* player) AddUse(); if (!m_firstUser) - { m_firstUser = player->GetObjectGuid(); } + { + m_firstUser = player->GetObjectGuid(); + } m_UniqueUsers.insert(player->GetObjectGuid()); } @@ -559,7 +611,9 @@ void GameObject::Delete() SetUInt32Value(GAMEOBJECT_FLAGS, GetGOInfo()->flags); if (uint16 poolid = sPoolMgr.IsPartOfAPool(GetGUIDLow())) - { sPoolMgr.UpdatePool(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); } + { + sPoolMgr.UpdatePool(*GetMap()->GetPersistentState(), poolid, GetGUIDLow()); + } else { AddObjectToRemoveList(); } } @@ -583,7 +637,9 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) const GameObjectInfo* goI = GetGOInfo(); if (!goI) - { return; } + { + return; + } // update in loaded data (changing data only in this place) GameObjectData& data = sObjectMgr.NewGOData(GetGUIDLow()); @@ -653,7 +709,9 @@ bool GameObject::LoadFromDB(uint32 guid, Map* map) GOState go_state = data->go_state; if (!Create(guid, entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state)) - { return false; } + { + return false; + } if (!GetGOInfo()->GetDespawnPossibility() && !GetGOInfo()->IsDespawnAtAction() && data->spawntimesecs >= 0) { @@ -733,7 +791,9 @@ bool GameObject::HasQuest(uint32 quest_id) const for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (itr->second == quest_id) - { return true; } + { + return true; + } } return false; } @@ -744,7 +804,9 @@ bool GameObject::HasInvolvedQuest(uint32 quest_id) const for (QuestRelationsMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (itr->second == quest_id) - { return true; } + { + return true; + } } return false; } @@ -765,14 +827,18 @@ Unit* GameObject::GetOwner() const void GameObject::SaveRespawnTime() { if (m_respawnTime > time(NULL) && m_spawnedByDefault) - { GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), m_respawnTime); } + { + GetMap()->GetPersistentState()->SaveGORespawnTime(GetGUIDLow(), m_respawnTime); + } } bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const { // Not in world if (!IsInWorld() || !u->IsInWorld()) - { return false; } + { + return false; + } // invisible at client always if (!GetGOInfo()->displayId) @@ -780,14 +846,18 @@ bool GameObject::isVisibleForInState(Player const* u, WorldObject const* viewPoi // Transport always visible at this step implementation if (IsTransport() && IsInMap(u)) - { return true; } + { + return true; + } // quick check visibility false cases for non-GM-mode if (!u->isGameMaster()) { // despawned and then not visible for non-GM in GM-mode if (!isSpawned()) - { return false; } + { + return false; + } // special invisibility cases if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRAP && GetGOInfo()->trap.stealthed) @@ -850,10 +920,14 @@ bool GameObject::ActivateToQuest(Player* pTarget) const { // if GO is ReqCreatureOrGoN for quest if (pTarget->HasQuestForGO(GetEntry())) - { return true; } + { + return true; + } if (!sObjectMgr.IsGameObjectForQuests(GetEntry())) - { return false; } + { + return false; + } switch (GetGoType()) { @@ -871,7 +945,9 @@ bool GameObject::ActivateToQuest(Player* pTarget) const const Quest* qInfo = sObjectMgr.GetQuestTemplate(itr->second); if (pTarget->CanTakeQuest(qInfo, false)) - { return true; } + { + return true; + } } bounds = sObjectMgr.GetGOQuestInvolvedRelationsMapBounds(GetEntry()); @@ -889,7 +965,9 @@ bool GameObject::ActivateToQuest(Player* pTarget) const case GAMEOBJECT_TYPE_CHEST: { if (pTarget->GetQuestStatus(GetGOInfo()->chest.questId) == QUEST_STATUS_INCOMPLETE) - { return true; } + { + return true; + } if (LootTemplates_Gameobject.HaveQuestLootForPlayer(GetGOInfo()->GetLootId(), pTarget)) { @@ -897,7 +975,9 @@ bool GameObject::ActivateToQuest(Player* pTarget) const if (GetEntry() == BG_AV_OBJECTID_MINE_N || GetEntry() == BG_AV_OBJECTID_MINE_S) if (BattleGround* bg = pTarget->GetBattleGround()) if (bg->GetTypeID() == BATTLEGROUND_AV && !(((BattleGroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(), pTarget->GetTeam()))) - { return false; } + { + return false; + } return true; } break; @@ -905,19 +985,25 @@ bool GameObject::ActivateToQuest(Player* pTarget) const case GAMEOBJECT_TYPE_GENERIC: { if (pTarget->GetQuestStatus(GetGOInfo()->_generic.questID) == QUEST_STATUS_INCOMPLETE) - { return true; } + { + return true; + } break; } case GAMEOBJECT_TYPE_SPELL_FOCUS: { if (pTarget->GetQuestStatus(GetGOInfo()->spellFocus.questID) == QUEST_STATUS_INCOMPLETE) - { return true; } + { + return true; + } break; } case GAMEOBJECT_TYPE_GOOBER: { if (pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE) - { return true; } + { + return true; + } break; } default: @@ -931,7 +1017,9 @@ void GameObject::SummonLinkedTrapIfAny() { uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry(); if (!linkedEntry) - { return; } + { + return; + } GameObject* linkedGO = new GameObject; if (!linkedGO->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), linkedEntry, GetMap(), @@ -958,11 +1046,15 @@ void GameObject::TriggerLinkedGameObject(Unit* target) uint32 trapEntry = GetGOInfo()->GetLinkedGameObjectEntry(); if (!trapEntry) - { return; } + { + return; + } GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(trapEntry); if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP) - { return; } + { + return; + } SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId); @@ -972,7 +1064,9 @@ void GameObject::TriggerLinkedGameObject(Unit* target) float range = 0.5f; if (trapSpell) // checked at load already - { range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(trapSpell->rangeIndex)); } + { + range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(trapSpell->rangeIndex)); + } // search nearest linked GO GameObject* trapGO = NULL; @@ -987,7 +1081,9 @@ void GameObject::TriggerLinkedGameObject(Unit* target) // found correct GO if (trapGO) - { trapGO->Use(target); } + { + trapGO->Use(target); + } } GameObject* GameObject::LookupFishingHoleAround(float range) @@ -1004,7 +1100,9 @@ GameObject* GameObject::LookupFishingHoleAround(float range) bool GameObject::IsCollisionEnabled() const { if (!isSpawned()) - { return false; } + { + return false; + } // TODO: Possible that this function must consider multiple checks switch (GetGoType()) @@ -1021,7 +1119,9 @@ bool GameObject::IsCollisionEnabled() const void GameObject::ResetDoorOrButton() { if (m_lootState == GO_READY || m_lootState == GO_JUST_DEACTIVATED) - { return; } + { + return; + } SwitchDoorOrButton(false); SetLootState(GO_JUST_DEACTIVATED); @@ -1031,10 +1131,14 @@ void GameObject::ResetDoorOrButton() void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */) { if (m_lootState != GO_READY) - { return; } + { + return; + } if (!time_to_restore) - { time_to_restore = GetGOInfo()->GetAutoCloseTime(); } + { + time_to_restore = GetGOInfo()->GetAutoCloseTime(); + } SwitchDoorOrButton(true, alternative); SetLootState(GO_ACTIVATED); @@ -1045,12 +1149,16 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */) { if (activate) - { SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); } + { + SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); + } else { RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); } if (GetGoState() == GO_STATE_READY) // if closed -> open - { SetGoState(alternative ? GO_STATE_ACTIVE_ALTERNATIVE : GO_STATE_ACTIVE); } + { + SetGoState(alternative ? GO_STATE_ACTIVE_ALTERNATIVE : GO_STATE_ACTIVE); + } else // if open -> close { SetGoState(GO_STATE_READY); } } @@ -1069,14 +1177,18 @@ void GameObject::Use(Unit* user) if (uint32 cooldown = GetGOInfo()->GetCooldown()) { if (m_cooldownTime > sWorld.GetGameTime()) - { return; } + { + return; + } m_cooldownTime = sWorld.GetGameTime() + cooldown; } bool scriptReturnValue = user->GetTypeId() == TYPEID_PLAYER && sScriptMgr.OnGameObjectUse((Player*)user, this); if (!scriptReturnValue) - { GetMap()->ScriptsStart(DBS_ON_GOT_USE, GetEntry(), spellCaster, this); } + { + GetMap()->ScriptsStart(DBS_ON_GOT_USE, GetEntry(), spellCaster, this); + } switch (GetGoType()) { @@ -1087,7 +1199,9 @@ void GameObject::Use(Unit* user) // activate script if (!scriptReturnValue) - { GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); } + { + GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); + } return; } case GAMEOBJECT_TYPE_BUTTON: // 1 @@ -1099,14 +1213,18 @@ void GameObject::Use(Unit* user) // activate script if (!scriptReturnValue) - { GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); } + { + GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); + } return; } case GAMEOBJECT_TYPE_QUESTGIVER: // 2 { if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; @@ -1121,7 +1239,9 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_CHEST: // 3 { if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } TriggerLinkedGameObject(user); @@ -1137,7 +1257,9 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_GENERIC: // 5 { if (scriptReturnValue) - { return; } + { + return; + } // No known way to exclude some - only different approach is to select despawnable GOs by Entry SetLootState(GO_JUST_DEACTIVATED); @@ -1146,7 +1268,9 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_TRAP: // 6 { if (scriptReturnValue) - { return; } + { + return; + } Unit* owner = GetOwner(); Unit* caster = owner ? owner : user; @@ -1163,13 +1287,17 @@ void GameObject::Use(Unit* user) // count charges if (goInfo->trap.charges > 0) - { AddUse(); } + { + AddUse(); + } if (IsBattleGroundTrap && user->GetTypeId() == TYPEID_PLAYER) { // BattleGround gameobjects case if (BattleGround* bg = ((Player*)user)->GetBattleGround()) - { bg->HandleTriggerBuff(GetObjectGuid()); } + { + bg->HandleTriggerBuff(GetObjectGuid()); + } } // TODO: all traps can be activated, also those without spell. @@ -1177,7 +1305,9 @@ void GameObject::Use(Unit* user) // TODO: Improve this when more information is available, currently these traps are known that must send the anim (Onyxia/ Heigan Fissures/ Trap in DireMaul) if (GetDisplayId() == 4392 || GetDisplayId() == 4472 || GetDisplayId() == 4491 || GetDisplayId() == 6785 || GetDisplayId() == 3073 || GetDisplayId() == 7998) - { SendGameObjectCustomAnim(GetObjectGuid()); } + { + SendGameObjectCustomAnim(GetObjectGuid()); + } // TODO: Despawning of traps? (Also related to code in ::Update) return; @@ -1186,10 +1316,14 @@ void GameObject::Use(Unit* user) { GameObjectInfo const* info = GetGOInfo(); if (!info) - { return; } + { + return; + } if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; @@ -1257,7 +1391,9 @@ void GameObject::Use(Unit* user) { Player* player = (Player*)user; if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId())) - { outdoorPvP->HandleGameObjectUse(player, this); } + { + outdoorPvP->HandleGameObjectUse(player, this); + } } GameObjectInfo const* info = GetGOInfo(); @@ -1269,7 +1405,9 @@ void GameObject::Use(Unit* user) // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389) if (info->goober.customAnim) - { SendGameObjectCustomAnim(GetObjectGuid()); } + { + SendGameObjectCustomAnim(GetObjectGuid()); + } else { SetGoState(GO_STATE_ACTIVE); } @@ -1305,7 +1443,9 @@ void GameObject::Use(Unit* user) { // Quest require to be active for GO using if (player->GetQuestStatus(info->goober.questId) != QUEST_STATUS_INCOMPLETE) - { break; } + { + break; + } } player->RewardPlayerAndGroupAtCast(this); @@ -1313,7 +1453,9 @@ void GameObject::Use(Unit* user) // activate script if (!scriptReturnValue) - { GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); } + { + GetMap()->ScriptsStart(DBS_ON_GO_USE, GetGUIDLow(), spellCaster, this); + } else { return; } @@ -1336,30 +1478,42 @@ void GameObject::Use(Unit* user) { GameObjectInfo const* info = GetGOInfo(); if (!info) - { return; } + { + return; + } if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; if (info->camera.cinematicId) - { player->SendCinematicStart(info->camera.cinematicId); } + { + player->SendCinematicStart(info->camera.cinematicId); + } if (info->camera.eventID) - { StartEvents_Event(GetMap(), info->camera.eventID, player, this); } + { + StartEvents_Event(GetMap(), info->camera.eventID, player, this); + } return; } case GAMEOBJECT_TYPE_FISHINGNODE: // 17 fishing bobber { if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; if (player->GetObjectGuid() != GetOwnerGuid()) - { return; } + { + return; + } switch (getLootState()) { @@ -1374,11 +1528,15 @@ void GameObject::Use(Unit* user) int32 zone_skill = sObjectMgr.GetFishingBaseSkillLevel(subzone); if (!zone_skill) - { zone_skill = sObjectMgr.GetFishingBaseSkillLevel(zone); } + { + zone_skill = sObjectMgr.GetFishingBaseSkillLevel(zone); + } // provide error, no fishable zone or area should be 0 if (!zone_skill) - { sLog.outErrorDb("Fishable areaId %u are not properly defined in `skill_fishing_base_level`.", subzone); } + { + sLog.outErrorDb("Fishable areaId %u are not properly defined in `skill_fishing_base_level`.", subzone); + } int32 skill = player->GetSkillValue(SKILL_FISHING); int32 chance = skill - zone_skill + 5; @@ -1398,7 +1556,9 @@ void GameObject::Use(Unit* user) // TODO: find reasonable value for fishing hole search fishingHole = LookupFishingHoleAround(20.0f + CONTACT_DISTANCE); if (fishingHole) - { success = true; } + { + success = true; + } } } // just search fishhole for success case @@ -1407,7 +1567,9 @@ void GameObject::Use(Unit* user) { fishingHole = LookupFishingHoleAround(20.0f + CONTACT_DISTANCE); } if (success || sWorld.getConfig(CONFIG_BOOL_SKILL_FAIL_GAIN_FISHING)) - { player->UpdateFishingSkill(); } + { + player->UpdateFishingSkill(); + } // fish catch or fail and junk allowed (after 3.1.0) if (success || sWorld.getConfig(CONFIG_BOOL_SKILL_FAIL_LOOT_FISHING)) @@ -1452,7 +1614,9 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_SUMMONING_RITUAL: // 18 { if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; @@ -1463,15 +1627,21 @@ void GameObject::Use(Unit* user) if (owner) { if (owner->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect) if (player == (Player*)owner || (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(((Player*)owner)))) - { return; } + { + return; + } // expect owner to already be channeling, so if not... if (!owner->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - { return; } + { + return; + } // in case summoning ritual caster is GO creator spellCaster = owner; @@ -1483,7 +1653,9 @@ void GameObject::Use(Unit* user) if (Group* group = player->GetGroup()) { if (!group->IsMember(m_firstUser)) - { return; } + { + return; + } } else { return; } @@ -1504,12 +1676,16 @@ void GameObject::Use(Unit* user) // full amount unique participants including original summoner, need more if (GetUniqueUseCount() < info->summoningRitual.reqParticipants) - { return; } + { + return; + } // owner is first user for non-wild GO objects, if it offline value already set to current user if (!GetOwnerGuid()) if (Player* firstUser = GetMap()->GetPlayer(m_firstUser)) - { spellCaster = firstUser; } + { + spellCaster = firstUser; + } spellId = info->summoningRitual.spellId; @@ -1522,11 +1698,15 @@ void GameObject::Use(Unit* user) // finish owners spell if (owner) - { owner->FinishSpell(CURRENT_CHANNELED_SPELL); } + { + owner->FinishSpell(CURRENT_CHANNELED_SPELL); + } // can be deleted now, if if (!info->summoningRitual.ritualPersistent) - { SetLootState(GO_JUST_DEACTIVATED); } + { + SetLootState(GO_JUST_DEACTIVATED); + } // reset ritual for this GO else { ClearAllUsesData(); } @@ -1540,16 +1720,22 @@ void GameObject::Use(Unit* user) GameObjectInfo const* info = GetGOInfo(); if (!info) - { return; } + { + return; + } if (info->spellcaster.partyOnly) { Unit* caster = GetOwner(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } if (user->GetTypeId() != TYPEID_PLAYER || !((Player*)user)->IsInSameRaidWith((Player*)caster)) - { return; } + { + return; + } } spellId = info->spellcaster.spellId; @@ -1562,7 +1748,9 @@ void GameObject::Use(Unit* user) GameObjectInfo const* info = GetGOInfo(); if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; @@ -1570,16 +1758,22 @@ void GameObject::Use(Unit* user) // accept only use by player from same group for caster except caster itself if (!targetPlayer || targetPlayer == player || !targetPlayer->IsInSameGroupWith(player)) - { return; } + { + return; + } // required lvl checks! uint8 level = player->getLevel(); if (level < info->meetingstone.minLevel || level > info->meetingstone.maxLevel) - { return; } + { + return; + } level = targetPlayer->getLevel(); if (level < info->meetingstone.minLevel || level > info->meetingstone.maxLevel) - { return; } + { + return; + } if (info->id == 194097) spellId = 61994; // Ritual of Summoning @@ -1591,7 +1785,9 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_FLAGSTAND: // 24 { if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; @@ -1600,7 +1796,9 @@ void GameObject::Use(Unit* user) // in battleground check BattleGround* bg = player->GetBattleGround(); if (!bg) - { return; } + { + return; + } // BG flag click // AB: // 15001 @@ -1616,7 +1814,9 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_FISHINGHOLE: // 25 { if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; @@ -1627,7 +1827,9 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_FLAGDROP: // 26 { if (user->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* player = (Player*)user; @@ -1636,7 +1838,9 @@ void GameObject::Use(Unit* user) // in battleground check BattleGround* bg = player->GetBattleGround(); if (!bg) - { return; } + { + return; + } // BG flag dropped // WS: // 179785 - Silverwing Flag @@ -1652,7 +1856,9 @@ void GameObject::Use(Unit* user) case 179786: // Warsong Flag // check if it's correct bg if (bg->GetTypeID() == BATTLEGROUND_WS) - { bg->EventPlayerClickedOnFlag(player, this); } + { + bg->EventPlayerClickedOnFlag(player, this); + } break; case 184142: // Netherstorm Flag if (bg->GetTypeID() == BATTLEGROUND_EY) @@ -1692,7 +1898,9 @@ void GameObject::Use(Unit* user) } if (!spellId) - { return; } + { + return; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) @@ -1719,7 +1927,9 @@ const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const if (cl) { if (cl->Name.size() > (size_t)loc_idx && !cl->Name[loc_idx].empty()) - { return cl->Name[loc_idx].c_str(); } + { + return cl->Name[loc_idx].c_str(); + } } } @@ -1796,24 +2006,34 @@ bool GameObject::IsHostileTo(Unit const* unit) const { // always non-hostile to GM in GM mode if (unit->GetTypeId() == TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) - { return false; } + { + return false; + } // test owner instead if have if (Unit const* owner = GetOwner()) - { return owner->IsHostileTo(unit); } + { + return owner->IsHostileTo(unit); + } if (Unit const* targetOwner = unit->GetCharmerOrOwner()) - { return IsHostileTo(targetOwner); } + { + return IsHostileTo(targetOwner); + } // for not set faction case: be hostile towards player, not hostile towards not-players if (!GetGOInfo()->faction) - { return unit->IsControlledByPlayer(); } + { + return unit->IsControlledByPlayer(); + } // faction base cases FactionTemplateEntry const* tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction); FactionTemplateEntry const* target_faction = unit->getFactionTemplateEntry(); if (!tester_faction || !target_faction) - { return false; } + { + return false; + } // GvP forced reaction and reputation case if (unit->GetTypeId() == TYPEID_PLAYER) @@ -1822,12 +2042,16 @@ bool GameObject::IsHostileTo(Unit const* unit) const { // forced reaction if (ReputationRank const* force = ((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) - { return *force <= REP_HOSTILE; } + { + 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*)unit)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE; } + { + return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) <= REP_HOSTILE; + } } } @@ -1839,24 +2063,34 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const { // always friendly to GM in GM mode if (unit->GetTypeId() == TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) - { return true; } + { + return true; + } // test owner instead if have if (Unit const* owner = GetOwner()) - { return owner->IsFriendlyTo(unit); } + { + return owner->IsFriendlyTo(unit); + } if (Unit const* targetOwner = unit->GetCharmerOrOwner()) - { return IsFriendlyTo(targetOwner); } + { + return IsFriendlyTo(targetOwner); + } // for not set faction case (wild object) use hostile case if (!GetGOInfo()->faction) - { return false; } + { + return false; + } // faction base cases FactionTemplateEntry const* tester_faction = sFactionTemplateStore.LookupEntry(GetGOInfo()->faction); FactionTemplateEntry const* target_faction = unit->getFactionTemplateEntry(); if (!tester_faction || !target_faction) - { return false; } + { + return false; + } // GvP forced reaction and reputation case if (unit->GetTypeId() == TYPEID_PLAYER) @@ -1865,12 +2099,16 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const { // forced reaction if (ReputationRank const* force = ((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) - { return *force >= REP_FRIENDLY; } + { + 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*)unit)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY; } + { + return ((Player const*)unit)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY; + } } } @@ -1912,7 +2150,9 @@ void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update) void GameObject::UpdateCollisionState() const { if (!m_model || !IsInWorld()) - { return; } + { + return; + } m_model->enable(IsCollisionEnabled() ? GetPhaseMask() : 0); } @@ -1920,12 +2160,16 @@ void GameObject::UpdateCollisionState() const void GameObject::UpdateModel() { if (m_model && IsInWorld() && GetMap()->ContainsGameObjectModel(*m_model)) - { GetMap()->RemoveGameObjectModel(*m_model); } + { + GetMap()->RemoveGameObjectModel(*m_model); + } delete m_model; m_model = GameObjectModel::construct(this); if (m_model) - { GetMap()->InsertGameObjectModel(*m_model); } + { + GetMap()->InsertGameObjectModel(*m_model); + } } void GameObject::StartGroupLoot(Group* group, uint32 timer) @@ -1937,10 +2181,14 @@ void GameObject::StartGroupLoot(Group* group, uint32 timer) void GameObject::StopGroupLoot() { if (!m_groupLootId) - { return; } + { + return; + } if (Group* group = sObjectMgr.GetGroupById(m_groupLootId)) - { group->EndRoll(); } + { + group->EndRoll(); + } m_groupLootTimer = 0; m_groupLootId = 0; @@ -1967,18 +2215,24 @@ Player* GameObject::GetLootRecipient() const // if group not set or disbanded return original recipient player if any if (!group) - { return player; } + { + return player; + } // group case // return player if it still be in original recipient group if (player && player->GetGroup() == group) - { return player; } + { + return player; + } // find any in group for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) if (Player* newPlayer = itr->getSource()) - { return newPlayer; } + { + return newPlayer; + } return NULL; } @@ -1999,14 +2253,18 @@ void GameObject::SetLootRecipient(Unit* pUnit) Player* player = pUnit->GetCharmerOrOwnerPlayerOrPlayerItself(); if (!player) // normal creature, no player involved - { return; } + { + return; + } // set player for non group case or if group will disbanded m_lootRecipientGuid = player->GetObjectGuid(); // set group for group existed case including if player will leave group at loot time if (Group* group = player->GetGroup()) - { m_lootGroupRecipientId = group->GetId(); } + { + m_lootGroupRecipientId = group->GetId(); + } ForceValuesUpdateAtIndex(UNIT_DYNAMIC_FLAGS); // needed to be sure tapping status is updated } @@ -2045,7 +2303,9 @@ struct AddGameObjectToRemoveListInMapsWorker void operator()(Map* map) { if (GameObject* pGameobject = map->GetGameObject(i_guid)) - { pGameobject->AddObjectToRemoveList(); } + { + pGameobject->AddObjectToRemoveList(); + } } ObjectGuid i_guid; @@ -2076,7 +2336,9 @@ struct SpawnGameObjectInMapsWorker else { if (pGameobject->isSpawnedByDefault()) - { map->Add(pGameobject); } + { + map->Add(pGameobject); + } } } } @@ -2104,11 +2366,15 @@ void GameObject::SetCapturePointSlider(float value, bool isLocked) // only activate non-locked capture point if (!isLocked) - { SetLootState(GO_ACTIVATED); } + { + SetLootState(GO_ACTIVATED); + } // set the state of the capture point based on the slider value if ((int)m_captureSlider == CAPTURE_SLIDER_ALLIANCE) - { m_captureState = CAPTURE_STATE_WIN_ALLIANCE; } + { + m_captureState = CAPTURE_STATE_WIN_ALLIANCE; + } else if ((int)m_captureSlider == CAPTURE_SLIDER_HORDE) { m_captureState = CAPTURE_STATE_WIN_HORDE; } else if (m_captureSlider > CAPTURE_SLIDER_MIDDLE + info->capturePoint.neutralPercent * 0.5f) @@ -2140,7 +2406,9 @@ void GameObject::TickCapturePoint() for (std::list::iterator itr = capturingPlayers.begin(); itr != capturingPlayers.end(); ++itr) { if ((*itr)->GetTeam() == ALLIANCE) - { ++rangePlayers; } + { + ++rangePlayers; + } else { --rangePlayers; } @@ -2162,7 +2430,9 @@ void GameObject::TickCapturePoint() { // send capture point leave packet if (Player* owner = GetMap()->GetPlayer(*itr)) - { owner->SendUpdateWorldState(info->capturePoint.worldState1, WORLD_STATE_REMOVE); } + { + owner->SendUpdateWorldState(info->capturePoint.worldState1, WORLD_STATE_REMOVE); + } // player left capture point zone m_UniqueUsers.erase(*itr); @@ -2173,7 +2443,9 @@ void GameObject::TickCapturePoint() { // set to inactive if all players left capture point zone if (m_UniqueUsers.empty()) - { SetActiveObjectState(false); } + { + SetActiveObjectState(false); + } return; } @@ -2183,7 +2455,9 @@ void GameObject::TickCapturePoint() // cap speed int maxSuperiority = info->capturePoint.maxSuperiority; if (rangePlayers > maxSuperiority) - { rangePlayers = maxSuperiority; } + { + rangePlayers = maxSuperiority; + } else if (rangePlayers < -maxSuperiority) { rangePlayers = -maxSuperiority; } @@ -2191,7 +2465,9 @@ void GameObject::TickCapturePoint() float deltaSlider = info->capturePoint.minTime; if (int deltaSuperiority = maxSuperiority - info->capturePoint.minSuperiority) - { deltaSlider += (float)(maxSuperiority - abs(rangePlayers)) / deltaSuperiority * (info->capturePoint.maxTime - info->capturePoint.minTime); } + { + deltaSlider += (float)(maxSuperiority - abs(rangePlayers)) / deltaSuperiority * (info->capturePoint.maxTime - info->capturePoint.minTime); + } // calculate changed slider value for a duration of 5 seconds (5 * 100%) deltaSlider = 500.0f / deltaSlider; @@ -2202,19 +2478,25 @@ void GameObject::TickCapturePoint() progressFaction = ALLIANCE; m_captureSlider += deltaSlider; if (m_captureSlider > CAPTURE_SLIDER_ALLIANCE) - { m_captureSlider = CAPTURE_SLIDER_ALLIANCE; } + { + m_captureSlider = CAPTURE_SLIDER_ALLIANCE; + } } else { progressFaction = HORDE; m_captureSlider -= deltaSlider; if (m_captureSlider < CAPTURE_SLIDER_HORDE) - { m_captureSlider = CAPTURE_SLIDER_HORDE; } + { + m_captureSlider = CAPTURE_SLIDER_HORDE; + } } // return if slider did not move a whole percent if ((int)m_captureSlider == oldValue) - { return; } + { + return; + } // on retail this is also sent to newly added players even though they already received a slider value for (std::list::iterator itr = capturingPlayers.begin(); itr != capturingPlayers.end(); ++itr) @@ -2246,7 +2528,9 @@ void GameObject::TickCapturePoint() // handle objective complete if (m_captureState == CAPTURE_STATE_NEUTRAL) if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript((*capturingPlayers.begin())->GetCachedZoneId())) - { outdoorPvP->HandleObjectiveComplete(eventId, capturingPlayers, progressFaction); } + { + outdoorPvP->HandleObjectiveComplete(eventId, capturingPlayers, progressFaction); + } // set capture state to alliance m_captureState = CAPTURE_STATE_PROGRESS_ALLIANCE; @@ -2259,7 +2543,9 @@ void GameObject::TickCapturePoint() // handle objective complete if (m_captureState == CAPTURE_STATE_NEUTRAL) if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript((*capturingPlayers.begin())->GetCachedZoneId())) - { outdoorPvP->HandleObjectiveComplete(eventId, capturingPlayers, progressFaction); } + { + outdoorPvP->HandleObjectiveComplete(eventId, capturingPlayers, progressFaction); + } // set capture state to horde m_captureState = CAPTURE_STATE_PROGRESS_HORDE; @@ -2294,7 +2580,9 @@ void GameObject::TickCapturePoint() } if (eventId) - { StartEvents_Event(GetMap(), eventId, this, this, true, *capturingPlayers.begin()); } + { + StartEvents_Event(GetMap(), eventId, this, this, true, *capturingPlayers.begin()); + } } // //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/game/Object/GameObject.h b/src/game/Object/GameObject.h index 62a9c17f9..0b01bdba7 100644 --- a/src/game/Object/GameObject.h +++ b/src/game/Object/GameObject.h @@ -690,7 +690,9 @@ class GameObject : public WorldObject { time_t now = time(NULL); if (m_respawnTime > now) - { return m_respawnTime; } + { + return m_respawnTime; + } else { return now; } } diff --git a/src/game/Object/GuardAI.cpp b/src/game/Object/GuardAI.cpp index 1fccb804b..97f72cc1e 100644 --- a/src/game/Object/GuardAI.cpp +++ b/src/game/Object/GuardAI.cpp @@ -31,7 +31,9 @@ int GuardAI::Permissible(const Creature* creature) { if (creature->IsGuard()) - { return PERMIT_BASE_SPECIAL; } + { + return PERMIT_BASE_SPECIAL; + } return PERMIT_BASE_NO; } @@ -44,7 +46,9 @@ void GuardAI::MoveInLineOfSight(Unit* u) { // Ignore Z for flying creatures if (!m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE) - { return; } + { + return; + } if (!m_creature->getVictim() && u->IsTargetableForAttack() && (u->IsHostileToPlayers() || m_creature->IsHostileTo(u) /*|| u->getVictim() && m_creature->IsFriendlyTo(u->getVictim())*/) && @@ -107,14 +111,18 @@ void GuardAI::EnterEvadeMode() // Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE) - { m_creature->GetMotionMaster()->MoveTargetedHome(); } + { + m_creature->GetMotionMaster()->MoveTargetedHome(); + } } void GuardAI::UpdateAI(const uint32 /*diff*/) { // update i_victimGuid if i_creature.getVictim() !=0 and changed if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) - { return; } + { + return; + } i_victimGuid = m_creature->getVictim()->GetObjectGuid(); @@ -130,7 +138,9 @@ bool GuardAI::IsVisible(Unit* pl) const void GuardAI::AttackStart(Unit* u) { if (!u) - { return; } + { + return; + } if (m_creature->Attack(u, true)) { @@ -146,5 +156,7 @@ void GuardAI::AttackStart(Unit* u) void GuardAI::JustDied(Unit* killer) { if (Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself()) - { m_creature->SendZoneUnderAttackMessage(pkiller); } + { + m_creature->SendZoneUnderAttackMessage(pkiller); + } } diff --git a/src/game/Object/Guild.cpp b/src/game/Object/Guild.cpp index 888f14f24..92b24e2e3 100644 --- a/src/game/Object/Guild.cpp +++ b/src/game/Object/Guild.cpp @@ -79,7 +79,9 @@ void MemberSlot::ChangeRank(uint32 newRank) Player* player = sObjectMgr.GetPlayer(guid); // If player not online data in data field will be loaded from guild tabs no need to update it !! if (player) - { player->SetRank(newRank); } + { + player->SetRank(newRank); + } CharacterDatabase.PExecute("UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, guid.GetCounter()); } @@ -117,11 +119,15 @@ Guild::~Guild() bool Guild::Create(Player* leader, std::string gname) { if (sGuildMgr.GetGuildByName(gname)) - { return false; } + { + return false; + } WorldSession* lSession = leader->GetSession(); if (!lSession) - { return false; } + { + return false; + } m_LeaderGuid = leader->GetObjectGuid(); m_Name = gname; @@ -179,12 +185,16 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank) if (pl) { if (pl->GetGuildId() != 0) - { return false; } + { + return false; + } } else { if (Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild - { return false; } + { + return false; + } } // remove all player signs from another petitions @@ -296,7 +306,9 @@ void Guild::SetGINFO(std::string ginfo) bool Guild::LoadGuildFromDB(QueryResult* guildDataResult) { if (!guildDataResult) - { return false; } + { + return false; + } Field* fields = guildDataResult->Fetch(); @@ -345,7 +357,9 @@ bool Guild::CheckGuildStructure() { MemberSlot &member = itr->second; if (member.RankId == GR_GUILDMASTER && m_LeaderGuid != member.guid) - { member.ChangeRank(GR_OFFICER); } + { + member.ChangeRank(GR_OFFICER); + } } return true; @@ -373,7 +387,9 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult) fields = guildRanksResult->Fetch(); // condition that would be true when all ranks in QueryResult will be processed and guild without ranks is being processed if (!fields) - { break; } + { + break; + } uint32 guildId = fields[0].GetUInt32(); if (guildId < m_Id) @@ -385,7 +401,9 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult) } if (guildId > m_Id) // we loaded all ranks for this guild already, break cycle - { break; } + { + break; + } uint32 rankID = fields[1].GetUInt32(); std::string rankName = fields[2].GetCppString(); @@ -393,11 +411,15 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult) uint32 rankMoney = fields[4].GetUInt32(); if (rankID != m_Ranks.size()) // guild_rank.ids are sequence 0,1,2,3.. - { broken_ranks = true; } + { + broken_ranks = true; + } // first rank is guildmaster, prevent loss leader rights if (m_Ranks.empty()) - { rankRights |= GR_RIGHT_ALL; } + { + rankRights |= GR_RIGHT_ALL; + } AddRank(rankName, rankRights, rankMoney); } @@ -432,14 +454,18 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult) bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult) { if (!guildMembersResult) - { return false; } + { + return false; + } do { Field* fields = guildMembersResult->Fetch(); // this condition will be true when all rows in QueryResult are processed and new guild without members is going to be loaded - prevent crash if (!fields) - { break; } + { + break; + } uint32 guildId = fields[0].GetUInt32(); if (guildId < m_Id) { @@ -459,7 +485,9 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult) newmember.RankId = fields[2].GetUInt32(); // don't allow member to have not existing rank! if (newmember.RankId >= m_Ranks.size()) - { newmember.RankId = GetLowestRank(); } + { + newmember.RankId = GetLowestRank(); + } newmember.Pnote = fields[3].GetCppString(); newmember.OFFnote = fields[4].GetCppString(); @@ -504,7 +532,9 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult) while (guildMembersResult->NextRow()); if (members.empty()) - { return false; } + { + return false; + } UpdateAccountsNumber(); @@ -515,7 +545,9 @@ void Guild::SetLeader(ObjectGuid guid) { MemberSlot* slot = GetMemberSlot(guid); if (!slot) - { return; } + { + return; + } m_LeaderGuid = guid; slot->ChangeRank(GR_GUILDMASTER); @@ -558,13 +590,17 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding) } if (!best) - { return true; } + { + return true; + } SetLeader(newLeaderGUID); // If player not online data in data field will be loaded from guild tabs no need to update it !! if (Player* newLeader = sObjectMgr.GetPlayer(newLeaderGUID)) - { newLeader->SetRank(GR_GUILDMASTER); } + { + newLeader->SetRank(GR_GUILDMASTER); + } // when leader non-exist (at guild load with deleted leader only) not send broadcasts if (oldLeader) @@ -588,7 +624,9 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding) CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid); if (!isDisbanding) - { UpdateAccountsNumber(); } + { + UpdateAccountsNumber(); + } // Used by Eluna #ifdef ENABLE_ELUNA @@ -612,11 +650,15 @@ bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank) void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language) { if (!session) - { return; } + { + return; + } Player* player = session->GetPlayer(); if (!player || !HasRankRight(player->GetRank(), GR_RIGHT_GCHATSPEAK)) - { return; } + { + return; + } WorldPacket data; ChatHandler::BuildChatPacket(data, CHAT_MSG_GUILD, msg.c_str(), Language(language), player->GetChatTag(), player->GetObjectGuid(), player->GetName()); @@ -626,7 +668,9 @@ void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint Player* pl = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(player->GetObjectGuid())) - { pl->GetSession()->SendPacket(&data); } + { + pl->GetSession()->SendPacket(&data); + } } } @@ -650,11 +694,15 @@ void Guild::BroadcastAddonToGuild(WorldSession* session, const std::string& msg, void Guild::BroadcastToOfficers(WorldSession* session, const std::string& msg, uint32 language) { if (!session) - { return; } + { + return; + } Player* player = session->GetPlayer(); if (!player || !HasRankRight(player->GetRank(), GR_RIGHT_OFFCHATSPEAK)) - { return; } + { + return; + } for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr) { @@ -691,7 +739,9 @@ void Guild::BroadcastPacket(WorldPacket* packet) { Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); if (player) - { player->GetSession()->SendPacket(packet); } + { + player->GetSession()->SendPacket(packet); + } } } @@ -703,7 +753,9 @@ void Guild::BroadcastPacketToRank(WorldPacket* packet, uint32 rankId) { Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); if (player) - { player->GetSession()->SendPacket(packet); } + { + player->GetSession()->SendPacket(packet); + } } } } @@ -744,7 +796,9 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max void Guild::CreateRank(std::string name_, uint32 rights) { if (m_Ranks.size() >= GUILD_RANKS_MAX_COUNT) - { return; } + { + return; + } // ranks are sequence 0,1,2,... where 0 means guildmaster uint32 new_rank_id = m_Ranks.size(); @@ -775,7 +829,9 @@ void Guild::DelRank(uint32 rankId) // 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) - { return; } + { + return; + } RankList::iterator itr = m_Ranks.erase(m_Ranks.begin() + rankId); // delete lowest guild_rank @@ -826,7 +882,9 @@ void Guild::SwitchRank(uint32 rankId, bool up) std::string Guild::GetRankName(uint32 rankId) { if (rankId >= m_Ranks.size()) - { return ""; } + { + return ""; + } return m_Ranks[rankId].Name; } @@ -834,7 +892,9 @@ std::string Guild::GetRankName(uint32 rankId) uint32 Guild::GetRankRights(uint32 rankId) { if (rankId >= m_Ranks.size()) - { return 0; } + { + return 0; + } return m_Ranks[rankId].Rights; } @@ -842,7 +902,9 @@ uint32 Guild::GetRankRights(uint32 rankId) void Guild::SetRankName(uint32 rankId, std::string name_) { if (rankId >= m_Ranks.size()) - { return; } + { + return; + } m_Ranks[rankId].Name = name_; @@ -854,7 +916,9 @@ void Guild::SetRankName(uint32 rankId, std::string name_) void Guild::SetRankRights(uint32 rankId, uint32 rights) { if (rankId >= m_Ranks.size()) - { return; } + { + return; + } m_Ranks[rankId].Rights = rights; @@ -980,7 +1044,9 @@ void Guild::Roster(WorldSession* session /*= NULL*/) data << uint32(0); if (session) - { session->SendPacket(&data); } + { + session->SendPacket(&data); + } else { BroadcastPacket(&data); } DEBUG_LOG("WORLD: Sent (SMSG_GUILD_ROSTER)"); @@ -996,7 +1062,9 @@ void Guild::Query(WorldSession* session) for (size_t i = 0 ; i < GUILD_RANKS_MAX_COUNT; ++i) // show always 10 ranks { if (i < m_Ranks.size()) - { data << m_Ranks[i].Name; } + { + data << m_Ranks[i].Name; + } else { data << uint8(0); } // null string } @@ -1079,7 +1147,9 @@ uint32 Guild::GetAccountsNumber() { // not need recalculation if (m_accountsNumber) - { return m_accountsNumber; } + { + return m_accountsNumber; + } // We use a set to be sure each element will be unique std::set accountsIdSet; @@ -1119,7 +1189,9 @@ void Guild::LoadGuildEventLogFromDB() // 0 1 2 3 4 5 QueryResult* result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS); if (!result) - { return; } + { + return; + } bool isNextLogGuidSet = false; // uint32 configCount = sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT); // First event in list will be the oldest and the latest event is last event in list @@ -1164,7 +1236,9 @@ void Guild::LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid pl m_GuildEventLogNextGuid = (m_GuildEventLogNextGuid + 1) % sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT); // Check max records limit if (m_GuildEventLog.size() >= GUILD_EVENTLOG_MAX_RECORDS) - { m_GuildEventLog.pop_front(); } + { + m_GuildEventLog.pop_front(); + } // Add event to list m_GuildEventLog.push_back(NewEvent); // Save event to DB diff --git a/src/game/Object/Guild.h b/src/game/Object/Guild.h index 70e2bdafe..7cd630d15 100644 --- a/src/game/Object/Guild.h +++ b/src/game/Object/Guild.h @@ -401,7 +401,9 @@ class Guild for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first))) if (player != except) - { _do(player); } + { + _do(player); + } } void CreateRank(std::string name, uint32 rights); @@ -443,7 +445,9 @@ class Guild { for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr) if (itr->second.Name == name) - { return &itr->second; } + { + return &itr->second; + } return NULL; } diff --git a/src/game/Object/Item.cpp b/src/game/Object/Item.cpp index 46558f6ea..3313b0925 100644 --- a/src/game/Object/Item.cpp +++ b/src/game/Object/Item.cpp @@ -47,7 +47,9 @@ void AddItemsSetItem(Player* player, Item* item) } if (set->required_skill_id && player->GetSkillValue(set->required_skill_id) < set->required_skill_value) - { return; } + { + return; + } ItemSetEffect* eff = NULL; @@ -69,10 +71,14 @@ void AddItemsSetItem(Player* player, Item* item) size_t x = 0; for (; x < player->ItemSetEff.size(); ++x) if (!player->ItemSetEff[x]) - { break; } + { + break; + } if (x < player->ItemSetEff.size()) - { player->ItemSetEff[x] = eff; } + { + player->ItemSetEff[x] = eff; + } else { player->ItemSetEff.push_back(eff); } } @@ -82,18 +88,26 @@ void AddItemsSetItem(Player* player, Item* item) for (uint32 x = 0; x < 8; ++x) { if (!set->spells[x]) - { continue; } + { + continue; + } // not enough for spell if (set->items_to_triggerspell[x] > eff->item_count) - { continue; } + { + continue; + } uint32 z = 0; for (; z < 8; ++z) if (eff->spells[z] && eff->spells[z]->Id == set->spells[x]) - { break; } + { + break; + } if (z < 8) - { continue; } + { + continue; + } // new spell for (uint32 y = 0; y < 8; ++y) @@ -141,18 +155,24 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto) // can be in case now enough skill requirement for set appling but set has been appliend when skill requirement not enough if (!eff) - { return; } + { + return; + } --eff->item_count; for (uint32 x = 0; x < 8; ++x) { if (!set->spells[x]) - { continue; } + { + continue; + } // enough for spell if (set->items_to_triggerspell[x] <= eff->item_count) - { continue; } + { + continue; + } for (uint32 z = 0; z < 8; ++z) { @@ -177,7 +197,9 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto) bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProto) { if (!pProto || !pBagProto) - { return false; } + { + return false; + } switch (pBagProto->Class) { @@ -188,15 +210,21 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt return true; case ITEM_SUBCLASS_SOUL_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_SOUL_SHARDS)) - { return false; } + { + return false; + } return true; case ITEM_SUBCLASS_HERB_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_HERBS)) - { return false; } + { + return false; + } return true; case ITEM_SUBCLASS_ENCHANTING_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_ENCHANTING_SUPP)) - { return false; } + { + return false; + } return true; case ITEM_SUBCLASS_MINING_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_MINING_SUPP)) @@ -204,7 +232,9 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt return true; case ITEM_SUBCLASS_ENGINEERING_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_ENGINEERING_SUPP)) - { return false; } + { + return false; + } return true; case ITEM_SUBCLASS_GEM_CONTAINER: if (!(pProto->BagFamily & BAG_FAMILY_GEMS)) @@ -230,11 +260,15 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt { case ITEM_SUBCLASS_QUIVER: if (!(pProto->BagFamily & BAG_FAMILY_ARROWS)) - { return false; } + { + return false; + } return true; case ITEM_SUBCLASS_AMMO_POUCH: if (!(pProto->BagFamily & BAG_FAMILY_BULLETS)) - { return false; } + { + return false; + } return true; default: return false; @@ -402,7 +436,9 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid); if (!itemProto) - { return false; } + { + return false; + } SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1); SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability); @@ -426,7 +462,9 @@ bool Item::IsNotEmptyBag() const void Item::UpdateDuration(Player* owner, uint32 diff) { if (!GetUInt32Value(ITEM_FIELD_DURATION)) - { return; } + { + return; + } // DEBUG_LOG("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff); @@ -546,11 +584,15 @@ void Item::SaveToDB() LootItem* item = loot.LootItemInSlot(i, owner, &qitem); if (!item) - { continue; } + { + continue; + } // questitems use the blocked field for other purposes if (!qitem && item->is_blocked) - { continue; } + { + continue; + } stmt.addUInt32(GetGUIDLow()); stmt.addUInt32(owner->GetGUIDLow()); @@ -565,7 +607,9 @@ void Item::SaveToDB() } if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY) - { SetLootState(ITEM_LOOT_UNCHANGED); } + { + SetLootState(ITEM_LOOT_UNCHANGED); + } SetState(ITEM_UNCHANGED); } @@ -596,14 +640,18 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid) ItemPrototype const* proto = GetProto(); if (!proto) - { return false; } + { + return false; + } // update max durability (and durability) if need if (proto->MaxDurability != GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) { SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability); if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability) - { SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability); } + { + SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability); + } need_save = true; } @@ -768,13 +816,17 @@ uint32 Item::GetSkill() { case ITEM_CLASS_WEAPON: if (proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON) - { return 0; } + { + return 0; + } else { return item_weapon_skills[proto->SubClass]; } case ITEM_CLASS_ARMOR: if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR) - { return 0; } + { + return 0; + } else { return item_armor_skills[proto->SubClass]; } @@ -788,7 +840,9 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id) ItemPrototype const* itemProto = sItemStorage.LookupEntry(item_id); if (!itemProto) - { return 0; } + { + return 0; + } // item must have one from this field values not null if it can have random enchantments if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix)) @@ -825,7 +879,9 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id) void Item::SetItemRandomProperties(int32 randomPropId) { if (!randomPropId) - { return; } + { + return; + } if (randomPropId > 0) { @@ -875,7 +931,9 @@ void Item::SetState(ItemUpdateState state, Player* forplayer) { // pretend the item never existed if (forplayer || GetOwnerGuid()) - { RemoveFromUpdateQueueOf(forplayer); } + { + RemoveFromUpdateQueueOf(forplayer); + } delete this; return; } @@ -886,7 +944,9 @@ void Item::SetState(ItemUpdateState state, Player* forplayer) if (uState != ITEM_NEW) { uState = state; } if (forplayer || GetOwnerGuid()) - { AddToUpdateQueueOf(forplayer); } + { + AddToUpdateQueueOf(forplayer); + } } else { @@ -900,7 +960,9 @@ void Item::SetState(ItemUpdateState state, Player* forplayer) void Item::AddToUpdateQueueOf(Player* player) { if (IsInUpdateQueue()) - { return; } + { + return; + } if (!player) { @@ -921,7 +983,9 @@ void Item::AddToUpdateQueueOf(Player* player) } if (player->m_itemUpdateQueueBlocked) - { return; } + { + return; + } player->m_itemUpdateQueue.push_back(this); uQueuePos = player->m_itemUpdateQueue.size() - 1; @@ -930,7 +994,9 @@ void Item::AddToUpdateQueueOf(Player* player) void Item::RemoveFromUpdateQueueOf(Player* player) { if (!IsInUpdateQueue()) - { return; } + { + return; + } if (!player) { @@ -951,7 +1017,9 @@ void Item::RemoveFromUpdateQueueOf(Player* player) } if (player->m_itemUpdateQueueBlocked) - { return; } + { + return; + } player->m_itemUpdateQueue[uQueuePos] = NULL; uQueuePos = -1; @@ -970,23 +1038,35 @@ bool Item::IsEquipped() const bool Item::CanBeTraded(bool mail) const { if ((!mail || !IsBoundAccountWide()) && IsSoulBound()) - { return false; } + { + return false; + } if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty())) - { return false; } + { + return false; + } if (Player* owner = GetOwner()) { if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK) - { return false; } + { + return false; + } if (owner->GetLootGuid() == GetObjectGuid()) - { return false; } + { + return false; + } } if (HasGeneratedLoot()) - { return false; } + { + return false; + } if (IsBoundByEnchant()) - { return false; } + { + return false; + } return true; } @@ -998,7 +1078,9 @@ bool Item::IsBoundByEnchant() const { uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) - { continue; } + { + continue; + } if (enchant_slot == TRANSMOGRIFY_ENCHANTMENT_SLOT) return true; @@ -1008,10 +1090,14 @@ bool Item::IsBoundByEnchant() const SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!enchantEntry) - { continue; } + { + continue; + } if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND) - { return true; } + { + return true; + } } return false; } @@ -1069,14 +1155,20 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget) ItemRequiredTargetMapBounds bounds = sObjectMgr.GetItemRequiredTargetMapBounds(GetProto()->ItemId); if (bounds.first == bounds.second) - { return true; } + { + return true; + } if (!pUnitTarget) - { return false; } + { + return false; + } for (ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) if (itr->second.IsFitToRequirements(pUnitTarget)) - { return true; } + { + return true; + } return false; } @@ -1085,7 +1177,9 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint { // Better lost small time at check in comparison lost time at item save to DB. if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges)) - { return; } + { + return; + } if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT) { @@ -1106,7 +1200,9 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration) { if (GetEnchantmentDuration(slot) == duration) - { return; } + { + return; + } SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration); SetState(ITEM_CHANGED); @@ -1115,7 +1211,9 @@ void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration) void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges) { if (GetEnchantmentCharges(slot) == charges) - { return; } + { + return; + } SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges); SetState(ITEM_CHANGED); @@ -1124,7 +1222,9 @@ void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges) void Item::ClearEnchantment(EnchantmentSlot slot) { if (!GetEnchantmentId(slot)) - { return; } + { + return; + } for (uint8 x = 0; x < 3; ++x) SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + x, 0); @@ -1241,7 +1341,9 @@ void Item::SendTimeUpdate(Player* owner) uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION); if (!duration) - { return; } + { + return; + } WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4)); data << ObjectGuid(GetObjectGuid()); @@ -1257,7 +1359,9 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 r if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item)) { if (count > pProto->GetMaxStackSize()) - { count = pProto->GetMaxStackSize(); } + { + count = pProto->GetMaxStackSize(); + } MANGOS_ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already"); @@ -1266,7 +1370,9 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 r { pItem->SetCount(count); if (uint32 randId = randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item)) - { pItem->SetItemRandomProperties(randId); } + { + pItem->SetItemRandomProperties(randId); + } return pItem; } @@ -1280,7 +1386,9 @@ Item* Item::CloneItem(uint32 count, Player const* player) const { Item* newItem = CreateItem(GetEntry(), count, player, GetItemRandomPropertyId()); if (!newItem) - { return NULL; } + { + return NULL; + } newItem->SetGuidValue(ITEM_FIELD_CREATOR, GetGuidValue(ITEM_FIELD_CREATOR)); newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR)); @@ -1293,15 +1401,21 @@ bool Item::IsBindedNotWith(Player const* player) const { // own item if (GetOwnerGuid() == player->GetObjectGuid()) - { return false; } + { + return false; + } // has loot with diff owner if (HasGeneratedLoot()) - { return true; } + { + return true; + } // not binded item if (!IsSoulBound()) - { return false; } + { + return false; + } // not BOA item case if (!IsBoundAccountWide()) @@ -1322,19 +1436,25 @@ bool Item::IsBindedNotWith(Player const* player) const void Item::AddToClientUpdateList() { if (Player* pl = GetOwner()) - { pl->GetMap()->AddUpdateObject(this); } + { + pl->GetMap()->AddUpdateObject(this); + } } void Item::RemoveFromClientUpdateList() { if (Player* pl = GetOwner()) - { pl->GetMap()->RemoveUpdateObject(this); } + { + pl->GetMap()->RemoveUpdateObject(this); + } } void Item::BuildUpdateData(UpdateDataMapType& update_players) { if (Player* pl = GetOwner()) - { BuildUpdateDataForPlayer(pl, update_players); } + { + BuildUpdateDataForPlayer(pl, update_players); + } ClearUpdateMask(false); } @@ -1343,15 +1463,21 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const { // check item type if (GetEntry() != proto->ItemId) - { return EQUIP_ERR_ITEM_CANT_STACK; } + { + return EQUIP_ERR_ITEM_CANT_STACK; + } // check free space (full stacks can't be target of merge if (GetCount() >= proto->GetMaxStackSize()) - { return EQUIP_ERR_ITEM_CANT_STACK; } + { + return EQUIP_ERR_ITEM_CANT_STACK; + } // not allow merge looting currently items if (HasGeneratedLoot()) - { return EQUIP_ERR_ALREADY_LOOTED; } + { + return EQUIP_ERR_ALREADY_LOOTED; + } return EQUIP_ERR_OK; } @@ -1359,10 +1485,14 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const bool ItemRequiredTarget::IsFitToRequirements(Unit* pUnitTarget) const { if (pUnitTarget->GetTypeId() != TYPEID_UNIT) - { return false; } + { + return false; + } if (pUnitTarget->GetEntry() != m_uiTargetEntry) - { return false; } + { + return false; + } switch (m_uiType) { @@ -1418,12 +1548,16 @@ void Item::SetLootState(ItemLootUpdateState state) case ITEM_LOOT_CHANGED: // new loot must stay in new state until saved, temporary must stay until remove if (m_lootState != ITEM_LOOT_NEW && m_lootState != ITEM_LOOT_TEMPORARY) - { m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state; } + { + m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state; + } break; case ITEM_LOOT_UNCHANGED: // expected that called after DB update or load if (m_lootState == ITEM_LOOT_REMOVED) - { m_lootState = ITEM_LOOT_NONE; } + { + m_lootState = ITEM_LOOT_NONE; + } // temporary must stay until remove (ignore any changes) else if (m_lootState != ITEM_LOOT_TEMPORARY) { m_lootState = ITEM_LOOT_UNCHANGED; } @@ -1441,7 +1575,9 @@ void Item::SetLootState(ItemLootUpdateState state) } if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_UNCHANGED && m_lootState != ITEM_LOOT_TEMPORARY) - { SetState(ITEM_CHANGED); } + { + SetState(ITEM_CHANGED); + } } uint32 Item::GetScriptId() const diff --git a/src/game/Object/LootMgr.cpp b/src/game/Object/LootMgr.cpp index f8a40401c..15995a5b1 100644 --- a/src/game/Object/LootMgr.cpp +++ b/src/game/Object/LootMgr.cpp @@ -150,7 +150,9 @@ void LootStore::LoadLootTable() LootStoreItem storeitem = LootStoreItem(item, type, chanceOrQuestChance, group, conditionId, mincountOrRef, maxcount); if (!storeitem.IsValid(*this, entry)) // Validity checks - { continue; } + { + continue; + } // Looking for the template of the entry // often entries are put together @@ -191,7 +193,9 @@ bool LootStore::HaveQuestLootFor(uint32 loot_id) const { LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id); if (itr == m_LootTemplates.end()) - { return false; } + { + return false; + } // scan loot for quest items return itr->second->HasQuestDrop(m_LootTemplates); @@ -202,7 +206,9 @@ bool LootStore::HaveQuestLootForPlayer(uint32 loot_id, Player* player) const LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id); if (tab != m_LootTemplates.end()) if (tab->second->HasQuestDropForPlayer(m_LootTemplates, player)) - { return true; } + { + return true; + } return false; } @@ -212,7 +218,9 @@ LootTemplate const* LootStore::GetLootFor(uint32 loot_id) const LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id); if (tab == m_LootTemplates.end()) - { return NULL; } + { + return NULL; + } return tab->second; } @@ -256,10 +264,14 @@ void LootStore::ReportNotExistedId(uint32 id) const bool LootStoreItem::Roll(bool rate) const { if (chance >= 100.0f) - { return true; } + { + return true; + } if (mincountOrRef < 0) // reference case - { return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); } + { + return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); + } if (type == LOOTITEM_TYPE_CURRENCY) return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_CURRENCY) : 1.0f)); @@ -430,41 +442,57 @@ bool LootItem::AllowedForPlayer(Player const* player, WorldObject const* lootTar { ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); if (!pProto) - { return false; } + { + return false; + } // not show loot for not own team if ((pProto->Flags2 & ITEM_FLAG2_HORDE_ONLY) && player->GetTeam() != HORDE) - { return false; } + { + return false; + } if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE) - { return false; } + { + return false; + } if (needs_quest) { // Checking quests for quest-only drop (check only quests requirements in this case) if (!player->HasQuestForItem(itemid)) - { return false; } + { + return false; + } } else { // Not quest only drop (check quest starting items for already accepted non-repeatable quests) if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid)) - { return false; } + { + return false; + } } } else if (type == LOOT_ITEM_TYPE_CURRENCY) { CurrencyTypesEntry const * currency = sCurrencyTypesStore.LookupEntry(itemid); if (!itemid) - { return false; } + { + return false; + } if (!player->isGameMaster()) { if (currency->Category == CURRENCY_CATEGORY_META) - { return false; } + { + return false; + } if (currency->Category == CURRENCY_CATEGORY_ARCHAEOLOGY && !player->HasSkill(SKILL_ARCHAEOLOGY)) - { return false; } + { + return false; + } } } @@ -475,7 +503,9 @@ LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Play { // ignore currencies, looted items, FFA (each player get own copy) and not allowed items if (currency || is_looted || freeforall || (conditionId && !condition_ok) || !AllowedForPlayer(viewer, lootTarget)) - { return MAX_LOOT_SLOT_TYPE; } + { + return MAX_LOOT_SLOT_TYPE; + } switch (permission) { @@ -502,7 +532,9 @@ void Loot::AddItem(LootStoreItem const& item) if (item.needs_quest) // Quest drop { if (m_questItems.size() < MAX_NR_QUEST_ITEMS) - { m_questItems.push_back(LootItem(item)); } + { + m_questItems.push_back(LootItem(item)); + } } else if (items.size() < MAX_NR_LOOT_ITEMS) // Non-quest drop { @@ -516,7 +548,9 @@ void Loot::AddItem(LootStoreItem const& item) { ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item.itemid); if (!proto || !(proto->Flags & ITEM_FLAG_PARTY_LOOT)) - { ++unlootedCount; } + { + ++unlootedCount; + } } } } @@ -526,14 +560,18 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, { // Must be provided if (!loot_owner) - { return false; } + { + return false; + } LootTemplate const* tab = store.GetLootFor(loot_id); if (!tab) { if (!noEmptyError) - { sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.", store.GetName(), loot_id); } + { + sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.", store.GetName(), loot_id); + } return false; } @@ -548,7 +586,9 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, { for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) if (Player* pl = itr->getSource()) - { FillNotNormalLootFor(pl); } + { + FillNotNormalLootFor(pl); + } } // ... for personal loot else @@ -567,11 +607,15 @@ void Loot::FillNotNormalLootFor(Player* pl) qmapitr = m_playerQuestItems.find(plguid); if (qmapitr == m_playerQuestItems.end()) - { FillQuestLoot(pl); } + { + FillQuestLoot(pl); + } qmapitr = m_playerFFAItems.find(plguid); if (qmapitr == m_playerFFAItems.end()) - { FillFFALoot(pl); } + { + FillFFALoot(pl); + } qmapitr = m_playerNonQuestNonFFANonCurrencyConditionalItems.find(plguid); if (qmapitr == m_playerNonQuestNonFFANonCurrencyConditionalItems.end()) @@ -641,12 +685,16 @@ QuestItemList* Loot::FillQuestLoot(Player* player) // // increase once if one looter only, looter-times if free for all if (item.freeforall || !item.is_blocked) - { ++unlootedCount; } + { + ++unlootedCount; + } item.is_blocked = true; if (items.size() + ql->size() == MAX_NR_LOOT_ITEMS) - { break; } + { + break; + } } } if (ql->empty()) @@ -698,7 +746,9 @@ void Loot::NotifyItemRemoved(uint8 lootIndex) i_next = i; ++i_next; if (Player* pl = ObjectAccessor::FindPlayer(*i)) - { pl->SendNotifyLootItemRemoved(lootIndex); } + { + pl->SendNotifyLootItemRemoved(lootIndex); + } else { m_playersLooting.erase(i); } } @@ -713,7 +763,9 @@ void Loot::NotifyMoneyRemoved() i_next = i; ++i_next; if (Player* pl = ObjectAccessor::FindPlayer(*i)) - { pl->SendNotifyLootMoneyRemoved(); } + { + pl->SendNotifyLootMoneyRemoved(); + } else { m_playersLooting.erase(i); } } @@ -742,10 +794,14 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) uint8 j; for (j = 0; j < pql.size(); ++j) if (pql[j].index == questIndex) - { break; } + { + break; + } if (j < pql.size()) - { pl->SendNotifyLootItemRemoved(items.size() + j); } + { + pl->SendNotifyLootItemRemoved(items.size() + j); + } } } else @@ -758,7 +814,9 @@ void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount) if (maxAmount > 0) { if (maxAmount <= minAmount) - { gold = uint32(maxAmount * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); } + { + 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)); } else @@ -778,7 +836,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite { QuestItem* qitem2 = &itr->second->at(questSlot); if (qitem) - { *qitem = qitem2; } + { + *qitem = qitem2; + } item = &m_questItems[qitem2->index]; is_looted = qitem2->is_looted; } @@ -815,7 +875,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite { QuestItem* ffaitem2 = (QuestItem*) & (*iter); if (ffaitem) - { *ffaitem = ffaitem2; } + { + *ffaitem = ffaitem2; + } is_looted = ffaitem2->is_looted; break; } @@ -832,7 +894,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite { QuestItem* conditem2 = (QuestItem*) & (*iter); if (conditem) - { *conditem = conditem2; } + { + *conditem = conditem2; + } is_looted = conditem2->is_looted; break; } @@ -842,7 +906,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite } if (is_looted) - { return NULL; } + { + return NULL; + } return item; } @@ -899,7 +965,9 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) { LootSlotType slot_type = l.items[i].GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget()); if (slot_type >= MAX_LOOT_SLOT_TYPE) - { continue; } + { + continue; + } b << uint8(i) << l.items[i]; b << uint8(slot_type); // 0 - get 1 - look only 2 - master selection @@ -917,7 +985,9 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget(), !ci->is_looted); if (slot_type >= MAX_LOOT_SLOT_TYPE) - { continue; } + { + continue; + } b << uint8(ci->index) << item; b << uint8(slot_type); // allow loot @@ -994,7 +1064,9 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) void LootTemplate::LootGroup::AddEntry(LootStoreItem& item) { if (item.chance != 0) - { ExplicitlyChanced.push_back(item); } + { + ExplicitlyChanced.push_back(item); + } else { EqualChanced.push_back(item); } } @@ -1009,15 +1081,21 @@ LootStoreItem const* LootTemplate::LootGroup::Roll() const for (uint32 i = 0; i < ExplicitlyChanced.size(); ++i) // check each explicitly chanced entry in the template and modify its chance based on quality. { if (ExplicitlyChanced[i].chance >= 100.0f) - { return &ExplicitlyChanced[i]; } + { + return &ExplicitlyChanced[i]; + } Roll -= ExplicitlyChanced[i].chance; if (Roll < 0) - { return &ExplicitlyChanced[i]; } + { + return &ExplicitlyChanced[i]; + } } } if (!EqualChanced.empty()) // If nothing selected yet - an item is taken from equal-chanced part - { return &EqualChanced[irand(0, EqualChanced.size() - 1)]; } + { + return &EqualChanced[irand(0, EqualChanced.size() - 1)]; + } return NULL; // Empty drop from the group } @@ -1027,10 +1105,14 @@ bool LootTemplate::LootGroup::HasQuestDrop() const { for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) if (i->needs_quest) - { return true; } + { + return true; + } for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i) if (i->needs_quest) - { return true; } + { + return true; + } return false; } @@ -1039,10 +1121,14 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const { for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) if (player->HasQuestForItem(i->itemid)) - { return true; } + { + return true; + } for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i) if (player->HasQuestForItem(i->itemid)) - { return true; } + { + return true; + } return false; } @@ -1051,7 +1137,9 @@ void LootTemplate::LootGroup::Process(Loot& loot) const { LootStoreItem const* item = Roll(); if (item != NULL) - { loot.AddItem(*item); } + { + loot.AddItem(*item); + } } // Overall chance for the group without equal chanced items @@ -1061,7 +1149,9 @@ float LootTemplate::LootGroup::RawTotalChance() const for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) if (!i->needs_quest) - { result += i->chance; } + { + result += i->chance; + } return result; } @@ -1072,7 +1162,9 @@ float LootTemplate::LootGroup::TotalChance() const float result = RawTotalChance(); if (!EqualChanced.empty() && result < 100.0f) - { return 100.0f; } + { + return 100.0f; + } return result; } @@ -1098,7 +1190,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const if (ieItr->mincountOrRef < 0) { if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) - { LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); } + { + LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); + } else if (ref_set) { ref_set->erase(-ieItr->mincountOrRef); } } @@ -1109,7 +1203,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const if (ieItr->mincountOrRef < 0) { if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) - { LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); } + { + LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); + } else if (ref_set) { ref_set->erase(-ieItr->mincountOrRef); } } @@ -1160,7 +1256,9 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8 // Check condition if (i->conditionId && !sObjectMgr.IsPlayerMeetToCondition(i->conditionId, NULL, NULL, loot.GetLootTarget(), CONDITION_FROM_REFERING_LOOT)) - { continue; } + { + continue; + } for (uint32 loop = 0; loop < i->maxcount; ++loop) // Ref multiplicator { Referenced->Process(loot, store, rate, i->group); } @@ -1192,7 +1290,9 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con if (Referenced == store.end()) { continue; } // Error message [should be] already printed at loading stage if (Referenced->second->HasQuestDrop(store, i->group)) - { return true; } + { + return true; + } } else if (i->needs_quest) { return true; } // quest drop found @@ -1201,7 +1301,9 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con // Now processing groups for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i) if (i->HasQuestDrop()) - { return true; } + { + return true; + } return false; } @@ -1225,7 +1327,9 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co if (Referenced == store.end()) { continue; } // Error message already printed at loading stage if (Referenced->second->HasQuestDropForPlayer(store, player, i->group)) - { return true; } + { + return true; + } } else if (player->HasQuestForItem(i->itemid)) { return true; } // active quest drop found @@ -1234,7 +1338,9 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co // Now checking groups for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i) if (i->HasQuestDropForPlayer(player)) - { return true; } + { + return true; + } return false; } @@ -1256,7 +1362,9 @@ void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const if (ieItr->mincountOrRef < 0) { if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef)) - { LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); } + { + LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); + } else if (ref_set) { ref_set->erase(-ieItr->mincountOrRef); } } @@ -1279,7 +1387,9 @@ void LoadLootTemplates_Creature() if (uint32 lootid = cInfo->LootId) { if (ids_set.find(lootid) == ids_set.end()) - { LootTemplates_Creature.ReportNotExistedId(lootid); } + { + LootTemplates_Creature.ReportNotExistedId(lootid); + } else { ids_setUsed.insert(lootid); } } @@ -1309,7 +1419,9 @@ void LoadLootTemplates_Disenchant() if (uint32 lootid = proto->DisenchantID) { if (ids_set.find(lootid) == ids_set.end()) - { LootTemplates_Disenchant.ReportNotExistedId(lootid); } + { + LootTemplates_Disenchant.ReportNotExistedId(lootid); + } else { ids_setUsed.insert(lootid); } } @@ -1331,7 +1443,9 @@ void LoadLootTemplates_Fishing() { if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i)) if (ids_set.find(areaEntry->ID) != ids_set.end()) - { ids_set.erase(areaEntry->ID); } + { + ids_set.erase(areaEntry->ID); + } } // by default (look config options) fishing at fail provide junk loot, entry 0 use for store this loot @@ -1352,7 +1466,9 @@ void LoadLootTemplates_Gameobject() if (uint32 lootid = itr->GetLootId()) { if (ids_set.find(lootid) == ids_set.end()) - { LootTemplates_Gameobject.ReportNotExistedId(lootid); } + { + LootTemplates_Gameobject.ReportNotExistedId(lootid); + } else { ids_setUsed.insert(lootid); } } @@ -1375,10 +1491,14 @@ void LoadLootTemplates_Item() if (ItemPrototype const* proto = sItemStorage.LookupEntry(i)) { if (!(proto->Flags & ITEM_FLAG_LOOTABLE)) - { continue; } + { + continue; + } if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0) - { ids_set.erase(proto->ItemId); } + { + ids_set.erase(proto->ItemId); + } // wdb have wrong data cases, so skip by default else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) { LootTemplates_Item.ReportNotExistedId(proto->ItemId); } @@ -1427,7 +1547,9 @@ void LoadLootTemplates_Pickpocketing() if (uint32 lootid = cInfo->PickpocketLootId) { if (ids_set.find(lootid) == ids_set.end()) - { LootTemplates_Pickpocketing.ReportNotExistedId(lootid); } + { + LootTemplates_Pickpocketing.ReportNotExistedId(lootid); + } else { ids_setUsed.insert(lootid); } } @@ -1474,7 +1596,9 @@ void LoadLootTemplates_Mail() for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i) if (sMailTemplateStore.LookupEntry(i)) if (ids_set.find(i) != ids_set.end()) - { ids_set.erase(i); } + { + ids_set.erase(i); + } // output error for any still listed (not referenced from appropriate table) ids LootTemplates_Mail.ReportUnusedIds(ids_set); @@ -1493,7 +1617,9 @@ void LoadLootTemplates_Skinning() if (uint32 lootid = cInfo->SkinningLootId) { if (ids_set.find(lootid) == ids_set.end()) - { LootTemplates_Skinning.ReportNotExistedId(lootid); } + { + LootTemplates_Skinning.ReportNotExistedId(lootid); + } else { ids_setUsed.insert(lootid); } } diff --git a/src/game/Object/Object.cpp b/src/game/Object/Object.cpp index d426cbb57..589f38810 100644 --- a/src/game/Object/Object.cpp +++ b/src/game/Object/Object.cpp @@ -98,7 +98,9 @@ void Object::_InitValues() void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh) { if (!m_uint32Values) - { _InitValues(); } + { + _InitValues(); + } ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow); SetGuidValue(OBJECT_FIELD_GUID, guid); @@ -114,7 +116,9 @@ void Object::SetObjectScale(float newScale) void Object::SendForcedObjectUpdate() { if (!m_inWorld || !m_objectUpdated) - { return; } + { + return; + } UpdateDataMapType update_players; @@ -133,14 +137,18 @@ void Object::SendForcedObjectUpdate() void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const { if (!target) - { return; } + { + return; + } uint8 updatetype = UPDATETYPE_CREATE_OBJECT; uint16 updateFlags = m_updateFlag; /** lower flag1 **/ if (target == this) // building packet for yourself - { updateFlags |= UPDATEFLAG_SELF; } + { + updateFlags |= UPDATEFLAG_SELF; + } if (m_itsNewObject) { @@ -518,7 +526,9 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 updateFlags) const void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* updateMask, Player* target) const { if (!target) - { return; } + { + return; + } uint32 valuesCount = m_valuesCount; if(GetTypeId() == TYPEID_PLAYER && target != this) @@ -532,7 +542,9 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport()) { if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster()) - { IsActivateToQuest = true; } + { + IsActivateToQuest = true; + } updateMask->SetBit(GAMEOBJECT_DYNAMIC); } @@ -550,7 +562,9 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport()) { if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster()) - { IsActivateToQuest = true; } + { + IsActivateToQuest = true; + } updateMask->SetBit(GAMEOBJECT_DYNAMIC); updateMask->SetBit(GAMEOBJECT_BYTES_1); // why do we need this here? @@ -595,7 +609,9 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u if (appendValue & UNIT_NPC_FLAG_STABLEMASTER) { if (target->getClass() != CLASS_HUNTER) - { appendValue &= ~UNIT_NPC_FLAG_STABLEMASTER; } + { + appendValue &= ~UNIT_NPC_FLAG_STABLEMASTER; + } } } @@ -656,14 +672,18 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u /* If we're not allowed to loot the target, destroy the lootable flag */ if (!target->isAllowedToLoot((Creature*)this)) if (send_value & UNIT_DYNFLAG_LOOTABLE) - { send_value = send_value & ~UNIT_DYNFLAG_LOOTABLE; } + { + send_value = send_value & ~UNIT_DYNFLAG_LOOTABLE; + } /* If we are allowed to loot it and mob is tapped by us, destroy the tapped flag */ bool is_tapped = target->IsTappedByMeOrMyGroup((Creature*)this); /* If the creature has tapped flag but is tapped by us, remove the flag */ if (send_value & UNIT_DYNFLAG_TAPPED && is_tapped) - { send_value = send_value & ~UNIT_DYNFLAG_TAPPED; } + { + send_value = send_value & ~UNIT_DYNFLAG_TAPPED; + } *data << send_value; } @@ -753,7 +773,9 @@ void Object::ClearUpdateMask(bool remove) if (m_objectUpdated) { if (remove) - { RemoveFromClientUpdateList(); } + { + RemoveFromClientUpdateList(); + } m_objectUpdated = false; } } @@ -765,7 +787,9 @@ bool Object::LoadValues(const char* data) Tokens tokens = StrSplit(data, " "); if (tokens.size() != m_valuesCount) - { return false; } + { + return false; + } Tokens::iterator iter; int index; @@ -785,7 +809,9 @@ void Object::_SetUpdateBits(UpdateMask* updateMask, Player* target) const for (uint16 index = 0; index < valuesCount; ++index ) if (m_changedValues[index]) - { updateMask->SetBit(index); } + { + updateMask->SetBit(index); + } } void Object::_SetCreateBits(UpdateMask* updateMask, Player* target) const @@ -796,7 +822,9 @@ void Object::_SetCreateBits(UpdateMask* updateMask, Player* target) const for (uint16 index = 0; index < valuesCount; ++index) if (GetUInt32Value(index) != 0) - { updateMask->SetBit(index); } + { + updateMask->SetBit(index); + } } void Object::SetInt32Value(uint16 index, int32 value) @@ -897,7 +925,9 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value) void Object::SetStatFloatValue(uint16 index, float value) { if (value < 0) - { value = 0.0f; } + { + value = 0.0f; + } SetFloatValue(index, value); } @@ -905,7 +935,9 @@ void Object::SetStatFloatValue(uint16 index, float value) void Object::SetStatInt32Value(uint16 index, int32 value) { if (value < 0) - { value = 0; } + { + value = 0; + } SetUInt32Value(index, uint32(value)); } @@ -915,7 +947,9 @@ void Object::ApplyModUInt32Value(uint16 index, int32 val, bool apply) int32 cur = GetUInt32Value(index); cur += (apply ? val : -val); if (cur < 0) - { cur = 0; } + { + cur = 0; + } SetUInt32Value(index, cur); } @@ -938,7 +972,9 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply) float cur = GetFloatValue(index); cur += (apply ? val : -val); if (cur < 0) - { cur = 0; } + { + cur = 0; + } SetFloatValue(index, cur); } @@ -1145,7 +1181,9 @@ void WorldObject::Relocate(float x, float y, float z, float orientation) m_position.o = NormalizeOrientation(orientation); if (isType(TYPEMASK_UNIT)) - { ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, orientation); } + { + ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, orientation); + } } void WorldObject::Relocate(float x, float y, float z) @@ -1155,7 +1193,9 @@ void WorldObject::Relocate(float x, float y, float z) m_position.z = z; if (isType(TYPEMASK_UNIT)) - { ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation()); } + { + ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation()); + } } void WorldObject::SetOrientation(float orientation) @@ -1163,7 +1203,9 @@ void WorldObject::SetOrientation(float orientation) m_position.o = NormalizeOrientation(orientation); if (isType(TYPEMASK_UNIT)) - { ((Unit*)this)->m_movementInfo.ChangeOrientation(orientation); } + { + ((Unit*)this)->m_movementInfo.ChangeOrientation(orientation); + } } uint32 WorldObject::GetZoneId() const @@ -1330,7 +1372,9 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan { float mindist = minRange + sizefactor; if (distsq < mindist * mindist) - { return false; } + { + return false; + } } float maxdist = maxRange + sizefactor; @@ -1350,7 +1394,9 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange) { float mindist = minRange + sizefactor; if (distsq < mindist * mindist) - { return false; } + { + return false; + } } float maxdist = maxRange + sizefactor; @@ -1371,7 +1417,9 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m { float mindist = minRange + sizefactor; if (distsq < mindist * mindist) - { return false; } + { + return false; + } } float maxdist = maxRange + sizefactor; @@ -1381,7 +1429,9 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m float WorldObject::GetAngle(const WorldObject* obj) const { if (!obj) - { return 0.0f; } + { + return 0.0f; + } // Rework the assert, when more cases where such a call can happen have been fixed // MANGOS_ASSERT(obj != this || PrintEntryError("GetAngle (for self)")); @@ -1408,7 +1458,9 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const { // always have self in arc if (obj == this) - { return true; } + { + return true; + } float arc = arcangle; @@ -1421,7 +1473,9 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const // move angle to range -pi ... +pi angle = NormalizeOrientation(angle); if (angle > M_PI_F) - { angle -= 2.0f * M_PI_F; } + { + angle -= 2.0f * M_PI_F; + } float lborder = -1 * (arc / 2.0f); // in range -pi..0 float rborder = (arc / 2.0f); // in range 0..pi @@ -1490,7 +1544,9 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap /*=NULL*/) const { if (!atMap) - { atMap = GetMap(); } + { + atMap = GetMap(); + } switch (GetTypeId()) { @@ -1508,7 +1564,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap if (max_z > INVALID_HEIGHT) { if (z > max_z) - { z = max_z; } + { + z = max_z; + } else if (z < ground_z) { z = ground_z; } } @@ -1517,7 +1575,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap { float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z); if (z < ground_z) - { z = ground_z; } + { + z = ground_z; + } } break; } @@ -1531,7 +1591,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap if (max_z > INVALID_HEIGHT) { if (z > max_z) - { z = max_z; } + { + z = max_z; + } else if (z < ground_z) { z = ground_z; } } @@ -1548,7 +1610,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap { float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z); if (ground_z > INVALID_HEIGHT) - { z = ground_z; } + { + z = ground_z; + } break; } } @@ -1586,7 +1650,9 @@ void WorldObject::MonsterTextEmote(const char* text, Unit const* target, bool Is void WorldObject::MonsterWhisper(const char* text, Unit const* target, bool IsBossWhisper) const { if (!target || target->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } WorldPacket data(SMSG_MESSAGECHAT, 200); ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(), @@ -1605,7 +1671,9 @@ namespace MaNGOS { char const* text = NULL; if ((int32)i_textData->Content.size() > loc_idx + 1 && !i_textData->Content[loc_idx + 1].empty()) - { text = i_textData->Content[loc_idx + 1].c_str(); } + { + text = i_textData->Content[loc_idx + 1].c_str(); + } else { text = i_textData->Content[0].c_str(); } @@ -1653,7 +1721,9 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta case CHAT_TYPE_WHISPER: { if (!target || target->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_WHISPER, textData, LANG_UNIVERSAL, target); MaNGOS::LocalizedPacketDo say_do(say_build); say_do((Player*)target); @@ -1662,7 +1732,9 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta case CHAT_TYPE_BOSS_WHISPER: { if (!target || target->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_RAID_BOSS_WHISPER, textData, LANG_UNIVERSAL, target); MaNGOS::LocalizedPacketDo say_do(say_build); say_do((Player*)target); @@ -1676,7 +1748,9 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta Map::PlayerList const& pList = GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) if (itr->getSource()->GetZoneId() == zoneid) - { say_do(itr->getSource()); } + { + say_do(itr->getSource()); + } break; } } @@ -1686,14 +1760,18 @@ void WorldObject::SendMessageToSet(WorldPacket* data, bool /*bToSelf*/) const { // if object is in world, map for it already created! if (IsInWorld()) - { GetMap()->MessageBroadcast(this, data); } + { + GetMap()->MessageBroadcast(this, data); + } } void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*bToSelf*/) const { // if object is in world, map for it already created! if (IsInWorld()) - { GetMap()->MessageDistBroadcast(this, data, dist); } + { + GetMap()->MessageDistBroadcast(this, data, dist); + } } void WorldObject::SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver) const @@ -1768,12 +1846,16 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa Team team = TEAM_NONE; if (GetTypeId() == TYPEID_PLAYER) - { team = ((Player*)this)->GetTeam(); } + { + team = ((Player*)this)->GetTeam(); + } CreatureCreatePos pos(GetMap(), x, y, z, ang, GetPhaseMask()); if (x == 0.0f && y == 0.0f && z == 0.0f) - { pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); } + { + pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); + } if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, team)) { @@ -1792,7 +1874,9 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa pCreature->Summon(spwtype, despwtime); // Also initializes the AI and MMGen if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) - { ((Creature*)this)->AI()->JustSummoned(pCreature); } + { + ((Creature*)this)->AI()->JustSummoned(pCreature); + } #ifdef ENABLE_ELUNA if (Unit* summoner = ToUnit()) @@ -1801,7 +1885,9 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa // Creature Linking, Initial load is handled like respawn if (pCreature->IsLinkingEventTrigger()) - { GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature); } + { + GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature); + } // return the creature therewith the summoner has access to it return pCreature; @@ -1847,7 +1933,9 @@ namespace MaNGOS { // skip self or target if (c == i_searcher || c == &i_object) - { return; } + { + return; + } float x, y, z; @@ -1865,7 +1953,9 @@ namespace MaNGOS { // skip self or target if (u == i_searcher || u == &i_object) - { return; } + { + return; + } float x, y; @@ -1885,19 +1975,25 @@ namespace MaNGOS // It is ok for the objects to require a bit more space float delta = u->GetObjectBoundingRadius(); if (i_selector.m_searchPosFor && i_selector.m_searchPosFor != u) - { delta += i_selector.m_searchPosFor->GetObjectBoundingRadius(); } + { + delta += i_selector.m_searchPosFor->GetObjectBoundingRadius(); + } delta *= OCCUPY_POS_DEPTH_FACTOR; // Increase by factor // u is too near/far away from i_object. Do not consider it to occupy space if (fabs(i_selector.m_searcherDist - dist2d) > delta) - { return; } + { + return; + } float angle = i_object.GetAngle(u) - i_absAngle; // move angle to range -pi ... +pi, range before is -2Pi..2Pi if (angle > M_PI_F) - { angle -= 2.0f * M_PI_F; } + { + angle -= 2.0f * M_PI_F; + } else if (angle < -M_PI_F) { angle += 2.0f * M_PI_F; } @@ -1964,7 +2060,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, { UpdateGroundPositionZ(x, y, z); } if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) - { return; } + { + return; + } first_los_conflict = true; // first point have LOS problems } @@ -1986,7 +2084,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, { UpdateGroundPositionZ(x, y, z); } if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) - { return; } + { + return; + } } // BAD NEWS: not free pos (or used or have LOS problems) @@ -2018,7 +2118,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, { UpdateGroundPositionZ(x, y, z); } if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z)) - { return; } + { + return; + } } // BAD BAD NEWS: all found pos (free and used) have LOS problem :( @@ -2046,7 +2148,9 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player const* target /*= NU data << GetObjectGuid(); data << GetObjectGuid(); if (target) - { target->SendDirectMessage(&data); } + { + target->SendDirectMessage(&data); + } else { SendMessageToSet(&data, true); } } @@ -2057,7 +2161,9 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL data << uint32(sound_id); data << ObjectGuid(); if (target) - { target->SendDirectMessage(&data); } + { + target->SendDirectMessage(&data); + } else { SendMessageToSet(&data, true); } } @@ -2067,7 +2173,9 @@ void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) co WorldPacket data(SMSG_PLAY_MUSIC, 4); data << uint32(sound_id); if (target) - { target->SendDirectMessage(&data); } + { + target->SendDirectMessage(&data); + } else { SendMessageToSet(&data, true); } } @@ -2106,7 +2214,9 @@ struct WorldObjectChangeAccumulator // send self fields changes in another way, otherwise // with new camera system when player's camera too far from player, camera wouldn't receive packets and changes from player if (i_object.isType(TYPEMASK_PLAYER)) - { i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas); } + { + i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas); + } } void Visit(CameraMapType& m) @@ -2115,7 +2225,9 @@ struct WorldObjectChangeAccumulator { Player* owner = iter->getSource()->GetOwner(); if (owner != &i_object && owner->HaveAtClient(&i_object)) - { i_object.BuildUpdateDataForPlayer(owner, i_updateDatas); } + { + i_object.BuildUpdateDataForPlayer(owner, i_updateDatas); + } } } @@ -2157,14 +2269,18 @@ bool WorldObject::PrintCoordinatesError(float x, float y, float z, char const* d void WorldObject::SetActiveObjectState(bool active) { if (m_isActiveObject == active || (isType(TYPEMASK_PLAYER) && !active)) // player shouldn't became inactive, never - { return; } + { + return; + } if (IsInWorld() && !isType(TYPEMASK_PLAYER)) // player's update implemented in a different from other active worldobject's way // it's considired to use generic way in future { if (IsActiveObject() && !active) - { GetMap()->RemoveFromActive(this); } + { + GetMap()->RemoveFromActive(this); + } else if (!IsActiveObject() && active) { GetMap()->AddToActive(this); } } diff --git a/src/game/Object/Object.h b/src/game/Object/Object.h index 8916ab01a..4582d145a 100644 --- a/src/game/Object/Object.h +++ b/src/game/Object/Object.h @@ -128,7 +128,9 @@ class WorldUpdateCounter time_t timeElapsed() { if (!m_tmStart) - { m_tmStart = WorldTimer::tickPrevTime(); } + { + m_tmStart = WorldTimer::tickPrevTime(); + } return WorldTimer::getMSTimeDiff(m_tmStart, WorldTimer::tickTime()); } @@ -148,7 +150,9 @@ class Object virtual void AddToWorld() { if (m_inWorld) - { return; } + { + return; + } m_inWorld = true; @@ -284,7 +288,9 @@ class Object void ToggleFlag(uint16 index, uint32 flag) { if (HasFlag(index, flag)) - { RemoveFlag(index, flag); } + { + RemoveFlag(index, flag); + } else { SetFlag(index, flag); } } @@ -306,7 +312,9 @@ class Object void ApplyModFlag(uint16 index, uint32 flag, bool apply) { if (apply) - { SetFlag(index, flag); } + { + SetFlag(index, flag); + } else { RemoveFlag(index, flag); } } @@ -317,7 +325,9 @@ class Object void ToggleByteFlag(uint16 index, uint8 offset, uint8 flag) { if (HasByteFlag(index, offset, flag)) - { RemoveByteFlag(index, offset, flag); } + { + RemoveByteFlag(index, offset, flag); + } else { SetByteFlag(index, offset, flag); } } @@ -332,7 +342,9 @@ class Object void ApplyModByteFlag(uint16 index, uint8 offset, uint32 flag, bool apply) { if (apply) - { SetByteFlag(index, offset, flag); } + { + SetByteFlag(index, offset, flag); + } else { RemoveByteFlag(index, offset, flag); } } @@ -343,7 +355,9 @@ class Object void ToggleShortFlag(uint16 index, bool highpart, uint8 flag) { if (HasShortFlag(index, highpart, flag)) - { RemoveShortFlag(index, highpart, flag); } + { + RemoveShortFlag(index, highpart, flag); + } else { SetShortFlag(index, highpart, flag); } } @@ -357,7 +371,9 @@ class Object void ApplyModShortFlag(uint16 index, bool highpart, uint32 flag, bool apply) { if (apply) - { SetShortFlag(index, highpart, flag); } + { + SetShortFlag(index, highpart, flag); + } else { RemoveShortFlag(index, highpart, flag); } } @@ -379,7 +395,9 @@ class Object void ToggleFlag64(uint16 index, uint64 flag) { if (HasFlag64(index, flag)) - { RemoveFlag64(index, flag); } + { + RemoveFlag64(index, flag); + } else { SetFlag64(index, flag); } } @@ -393,7 +411,9 @@ class Object void ApplyModFlag64(uint16 index, uint64 flag, bool apply) { if (apply) - { SetFlag64(index, flag); } + { + SetFlag64(index, flag); + } else { RemoveFlag64(index, flag); } } diff --git a/src/game/Object/ObjectAccessor.cpp b/src/game/Object/ObjectAccessor.cpp index a218cb2ec..30d5783e3 100644 --- a/src/game/Object/ObjectAccessor.cpp +++ b/src/game/Object/ObjectAccessor.cpp @@ -59,13 +59,19 @@ Unit* ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid) { if (!guid) - { return NULL; } + { + return NULL; + } if (guid.IsPlayer()) - { return FindPlayer(guid); } + { + return FindPlayer(guid); + } if (!u.IsInWorld()) - { return NULL; } + { + return NULL; + } return u.GetMap()->GetAnyTypeCreature(guid); } @@ -74,9 +80,13 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid) { Corpse* ret = HashMapHolder::Find(guid); if (!ret) - { return NULL; } + { + return NULL; + } if (ret->GetMapId() != mapid) - { return NULL; } + { + return NULL; + } return ret; } @@ -84,11 +94,15 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid) Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/) { if (!guid) - { return NULL; } + { + return NULL; + } Player* plr = HashMapHolder::Find(guid); if (!plr || (!plr->IsInWorld() && inWorld)) - { return NULL; } + { + return NULL; + } return plr; } @@ -99,7 +113,9 @@ Player* ObjectAccessor::FindPlayerByName(const char* name) HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); for (HashMapHolder::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) if (iter->second->IsInWorld() && (::strcmp(name, iter->second->GetName()) == 0)) - { return iter->second; } + { + return iter->second; + } return NULL; } @@ -130,7 +146,9 @@ ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid) Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid); if (iter == i_player2corpse.end()) - { return NULL; } + { + return NULL; + } MANGOS_ASSERT(iter->second->GetType() != CORPSE_BONES); return iter->second; @@ -145,7 +163,9 @@ ObjectAccessor::RemoveCorpse(Corpse* corpse) Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid()); if (iter == i_player2corpse.end()) - { return; } + { + return; + } // build mapid*cellid -> guid_set map CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY()); @@ -218,7 +238,9 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia) // do not load the map if it's not loaded Map* map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId()); if (map) - { map->Remove(corpse, false); } + { + map->Remove(corpse, false); + } // remove corpse from DB corpse->DeleteFromDB(); @@ -250,7 +272,9 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia) for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) { if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i)) - { bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); } + { + bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); + } } // add bones in grid store if grid loaded where corpse placed @@ -273,7 +297,9 @@ void ObjectAccessor::RemoveOldCorpses() ++next; if (!itr->second->IsExpired(now)) - { continue; } + { + continue; + } ConvertCorpseForPlayer(itr->first); } diff --git a/src/game/Object/ObjectGuid.cpp b/src/game/Object/ObjectGuid.cpp index 7c5332102..d275ffea9 100644 --- a/src/game/Object/ObjectGuid.cpp +++ b/src/game/Object/ObjectGuid.cpp @@ -60,12 +60,16 @@ std::string ObjectGuid::GetString() const { std::string name; if (sObjectMgr.GetPlayerNameByGUID(*this, name)) - { str << " " << name; } + { + str << " " << name; + } } str << " ("; if (HasEntry()) - { str << (IsPet() ? "Petnumber: " : "Entry: ") << GetEntry() << " "; } + { + str << (IsPet() ? "Petnumber: " : "Entry: ") << GetEntry() << " "; + } str << "Guid: " << GetCounter() << ")"; return str.str(); } diff --git a/src/game/Object/ObjectMgr.cpp b/src/game/Object/ObjectMgr.cpp index 4d433a729..e4a98d206 100644 --- a/src/game/Object/ObjectMgr.cpp +++ b/src/game/Object/ObjectMgr.cpp @@ -65,20 +65,26 @@ INSTANTIATE_SINGLETON_1(ObjectMgr); bool normalizePlayerName(std::string& name) { if (name.empty()) - { return false; } + { + return false; + } wchar_t wstr_buf[MAX_INTERNAL_PLAYER_NAME + 1]; size_t wstr_len = MAX_INTERNAL_PLAYER_NAME; if (!Utf8toWStr(name, &wstr_buf[0], wstr_len)) - { return false; } + { + return false; + } wstr_buf[0] = wcharToUpper(wstr_buf[0]); for (size_t i = 1; i < wstr_len; ++i) { wstr_buf[i] = wcharToLower(wstr_buf[i]); } if (!WStrToUtf8(wstr_buf, wstr_len, name)) - { return false; } + { + return false; + } return true; } @@ -113,7 +119,9 @@ LanguageDesc const* GetLanguageDescByID(uint32 lang) for (int i = 0; i < LANGUAGES_COUNT; ++i) { if (uint32(lang_description[i].lang_id) == lang) - { return &lang_description[i]; } + { + return &lang_description[i]; + } } return NULL; @@ -201,7 +209,9 @@ Group* ObjectMgr::GetGroupById(uint32 id) const { GroupMap::const_iterator itr = mGroupMap.find(id); if (itr != mGroupMap.end()) - { return itr->second; } + { + return itr->second; + } return NULL; } @@ -276,7 +286,9 @@ void ObjectMgr::LoadCreatureLocales() if (idx >= 0) { if ((int32)data.Name.size() <= idx) - { data.Name.resize(idx + 1); } + { + data.Name.resize(idx + 1); + } data.Name[idx] = str; } @@ -288,7 +300,9 @@ void ObjectMgr::LoadCreatureLocales() if (idx >= 0) { if ((int32)data.SubName.size() <= idx) - { data.SubName.resize(idx + 1); } + { + data.SubName.resize(idx + 1); + } data.SubName[idx] = str; } @@ -367,7 +381,9 @@ void ObjectMgr::LoadGossipMenuItemsLocales() if (idx >= 0) { if ((int32)data.OptionText.size() <= idx) - { data.OptionText.resize(idx + 1); } + { + data.OptionText.resize(idx + 1); + } data.OptionText[idx] = str; } @@ -379,7 +395,9 @@ void ObjectMgr::LoadGossipMenuItemsLocales() if (idx >= 0) { if ((int32)data.BoxText.size() <= idx) - { data.BoxText.resize(idx + 1); } + { + data.BoxText.resize(idx + 1); + } data.BoxText[idx] = str; } @@ -432,13 +450,17 @@ void ObjectMgr::LoadPointOfInterestLocales() { std::string str = fields[i].GetCppString(); if (str.empty()) - { continue; } + { + continue; + } int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.IconName.size() <= idx) - { data.IconName.resize(idx + 1); } + { + data.IconName.resize(idx + 1); + } data.IconName[idx] = str; } @@ -477,7 +499,9 @@ void ObjectMgr::LoadCreatureTemplates() { CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i); if (!cInfo) - { continue; } + { + continue; + } bool ok = true; // bool to allow continue outside this loop for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) @@ -581,11 +605,15 @@ void ObjectMgr::LoadCreatureTemplates() FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->FactionAlliance); if (!factionTemplate) - { sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_A template (%u)", cInfo->Entry, cInfo->FactionAlliance); } + { + sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_A template (%u)", cInfo->Entry, cInfo->FactionAlliance); + } factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->FactionHorde); if (!factionTemplate) - { sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_H template (%u)", cInfo->Entry, cInfo->FactionHorde); } + { + sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_H template (%u)", cInfo->Entry, cInfo->FactionHorde); + } for (int k = 0; k < MAX_KILL_CREDIT; ++k) { @@ -617,7 +645,9 @@ void ObjectMgr::LoadCreatureTemplates() CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(cInfo->ModelId[i]); if (!minfo) - { sLog.outErrorDb("Creature (Entry: %u) are using modelid_%d (%u), but creature_model_info are missing for this model.", cInfo->Entry, i + 1, cInfo->ModelId[i]); } + { + sLog.outErrorDb("Creature (Entry: %u) are using modelid_%d (%u), but creature_model_info are missing for this model.", cInfo->Entry, i + 1, cInfo->ModelId[i]); + } } } @@ -694,7 +724,9 @@ void ObjectMgr::LoadCreatureTemplates() } if ((cInfo->NpcFlags & UNIT_NPC_FLAG_TRAINER) && cInfo->TrainerType >= MAX_TRAINER_TYPE) - { sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u", cInfo->Entry, cInfo->TrainerType); } + { + sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u", cInfo->Entry, cInfo->TrainerType); + } if (cInfo->CreatureType && !sCreatureTypeStore.LookupEntry(cInfo->CreatureType)) { @@ -719,7 +751,9 @@ void ObjectMgr::LoadCreatureTemplates() { CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId); if (!spellDataId) - { sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId); } + { + sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId); + } } if (cInfo->MovementType >= MAX_DB_MOTION_TYPE) @@ -753,7 +787,9 @@ void ObjectMgr::LoadCreatureTemplates() if (cInfo->Scale <= 0.0f) { if (displayScaleEntry) - { const_cast(cInfo)->Scale = displayScaleEntry->Scale; } + { + const_cast(cInfo)->Scale = displayScaleEntry->Scale; + } else { const_cast(cInfo)->Scale = DEFAULT_OBJECT_SCALE; } } @@ -778,7 +814,9 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* } } if (p != s) - { val.push_back(atoi(s)); } + { + val.push_back(atoi(s)); + } // free char* loaded memory delete[](char*)reinterpret_cast(addon->auras); @@ -852,7 +890,9 @@ void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entry { CreatureDataAddon const* addon = creatureaddons.LookupEntry(i); if (!addon) - { continue; } + { + continue; + } if (addon->mount) { @@ -864,7 +904,9 @@ void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entry } if (addon->sheath_state > SHEATH_STATE_RANGED) - { sLog.outErrorDb("Creature (%s %u) has unknown sheath state (%u) defined in `%s`.", entryName, addon->guidOrEntry, addon->sheath_state, creatureaddons.GetTableName()); } + { + sLog.outErrorDb("Creature (%s %u) has unknown sheath state (%u) defined in `%s`.", entryName, addon->guidOrEntry, addon->sheath_state, creatureaddons.GetTableName()); + } if (!sEmotesStore.LookupEntry(addon->emote)) { @@ -884,7 +926,9 @@ void ObjectMgr::LoadCreatureAddons() for (uint32 i = 1; i < sCreatureInfoAddonStorage.GetMaxEntry(); ++i) if (CreatureDataAddon const* addon = sCreatureInfoAddonStorage.LookupEntry(i)) if (!sCreatureStorage.LookupEntry(addon->guidOrEntry)) - { sLog.outErrorDb("Creature (Entry: %u) does not exist but has a record in `%s`", addon->guidOrEntry, sCreatureInfoAddonStorage.GetTableName()); } + { + sLog.outErrorDb("Creature (Entry: %u) does not exist but has a record in `%s`", addon->guidOrEntry, sCreatureInfoAddonStorage.GetTableName()); + } LoadCreatureAddons(sCreatureDataAddonStorage, "GUID", "creature addons"); @@ -892,7 +936,9 @@ void ObjectMgr::LoadCreatureAddons() for (uint32 i = 1; i < sCreatureDataAddonStorage.GetMaxEntry(); ++i) if (CreatureDataAddon const* addon = sCreatureDataAddonStorage.LookupEntry(i)) if (mCreatureDataMap.find(addon->guidOrEntry) == mCreatureDataMap.end()) - { sLog.outErrorDb("Creature (GUID: %u) does not exist but has a record in `creature_addon`", addon->guidOrEntry); } + { + sLog.outErrorDb("Creature (GUID: %u) does not exist but has a record in `creature_addon`", addon->guidOrEntry); + } } void ObjectMgr::LoadCreatureClassLvlStats() @@ -994,12 +1040,16 @@ void ObjectMgr::LoadEquipmentTemplates() EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry(i); if (!eqInfo) - { continue; } + { + continue; + } for (uint8 j = 0; j < 3; ++j) { if (!eqInfo->equipentry[j]) - { continue; } + { + continue; + } ItemEntry const* dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]); if (!dbcitem) @@ -1043,7 +1093,9 @@ CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_ { CreatureModelInfo const* minfo = GetCreatureModelInfo(display_id); if (!minfo) - { return NULL; } + { + return NULL; + } // If a model for another gender exists, 50% chance to use it if (minfo->modelid_other_gender != 0 && urand(0, 1) == 0) @@ -1095,10 +1147,14 @@ void ObjectMgr::LoadCreatureModelInfo() { CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(i); if (!minfo) - { continue; } + { + continue; + } if (!sCreatureDisplayInfoStore.LookupEntry(minfo->modelid)) - { sLog.outErrorDb("Table `creature_model_info` has model for nonexistent model id (%u).", minfo->modelid); } + { + sLog.outErrorDb("Table `creature_model_info` has model for nonexistent model id (%u).", minfo->modelid); + } if (minfo->gender >= MAX_GENDER) { @@ -1140,18 +1196,26 @@ void ObjectMgr::LoadCreatureModelInfo() { ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race); if (!raceEntry) - { continue; } + { + continue; + } if (!((1 << (race - 1)) & RACEMASK_ALL_PLAYABLE)) - { continue; } + { + continue; + } if (CreatureModelInfo const* minfo = GetCreatureModelInfo(raceEntry->model_f)) { if (minfo->gender != GENDER_FEMALE) - { sLog.outErrorDb("Table `creature_model_info` have wrong gender %u for character race %u female model id %u", minfo->gender, race, raceEntry->model_f); } + { + sLog.outErrorDb("Table `creature_model_info` have wrong gender %u for character race %u female model id %u", minfo->gender, race, raceEntry->model_f); + } if (minfo->modelid_other_gender != raceEntry->model_m) - { sLog.outErrorDb("Table `creature_model_info` have wrong other gender model id %u for character race %u female model id %u", minfo->modelid_other_gender, race, raceEntry->model_f); } + { + sLog.outErrorDb("Table `creature_model_info` have wrong other gender model id %u for character race %u female model id %u", minfo->modelid_other_gender, race, raceEntry->model_f); + } if (minfo->bounding_radius <= 0.0f) { @@ -1171,10 +1235,14 @@ void ObjectMgr::LoadCreatureModelInfo() if (CreatureModelInfo const* minfo = GetCreatureModelInfo(raceEntry->model_m)) { if (minfo->gender != GENDER_MALE) - { sLog.outErrorDb("Table `creature_model_info` have wrong gender %u for character race %u male model id %u", minfo->gender, race, raceEntry->model_m); } + { + sLog.outErrorDb("Table `creature_model_info` have wrong gender %u for character race %u male model id %u", minfo->gender, race, raceEntry->model_m); + } if (minfo->modelid_other_gender != raceEntry->model_f) - { sLog.outErrorDb("Table `creature_model_info` have wrong other gender model id %u for character race %u male model id %u", minfo->modelid_other_gender, race, raceEntry->model_m); } + { + sLog.outErrorDb("Table `creature_model_info` have wrong other gender model id %u for character race %u male model id %u", minfo->modelid_other_gender, race, raceEntry->model_m); + } if (minfo->bounding_radius <= 0.0f) { @@ -1827,7 +1895,9 @@ Team ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const { // prevent DB access for online player if (Player* player = GetPlayer(guid)) - { return Player::TeamForRace(player->getRace()); } + { + return Player::TeamForRace(player->getRace()); + } uint32 lowguid = guid.GetCounter(); @@ -1846,11 +1916,15 @@ Team ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const { if (!guid.IsPlayer()) - { return 0; } + { + return 0; + } // prevent DB access for online player if (Player* player = GetPlayer(guid)) - { return player->GetSession()->GetAccountId(); } + { + return player->GetSession()->GetAccountId(); + } uint32 lowguid = guid.GetCounter(); @@ -1921,7 +1995,9 @@ void ObjectMgr::LoadItemLocales() if (idx >= 0) { if ((int32)data.Name.size() <= idx) - { data.Name.resize(idx + 1); } + { + data.Name.resize(idx + 1); + } data.Name[idx] = str; } @@ -1934,7 +2010,9 @@ void ObjectMgr::LoadItemLocales() if (idx >= 0) { if ((int32)data.Description.size() <= idx) - { data.Description.resize(idx + 1); } + { + data.Description.resize(idx + 1); + } data.Description[idx] = str; } @@ -2131,10 +2209,14 @@ void ObjectMgr::LoadItemPrototypes() if (req) { if (!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE)) - { sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped or use.", i, proto->AllowableClass); } + { + sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped or use.", i, proto->AllowableClass); + } if (!(proto->AllowableRace & RACEMASK_ALL_PLAYABLE)) - { sLog.outErrorDb("Item (Entry: %u) not have in `AllowableRace` any playable races (%u) and can't be equipped or use.", i, proto->AllowableRace); } + { + sLog.outErrorDb("Item (Entry: %u) not have in `AllowableRace` any playable races (%u) and can't be equipped or use.", i, proto->AllowableRace); + } } } @@ -2145,7 +2227,9 @@ void ObjectMgr::LoadItemPrototypes() } if (proto->RequiredReputationRank >= MAX_REPUTATION_RANK) - { sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.", i, proto->RequiredReputationRank); } + { + sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.", i, proto->RequiredReputationRank); + } if (proto->RequiredReputationFaction) { @@ -2156,7 +2240,9 @@ void ObjectMgr::LoadItemPrototypes() } if (proto->RequiredReputationRank == MIN_REPUTATION_RANK) - { sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", i); } + { + sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.", i); + } } else if (proto->RequiredReputationRank > MIN_REPUTATION_RANK) sLog.outErrorDb("Item (Entry: %u) has RequiredReputationFaction ==0 but RequiredReputationRank > 0, rank setting is useless.", i); @@ -2348,16 +2434,22 @@ void ObjectMgr::LoadItemPrototypes() } if (proto->Bonding >= MAX_BIND_TYPE) - { sLog.outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)", i, proto->Bonding); } + { + sLog.outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)", i, proto->Bonding); + } if (proto->PageText) { if (!sPageTextStore.LookupEntry(proto->PageText)) - { sLog.outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i, proto->PageText); } + { + sLog.outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i, proto->PageText); + } } if (proto->LockID && !sLockStore.LookupEntry(proto->LockID)) - { sLog.outErrorDb("Item (Entry: %u) has wrong LockID (%u)", i, proto->LockID); } + { + sLog.outErrorDb("Item (Entry: %u) has wrong LockID (%u)", i, proto->LockID); + } if (proto->Sheath >= MAX_SHEATHETYPE) { @@ -2392,10 +2484,14 @@ void ObjectMgr::LoadItemPrototypes() } if (proto->Area && !GetAreaEntryByAreaID(proto->Area)) - { sLog.outErrorDb("Item (Entry: %u) has wrong Area (%u)", i, proto->Area); } + { + sLog.outErrorDb("Item (Entry: %u) has wrong Area (%u)", i, proto->Area); + } if (proto->Map && !sMapStore.LookupEntry(proto->Map)) - { sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)", i, proto->Map); } + { + sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)", i, proto->Map); + } if (proto->BagFamily) { @@ -2509,7 +2605,9 @@ void ObjectMgr::LoadItemPrototypes() if (proto->ExtraFlags) { if (proto->ExtraFlags & ~ITEM_EXTRA_ALL) - { sLog.outErrorDb("Item (Entry: %u) has wrong ExtraFlags (%u) with unused bits set", i, proto->ExtraFlags); } + { + sLog.outErrorDb("Item (Entry: %u) has wrong ExtraFlags (%u) with unused bits set", i, proto->ExtraFlags); + } if (proto->ExtraFlags & ITEM_EXTRA_NON_CONSUMABLE) { @@ -2547,18 +2645,24 @@ void ObjectMgr::LoadItemPrototypes() { CharStartOutfitEntry const* entry = sCharStartOutfitStore.LookupEntry(i); if (!entry) - { continue; } + { + continue; + } for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j) { if (entry->ItemId[j] <= 0) - { continue; } + { + continue; + } uint32 item_id = entry->ItemId[j]; if (!GetItemPrototype(item_id)) if (item_id != 40582) // nonexistent item by default but referenced in DBC, skip it from errors - { notFoundOutfit.insert(item_id); } + { + notFoundOutfit.insert(item_id); + } } } @@ -2741,7 +2845,9 @@ void ObjectMgr::LoadItemRequiredTarget() { SQLMultiStorage::SQLMSIteratorBounds bounds = sSpellScriptTargetStorage.getBounds(pSpellInfo->Id); if (bounds.first != bounds.second) - { break; } + { + break; + } for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { @@ -2759,7 +2865,9 @@ void ObjectMgr::LoadItemRequiredTarget() } } if (bIsItemSpellValid) - { break; } + { + break; + } } } } @@ -2837,7 +2945,9 @@ void ObjectMgr::LoadPetLevelInfo() if (current_level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum - { sLog.outErrorDb("Wrong (> %u) level %u in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level); } + { + sLog.outErrorDb("Wrong (> %u) level %u in `pet_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level); + } else { DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `pet_levelstats` table, ignoring.", current_level); @@ -2854,7 +2964,9 @@ void ObjectMgr::LoadPetLevelInfo() PetLevelInfo*& pInfoMapEntry = petInfo[creature_id]; if (pInfoMapEntry == NULL) - { pInfoMapEntry = new PetLevelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)]; } + { + pInfoMapEntry = new PetLevelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)]; + } // data for level 1 stored in [0] array element, ... PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1]; @@ -2907,11 +3019,15 @@ void ObjectMgr::LoadPetLevelInfo() PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) const { if (level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) - { level = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); } + { + level = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); + } PetLevelInfoMap::const_iterator itr = petInfo.find(creature_id); if (itr == petInfo.end()) - { return NULL; } + { + return NULL; + } return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ... } @@ -3183,7 +3299,9 @@ void ObjectMgr::LoadPlayerInfo() uint8 action_type = fields[4].GetUInt8(); if (!Player::IsActionButtonDataValid(action_button, action, action_type, NULL)) - { continue; } + { + continue; + } PlayerInfo* pInfo = &playerInfo[current_race][current_class]; pInfo->action.push_back(PlayerCreateInfoAction(action_button, action, action_type)); @@ -3245,7 +3363,9 @@ void ObjectMgr::LoadPlayerInfo() if (current_level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum - { sLog.outErrorDb("Wrong (> %u) level %u in `player_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level); } + { + sLog.outErrorDb("Wrong (> %u) level %u in `player_levelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level); + } else { DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_levelstats` table, ignoring.", current_level); @@ -3257,7 +3377,9 @@ void ObjectMgr::LoadPlayerInfo() PlayerInfo* pInfo = &playerInfo[current_race][current_class]; if (!pInfo->levelInfo) - { pInfo->levelInfo = new PlayerLevelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)]; } + { + pInfo->levelInfo = new PlayerLevelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)]; + } PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level - 1]; @@ -3280,19 +3402,25 @@ void ObjectMgr::LoadPlayerInfo() { // skip nonexistent races if (!((1 << (race - 1)) & RACEMASK_ALL_PLAYABLE) || !sChrRacesStore.LookupEntry(race)) - { continue; } + { + continue; + } for (int class_ = 0; class_ < MAX_CLASSES; ++class_) { // skip nonexistent classes if (!((1 << (class_ - 1)) & CLASSMASK_ALL_PLAYABLE) || !sChrClassesStore.LookupEntry(class_)) - { continue; } + { + continue; + } PlayerInfo* pInfo = &playerInfo[race][class_]; // skip non loaded combinations if (!pInfo->displayId_m || !pInfo->displayId_f) - { continue; } + { + continue; + } // skip expansion races if not playing with expansion if (sWorld.getConfig(CONFIG_UINT32_EXPANSION) < EXPANSION_TBC && (race == RACE_BLOODELF || race == RACE_DRAENEI)) @@ -3360,7 +3488,9 @@ void ObjectMgr::LoadPlayerInfo() if (current_level >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum - { sLog.outErrorDb("Wrong (> %u) level %u in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level); } + { + sLog.outErrorDb("Wrong (> %u) level %u in `player_xp_for_level` table, ignoring.", STRONG_MAX_LEVEL, current_level); + } else { DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_xp_for_levels` table, ignoring.", current_level); @@ -3395,10 +3525,14 @@ void ObjectMgr::LoadPlayerInfo() void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, uint32& baseHP, uint32& baseMana) const { if (level < 1 || class_ >= MAX_CLASSES) - { return; } + { + return; + } if (level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) - { level = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); } + { + level = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); + } GtOCTBaseHPByClassEntry const* hp = sGtOCTBaseHPByClassStore.LookupEntry((class_-1) * GT_MAX_LEVEL + level-1); GtOCTBaseMPByClassEntry const* mp = sGtOCTBaseMPByClassStore.LookupEntry((class_-1) * GT_MAX_LEVEL + level-1); @@ -3416,14 +3550,20 @@ void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, uint32& bas void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const { if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) - { return; } + { + return; + } PlayerInfo const* pInfo = &playerInfo[race][class_]; if (pInfo->displayId_m == 0 || pInfo->displayId_f == 0) - { return; } + { + return; + } if (level <= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) - { *info = pInfo->levelInfo[level - 1]; } + { + *info = pInfo->levelInfo[level - 1]; + } else { BuildPlayerLevelInfo(race, class_, level, info); } } @@ -4551,10 +4691,14 @@ void ObjectMgr::LoadQuests() } if (qinfo->ExclusiveGroup) - { m_ExclusiveQuestGroups.insert(ExclusiveQuestGroupsMap::value_type(qinfo->ExclusiveGroup, qinfo->GetQuestId())); } + { + m_ExclusiveQuestGroups.insert(ExclusiveQuestGroupsMap::value_type(qinfo->ExclusiveGroup, qinfo->GetQuestId())); + } if (qinfo->LimitTime) - { qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAG_TIMED); } + { + qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAG_TIMED); + } } // check QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE @@ -4562,7 +4706,9 @@ void ObjectMgr::LoadQuests() { SpellEntry const* spellInfo = sSpellStore.LookupEntry(i); if (!spellInfo) - { continue; } + { + continue; + } for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { @@ -4570,7 +4716,9 @@ void ObjectMgr::LoadQuests() if(!spellEffect) continue; if (spellEffect->Effect != SPELL_EFFECT_QUEST_COMPLETE) - { continue; } + { + continue; + } uint32 quest_id = spellEffect->EffectMiscValue; @@ -4578,7 +4726,9 @@ void ObjectMgr::LoadQuests() // some quest referenced in spells not exist (outdated spells) if (!quest) - { continue; } + { + continue; + } // Exclude false positive of quest 10162 if (!quest->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT) && spellInfo->Id != 33824 && quest_id != 10162) @@ -4649,7 +4799,9 @@ void ObjectMgr::LoadQuestLocales() if (idx >= 0) { if ((int32)data.Title.size() <= idx) - { data.Title.resize(idx + 1); } + { + data.Title.resize(idx + 1); + } data.Title[idx] = str; } @@ -4661,7 +4813,9 @@ void ObjectMgr::LoadQuestLocales() if (idx >= 0) { if ((int32)data.Details.size() <= idx) - { data.Details.resize(idx + 1); } + { + data.Details.resize(idx + 1); + } data.Details[idx] = str; } @@ -4673,7 +4827,9 @@ void ObjectMgr::LoadQuestLocales() if (idx >= 0) { if ((int32)data.Objectives.size() <= idx) - { data.Objectives.resize(idx + 1); } + { + data.Objectives.resize(idx + 1); + } data.Objectives[idx] = str; } @@ -4685,7 +4841,9 @@ void ObjectMgr::LoadQuestLocales() if (idx >= 0) { if ((int32)data.OfferRewardText.size() <= idx) - { data.OfferRewardText.resize(idx + 1); } + { + data.OfferRewardText.resize(idx + 1); + } data.OfferRewardText[idx] = str; } @@ -4697,7 +4855,9 @@ void ObjectMgr::LoadQuestLocales() if (idx >= 0) { if ((int32)data.RequestItemsText.size() <= idx) - { data.RequestItemsText.resize(idx + 1); } + { + data.RequestItemsText.resize(idx + 1); + } data.RequestItemsText[idx] = str; } @@ -4709,7 +4869,9 @@ void ObjectMgr::LoadQuestLocales() if (idx >= 0) { if ((int32)data.EndText.size() <= idx) - { data.EndText.resize(idx + 1); } + { + data.EndText.resize(idx + 1); + } data.EndText[idx] = str; } @@ -4735,7 +4897,9 @@ void ObjectMgr::LoadQuestLocales() if (idx >= 0) { if ((int32)data.ObjectiveText[k].size() <= idx) - { data.ObjectiveText[k].resize(idx + 1); } + { + data.ObjectiveText[k].resize(idx + 1); + } data.ObjectiveText[k][idx] = str; } @@ -4810,7 +4974,9 @@ void ObjectMgr::LoadPageTexts() // check data correctness PageText const* page = sPageTextStore.LookupEntry(i); if (!page) - { continue; } + { + continue; + } if (page->Next_Page && !sPageTextStore.LookupEntry(page->Next_Page)) { @@ -4823,7 +4989,9 @@ void ObjectMgr::LoadPageTexts() for (PageText const* pageItr = page; pageItr; pageItr = sPageTextStore.LookupEntry(pageItr->Next_Page)) { if (!pageItr->Next_Page) - { break; } + { + break; + } checkedPages.insert(pageItr->Page_ID); if (checkedPages.find(pageItr->Next_Page) != checkedPages.end()) { @@ -4879,13 +5047,17 @@ void ObjectMgr::LoadPageTextLocales() { std::string str = fields[i].GetCppString(); if (str.empty()) - { continue; } + { + continue; + } int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.Text.size() <= idx) - { data.Text.resize(idx + 1); } + { + data.Text.resize(idx + 1); + } data.Text[idx] = str; } @@ -4990,7 +5162,9 @@ void ObjectMgr::LoadInstanceTemplate() { InstanceTemplate const* temp = GetInstanceTemplate(i); if (!temp) - { continue; } + { + continue; + } MapEntry const* mapEntry = sMapStore.LookupEntry(temp->map); if (!mapEntry) @@ -5082,7 +5256,9 @@ void ObjectMgr::LoadConditions() { const PlayerCondition* condition = sConditionStorage.LookupEntry(i); if (!condition) - { continue; } + { + continue; + } if (!condition->IsValid()) { @@ -5100,7 +5276,9 @@ GossipText const* ObjectMgr::GetGossipText(uint32 Text_ID) const { GossipTextMap::const_iterator itr = mGossipText.find(Text_ID); if (itr != mGossipText.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -5215,7 +5393,9 @@ void ObjectMgr::LoadGossipTextLocales() if (idx >= 0) { if ((int32)data.Text_0[j].size() <= idx) - { data.Text_0[j].resize(idx + 1); } + { + data.Text_0[j].resize(idx + 1); + } data.Text_0[j][idx] = str0; } @@ -5227,7 +5407,9 @@ void ObjectMgr::LoadGossipTextLocales() if (idx >= 0) { if ((int32)data.Text_1[j].size() <= idx) - { data.Text_1[j].resize(idx + 1); } + { + data.Text_1[j].resize(idx + 1); + } data.Text_1[j][idx] = str1; } @@ -5290,7 +5472,9 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) Player* pl = 0; if (serverUp) - { pl = GetPlayer(m->receiverGuid); } + { + pl = GetPlayer(m->receiverGuid); + } if (pl) { // this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail @@ -5473,14 +5657,18 @@ uint32 ObjectMgr::GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Te { TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); if (!node || node->map_id != mapid || !node->MountCreatureID[team == ALLIANCE ? 1 : 0]) - { continue; } + { + continue; + } uint8 field = (uint8)((i - 1) / 8); uint8 submask = 1 << ((i - 1) % 8); // skip not taxi network nodes if ((sTaxiNodesMask[field] & submask) == 0) - { continue; } + { + continue; + } float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z); if (found) @@ -5538,28 +5726,38 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, Team team, bool allowed_alt_t { mount_entry = node->MountCreatureID[1]; if (!mount_entry && allowed_alt_team) - { mount_entry = node->MountCreatureID[0]; } + { + mount_entry = node->MountCreatureID[0]; + } } else if (team == HORDE) { mount_entry = node->MountCreatureID[0]; if (!mount_entry && allowed_alt_team) - { mount_entry = node->MountCreatureID[1]; } + { + mount_entry = node->MountCreatureID[1]; + } } } CreatureInfo const* mount_info = GetCreatureTemplate(mount_entry); if (!mount_info) - { return 0; } + { + return 0; + } uint16 mount_id = Creature::ChooseDisplayId(mount_info); if (!mount_id) - { return 0; } + { + return 0; + } CreatureModelInfo const* minfo = GetCreatureModelRandomGender(mount_id); if (minfo) - { mount_id = minfo->modelid; } + { + mount_id = minfo->modelid; + } return mount_id; } @@ -5622,7 +5820,9 @@ void ObjectMgr::LoadGraveyardZones() } if (!AddGraveYardLink(safeLocId, zoneId, Team(team), false)) - { sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.", safeLocId, zoneId); } + { + sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.", safeLocId, zoneId); + } } while (result->NextRow()); @@ -5678,7 +5878,9 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float // team == TEAM_BOTH_ALLOWED case can be at call from .neargrave // TEAM_INVALID != team for all teams if (data.team != TEAM_BOTH_ALLOWED && data.team != team && team != TEAM_BOTH_ALLOWED) - { continue; } + { + continue; + } // find now nearest graveyard at other (continent) map if (MapId != entry->map_id) @@ -5734,10 +5936,14 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float } if (entryNear) - { return entryNear; } + { + return entryNear; + } if (entryEntr) - { return entryEntr; } + { + return entryEntr; + } return entryFar; } @@ -5749,7 +5955,9 @@ GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) cons for (GraveYardMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (itr->second.safeLocId == id) - { return &itr->second; } + { + return &itr->second; + } } return NULL; @@ -5758,7 +5966,9 @@ GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) cons bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, Team team, bool inDB) { if (FindGraveYardData(id, zoneId)) // This ensures that (safeLoc)Id, zoneId is unique in mGraveYardMap - { return false; } + { + return false; + } // add link to loaded data GraveYardData data; @@ -5769,7 +5979,9 @@ bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, Team team, bool inDB) // add link to DB if (inDB) - { WorldDatabase.PExecuteLog("INSERT INTO game_graveyard_zone ( id,ghost_zone,faction) VALUES ('%u', '%u','%u')", id, zoneId, uint32(team)); } + { + WorldDatabase.PExecuteLog("INSERT INTO game_graveyard_zone ( id,ghost_zone,faction) VALUES ('%u', '%u','%u')", id, zoneId, uint32(team)); + } return true; } @@ -5784,14 +5996,18 @@ void ObjectMgr::SetGraveYardLinkTeam(uint32 id, uint32 zoneId, Team team) // skip not matching safezone id if (data.safeLocId != id) - { continue; } + { + continue; + } data.team = team; // Validate link return; } if (team == TEAM_INVALID) - { return; } + { + return; + } // Link expected but not exist. sLog.outErrorDb("ObjectMgr::SetGraveYardLinkTeam called for safeLoc %u, zoneId %u, but no graveyard link for this found in database.", id, zoneId); @@ -5941,7 +6157,9 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 map_id) const { const MapEntry* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry || mapEntry->ghost_entrance_map < 0) - { return NULL; } + { + return NULL; + } // Try to find one that teleports to the map we want to enter std::list ghostTrigger; @@ -5955,14 +6173,18 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 map_id) const if ((!compareTrigger || itr->second.IsLessOrEqualThan(compareTrigger)) && sAreaTriggerStore.LookupEntry(itr->first)->mapid == map_id) { if (itr->second.IsMinimal()) - { return &itr->second; } + { + return &itr->second; + } compareTrigger = &itr->second; } } } if (compareTrigger) - { return compareTrigger; } + { + return compareTrigger; + } // Second attempt: take one fitting for (std::list::const_iterator itr = ghostTrigger.begin(); itr != ghostTrigger.end(); ++itr) @@ -5970,7 +6192,9 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 map_id) const if (!compareTrigger || (*itr)->IsLessOrEqualThan(compareTrigger)) { if ((*itr)->IsMinimal()) - { return *itr; } + { + return *itr; + } compareTrigger = *itr; } @@ -5994,14 +6218,18 @@ AreaTrigger const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const { // Remark that IsLessOrEqualThan is no total order, and a->IsLeQ(b) != !b->IsLeQ(a) if (!compareTrigger || compareTrigger->IsLessOrEqualThan(&itr->second)) - { compareTrigger = &itr->second; } + { + compareTrigger = &itr->second; + } } else { if (!compareTrigger || itr->second.IsLessOrEqualThan(compareTrigger)) { if (itr->second.IsMinimal()) - { return &itr->second; } + { + return &itr->second; + } compareTrigger = &itr->second; } @@ -6260,7 +6488,9 @@ struct SQLGameObjectLoader : public SQLStorageLoaderBaseid, goInfo->type, N, dataN, dataN); @@ -6283,7 +6513,9 @@ inline void CheckGOLinkedTrapId(GameObjectInfo const* goInfo, uint32 dataN, uint inline void CheckGOSpellId(GameObjectInfo const* goInfo, uint32 dataN, uint32 N) { if (sSpellStore.LookupEntry(dataN)) - { return; } + { + return; + } sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but Spell (Entry %u) not exist.", goInfo->id, goInfo->type, N, dataN, dataN); @@ -6292,7 +6524,9 @@ inline void CheckGOSpellId(GameObjectInfo const* goInfo, uint32 dataN, uint32 N) inline void CheckAndFixGOChairHeightId(GameObjectInfo const* goInfo, uint32 const& dataN, uint32 N) { if (dataN <= (UNIT_STAND_STATE_SIT_HIGH_CHAIR - UNIT_STAND_STATE_SIT_LOW_CHAIR)) - { return; } + { + return; + } sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but correct chair height in range 0..%i.", goInfo->id, goInfo->type, N, dataN, UNIT_STAND_STATE_SIT_HIGH_CHAIR - UNIT_STAND_STATE_SIT_LOW_CHAIR); @@ -6305,7 +6539,9 @@ inline void CheckGONoDamageImmuneId(GameObjectInfo const* goInfo, uint32 dataN, { // 0/1 correct values if (dataN <= 1) - { return; } + { + return; + } sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but expected boolean (0/1) noDamageImmune field value.", goInfo->id, goInfo->type, N, dataN); @@ -6315,7 +6551,9 @@ inline void CheckGOConsumable(GameObjectInfo const* goInfo, uint32 dataN, uint32 { // 0/1 correct values if (dataN <= 1) - { return; } + { + return; + } sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but expected boolean (0/1) consumable field value.", goInfo->id, goInfo->type, N, dataN); @@ -6324,7 +6562,9 @@ inline void CheckGOConsumable(GameObjectInfo const* goInfo, uint32 dataN, uint32 inline void CheckAndFixGOCaptureMinTime(GameObjectInfo const* goInfo, uint32 const& dataN, uint32 N) { if (dataN > 0) - { return; } + { + return; + } sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) has data%d=%u but minTime field value must be > 0.", goInfo->id, goInfo->type, N, dataN); @@ -6357,41 +6597,55 @@ void ObjectMgr::LoadGameobjectInfo() case GAMEOBJECT_TYPE_DOOR: // 0 { if (goInfo->door.lockId) - { CheckGOLockId(goInfo, goInfo->door.lockId, 1); } + { + CheckGOLockId(goInfo, goInfo->door.lockId, 1); + } CheckGONoDamageImmuneId(goInfo, goInfo->door.noDamageImmune, 3); break; } case GAMEOBJECT_TYPE_BUTTON: // 1 { if (goInfo->button.lockId) - { CheckGOLockId(goInfo, goInfo->button.lockId, 1); } + { + CheckGOLockId(goInfo, goInfo->button.lockId, 1); + } if (goInfo->button.linkedTrapId) // linked trap - { CheckGOLinkedTrapId(goInfo, goInfo->button.linkedTrapId, 3); } + { + CheckGOLinkedTrapId(goInfo, goInfo->button.linkedTrapId, 3); + } CheckGONoDamageImmuneId(goInfo, goInfo->button.noDamageImmune, 4); break; } case GAMEOBJECT_TYPE_QUESTGIVER: // 2 { if (goInfo->questgiver.lockId) - { CheckGOLockId(goInfo, goInfo->questgiver.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->questgiver.lockId, 0); + } CheckGONoDamageImmuneId(goInfo, goInfo->questgiver.noDamageImmune, 5); break; } case GAMEOBJECT_TYPE_CHEST: // 3 { if (goInfo->chest.lockId) - { CheckGOLockId(goInfo, goInfo->chest.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->chest.lockId, 0); + } CheckGOConsumable(goInfo, goInfo->chest.consumable, 3); if (goInfo->chest.linkedTrapId) // linked trap - { CheckGOLinkedTrapId(goInfo, goInfo->chest.linkedTrapId, 7); } + { + CheckGOLinkedTrapId(goInfo, goInfo->chest.linkedTrapId, 7); + } break; } case GAMEOBJECT_TYPE_TRAP: // 6 { if (goInfo->trap.lockId) - { CheckGOLockId(goInfo, goInfo->trap.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->trap.lockId, 0); + } /* disable check for while, too many nonexistent spells if (goInfo->trap.spellId) // spell CheckGOSpellId(goInfo,goInfo->trap.spellId,3); @@ -6411,13 +6665,17 @@ void ObjectMgr::LoadGameobjectInfo() } if (goInfo->spellFocus.linkedTrapId) // linked trap - { CheckGOLinkedTrapId(goInfo, goInfo->spellFocus.linkedTrapId, 2); } + { + CheckGOLinkedTrapId(goInfo, goInfo->spellFocus.linkedTrapId, 2); + } break; } case GAMEOBJECT_TYPE_GOOBER: // 10 { if (goInfo->goober.lockId) - { CheckGOLockId(goInfo, goInfo->goober.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->goober.lockId, 0); + } CheckGOConsumable(goInfo, goInfo->goober.consumable, 3); @@ -6433,7 +6691,9 @@ void ObjectMgr::LoadGameobjectInfo() */ CheckGONoDamageImmuneId(goInfo, goInfo->goober.noDamageImmune, 11); if (goInfo->goober.linkedTrapId) // linked trap - { CheckGOLinkedTrapId(goInfo, goInfo->goober.linkedTrapId, 12); } + { + CheckGOLinkedTrapId(goInfo, goInfo->goober.linkedTrapId, 12); + } break; } case GAMEOBJECT_TYPE_TRANSPORT: // 11 @@ -6486,13 +6746,17 @@ void ObjectMgr::LoadGameobjectInfo() case GAMEOBJECT_TYPE_AREADAMAGE: // 12 { if (goInfo->areadamage.lockId) - { CheckGOLockId(goInfo, goInfo->areadamage.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->areadamage.lockId, 0); + } break; } case GAMEOBJECT_TYPE_CAMERA: // 13 { if (goInfo->camera.lockId) - { CheckGOLockId(goInfo, goInfo->camera.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->camera.lockId, 0); + } break; } case GAMEOBJECT_TYPE_MO_TRANSPORT: // 15 @@ -6522,20 +6786,26 @@ void ObjectMgr::LoadGameobjectInfo() case GAMEOBJECT_TYPE_FLAGSTAND: // 24 { if (goInfo->flagstand.lockId) - { CheckGOLockId(goInfo, goInfo->flagstand.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->flagstand.lockId, 0); + } CheckGONoDamageImmuneId(goInfo, goInfo->flagstand.noDamageImmune, 5); break; } case GAMEOBJECT_TYPE_FISHINGHOLE: // 25 { if (goInfo->fishinghole.lockId) - { CheckGOLockId(goInfo, goInfo->fishinghole.lockId, 4); } + { + CheckGOLockId(goInfo, goInfo->fishinghole.lockId, 4); + } break; } case GAMEOBJECT_TYPE_FLAGDROP: // 26 { if (goInfo->flagdrop.lockId) - { CheckGOLockId(goInfo, goInfo->flagdrop.lockId, 0); } + { + CheckGOLockId(goInfo, goInfo->flagdrop.lockId, 0); + } CheckGONoDamageImmuneId(goInfo, goInfo->flagdrop.noDamageImmune, 3); break; } @@ -6599,7 +6869,9 @@ uint32 ObjectMgr::GetBaseXP(uint32 level) const uint32 ObjectMgr::GetXPForLevel(uint32 level) const { if (level < mPlayerXPperLevel.size()) - { return mPlayerXPperLevel[level]; } + { + return mPlayerXPperLevel[level]; + } return 0; } @@ -6630,7 +6902,9 @@ void ObjectMgr::LoadPetNames() uint32 entry = fields[1].GetUInt32(); bool half = fields[2].GetBool(); if (half) - { PetHalfName1[entry].push_back(word); } + { + PetHalfName1[entry].push_back(word); + } else { PetHalfName0[entry].push_back(word); } ++count; @@ -6669,7 +6943,9 @@ std::string ObjectMgr::GeneratePetName(uint32 entry) CreatureInfo const* cinfo = GetCreatureTemplate(entry); char const* petname = GetPetName(cinfo->Family, sWorld.GetDefaultDbcLocale()); if (!petname) - { petname = cinfo->Name; } + { + petname = cinfo->Name; + } return std::string(petname); } @@ -7501,7 +7777,9 @@ void ObjectMgr::DeleteCreatureData(uint32 guid) // remove mapid*cellid -> guid_set map CreatureData const* data = GetCreatureData(guid); if (data) - { RemoveCreatureFromGrid(guid, data); } + { + RemoveCreatureFromGrid(guid, data); + } mCreatureDataMap.erase(guid); } @@ -7511,7 +7789,9 @@ void ObjectMgr::DeleteGOData(uint32 guid) // remove mapid*cellid -> guid_set map GameObjectData const* data = GetGOData(guid); if (data) - { RemoveGameobjectFromGrid(guid, data); } + { + RemoveGameobjectFromGrid(guid, data); + } mGameObjectDataMap.erase(guid); } @@ -7585,7 +7865,9 @@ void ObjectMgr::LoadGameobjectQuestRelations() { GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); if (!goInfo) - { sLog.outErrorDb("Table `quest_relations` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second); } + { + 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); } } @@ -7599,7 +7881,9 @@ void ObjectMgr::LoadGameobjectInvolvedRelations() { GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); if (!goInfo) - { sLog.outErrorDb("Table `quest_relations` have data for nonexistent gameobject entry (%u) and existing quest %u", itr->first, itr->second); } + { + 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); } } @@ -7613,7 +7897,9 @@ void ObjectMgr::LoadCreatureQuestRelations() { CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); if (!cInfo) - { sLog.outErrorDb("Table `quest_relations` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); } + { + 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); } } @@ -7627,7 +7913,9 @@ void ObjectMgr::LoadCreatureInvolvedRelations() { CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); if (!cInfo) - { sLog.outErrorDb("Table `quest_relations` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); } + { + 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); } } @@ -7683,7 +7971,9 @@ bool ObjectMgr::IsReservedName(const std::string& name) const { std::wstring wstr; if (!Utf8toWStr(name, wstr)) - { return false; } + { + return false; + } wstrToLower(wstr); @@ -7732,11 +8022,17 @@ bool isValidString(const std::wstring& wstr, uint32 strictMask, bool numericOrSp if (strictMask == 0) // any language, ignore realm { if (isExtendedLatinString(wstr, numericOrSpace)) - { return true; } + { + return true; + } if (isCyrillicString(wstr, numericOrSpace)) - { return true; } + { + return true; + } if (isEastAsianString(wstr, numericOrSpace)) - { return true; } + { + return true; + } return false; } @@ -7745,19 +8041,27 @@ bool isValidString(const std::wstring& wstr, uint32 strictMask, bool numericOrSp LanguageType lt = GetRealmLanguageType(create); if (lt & LT_EXTENDEN_LATIN) if (isExtendedLatinString(wstr, numericOrSpace)) - { return true; } + { + return true; + } if (lt & LT_CYRILLIC) if (isCyrillicString(wstr, numericOrSpace)) - { return true; } + { + return true; + } if (lt & LT_EAST_ASIA) if (isEastAsianString(wstr, numericOrSpace)) - { return true; } + { + return true; + } } if (strictMask & 0x1) // basic Latin { if (isBasicLatinString(wstr, numericOrSpace)) - { return true; } + { + return true; + } } return false; @@ -7767,18 +8071,26 @@ uint8 ObjectMgr::CheckPlayerName(const std::string& name, bool create) { std::wstring wname; if (!Utf8toWStr(name, wname)) - { return CHAR_NAME_INVALID_CHARACTER; } + { + return CHAR_NAME_INVALID_CHARACTER; + } if (wname.size() > MAX_PLAYER_NAME) - { return CHAR_NAME_TOO_LONG; } + { + return CHAR_NAME_TOO_LONG; + } uint32 minName = sWorld.getConfig(CONFIG_UINT32_MIN_PLAYER_NAME); if (wname.size() < minName) - { return CHAR_NAME_TOO_SHORT; } + { + return CHAR_NAME_TOO_SHORT; + } uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_PLAYER_NAMES); if (!isValidString(wname, strictMask, false, create)) - { return CHAR_NAME_MIXED_LANGUAGES; } + { + return CHAR_NAME_MIXED_LANGUAGES; + } return CHAR_NAME_SUCCESS; } @@ -7787,14 +8099,20 @@ bool ObjectMgr::IsValidCharterName(const std::string& name) { std::wstring wname; if (!Utf8toWStr(name, wname)) - { return false; } + { + return false; + } if (wname.size() > MAX_CHARTER_NAME) - { return false; } + { + return false; + } uint32 minName = sWorld.getConfig(CONFIG_UINT32_MIN_CHARTER_NAME); if (wname.size() < minName) - { return false; } + { + return false; + } uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_CHARTER_NAMES); @@ -7805,18 +8123,26 @@ PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) { std::wstring wname; if (!Utf8toWStr(name, wname)) - { return PET_NAME_INVALID; } + { + return PET_NAME_INVALID; + } if (wname.size() > MAX_PET_NAME) - { return PET_NAME_TOO_LONG; } + { + return PET_NAME_TOO_LONG; + } uint32 minName = sWorld.getConfig(CONFIG_UINT32_MIN_PET_NAME); if (wname.size() < minName) - { return PET_NAME_TOO_SHORT; } + { + return PET_NAME_TOO_SHORT; + } uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_PET_NAMES); if (!isValidString(wname, strictMask, false)) - { return PET_NAME_MIXED_LANGUAGES; } + { + return PET_NAME_MIXED_LANGUAGES; + } return PET_NAME_SUCCESS; } @@ -7824,11 +8150,15 @@ PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) int ObjectMgr::GetIndexForLocale(LocaleConstant loc) { if (loc == LOCALE_enUS) - { return -1; } + { + return -1; + } for (size_t i = 0; i < m_LocalForIndex.size(); ++i) if (m_LocalForIndex[i] == loc) - { return i; } + { + return i; + } return -1; } @@ -7836,7 +8166,9 @@ int ObjectMgr::GetIndexForLocale(LocaleConstant loc) LocaleConstant ObjectMgr::GetLocaleForIndex(int i) { if (i < 0 || i >= (int32)m_LocalForIndex.size()) - { return LOCALE_enUS; } + { + return LOCALE_enUS; + } return m_LocalForIndex[i]; } @@ -7844,11 +8176,15 @@ LocaleConstant ObjectMgr::GetLocaleForIndex(int i) int ObjectMgr::GetOrNewIndexForLocale(LocaleConstant loc) { if (loc == LOCALE_enUS) - { return -1; } + { + return -1; + } for (size_t i = 0; i < m_LocalForIndex.size(); ++i) if (m_LocalForIndex[i] == loc) - { return i; } + { + return i; + } m_LocalForIndex.push_back(loc); return m_LocalForIndex.size() - 1; @@ -7947,7 +8283,9 @@ inline void _DoStringError(int32 entry, char const* text, ...) va_end(ap); if (entry <= MAX_CREATURE_AI_TEXT_STRING_ID) // script library error - { sLog.outErrorScriptLib("%s", buf); } + { + sLog.outErrorScriptLib("%s", buf); + } else if (entry <= MIN_CREATURE_AI_TEXT_STRING_ID) // eventAI error { sLog.outErrorEventAI("%s", buf); } else if (entry < MIN_DB_SCRIPT_STRING_ID) // mangos string error @@ -7987,7 +8325,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min for (MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();) { if (itr->first >= start_value && itr->first < end_value) - { mMangosStringLocaleMap.erase(itr++); } + { + mMangosStringLocaleMap.erase(itr++); + } else { ++itr; } } @@ -8005,7 +8345,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min sLog.outString(); if (min_value == MIN_MANGOS_STRING_ID) // error only in case internal strings - { sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Can not continue.", table); } + { + 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); } return false; @@ -8057,7 +8399,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min { // 0 -> default, idx in to idx+1 if ((int32)data.Content.size() <= idx + 1) - { data.Content.resize(idx + 2); } + { + data.Content.resize(idx + 2); + } data.Content[idx + 1] = str; } @@ -8102,7 +8446,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min delete result; if (min_value == MIN_MANGOS_STRING_ID) - { sLog.outString(">> Loaded %u MaNGOS strings from table %s", count, table); } + { + 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(); @@ -8119,7 +8465,9 @@ const char* ObjectMgr::GetMangosString(int32 entry, int locale_idx) const if (MangosStringLocale const* msl = GetMangosStringLocale(entry)) { if ((int32)msl->Content.size() > locale_idx + 1 && !msl->Content[locale_idx + 1].empty()) - { return msl->Content[locale_idx + 1].c_str(); } + { + return msl->Content[locale_idx + 1].c_str(); + } else { return msl->Content[0].c_str(); } } @@ -8177,7 +8525,9 @@ void ObjectMgr::LoadFishingBaseSkillLevel() bool ObjectMgr::IsPlayerMeetToCondition(uint16 conditionId, Player const* pPlayer, Map const* map, WorldObject const* source, ConditionSource conditionSourceType) const { if (const PlayerCondition* condition = sConditionStorage.LookupEntry(conditionId)) - { return condition->Meets(pPlayer, map, source, conditionSourceType); } + { + return condition->Meets(pPlayer, map, source, conditionSourceType); + } return false; } @@ -8217,7 +8567,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co m_entry, m_condition, conditionSourceToStr[conditionSourceType], player ? player->GetGuidStr().c_str() : "", map ? map->GetId() : -1, source ? source->GetGuidStr().c_str() : ""); if (!CheckParamRequirements(player, map, source, conditionSourceType)) - { return false; } + { + return false; + } switch (m_condition) { @@ -8253,7 +8605,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co case CONDITION_TEAM: { if (conditionSourceType == CONDITION_FROM_REFERING_LOOT && sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) - { return true; } + { + return true; + } else { return uint32(player->GetTeam()) == m_value1; } } @@ -8268,7 +8622,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co Unit::SpellAuraHolderMap const& auras = player->GetSpellAuraHolderMap(); for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) if ((itr->second->GetSpellProto()->HasAttribute(SPELL_ATTR_CASTABLE_WHILE_MOUNTED) || itr->second->GetSpellProto()->HasAttribute(SPELL_ATTR_UNK4)) && itr->second->GetSpellProto()->SpellVisual[0] == 3580) - { return true; } + { + return true; + } return false; } case CONDITION_NO_AURA: @@ -8281,13 +8637,17 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co if (AreaTableEntry const* pAreaEntry = GetAreaEntryByAreaID(searcher->GetAreaId())) { if ((!m_value1 || (pAreaEntry->flags & m_value1)) && (!m_value2 || !(pAreaEntry->flags & m_value2))) - { return true; } + { + return true; + } } return false; } case CONDITION_RACE_CLASS: if ((!m_value1 || (player->getRaceMask() & m_value1)) && (!m_value2 || (player->getClassMask() & m_value2))) - { return true; } + { + return true; + } return false; case CONDITION_LEVEL: { @@ -8313,10 +8673,14 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co case CONDITION_INSTANCE_SCRIPT: { if (!map) - { map = player ? player->GetMap() : source->GetMap(); } + { + map = player ? player->GetMap() : source->GetMap(); + } if (InstanceData* data = map->GetInstanceData()) - { return data->CheckConditionCriteriaMeet(player, m_value1, source, conditionSourceType); } + { + return data->CheckConditionCriteriaMeet(player, m_value1, source, conditionSourceType); + } return false; } case CONDITION_QUESTAVAILABLE: @@ -8345,7 +8709,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co case CONDITION_QUEST_NONE: { if (!player->IsCurrentQuest(m_value1) && !player->GetQuestRewardStatus(m_value1)) - { return true; } + { + return true; + } return false; } case CONDITION_ITEM_WITH_BANK: @@ -8362,7 +8728,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co { // Already know the spell if (player->HasSpell(m_value1)) - { return false; } + { + return false; + } // If item defined, check if player has the item already. if (m_value2) @@ -8371,7 +8739,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co // a all-in-one check regarding items that learn some ability (primary/secondary tradeskills). // Commonly, items like this is unique and/or are not expected to be obtained more than once. if (player->HasItemCount(m_value2, 1, true)) - { return false; } + { + return false; + } } bool isSkillOk = false; @@ -8383,37 +8753,51 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co const SkillLineAbilityEntry* skillInfo = itr->second; if (!skillInfo) - { continue; } + { + continue; + } // doesn't have skill if (!player->HasSkill(skillInfo->skillId)) - { return false; } + { + return false; + } // doesn't match class if (skillInfo->classmask && (skillInfo->classmask & player->getClassMask()) == 0) - { return false; } + { + return false; + } // doesn't match race if (skillInfo->racemask && (skillInfo->racemask & player->getRaceMask()) == 0) - { return false; } + { + return false; + } // skill level too low if (skillInfo->min_value > player->GetSkillValue(skillInfo->skillId)) - { return false; } + { + return false; + } isSkillOk = true; break; } if (isSkillOk) - { return true; } + { + return true; + } return false; } case CONDITION_SKILL_BELOW: { if (m_value2 == 1) - { return !player->HasSkill(m_value1); } + { + return !player->HasSkill(m_value1); + } else { return player->HasSkill(m_value1) && player->GetBaseSkillValue(m_value1) < m_value2; } } @@ -8492,14 +8876,18 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co return !player || !player->IsAlive() || (m_value2 && source && !source->IsWithinDistInMap(player, m_value2)); case 1: // All players in Group dead or out of range if (!player) - { return true; } + { + return true; + } if (Group const* grp = player->GetGroup()) { for (GroupReference const* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) { Player const* pl = itr->getSource(); if (pl && pl->IsAlive() && !pl->isGameMaster() && (!m_value2 || !source || source->IsWithinDistInMap(pl, m_value2))) - { return false; } + { + return false; + } } return true; } @@ -8510,7 +8898,9 @@ bool PlayerCondition::Meets(Player const* player, Map const* map, WorldObject co { Player const* plr = itr->getSource(); if (plr && plr->IsAlive() && !plr->isGameMaster() && (!m_value2 || !source || source->IsWithinDistInMap(plr, m_value2))) - { return false; } + { + return false; + } } return true; case 3: // Creature source is dead @@ -8585,10 +8975,14 @@ bool PlayerCondition::CheckParamRequirements(Player const* pPlayer, Map const* m return false; } if (m_value1 != 2) - { return true; } + { + return true; + } // Case 2 (Instance map only) if (!map && (pPlayer || source)) - { map = source ? source->GetMap() : pPlayer->GetMap(); } + { + map = source ? source->GetMap() : pPlayer->GetMap(); + } if (!map || !map->Instanceable()) { sLog.outErrorDb("CONDITION_DEAD_OR_AWAY %u (Player in instance case) - called from %s without map param or from non-instanceable map %i", m_entry, conditionSourceToStr[conditionSourceType], map ? map->GetId() : -1); @@ -8772,15 +9166,21 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu } if (value2 && condition != CONDITION_QUESTTAKEN) - { sLog.outErrorDb("Quest condition (entry %u, type %u) has useless data in value2 (%u)!", entry, condition, value2); } + { + sLog.outErrorDb("Quest condition (entry %u, type %u) has useless data in value2 (%u)!", entry, condition, value2); + } break; } case CONDITION_AD_COMMISSION_AURA: { if (value1) - { sLog.outErrorDb("Quest condition (entry %u, type %u) has useless data in value1 (%u)!", entry, condition, value1); } + { + sLog.outErrorDb("Quest condition (entry %u, type %u) has useless data in value1 (%u)!", entry, condition, value1); + } if (value2) - { sLog.outErrorDb("Quest condition (entry %u, type %u) has useless data in value2 (%u)!", entry, condition, value2); } + { + sLog.outErrorDb("Quest condition (entry %u, type %u) has useless data in value2 (%u)!", entry, condition, value2); + } break; } case CONDITION_NO_AURA: @@ -9008,7 +9408,9 @@ bool PlayerCondition::CanBeUsedWithoutPlayer(uint16 entry) { PlayerCondition const* condition = sConditionStorage.LookupEntry(entry); if (!condition) - { return false; } + { + return false; + } switch (condition->m_condition) { @@ -9050,7 +9452,9 @@ SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial) case SKILL_CATEGORY_PROFESSION: // not set skills for professions and racial abilities if (IsProfessionSkill(pSkill->id)) - { return SKILL_RANGE_RANK; } + { + return SKILL_RANGE_RANK; + } else if (racial) { return SKILL_RANGE_NONE; } else @@ -9127,7 +9531,9 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const // explicit name case std::wstring wname; if (!Utf8toWStr(name, wname)) - { return NULL; } + { + return NULL; + } // converting string that we try to find to lower case wstrToLower(wname); @@ -9136,7 +9542,9 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const const GameTele* alt = NULL; for (GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) if (itr->second.wnameLow == wname) - { return &itr->second; } + { + return &itr->second; + } else if (alt == NULL && itr->second.wnameLow.find(wname) != std::wstring::npos) { alt = &itr->second; } @@ -9149,13 +9557,17 @@ bool ObjectMgr::AddGameTele(GameTele& tele) uint32 new_id = 0; for (GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) if (itr->first > new_id) - { new_id = itr->first; } + { + new_id = itr->first; + } // use next ++new_id; if (!Utf8toWStr(tele.name, tele.wnameLow)) - { return false; } + { + return false; + } wstrToLower(tele.wnameLow); @@ -9175,7 +9587,9 @@ bool ObjectMgr::DeleteGameTele(const std::string& name) // explicit name case std::wstring wname; if (!Utf8toWStr(name, wname)) - { return false; } + { + return false; + } // converting string that we try to find to lower case wstrToLower(wname); @@ -9443,7 +9857,9 @@ void ObjectMgr::LoadTrainerTemplates() if (cInfo->TrainerTemplateId) { if (m_mCacheTrainerTemplateSpellMap.find(cInfo->TrainerTemplateId) != m_mCacheTrainerTemplateSpellMap.end()) - { trainer_ids.erase(cInfo->TrainerTemplateId); } + { + trainer_ids.erase(cInfo->TrainerTemplateId); + } else { sLog.outErrorDb("Creature (Entry: %u) has `TrainerTemplateId` = %u for nonexistent trainer template", cInfo->Entry, cInfo->TrainerTemplateId); @@ -9457,7 +9873,9 @@ void ObjectMgr::LoadTrainerTemplates() { sLog.outErrorDb("Table `npc_trainer_template` has trainer template %u not used by any trainers ", *tItr); } if (hasErrored || !trainer_ids.empty()) // Append extra line in case of reported errors - { sLog.outString(); } + { + sLog.outString(); + } } void ObjectMgr::LoadVendors(char const* tableName, bool isTemplates) @@ -9500,7 +9918,9 @@ void ObjectMgr::LoadVendors(char const* tableName, bool isTemplates) uint16 conditionId = fields[5].GetUInt16(); if (!IsVendorItemValid(isTemplates, tableName, entry, item_id, type, maxcount, incrtime, ExtendedCost, conditionId, NULL, &skip_vendors)) - { continue; } + { + continue; + } VendorItemData& vList = vendorList[entry]; @@ -9532,7 +9952,9 @@ void ObjectMgr::LoadVendorTemplates() if (cInfo->VendorTemplateId) { if (m_mCacheVendorTemplateItemMap.find(cInfo->VendorTemplateId) != m_mCacheVendorTemplateItemMap.end()) - { vendor_ids.erase(cInfo->VendorTemplateId); } + { + vendor_ids.erase(cInfo->VendorTemplateId); + } else sLog.outErrorDb("Creature (Entry: %u) has `VendorTemplateId` = %u for nonexistent vendor template", cInfo->Entry, cInfo->VendorTemplateId); } @@ -9715,11 +10137,15 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) { for (GossipMenusMap::const_iterator itr = m_mGossipMenusMap.begin(); itr != m_mGossipMenusMap.end(); ++itr) if (itr->first) - { menu_ids.insert(itr->first); } + { + menu_ids.insert(itr->first); + } for (SQLStorageBase::SQLSIterator itr = sGOStorage.getDataBegin(); itr < sGOStorage.getDataEnd(); ++itr) if (uint32 menuid = itr->GetGossipMenuId()) - { menu_ids.erase(menuid); } + { + menu_ids.erase(menuid); + } } // loading @@ -9738,7 +10164,9 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) // unused check data preparing part if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) - { menu_ids.erase(cInfo->GossipMenuId); } + { + menu_ids.erase(cInfo->GossipMenuId); + } } do @@ -9776,7 +10204,9 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) if (gMenuItem.action_menu_id > 0) { if (m_mGossipMenusMap.find(gMenuItem.action_menu_id) == m_mGossipMenusMap.end()) - { 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); } + { + 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); } } @@ -9788,10 +10218,14 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) } if (gMenuItem.option_id == GOSSIP_OPTION_NONE) - { sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u use option id GOSSIP_OPTION_NONE. Option will never be used", gMenuItem.menu_id, gMenuItem.id); } + { + sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u use option id GOSSIP_OPTION_NONE. Option will never be used", gMenuItem.menu_id, gMenuItem.id); + } if (gMenuItem.option_id >= GOSSIP_OPTION_MAX) - { sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u has unknown option id %u. Option will not be used", gMenuItem.menu_id, gMenuItem.id, gMenuItem.option_id); } + { + sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u has unknown option id %u. Option will not be used", gMenuItem.menu_id, gMenuItem.id, gMenuItem.option_id); + } if (gMenuItem.menu_id && gMenuItem.npc_option_NpcFlags) { @@ -9807,11 +10241,15 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) // some from creatures with gossip menu can use gossip option base at npc_flags if (gMenuItem.npc_option_NpcFlags & cInfo->NpcFlags) - { found_flags_uses = true; } + { + found_flags_uses = true; + } } if (found_menu_uses && !found_flags_uses) - { sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u has `npc_option_npcflag` = %u but creatures using this menu does not have corresponding`npcflag`. Option will not accessible in game.", gMenuItem.menu_id, gMenuItem.id, gMenuItem.npc_option_NpcFlags); } + { + sLog.outErrorDb("Table gossip_menu_option for menu %u, id %u has `npc_option_npcflag` = %u but creatures using this menu does not have corresponding`npcflag`. Option will not accessible in game.", gMenuItem.menu_id, gMenuItem.id, gMenuItem.npc_option_NpcFlags); + } } if (gMenuItem.action_poi_id && !GetPointOfInterest(gMenuItem.action_poi_id)) @@ -9897,10 +10335,14 @@ bool ObjectMgr::RemoveVendorItem(uint32 entry, uint32 item, uint8 type) { CacheVendorItemMap::iterator iter = m_mCacheVendorItemMap.find(entry); if (iter == m_mCacheVendorItemMap.end()) - { return false; } + { + return false; + } if (!iter->second.RemoveItem(item, type)) - { return false; } + { + return false; + } WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%i'", entry, type == VENDOR_ITEM_TYPE_CURRENCY ? -int32(item) : item); return true; @@ -10273,10 +10715,14 @@ void ObjectMgr::GetCreatureLocaleStrings(uint32 entry, int32 loc_idx, char const if (CreatureLocale const *il = GetCreatureLocale(entry)) { if (namePtr && il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) - { *namePtr = il->Name[loc_idx].c_str(); } + { + *namePtr = il->Name[loc_idx].c_str(); + } if (subnamePtr && il->SubName.size() > size_t(loc_idx) && !il->SubName[loc_idx].empty()) - { *subnamePtr = il->SubName[loc_idx].c_str(); } + { + *subnamePtr = il->SubName[loc_idx].c_str(); + } } } } @@ -10288,10 +10734,14 @@ void ObjectMgr::GetItemLocaleStrings(uint32 entry, int32 loc_idx, std::string* n if (ItemLocale const *il = GetItemLocale(entry)) { if (namePtr && il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) - { *namePtr = il->Name[loc_idx]; } + { + *namePtr = il->Name[loc_idx]; + } if (descriptionPtr && il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty()) - { *descriptionPtr = il->Description[loc_idx]; } + { + *descriptionPtr = il->Description[loc_idx]; + } } } } @@ -10303,7 +10753,9 @@ void ObjectMgr::GetQuestLocaleStrings(uint32 entry, int32 loc_idx, std::string* if (QuestLocale const *il = GetQuestLocale(entry)) { if (titlePtr && il->Title.size() > size_t(loc_idx) && !il->Title[loc_idx].empty()) - { *titlePtr = il->Title[loc_idx]; } + { + *titlePtr = il->Title[loc_idx]; + } } } } @@ -10317,12 +10769,16 @@ void ObjectMgr::GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, ObjectMg if (text0_Ptr) for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) if (nl->Text_0[i].size() > (size_t)loc_idx && !nl->Text_0[i][loc_idx].empty()) - { (*text0_Ptr)[i] = nl->Text_0[i][loc_idx]; } + { + (*text0_Ptr)[i] = nl->Text_0[i][loc_idx]; + } if (text1_Ptr) for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) if (nl->Text_1[i].size() > (size_t)loc_idx && !nl->Text_1[i][loc_idx].empty()) - { (*text1_Ptr)[i] = nl->Text_1[i][loc_idx]; } + { + (*text1_Ptr)[i] = nl->Text_1[i][loc_idx]; + } } } } @@ -10335,11 +10791,15 @@ void ObjectMgr::GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::strin { if (text0_0_Ptr) if (nl->Text_0[0].size() > (size_t)loc_idx && !nl->Text_0[0][loc_idx].empty()) - { *text0_0_Ptr = nl->Text_0[0][loc_idx]; } + { + *text0_0_Ptr = nl->Text_0[0][loc_idx]; + } if (text1_0_Ptr) if (nl->Text_1[0].size() > (size_t)loc_idx && !nl->Text_1[0][loc_idx].empty()) - { *text1_0_Ptr = nl->Text_1[0][loc_idx]; } + { + *text1_0_Ptr = nl->Text_1[0][loc_idx]; + } } } } @@ -10402,18 +10862,26 @@ bool FindCreatureData::operator()(CreatureDataPair const& dataPair) { // skip wrong entry ids if (i_id && dataPair.second.id != i_id) - { return false; } + { + return false; + } if (!i_anyData) - { i_anyData = &dataPair; } + { + i_anyData = &dataPair; + } // without player we can't find more stricted cases, so use fouded if (!i_player) - { return true; } + { + return true; + } // skip diff. map cases if (dataPair.second.mapid != i_player->GetMapId()) - { return false; } + { + return false; + } float new_dist = i_player->GetDistance2d(dataPair.second.posX, dataPair.second.posY); @@ -10450,12 +10918,16 @@ bool DoDisplayText(WorldObject* source, int32 entry, Unit const* target /*=NULL* if (data->SoundId) { if (data->Type == CHAT_TYPE_ZONE_YELL) - { source->GetMap()->PlayDirectSoundToMap(data->SoundId, source->GetZoneId()); } + { + source->GetMap()->PlayDirectSoundToMap(data->SoundId, source->GetZoneId()); + } else if (data->Type == CHAT_TYPE_WHISPER || data->Type == CHAT_TYPE_BOSS_WHISPER) { // An error will be displayed for the text if (target && target->GetTypeId() == TYPEID_PLAYER) - { source->PlayDirectSound(data->SoundId, (Player const*)target); } + { + source->PlayDirectSound(data->SoundId, (Player const*)target); + } } else { source->PlayDirectSound(data->SoundId); } diff --git a/src/game/Object/ObjectMgr.h b/src/game/Object/ObjectMgr.h index 31b9cf475..f1bfe0052 100644 --- a/src/game/Object/ObjectMgr.h +++ b/src/game/Object/ObjectMgr.h @@ -649,7 +649,9 @@ class ObjectMgr { QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID); if (itr != mQuestAreaTriggerMap.end()) - { return itr->second; } + { + return itr->second; + } return 0; } bool IsTavernAreaTrigger(uint32 Trigger_ID) const @@ -674,7 +676,9 @@ class ObjectMgr { AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger); if (itr != mAreaTriggers.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -685,7 +689,9 @@ class ObjectMgr { RepRewardRateMap::const_iterator itr = m_RepRewardRateMap.find(factionId); if (itr != m_RepRewardRateMap.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -694,7 +700,9 @@ class ObjectMgr { RepOnKillMap::const_iterator itr = mRepOnKill.find(id); if (itr != mRepOnKill.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -702,7 +710,9 @@ class ObjectMgr { RepSpilloverTemplateMap::const_iterator itr = m_RepSpilloverTemplateMap.find(factionId); if (itr != m_RepSpilloverTemplateMap.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -711,7 +721,9 @@ class ObjectMgr { PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id); if (itr != mPointsOfInterest.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -735,7 +747,9 @@ class ObjectMgr { DungeonFinderRewardsMap::const_iterator itr = mDungeonFinderRewardsMap.find(level); if (itr != mDungeonFinderRewardsMap.end()) - { return &itr->second; } + { + return &itr->second; + } return NULL; } @@ -884,13 +898,17 @@ class ObjectMgr uint32 GenerateStaticCreatureLowGuid() { if (m_StaticCreatureGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryCreatureGuid) - { return 0; } + { + return 0; + } return m_StaticCreatureGuids.Generate(); } uint32 GenerateStaticGameObjectLowGuid() { if (m_StaticGameObjectGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryGameObjectGuid) - { return 0; } + { + return 0; + } return m_StaticGameObjectGuids.Generate(); } @@ -966,7 +984,9 @@ class ObjectMgr { for (CreatureDataMap::const_iterator itr = mCreatureDataMap.begin(); itr != mCreatureDataMap.end(); ++itr) if (worker(*itr)) - { break; } + { + break; + } } CreatureLocale const* GetCreatureLocale(uint32 entry) const @@ -1059,7 +1079,9 @@ class ObjectMgr { for (GameObjectDataMap::const_iterator itr = mGameObjectDataMap.begin(); itr != mGameObjectDataMap.end(); ++itr) if (worker(*itr)) // arg = GameObjectDataPair - { break; } + { + break; + } } MangosStringLocale const* GetMangosStringLocale(int32 entry) const @@ -1072,7 +1094,9 @@ class ObjectMgr { std::map::const_iterator itr = m_loadedStringCount.find(minEntry); if (itr != m_loadedStringCount.end()) - { return itr->second; } + { + return itr->second; + } return 0; } @@ -1134,7 +1158,9 @@ class ObjectMgr { CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry); if (iter == m_mCacheNpcTextIdMap.end()) - { return 0; } + { + return 0; + } return iter->second; } @@ -1143,7 +1169,9 @@ class ObjectMgr { CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry); if (iter == m_mCacheTrainerSpellMap.end()) - { return NULL; } + { + return NULL; + } return &iter->second; } @@ -1152,7 +1180,9 @@ class ObjectMgr { CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry); if (iter == m_mCacheTrainerTemplateSpellMap.end()) - { return NULL; } + { + return NULL; + } return &iter->second; } @@ -1161,7 +1191,9 @@ class ObjectMgr { CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); if (iter == m_mCacheVendorItemMap.end()) - { return NULL; } + { + return NULL; + } return &iter->second; } @@ -1170,7 +1202,9 @@ class ObjectMgr { CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry); if (iter == m_mCacheVendorTemplateItemMap.end()) - { return NULL; } + { + return NULL; + } return &iter->second; } diff --git a/src/game/Object/ObjectPosSelector.cpp b/src/game/Object/ObjectPosSelector.cpp index c9573c7e9..ff753464c 100644 --- a/src/game/Object/ObjectPosSelector.cpp +++ b/src/game/Object/ObjectPosSelector.cpp @@ -33,11 +33,15 @@ ObjectPosSelector::ObjectPosSelector(float x, float y, float dist, float searche { // if size == 0, m_anglestep will become 0 -> freeze if (searchedForSize == 0.0f) - { searchedForSize = DEFAULT_WORLD_OBJECT_SIZE; } + { + searchedForSize = DEFAULT_WORLD_OBJECT_SIZE; + } // undefined behaviour if (m_searcherDist == 0.0f) - { m_searcherDist = DEFAULT_WORLD_OBJECT_SIZE; } + { + m_searcherDist = DEFAULT_WORLD_OBJECT_SIZE; + } m_searchedForReqHAngle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * searchedForSize / m_searcherDist); @@ -64,13 +68,17 @@ void ObjectPosSelector::AddUsedArea(WorldObject const* obj, float angle, float d // skip some unexpected results. if (dist == 0.0f) - { return; } + { + return; + } // (half) angle that obj occupies float sr_angle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * obj->GetObjectBoundingRadius() / dist); if (angle >= 0) - { m_UsedAreaLists[USED_POS_PLUS].insert(UsedArea(angle, OccupiedArea(sr_angle, obj))); } + { + 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))); } } @@ -149,13 +157,17 @@ bool ObjectPosSelector::NextAngle(float& angle) if (m_stepAngle[USED_POS_PLUS] < M_PI_F && m_stepAngle[USED_POS_PLUS] <= m_stepAngle[USED_POS_MINUS]) { if (NextSideAngle(USED_POS_PLUS, angle)) - { return true; } + { + return true; + } } // -- direction less updated else if (m_stepAngle[USED_POS_MINUS] < M_PI_F) { if (NextSideAngle(USED_POS_MINUS, angle)) - { return true; } + { + return true; + } } // both sides finishes else @@ -182,7 +194,9 @@ bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float& angle) // prevent jump to another side if (m_stepAngle[side] > M_PI_F) - { return false; } + { + return false; + } // no used area anymore on this side if (m_nextUsedAreaItr[side] == m_UsedAreaLists[side].end()) diff --git a/src/game/Object/Pet.cpp b/src/game/Object/Pet.cpp index b4dafb03b..cdca62b60 100644 --- a/src/game/Object/Pet.cpp +++ b/src/game/Object/Pet.cpp @@ -51,7 +51,9 @@ Pet::Pet(PetType type) : CharmInfo* charmInfo = InitCharmInfo(this); if (type == MINI_PET) // always passive - { charmInfo->SetReactState(REACT_PASSIVE); } + { + charmInfo->SetReactState(REACT_PASSIVE); + } } Pet::~Pet() @@ -63,7 +65,9 @@ void Pet::AddToWorld() { ///- Register the pet for guid lookup if (!IsInWorld()) - { GetMap()->GetObjectsStore().insert(GetObjectGuid(), (Pet*)this); } + { + GetMap()->GetObjectsStore().insert(GetObjectGuid(), (Pet*)this); + } Unit::AddToWorld(); } @@ -72,7 +76,9 @@ void Pet::RemoveFromWorld() { ///- Remove the pet from the accessor if (IsInWorld()) - { GetMap()->GetObjectsStore().erase(GetObjectGuid(), (Pet*)NULL); } + { + GetMap()->GetObjectsStore().erase(GetObjectGuid(), (Pet*)NULL); + } ///- Don't call the function for Creature, normal mobs + totems go in a different storage Unit::RemoveFromWorld(); @@ -200,7 +206,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType()); if (owner->IsPvP()) - { SetPvP(true); } + { + SetPvP(true); + } if (owner->IsFFAPvP()) SetFFAPvP(true); @@ -292,7 +300,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c { ((Player*)owner)->PetSpellInitialize(); if (((Player*)owner)->GetGroup()) - { ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); } + { + ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); + } ((Player*)owner)->SendTalentsInfoData(true); } @@ -323,19 +333,27 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c void Pet::SavePetToDB(PetSaveMode mode) { if (!GetEntry()) - { return; } + { + return; + } // save only fully controlled creature if (!isControlled()) - { return; } + { + return; + } // not save not player pets if (!GetOwnerGuid().IsPlayer()) - { return; } + { + return; + } Player* pOwner = (Player*)GetOwner(); if (!pOwner) - { return; } + { + return; + } // current/stable/not_in_slot if (mode >= PET_SAVE_AS_CURRENT) @@ -355,7 +373,9 @@ void Pet::SavePetToDB(PetSaveMode mode) { // pet will lost anyway at restore temporary unsummoned if (getPetType() == HUNTER_PET) - { return; } + { + return; + } // for warlock case mode = PET_SAVE_NOT_IN_SLOT; @@ -366,7 +386,9 @@ void Pet::SavePetToDB(PetSaveMode mode) // stable and not in slot saves if (mode != PET_SAVE_AS_CURRENT) - { RemoveAllAuras(); } + { + RemoveAllAuras(); + } // save pet's data as one single transaction CharacterDatabase.BeginTransaction(); @@ -445,7 +467,9 @@ void Pet::SavePetToDB(PetSaveMode mode) void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction) { if (separate_transaction) - { CharacterDatabase.BeginTransaction(); } + { + CharacterDatabase.BeginTransaction(); + } static SqlStatementID delPet ; static SqlStatementID delDeclName ; @@ -469,7 +493,9 @@ void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction) stmt.PExecute(guidlow); if (separate_transaction) - { CharacterDatabase.CommitTransaction(); } + { + CharacterDatabase.CommitTransaction(); + } } void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState @@ -479,7 +505,9 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual { // remove summoned pet (no corpse) if (getPetType() == SUMMON_PET) - { Unsummon(PET_SAVE_NOT_IN_SLOT); } + { + Unsummon(PET_SAVE_NOT_IN_SLOT); + } // other will despawn at corpse desppawning (Pet::Update code) else { @@ -500,7 +528,9 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual void Pet::Update(uint32 update_diff, uint32 diff) { if (m_removed) // pet already removed, just wait in remove queue, no updates - { return; } + { + return; + } switch (m_deathState) { @@ -538,7 +568,9 @@ void Pet::Update(uint32 update_diff, uint32 diff) if (m_duration > 0) { if (m_duration > (int32)update_diff) - { m_duration -= (int32)update_diff; } + { + m_duration -= (int32)update_diff; + } else { Unsummon(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT, owner); @@ -560,7 +592,9 @@ void Pet::RegenerateAll(uint32 update_diff) if (m_regenTimer <= update_diff) { if (!IsInCombat() || IsPolymorphed()) - { RegenerateHealth(); } + { + RegenerateHealth(); + } RegeneratePower(); @@ -576,17 +610,23 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid) uint32 chainstartstore[ACTIVE_SPELLS_MAX]; if (IsPassiveSpell(spellid)) - { return true; } + { + return true; + } chainstartstore[0] = sSpellMgr.GetFirstSpellInChain(spellid); for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) { if (itr->second.state == PETSPELL_REMOVED) - { continue; } + { + continue; + } if (IsPassiveSpell(itr->first)) - { continue; } + { + continue; + } uint32 chainstart = sSpellMgr.GetFirstSpellInChain(itr->first); @@ -595,14 +635,18 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid) for (x = 0; x < activecount; ++x) { if (chainstart == chainstartstore[x]) - { break; } + { + break; + } } if (x == activecount) // spellchain not yet saved -> add active count { ++activecount; if (activecount > ACTIVE_SPELLS_MAX) - { return false; } + { + return false; + } chainstartstore[x] = chainstart; } } @@ -612,14 +656,18 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid) void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) { if (!owner) - { owner = GetOwner(); } + { + owner = GetOwner(); + } CombatStop(); if (owner) { if (GetOwnerGuid() != owner->GetObjectGuid()) - { return; } + { + return; + } Player* p_owner = owner->GetTypeId() == TYPEID_PLAYER ? (Player*)owner : NULL; @@ -661,7 +709,9 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) p_owner->RemovePetActionBar(); if (p_owner->GetGroup()) - { p_owner->SetGroupUpdateFlag(GROUP_UPDATE_PET); } + { + p_owner->SetGroupUpdateFlag(GROUP_UPDATE_PET); + } } } @@ -678,7 +728,9 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) break; default: if (owner->GetPetGuid() == GetObjectGuid()) - { owner->SetPet(NULL); } + { + owner->SetPet(NULL); + } break; } } @@ -691,20 +743,28 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) void Pet::GivePetXP(uint32 xp) { if (getPetType() != HUNTER_PET) - { return; } + { + return; + } if (xp < 1) - { return; } + { + return; + } if (!IsAlive()) - { return; } + { + return; + } uint32 level = getLevel(); uint32 maxlevel = std::min(sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL), GetOwner()->getLevel()); // pet not receive xp for level equal to owner level if (level >= maxlevel) - { return; } + { + return; + } xp *= sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL); @@ -728,7 +788,9 @@ void Pet::GivePetXP(uint32 xp) void Pet::GivePetLevel(uint32 level) { if (!level || level == getLevel()) - { return; } + { + return; + } if (getPetType() == HUNTER_PET) { @@ -756,7 +818,9 @@ bool Pet::CreateBaseAtCreature(Creature* creature) BASIC_LOG("Create pet"); uint32 pet_number = sObjectMgr.GeneratePetNumber(); if (!Create(guid, pos, creature->GetCreatureInfo(), pet_number)) - { return false; } + { + return false; + } CreatureInfo const* cInfo = GetCreatureInfo(); if (!cInfo) @@ -774,7 +838,9 @@ bool Pet::CreateBaseAtCreature(Creature* creature) SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family)) - { SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]); } + { + SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]); + } else { SetName(creature->GetNameForLocaleIdx(sObjectMgr.GetDBCLocaleIndex())); } @@ -918,7 +984,9 @@ void Pet::InitStatsForLevel(uint32 petlevel) // 40% damage bonus of mage's frost damage float val = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) * 0.4f; if (val < 0) - { val = 0; } + { + val = 0; + } SetBonusDamage(int32(val)); break; } @@ -1097,15 +1165,21 @@ void Pet::InitStatsForLevel(uint32 petlevel) bool Pet::HaveInDiet(ItemPrototype const* item) const { if (!item->FoodType) - { return false; } + { + return false; + } CreatureInfo const* cInfo = GetCreatureInfo(); if (!cInfo) - { return false; } + { + return false; + } CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family); if (!cFamily) - { return false; } + { + return false; + } uint32 diet = cFamily->petFoodMask; uint32 FoodMask = 1 << (item->FoodType - 1); @@ -1116,7 +1190,9 @@ uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel) { // -5 or greater food level if (getLevel() <= itemlevel + 5) // possible to feed level 60 pet with level 55 level food for full effect - { return 35000; } + { + return 35000; + } // -10..-6 else if (getLevel() <= itemlevel + 10) // pure guess, but sounds good { return 17000; } @@ -1158,7 +1234,9 @@ void Pet::_LoadSpellCooldowns() // skip outdated cooldown if (db_time <= curTime) - { continue; } + { + continue; + } data << uint32(spell_id); data << uint32(uint32(db_time - curTime)*IN_MILLISECONDS); @@ -1192,7 +1270,9 @@ void Pet::_SaveSpellCooldowns() for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();) { if (itr->second <= curTime) - { m_CreatureSpellCooldowns.erase(itr++); } + { + m_CreatureSpellCooldowns.erase(itr++); + } else { stmt = CharacterDatabase.CreateStatement(insSpellCD, "INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES (?, ?, ?)"); @@ -1231,7 +1311,9 @@ void Pet::_SaveSpells() // prevent saving family passives to DB if (itr->second.type == PETSPELL_FAMILY) - { continue; } + { + continue; + } switch (itr->second.state) { @@ -1303,12 +1385,16 @@ void Pet::_LoadAuras(uint32 timediff) // do not load single target auras (unless they were cast by the player) if (casterGuid != GetObjectGuid() && IsSingleTargetSpell(spellproto)) - { continue; } + { + continue; + } if (remaintime != -1 && !IsPositiveSpell(spellproto)) { if (remaintime / IN_MILLISECONDS <= int32(timediff)) - { continue; } + { + continue; + } remaintime -= timediff * IN_MILLISECONDS; } @@ -1325,7 +1411,9 @@ void Pet::_LoadAuras(uint32 timediff) uint32 defstackamount = spellproto->GetStackAmount(); if (!defstackamount) - { stackcount = 1; } + { + stackcount = 1; + } else if (defstackamount < stackcount) stackcount = defstackamount; else if (!stackcount) @@ -1337,18 +1425,24 @@ void Pet::_LoadAuras(uint32 timediff) for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if ((effIndexMask & (1 << i)) == 0) - { continue; } + { + continue; + } Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this); if (!damage[i]) - { damage[i] = aura->GetModifier()->m_amount; } + { + damage[i] = aura->GetModifier()->m_amount; + } aura->SetLoadedState(damage[i], periodicTime[i]); holder->AddAura(aura, SpellEffectIndex(i)); } if (!holder->IsEmptyHolder()) - { AddSpellAuraHolder(holder); } + { + AddSpellAuraHolder(holder); + } else { delete holder; } } @@ -1369,7 +1463,9 @@ void Pet::_SaveAuras() SpellAuraHolderMap const& auraHolders = GetSpellAuraHolderMap(); if (auraHolders.empty()) - { return; } + { + return; + } stmt = CharacterDatabase.CreateStatement(insAuras, "INSERT INTO pet_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, " "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " @@ -1413,7 +1509,9 @@ void Pet::_SaveAuras() { // don't save not own area auras if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid()) - { continue; } + { + continue; + } damage[i] = aur->GetModifier()->m_amount; periodicTime[i] = aur->GetModifier()->periodictime; @@ -1422,7 +1520,9 @@ void Pet::_SaveAuras() } if (!effIndexMask) - { continue; } + { + continue; + } stmt.addUInt32(m_charmInfo->GetPetNumber()); stmt.addUInt64(holder->GetCasterGuid().GetRawValue()); @@ -1476,7 +1576,9 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe itr->second.state = PETSPELL_UNCHANGED; if (active == ACT_ENABLED) - { ToggleAutocast(spell_id, true); } + { + ToggleAutocast(spell_id, true); + } else if (active == ACT_DISABLED) { ToggleAutocast(spell_id, false); } @@ -1495,7 +1597,9 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here { if (IsPassiveSpell(spellInfo)) - { newspell.active = ACT_PASSIVE; } + { + newspell.active = ACT_PASSIVE; + } else { newspell.active = ACT_DISABLED; } } @@ -1551,12 +1655,16 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe m_spells[spell_id] = newspell; if (IsPassiveSpell(spellInfo)) - { CastSpell(this, spell_id, true); } + { + CastSpell(this, spell_id, true); + } else { m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); } if (newspell.active == ACT_ENABLED) - { ToggleAutocast(spell_id, true); } + { + ToggleAutocast(spell_id, true); + } uint32 talentCost = GetTalentSpellCost(spell_id); if (talentCost) @@ -1571,7 +1679,9 @@ bool Pet::learnSpell(uint32 spell_id) { // prevent duplicated entires in spell book if (!addSpell(spell_id)) - { return false; } + { + return false; + } if (!m_loading) { @@ -1652,13 +1762,19 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) { PetSpellMap::iterator itr = m_spells.find(spell_id); if (itr == m_spells.end()) - { return false; } + { + return false; + } if (itr->second.state == PETSPELL_REMOVED) - { return false; } + { + return false; + } if (itr->second.state == PETSPELL_NEW) - { m_spells.erase(itr); } + { + m_spells.erase(itr); + } else { itr->second.state = PETSPELL_REMOVED; } @@ -1678,7 +1794,9 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) if (learn_prev) { if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id)) - { learnSpell(prev_id); } + { + learnSpell(prev_id); + } else { learn_prev = false; } } @@ -1691,7 +1809,9 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) // need update action bar for last removed rank if (Unit* owner = GetOwner()) if (owner->GetTypeId() == TYPEID_PLAYER) - { ((Player*)owner)->PetSpellInitialize(); } + { + ((Player*)owner)->PetSpellInitialize(); + } } } @@ -1704,7 +1824,9 @@ void Pet::CleanupActionBar() if (UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i)) if (uint32 action = ab->GetAction()) if (ab->IsActionBarForSpell() && !HasSpell(action)) - { m_charmInfo->SetActionBar(i, 0, ACT_DISABLED); } + { + m_charmInfo->SetActionBar(i, 0, ACT_DISABLED); + } } void Pet::InitPetCreateSpells() @@ -1914,7 +2036,9 @@ uint32 Pet::resetTalentsCost() const // The first time reset costs 10 silver; after 1 day cost is reset to 10 silver if (m_resetTalentsCost < 10 * SILVER || days > 0) - { return 10 * SILVER; } + { + return 10 * SILVER; + } // then 50 silver else if (m_resetTalentsCost < 50 * SILVER) { return 50 * SILVER; } @@ -1938,7 +2062,9 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) void Pet::ToggleAutocast(uint32 spellid, bool apply) { if (IsPassiveSpell(spellid)) - { return; } + { + return; + } PetSpellMap::iterator itr = m_spells.find(spellid); PetSpell &petSpell = itr->second; @@ -1958,7 +2084,9 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) { petSpell.active = ACT_ENABLED; if (petSpell.state != PETSPELL_NEW) - { petSpell.state = PETSPELL_CHANGED; } + { + petSpell.state = PETSPELL_CHANGED; + } } } } @@ -1975,7 +2103,9 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) { petSpell.active = ACT_DISABLED; if (petSpell.state != PETSPELL_NEW) - { petSpell.state = PETSPELL_CHANGED; } + { + petSpell.state = PETSPELL_CHANGED; + } } } } @@ -1991,17 +2121,23 @@ bool Pet::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* ci m_originalEntry = cinfo->Entry; if (!InitEntry(cinfo->Entry)) - { return false; } + { + return false; + } cPos.SelectFinalPoint(this); if (!cPos.Relocate(this)) - { return false; } + { + return false; + } SetSheath(SHEATH_STATE_MELEE); if (getPetType() == MINI_PET) // always non-attackable - { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); } + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); + } return true; } @@ -2017,11 +2153,15 @@ void Pet::LearnPetPassives() { CreatureInfo const* cInfo = GetCreatureInfo(); if (!cInfo) - { return; } + { + return; + } CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family); if (!cFamily) - { return; } + { + return; + } PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID); if (petStore != sPetFamilySpellsStore.end()) @@ -2044,7 +2184,9 @@ void Pet::CastPetAuras(bool current) ++itr; if (!current && pa->IsRemovedOnChangePet()) - { owner->RemovePetAura(pa); } + { + owner->RemovePetAura(pa); + } else { CastPetAura(pa); } } @@ -2092,7 +2234,9 @@ void Pet::CastPetAura(PetAura const* aura) { uint32 auraId = aura->GetAura(GetEntry()); if (!auraId) - { return; } + { + return; + } if (auraId == 35696) // Demonic Knowledge { @@ -2122,7 +2266,9 @@ void Pet::SynchronizeLevelWithOwner() { Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } switch (getPetType()) { @@ -2133,7 +2279,9 @@ void Pet::SynchronizeLevelWithOwner() // can't be greater owner level case HUNTER_PET: if (getLevel() > owner->getLevel()) - { GivePetLevel(owner->getLevel()); } + { + GivePetLevel(owner->getLevel()); + } else if (getLevel() + 5 < owner->getLevel()) GivePetLevel(owner->getLevel() - 5); break; @@ -2148,7 +2296,9 @@ void Pet::SetModeFlags(PetModeFlags mode) Unit* owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } WorldPacket data(SMSG_PET_MODE, 12); data << GetObjectGuid(); diff --git a/src/game/Object/PetAI.cpp b/src/game/Object/PetAI.cpp index 32a4f6f35..314c49221 100644 --- a/src/game/Object/PetAI.cpp +++ b/src/game/Object/PetAI.cpp @@ -37,7 +37,9 @@ int PetAI::Permissible(const Creature* creature) { if (creature->IsPet()) - { return PERMIT_BASE_SPECIAL; } + { + return PERMIT_BASE_SPECIAL; + } return PERMIT_BASE_NO; } @@ -75,7 +77,9 @@ void PetAI::MoveInLineOfSight(Unit* pWho) void PetAI::AttackStart(Unit* u) { if (!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET)) - { return; } + { + return; + } if (m_creature->Attack(u, true)) { @@ -103,7 +107,9 @@ bool PetAI::_needToStop() const { // This is needed for charmed creatures, as once their target was reset other effects can trigger threat if (m_creature->IsCharmed() && m_creature->getVictim() == m_creature->GetCharmer()) - { return true; } + { + return true; + } return !m_creature->getVictim()->IsTargetableForAttack(); } @@ -129,7 +135,9 @@ void PetAI::_stopAttack() void PetAI::UpdateAI(const uint32 diff) { if (!m_creature->IsAlive()) - { return; } + { + return; + } Unit* owner = m_creature->GetCharmerOrOwner(); Unit* victim = NULL; @@ -218,21 +226,29 @@ void PetAI::UpdateAI(const uint32 diff) { uint32 spellID = m_creature->GetPetAutoSpellOnPos(i); if (!spellID) - { continue; } + { + continue; + } SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID); if (!spellInfo) - { continue; } + { + continue; + } if (m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) - { continue; } + { + continue; + } // ignore some combinations of combat state and combat/noncombat spells if (!inCombat) { // ignore attacking spells, and allow only self/around spells if (!IsPositiveSpell(spellInfo->Id)) - { continue; } + { + continue; + } // non combat spells allowed // only pet spells have IsNonCombatSpell and not fit this reqs: @@ -242,14 +258,18 @@ void PetAI::UpdateAI(const uint32 diff) int32 duration = GetSpellDuration(spellInfo); SpellPowerEntry const* spellPower = spellInfo->GetSpellPower(); if (spellPower && (spellPower->manaCost || spellPower->ManaCostPercentage || spellPower->manaPerSecond) && duration > 0) - { continue; } + { + continue; + } // allow only spell without cooldown > duration int32 cooldown = GetSpellRecoveryTime(spellInfo); // allow only spell not on cooldown if (cooldown != 0 && duration < cooldown) - { continue; } + { + continue; + } } } // just ignore non-combat spells @@ -272,7 +292,9 @@ void PetAI::UpdateAI(const uint32 diff) // only buff targets that are in combat, unless the spell can only be cast while out of combat if (!Target) - { continue; } + { + continue; + } if (spell->CanAutoCast(Target)) { @@ -282,7 +304,9 @@ void PetAI::UpdateAI(const uint32 diff) } } if (!spellUsed) - { delete spell; } + { + delete spell; + } } } @@ -303,10 +327,14 @@ void PetAI::UpdateAI(const uint32 diff) { m_creature->SetInFront(target); if (target->GetTypeId() == TYPEID_PLAYER) - { m_creature->SendCreateUpdateToPlayer((Player*)target); } + { + m_creature->SendCreateUpdateToPlayer((Player*)target); + } if (owner && owner->GetTypeId() == TYPEID_PLAYER) - { m_creature->SendCreateUpdateToPlayer((Player*)owner); } + { + m_creature->SendCreateUpdateToPlayer((Player*)owner); + } } m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id); @@ -433,16 +461,22 @@ void PetAI::UpdateAllies() m_updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance if (!owner) - { return; } + { + return; + } else if (owner->GetTypeId() == TYPEID_PLAYER) { pGroup = ((Player*)owner)->GetGroup(); } // only pet and owner/not in group->ok if (m_AllySet.size() == 2 && !pGroup) - { return; } + { + return; + } // owner is in group; group members filled in already (no raid -> subgroupcount = whole count) if (pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2)) - { return; } + { + return; + } m_AllySet.clear(); m_AllySet.insert(m_creature->GetObjectGuid()); @@ -452,10 +486,14 @@ void PetAI::UpdateAllies() { Player* target = itr->getSource(); if (!target || !pGroup->SameSubGroup((Player*)owner, target)) - { continue; } + { + continue; + } if (target->GetObjectGuid() == owner->GetObjectGuid()) - { continue; } + { + continue; + } m_AllySet.insert(target->GetObjectGuid()); } diff --git a/src/game/Object/Player.cpp b/src/game/Object/Player.cpp index b2d76d388..eb17bc8d7 100644 --- a/src/game/Object/Player.cpp +++ b/src/game/Object/Player.cpp @@ -224,11 +224,15 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team } if (m_TaxiDestinations.empty()) - { return true; } + { + return true; + } // Check integrity if (m_TaxiDestinations.size() < 2) - { return false; } + { + return false; + } for (size_t i = 1; i < m_TaxiDestinations.size(); ++i) { @@ -236,12 +240,16 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team uint32 path; sObjectMgr.GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost); if (!path) - { return false; } + { + return false; + } } // can't load taxi path without mount set (quest taxi path?) if (!sObjectMgr.GetTaxiMountDisplayId(GetTaxiSource(), team, true)) - { return false; } + { + return false; + } return true; } @@ -249,7 +257,9 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team std::string PlayerTaxi::SaveTaxiDestinationsToString() { if (m_TaxiDestinations.empty()) - { return ""; } + { + return ""; + } std::ostringstream ss; @@ -262,7 +272,9 @@ std::string PlayerTaxi::SaveTaxiDestinationsToString() uint32 PlayerTaxi::GetCurrentTaxiPath() const { if (m_TaxiDestinations.size() < 2) - { return 0; } + { + return 0; + } uint32 path; uint32 cost; @@ -294,7 +306,9 @@ bool TradeData::HasItem(ObjectGuid item_guid) const { for (int i = 0; i < TRADE_SLOT_COUNT; ++i) if (m_items[i] == item_guid) - { return true; } + { + return true; + } return false; } @@ -309,7 +323,9 @@ void TradeData::SetItem(TradeSlots slot, Item* item) ObjectGuid itemGuid = item ? item->GetObjectGuid() : ObjectGuid(); if (m_items[slot] == itemGuid) - { return; } + { + return; + } m_items[slot] = itemGuid; @@ -320,7 +336,9 @@ void TradeData::SetItem(TradeSlots slot, Item* item) // need remove possible trader spell applied to changed item if (slot == TRADE_SLOT_NONTRADED) - { GetTraderData()->SetSpell(0); } + { + GetTraderData()->SetSpell(0); + } // need remove possible player spell applied (possible move reagent) SetSpell(0); @@ -331,7 +349,9 @@ void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/) ObjectGuid itemGuid = castItem ? castItem->GetObjectGuid() : ObjectGuid(); if (m_spell == spell_id && m_spellCastItem == itemGuid) - { return; } + { + return; + } m_spell = spell_id; m_spellCastItem = itemGuid; @@ -346,7 +366,9 @@ void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/) void TradeData::SetMoney(uint64 money) { if (m_money == money) - { return; } + { + return; + } if (money > m_player->GetMoney()) { @@ -377,7 +399,9 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/) if (!state) { if (crosssend) - { m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); } + { + m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); + } else { m_player->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); } } @@ -405,11 +429,15 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_ m_ExtraFlags = 0; if (GetSession()->GetSecurity() >= SEC_GAMEMASTER) - { SetAcceptTicket(true); } + { + SetAcceptTicket(true); + } // players always accept if (GetSession()->GetSecurity() == SEC_PLAYER) - { SetAcceptWhispers(true); } + { + SetAcceptWhispers(true); + } m_comboPoints = 0; @@ -786,14 +814,18 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j) { if (oEntry->ItemId[j] <= 0) - { continue; } + { + continue; + } uint32 item_id = oEntry->ItemId[j]; // just skip, reported in ObjectMgr::LoadItemPrototypes ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(item_id); if (!iProto) - { continue; } + { + continue; + } // BuyCount by default int32 count = iProto->BuyCount; @@ -850,7 +882,9 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c // if this is ammo then use it msg = CanUseAmmo(pItem->GetEntry()); if (msg == EQUIP_ERR_OK) - { SetAmmo(pItem->GetEntry()); } + { + SetAmmo(pItem->GetEntry()); + } } } } @@ -872,7 +906,9 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) uint16 eDest; uint8 msg = CanEquipNewItem(NULL_SLOT, eDest, titem_id, false); if (msg != EQUIP_ERR_OK) - { break; } + { + break; + } EquipNewItem(eDest, titem_id, true); AutoUnequipOffhandIfNeed(); @@ -907,7 +943,9 @@ Item* Player::StoreNewItemInInventorySlot(uint32 itemEntry, uint32 amount) if (msg == EQUIP_ERR_OK) { if (Item* pItem = StoreNewItem(vDest, itemEntry, true, Item::GenerateItemRandomPropertyId(itemEntry))) - { return pItem; } + { + return pItem; + } } return NULL; @@ -918,7 +956,9 @@ void Player::SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 Curre if (int(MaxValue) == DISABLED_MIRROR_TIMER) { if (int(CurrentValue) != DISABLED_MIRROR_TIMER) - { StopMirrorTimer(Type); } + { + StopMirrorTimer(Type); + } return; } WorldPacket data(SMSG_START_MIRROR_TIMER, (21)); @@ -942,13 +982,17 @@ void Player::StopMirrorTimer(MirrorTimerType Type) uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) { if (!IsAlive() || isGameMaster()) - { return 0; } + { + return 0; + } // Absorb, resist some environmental damage type uint32 absorb = 0; uint32 resist = 0; if (type == DAMAGE_LAVA) - { CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist); } + { + 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); } @@ -993,7 +1037,9 @@ int32 Player::getMaxTimer(MirrorTimerType timer) { case FATIGUE_TIMER: if (GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_GMLEVEL)) - { return DISABLED_MIRROR_TIMER; } + { + return DISABLED_MIRROR_TIMER; + } return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_MAX) * IN_MILLISECONDS; case BREATH_TIMER: { @@ -1009,7 +1055,9 @@ int32 Player::getMaxTimer(MirrorTimerType timer) case FIRE_TIMER: { if (!IsAlive() || GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL)) - { return DISABLED_MIRROR_TIMER; } + { + return DISABLED_MIRROR_TIMER; + } return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_MAX) * IN_MILLISECONDS; } default: @@ -1022,13 +1070,17 @@ void Player::UpdateMirrorTimers() { // Desync flags for update on next HandleDrowning if (m_MirrorTimerFlags) - { m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags; } + { + m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags; + } } void Player::HandleDrowning(uint32 time_diff) { if (!m_MirrorTimerFlags) - { return; } + { + return; + } // In water if (m_MirrorTimerFlags & UNDERWATER_INWATER) @@ -1061,7 +1113,9 @@ void Player::HandleDrowning(uint32 time_diff) // Need breath regen m_MirrorTimer[BREATH_TIMER] += 10 * time_diff; if (m_MirrorTimer[BREATH_TIMER] >= UnderWaterTime || !IsAlive()) - { StopMirrorTimer(BREATH_TIMER); } + { + StopMirrorTimer(BREATH_TIMER); + } else if (m_MirrorTimerFlagsLast & UNDERWATER_INWATER) { SendMirrorTimer(BREATH_TIMER, UnderWaterTime, m_MirrorTimer[BREATH_TIMER], 10); } } @@ -1099,7 +1153,9 @@ void Player::HandleDrowning(uint32 time_diff) int32 DarkWaterTime = getMaxTimer(FATIGUE_TIMER); m_MirrorTimer[FATIGUE_TIMER] += 10 * time_diff; if (m_MirrorTimer[FATIGUE_TIMER] >= DarkWaterTime || !IsAlive()) - { StopMirrorTimer(FATIGUE_TIMER); } + { + StopMirrorTimer(FATIGUE_TIMER); + } else if (m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER) { SendMirrorTimer(FATIGUE_TIMER, DarkWaterTime, m_MirrorTimer[FATIGUE_TIMER], 10); } } @@ -1108,7 +1164,9 @@ void Player::HandleDrowning(uint32 time_diff) { // Breath timer not activated - activate it if (m_MirrorTimer[FIRE_TIMER] == DISABLED_MIRROR_TIMER) - { m_MirrorTimer[FIRE_TIMER] = getMaxTimer(FIRE_TIMER); } + { + m_MirrorTimer[FIRE_TIMER] = getMaxTimer(FIRE_TIMER); + } else { m_MirrorTimer[FIRE_TIMER] -= time_diff; @@ -1119,7 +1177,9 @@ void Player::HandleDrowning(uint32 time_diff) // TODO: Check this formula uint32 damage = urand(600, 700); if (m_MirrorTimerFlags & UNDERWATER_INLAVA) - { EnvironmentalDamage(DAMAGE_LAVA, damage); } + { + EnvironmentalDamage(DAMAGE_LAVA, damage); + } // need to skip Slime damage in Undercity, // maybe someone can find better way to handle environmental damage //else if (m_zoneUpdateId != 1497) @@ -13117,7 +13177,9 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me if (pMenuData.m_gAction_script) { if (pSource->GetTypeId() == TYPEID_UNIT) - { GetMap()->ScriptsStart(DBS_ON_GOSSIP, pMenuData.m_gAction_script, pSource, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); } + { + 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); } } @@ -13160,7 +13222,9 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource) // Start related script if (scriptId) - { GetMap()->ScriptsStart(DBS_ON_GOSSIP, scriptId, this, pSource, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET); } + { + GetMap()->ScriptsStart(DBS_ON_GOSSIP, scriptId, this, pSource, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET); + } return textId; } @@ -13705,7 +13769,9 @@ void Player::AddQuest(Quest const* pQuest, Object* questGiver) // starting initial DB quest script if (pQuest->GetQuestStartScript() != 0) - { GetMap()->ScriptsStart(DBS_ON_QUEST_START, pQuest->GetQuestStartScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); } + { + GetMap()->ScriptsStart(DBS_ON_QUEST_START, pQuest->GetQuestStartScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); + } } // remove start item if not need @@ -13928,7 +13994,9 @@ void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, } if (!handled && pQuest->GetQuestCompleteScript() != 0) - { GetMap()->ScriptsStart(DBS_ON_QUEST_END, pQuest->GetQuestCompleteScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); } + { + GetMap()->ScriptsStart(DBS_ON_QUEST_END, pQuest->GetQuestCompleteScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); + } // cast spells after mark quest complete (some spells have quest completed state reqyurements in spell_area data) if (pQuest->GetRewSpellCast() > 0) @@ -16022,7 +16090,9 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) case 1: SetGameMaster(true); break; // enable case 2: // save state if (extraflags & PLAYER_EXTRA_GM_ON) - { SetGameMaster(true); } + { + SetGameMaster(true); + } break; } @@ -16084,7 +16154,9 @@ bool Player::IsTappedByMeOrMyGroup(Creature* creature) { /* Nobody tapped the monster (solo kill by another NPC) */ if (!creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED)) - { return false; } + { + return false; + } /* If there is a loot recipient, assign it to recipient */ if (Player* recipient = creature->GetLootRecipient()) @@ -18183,7 +18255,9 @@ void Player::outDebugStatsValues() const { // optimize disabled debug output if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG) || sLog.HasLogFilter(LOG_FILTER_PLAYER_STATS)) - { return; } + { + return; + } sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u", GetMaxHealth(), GetMaxPower(POWER_MANA)); sLog.outDebug("AGILITY is: \t\t%f\t\tSTRENGTH is: \t\t%f", GetStat(STAT_AGILITY), GetStat(STAT_STRENGTH)); diff --git a/src/game/Object/Player.h b/src/game/Object/Player.h index dc91568b7..4e3187b9c 100644 --- a/src/game/Object/Player.h +++ b/src/game/Object/Player.h @@ -209,7 +209,9 @@ struct ActionButton { packedData = newData; if (uState != ACTIONBUTTON_NEW) - { uState = ACTIONBUTTON_CHANGED; } + { + uState = ACTIONBUTTON_CHANGED; + } } } }; @@ -1185,7 +1187,9 @@ class Player : public Unit m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY | PLAYER_EXTRA_AUCTION_NEUTRAL); if (state < 0) - { m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY; } + { + m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY; + } else if (state > 0) { m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL; } } @@ -1308,7 +1312,9 @@ class Player : public Unit InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const { if (!pItem) - { return EQUIP_ERR_ITEM_NOT_FOUND; } + { + return EQUIP_ERR_ITEM_NOT_FOUND; + } uint32 count = pItem->GetCount(); return _CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); } @@ -2284,7 +2290,9 @@ class Player : public Unit { for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE) - { return true; } + { + return true; + } return false; } @@ -2300,14 +2308,18 @@ class Player : public Unit { for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId) - { return i; } + { + return i; + } return PLAYER_MAX_BATTLEGROUND_QUEUES; } bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const { for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId) - { return m_bgBattleGroundQueueID[i].invitedToInstance != 0; } + { + return m_bgBattleGroundQueueID[i].invitedToInstance != 0; + } return false; } bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const @@ -2338,7 +2350,9 @@ class Player : public Unit { for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE) - { return true; } + { + return true; + } return false; } void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val) @@ -2357,13 +2371,17 @@ class Player : public Unit { for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId) - { m_bgBattleGroundQueueID[i].invitedToInstance = instanceId; } + { + m_bgBattleGroundQueueID[i].invitedToInstance = instanceId; + } } bool IsInvitedForBattleGroundInstance(uint32 instanceId) const { for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId) - { return true; } + { + return true; + } return false; } WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; } @@ -2876,7 +2894,9 @@ class Player : public Unit void ScheduleDelayedOperation(uint32 operation) { if (operation < DELAYED_END) - { m_DelayedOperations |= operation; } + { + m_DelayedOperations |= operation; + } } void _fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& twoHandScore); diff --git a/src/game/Object/StatSystem.cpp b/src/game/Object/StatSystem.cpp index 66aa6b5e9..e0ad2a2dc 100644 --- a/src/game/Object/StatSystem.cpp +++ b/src/game/Object/StatSystem.cpp @@ -40,7 +40,9 @@ bool Player::UpdateStats(Stats stat) { if (stat > STAT_SPIRIT) - { return false; } + { + return false; + } // value = ((base_value * base_pct) + total_value) * total_pct float value = GetTotalStatValue(stat); @@ -346,7 +348,9 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) { UpdateDamagePhysical(BASE_ATTACK); if (CanDualWield() && haveOffhandWeapon()) // allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon - { UpdateDamagePhysical(OFF_ATTACK); } + { + UpdateDamagePhysical(OFF_ATTACK); + } } } @@ -711,7 +715,9 @@ void Player::UpdateManaRegen() // Set regen rate in cast state apply only on spirit based regen int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); if (modManaRegenInterrupt > 100) - { modManaRegenInterrupt = 100; } + { + modManaRegenInterrupt = 100; + } SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, base_regen + power_regen_mp5 + spirit_regen * modManaRegenInterrupt / 100.0f); SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, base_regen + 0.001f + power_regen_mp5 + spirit_regen); @@ -868,7 +874,9 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged) SetFloatValue(index_mult, attPowerMultiplier); // UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field if (ranged) - { return; } + { + return; + } // automatically update weapon damage after attack power modification UpdateDamagePhysical(BASE_ATTACK); @@ -878,7 +886,9 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged) void Creature::UpdateDamagePhysical(WeaponAttackType attType) { if (attType > OFF_ATTACK) - { return; } + { + return; + } UnitMods unitMod = (attType == BASE_ATTACK ? UNIT_MOD_DAMAGE_MAINHAND : UNIT_MOD_DAMAGE_OFFHAND); @@ -909,7 +919,9 @@ void Creature::UpdateDamagePhysical(WeaponAttackType attType) bool Pet::UpdateStats(Stats stat) { if (stat > STAT_SPIRIT) - { return false; } + { + return false; + } // value = ((base_value * base_pct) + total_value) * total_pct float value = GetTotalStatValue(stat); @@ -1026,14 +1038,18 @@ void Pet::UpdateMaxPower(Powers power) void Pet::UpdateAttackPowerAndDamage(bool ranged) { if (ranged) - { return; } + { + return; + } float val = 0.0f; float bonusAP = 0.0f; UnitMods unitMod = UNIT_MOD_ATTACK_POWER; if (GetEntry() == 416) // imp's attack power - { val = GetStat(STAT_STRENGTH) - 10.0f; } + { + val = GetStat(STAT_STRENGTH) - 10.0f; + } else { val = 2 * GetStat(STAT_STRENGTH) - 20.0f; } @@ -1087,7 +1103,9 @@ void Pet::UpdateAttackPowerAndDamage(bool ranged) void Pet::UpdateDamagePhysical(WeaponAttackType attType) { if (attType > BASE_ATTACK) - { return; } + { + return; + } UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 1001babab..e8e2992ea 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -604,7 +604,9 @@ Unit::~Unit() void Unit::Update(uint32 update_diff, uint32 p_time) { if (!IsInWorld()) - { return; } + { + return; + } /*if(p_time > m_AurasCheck) { @@ -639,7 +641,9 @@ void Unit::Update(uint32 update_diff, uint32 p_time) { // m_CombatTimer set at aura start and it will be freeze until aura removing if (m_CombatTimer <= update_diff) - { CombatStop(); } + { + CombatStop(); + } else { m_CombatTimer -= update_diff; } } @@ -684,10 +688,14 @@ bool Unit::UpdateMeleeAttackingState() { Unit* victim = getVictim(); if (!victim || IsNonMeleeSpellCasted(false)) - { return false; } + { + return false; + } if (!isAttackReady(BASE_ATTACK) && !(isAttackReady(OFF_ATTACK) && haveOffhandWeapon())) - { return false; } + { + return false; + } uint8 swingError = 0; if (!CanReachWithMeleeAttack(victim)) @@ -711,7 +719,9 @@ bool Unit::UpdateMeleeAttackingState() if (haveOffhandWeapon()) { if (getAttackTimer(OFF_ATTACK) < ATTACK_DISPLAY_DELAY) - { setAttackTimer(OFF_ATTACK, ATTACK_DISPLAY_DELAY); } + { + setAttackTimer(OFF_ATTACK, ATTACK_DISPLAY_DELAY); + } } AttackerStateUpdate(victim, BASE_ATTACK); resetAttackTimer(BASE_ATTACK); @@ -721,7 +731,9 @@ bool Unit::UpdateMeleeAttackingState() // prevent base and off attack in same time, delay attack at 0.2 sec uint32 base_att = getAttackTimer(BASE_ATTACK); if (base_att < ATTACK_DISPLAY_DELAY) - { setAttackTimer(BASE_ATTACK, ATTACK_DISPLAY_DELAY); } + { + setAttackTimer(BASE_ATTACK, ATTACK_DISPLAY_DELAY); + } // do attack AttackerStateUpdate(victim, OFF_ATTACK); resetAttackTimer(OFF_ATTACK); @@ -732,7 +744,9 @@ bool Unit::UpdateMeleeAttackingState() if (player && swingError != player->LastSwingErrorMsg()) { if (swingError == 1) - { player->SendAttackSwingNotInRange(); } + { + player->SendAttackSwingNotInRange(); + } else if (swingError == 2) { player->SendAttackSwingBadFacingAttack(); } player->SwingErrorMsg(swingError); @@ -744,10 +758,14 @@ bool Unit::UpdateMeleeAttackingState() bool Unit::haveOffhandWeapon() const { if (!CanUseEquippedWeapon(OFF_ATTACK)) - { return false; } + { + return false; + } if (GetTypeId() == TYPEID_PLAYER) - { return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK, true, true); } + { + return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK, true, true); + } else { uint32 ItemId = GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1); @@ -781,7 +799,9 @@ float Unit::GetCombatReach(Unit const* pVictim, bool forMeleeRange /*=true*/, fl BASE_MELEERANGE_OFFSET + flat_mod; if (forMeleeRange && reach < ATTACK_DISTANCE) - { reach = ATTACK_DISTANCE; } + { + reach = ATTACK_DISTANCE; + } return reach; } @@ -856,7 +876,9 @@ void Unit::DealDamageMods(Unit* pVictim, uint32& damage, uint32* absorb) if (!pVictim->IsAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())) { if (absorb) - { *absorb += damage; } + { + *absorb += damage; + } damage = 0; return; } @@ -874,13 +896,19 @@ void Unit::DealDamageMods(Unit* pVictim, uint32& damage, uint32* absorb) // Script Event damage Deal if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) - { ((Creature*)this)->AI()->DamageDeal(pVictim, damage); } + { + ((Creature*)this)->AI()->DamageDeal(pVictim, damage); + } // Script Event damage taken if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->AI()) - { ((Creature*)pVictim)->AI()->DamageTaken(this, damage); } + { + ((Creature*)pVictim)->AI()->DamageTaken(this, damage); + } if (absorb && originalDamage > damage) - { *absorb += (originalDamage - damage); } + { + *absorb += (originalDamage - damage); + } } uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellProto, bool durabilityLoss) @@ -1030,7 +1058,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa ((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, damage); if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->IsPet() && !((Creature*)pVictim)->HasLootRecipient()) - { ((Creature*)pVictim)->SetLootRecipient(this); } + { + ((Creature*)pVictim)->SetLootRecipient(this); + } if (health <= damage) { @@ -1049,13 +1079,17 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa group_tap = ((Creature*)pVictim)->GetGroupLootRecipient(); if (Player* recipient = ((Creature*)pVictim)->GetOriginalLootRecipient()) - { player_tap = recipient; } + { + player_tap = recipient; + } } // in player kill case group tap selected by player_tap (killer-player itself, or charmer, or owner, etc) else { if (player_tap) - { group_tap = player_tap->GetGroup(); } + { + group_tap = player_tap->GetGroup(); + } } // Spirit of Redemtion Talent @@ -1089,7 +1123,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa data << pVictim->GetObjectGuid(); // victim if (group_tap) - { group_tap->BroadcastPacket(&data, false, group_tap->GetMemberGroup(player_tap->GetObjectGuid()), player_tap->GetObjectGuid()); } + { + group_tap->BroadcastPacket(&data, false, group_tap->GetMemberGroup(player_tap->GetObjectGuid()), player_tap->GetObjectGuid()); + } player_tap->SendDirectMessage(&data); } @@ -1100,7 +1136,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa if (player_tap != pVictim) { if (group_tap) - { group_tap->RewardGroupAtKill(pVictim, player_tap); } + { + group_tap->RewardGroupAtKill(pVictim, player_tap); + } else if (player_tap) { player_tap->RewardSinglePlayerAtKill(pVictim); } } @@ -1120,7 +1158,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa // save value before aura remove uint32 ressSpellId = pVictim->GetUInt32Value(PLAYER_SELF_RES_SPELL); if (!ressSpellId) - { ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId(); } + { + ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId(); + } // Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers) pVictim->RemoveAllAurasOnDeath(); @@ -1136,7 +1176,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa // Call KilledUnit for creatures if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) - { ((Creature*)this)->AI()->KilledUnit(pVictim); } + { + ((Creature*)this)->AI()->KilledUnit(pVictim); + } if (Creature* killer = ToCreature()) { @@ -1160,7 +1202,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa // remember victim PvP death for corpse type and corpse reclaim delay // at original death (not at SpiritOfRedemtionTalent timeout) if (!damageFromSpiritOfRedemtionTalent) - { playerVictim->SetPvPDeath(player_tap != NULL); } + { + playerVictim->SetPvPDeath(player_tap != NULL); + } // achievement stuff playerVictim->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health); @@ -1208,7 +1252,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa { // selfkills are not handled in outdoor pvp scripts if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(playerVictim->GetCachedZoneId())) - { outdoorPvP->HandlePlayerKill(player_tap, playerVictim); } + { + outdoorPvP->HandlePlayerKill(player_tap, playerVictim); + } } // Used by Eluna @@ -1282,14 +1328,18 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa { // skip channeled spell (processed differently below) if (i == CURRENT_CHANNELED_SPELL) - { continue; } + { + continue; + } if (Spell* spell = pVictim->GetCurrentSpell(CurrentSpellTypes(i))) { if (spell->getState() == SPELL_STATE_PREPARING) { if(spell->m_spellInfo->GetInterruptFlags() & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG) - { pVictim->InterruptSpell(CurrentSpellTypes(i)); } + { + pVictim->InterruptSpell(CurrentSpellTypes(i)); + } else { spell->Delayed(); } } @@ -1305,7 +1355,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa if (channelInterruptFlags & CHANNEL_FLAG_DELAY) { if (pVictim != this) // don't shorten the duration of channeling if you damage yourself - { spell->DelayedChannel(); } + { + spell->DelayedChannel(); + } } else if ((channelInterruptFlags & (CHANNEL_FLAG_DAMAGE | CHANNEL_FLAG_DAMAGE2))) { @@ -1353,7 +1405,9 @@ struct PetOwnerKilledUnitHelper if (pTarget->GetTypeId() == TYPEID_UNIT) { if (((Creature*)pTarget)->AI()) - { ((Creature*)pTarget)->AI()->OwnerKilledUnit(m_victim); } + { + ((Creature*)pTarget)->AI()->OwnerKilledUnit(m_victim); + } } } @@ -1369,7 +1423,9 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer) if (victim->GetCreatureType() == CREATURE_TYPE_CRITTER && GetTypeId() == TYPEID_PLAYER) { if (CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(victim->GetEntry())) - { ((Player*)this)->KilledMonster(normalInfo, victim->GetObjectGuid()); } + { + ((Player*)this)->KilledMonster(normalInfo, victim->GetObjectGuid()); + } } // Interrupt channeling spell when a Possessed Summoned is killed @@ -1381,14 +1437,18 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer) { Spell* channeledSpell = creator->GetCurrentSpell(CURRENT_CHANNELED_SPELL); if (channeledSpell && channeledSpell->m_spellInfo->Id == spellInfo->Id) - { creator->InterruptNonMeleeSpells(false); } + { + creator->InterruptNonMeleeSpells(false); + } } } /* ******************************* Inform various hooks ************************************ */ // Inform victim's AI if (victim->AI()) - { victim->AI()->JustDied(this); } + { + victim->AI()->JustDied(this); + } // Inform Owner Unit* pOwner = victim->GetCharmerOrOwner(); @@ -1398,17 +1458,23 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer) if (pSummon->GetSummonerGuid().IsCreatureOrVehicle()) if (Creature* pSummoner = victim->GetMap()->GetCreature(pSummon->GetSummonerGuid())) if (pSummoner->AI()) - { pSummoner->AI()->SummonedCreatureJustDied(victim); } + { + pSummoner->AI()->SummonedCreatureJustDied(victim); + } } else if (pOwner && pOwner->GetTypeId() == TYPEID_UNIT) { if (((Creature*)pOwner)->AI()) - { ((Creature*)pOwner)->AI()->SummonedCreatureJustDied(victim); } + { + ((Creature*)pOwner)->AI()->SummonedCreatureJustDied(victim); + } } // Inform Instance Data and Linking if (InstanceData* mapInstance = victim->GetInstanceData()) - { mapInstance->OnCreatureDeath(victim); } + { + mapInstance->OnCreatureDeath(victim); + } if (responsiblePlayer) // killedby Player, inform BG if (BattleGround* bg = responsiblePlayer->GetBattleGround()) @@ -1421,13 +1487,17 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer) // Notify the outdoor pvp script if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(responsiblePlayer ? responsiblePlayer->GetCachedZoneId() : GetZoneId())) - { outdoorPvP->HandleCreatureDeath(victim); } + { + outdoorPvP->HandleCreatureDeath(victim); + } // Start creature death script GetMap()->ScriptsStart(DBS_ON_CREATURE_DEATH, victim->GetEntry(), victim, responsiblePlayer ? responsiblePlayer : this); if (victim->IsLinkingEventTrigger()) - { victim->GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DIE, victim); } + { + victim->GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DIE, victim); + } // Dungeon specific stuff if (victim->GetInstanceId()) @@ -1441,7 +1511,9 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer) if (m->IsRaidOrHeroicDungeon()) { if (victim->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_INSTANCE_BIND) - { ((DungeonMap*)m)->PermBindAllPlayers(creditedPlayer); } + { + ((DungeonMap*)m)->PermBindAllPlayers(creditedPlayer); + } } else { @@ -1450,7 +1522,9 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer) // until the players leave the instance time_t resettime = victim->GetRespawnTimeEx() + 2 * HOUR; if (save->GetResetTime() < resettime) - { save->SetResetTime(resettime); } + { + save->SetResetTime(resettime); + } } // update encounter state if needed ((DungeonMap*)m)->GetPersistanceState()->UpdateEncounterState(ENCOUNTER_CREDIT_KILL_CREATURE, victim->GetEntry()); @@ -1484,7 +1558,9 @@ void Unit::CastStop(uint32 except_spellid) { for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id != except_spellid) - { InterruptSpell(CurrentSpellTypes(i), false); } + { + InterruptSpell(CurrentSpellTypes(i), false); + } } void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) @@ -1494,7 +1570,9 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castIte if (!spellInfo) { if (triggeredByAura) - { sLog.outError("CastSpell: unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); } + { + 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()); } return; @@ -1508,19 +1586,25 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, if (!spellInfo) { if (triggeredByAura) - { sLog.outError("CastSpell: unknown spell by caster: %s triggered by aura %u (eff %u)", GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); } + { + 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()); } return; } if (castItem) - { DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); } + { + DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); + } if (triggeredByAura) { if (!originalCaster) - { originalCaster = triggeredByAura->GetCasterGuid(); } + { + originalCaster = triggeredByAura->GetCasterGuid(); + } triggeredBy = triggeredByAura->GetSpellProto(); } @@ -1540,7 +1624,9 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, targets.setUnitTarget(Victim); if (spellInfo->GetTargets() & TARGET_FLAG_DEST_LOCATION) - { targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); } + { + targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); + } if (spellInfo->GetTargets() & TARGET_FLAG_SOURCE_LOCATION) if (WorldObject* caster = spell->GetCastingObject()) targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); @@ -1577,12 +1663,16 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 cons } if (castItem) - { DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); } + { + DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); + } if (triggeredByAura) { if (!originalCaster) - { originalCaster = triggeredByAura->GetCasterGuid(); } + { + originalCaster = triggeredByAura->GetCasterGuid(); + } triggeredBy = triggeredByAura->GetSpellProto(); } @@ -1590,23 +1680,33 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 cons Spell* spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy); if (bp0) - { spell->m_currentBasePoints[EFFECT_INDEX_0] = *bp0; } + { + spell->m_currentBasePoints[EFFECT_INDEX_0] = *bp0; + } if (bp1) - { spell->m_currentBasePoints[EFFECT_INDEX_1] = *bp1; } + { + spell->m_currentBasePoints[EFFECT_INDEX_1] = *bp1; + } if (bp2) - { spell->m_currentBasePoints[EFFECT_INDEX_2] = *bp2; } + { + spell->m_currentBasePoints[EFFECT_INDEX_2] = *bp2; + } SpellCastTargets targets; targets.setUnitTarget(Victim); spell->m_CastItem = castItem; if (spellInfo->GetTargets() & TARGET_FLAG_DEST_LOCATION) - { targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); } + { + targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); + } if (spellInfo->GetTargets() & TARGET_FLAG_SOURCE_LOCATION) if (WorldObject* caster = spell->GetCastingObject()) - { targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); } + { + targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); + } spell->SpellStart(&targets, triggeredByAura); } @@ -1641,12 +1741,16 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const* spellInfo, boo } if (castItem) - { DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); } + { + DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); + } if (triggeredByAura) { if (!originalCaster) - { originalCaster = triggeredByAura->GetCasterGuid(); } + { + originalCaster = triggeredByAura->GetCasterGuid(); + } triggeredBy = triggeredByAura->GetSpellProto(); } @@ -1656,13 +1760,19 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const* spellInfo, boo SpellCastTargets targets; if (spellInfo->GetTargets() & TARGET_FLAG_DEST_LOCATION) - { targets.setDestination(x, y, z); } + { + targets.setDestination(x, y, z); + } if (spellInfo->GetTargets() & TARGET_FLAG_SOURCE_LOCATION) - { targets.setSource(x, y, z); } + { + targets.setSource(x, y, z); + } // Spell cast with x,y,z but without dbc target-mask, set destination if (!(targets.m_targetMask & (TARGET_FLAG_DEST_LOCATION | TARGET_FLAG_SOURCE_LOCATION))) - { targets.setDestination(x, y, z); } + { + targets.setDestination(x, y, z); + } spell->m_CastItem = castItem; spell->SpellStart(&targets, triggeredByAura); @@ -1687,7 +1797,9 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S Unit* pVictim = damageInfo->target; if (damage < 0) - { return; } + { + return; + } if (!this || !pVictim) return; @@ -1767,15 +1879,21 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss) { if (!damageInfo) - { return; } + { + return; + } Unit* pVictim = damageInfo->target; if (!this || !pVictim) - { return; } + { + return; + } if (!pVictim->IsAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())) - { return; } + { + return; + } SpellEntry const* spellProto = sSpellStore.LookupEntry(damageInfo->SpellID); if (spellProto == NULL) @@ -1815,9 +1933,13 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo damageInfo->hitOutCome = MELEE_HIT_EVADE; if (!this || !pVictim) - { return; } + { + return; + } if (!this->IsAlive() || !pVictim->IsAlive()) - { return; } + { + return; + } // Select HitInfo/procAttacker/procVictim flag based on attack type switch (attackType) @@ -2001,17 +2123,25 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo // apply max/min bounds if (lowEnd < 0.01f) // the low end must not go bellow 0.01f - { lowEnd = 0.01f; } + { + lowEnd = 0.01f; + } else if (lowEnd > maxLowEnd) // the smaller value of this and 0.6 is kept as the low end { lowEnd = maxLowEnd; } if (highEnd < 0.2f) // high end limits - { highEnd = 0.2f; } + { + highEnd = 0.2f; + } if (highEnd > 0.99f) - { highEnd = 0.99f; } + { + highEnd = 0.99f; + } if (lowEnd > highEnd) // prevent negative range size - { lowEnd = highEnd; } + { + lowEnd = highEnd; + } reducePercent = lowEnd + rand_norm_f() * (highEnd - lowEnd); @@ -2057,7 +2187,9 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo damageInfo->procEx |= PROC_EX_ABSORB; } if (damageInfo->resist) - { damageInfo->HitInfo |= HITINFO_RESIST; } + { + damageInfo->HitInfo |= HITINFO_RESIST; + } } else // Umpossible get negative result but.... { damageInfo->damage = 0; } @@ -2069,10 +2201,14 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) Unit* pVictim = damageInfo->target; if (!this || !pVictim) - { return; } + { + return; + } if (!pVictim->IsAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())) - { return; } + { + return; + } // You don't lose health from damage taken from another player while in a sanctuary // You still see it in the combat log though @@ -2081,9 +2217,13 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) // Hmmmm dont like this emotes client must by self do all animations if (damageInfo->HitInfo & HITINFO_CRITICALHIT) - { pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); } + { + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); + } if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS) - { pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); } + { + pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); + } // This seems to reduce the victims time until next attack if your attack was parried if (damageInfo->TargetState == VICTIMSTATE_PARRY) @@ -2140,7 +2280,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) // there is a newbie protection, at level 10 just 7% base chance; assuming linear function if (pVictim->getLevel() < 30) - { Probability = 0.65f * pVictim->getLevel() + 0.5f; } + { + Probability = 0.65f * pVictim->getLevel() + 0.5f; + } uint32 VictimDefense = pVictim->GetMaxSkillValueForLevel(this); uint32 AttackerMeleeSkill = GetMaxSkillValueForLevel(); @@ -2148,10 +2290,14 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) Probability *= AttackerMeleeSkill / (float)VictimDefense; if (Probability > 40.0f) - { Probability = 40.0f; } + { + Probability = 40.0f; + } if (roll_chance_f(Probability)) - { CastSpell(pVictim, 1604, true); } + { + CastSpell(pVictim, 1604, true); + } } // If not miss @@ -2159,7 +2305,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) { // on weapon hit casts if (GetTypeId() == TYPEID_PLAYER && pVictim->IsAlive()) - { ((Player*)this)->CastItemCombatSpell(pVictim, damageInfo->attackType); } + { + ((Player*)this)->CastItemCombatSpell(pVictim, damageInfo->attackType); + } // victim's damage shield std::set alreadyDone; @@ -2219,11 +2367,15 @@ void Unit::HandleEmoteState(uint32 emote_id) void Unit::HandleEmote(uint32 emote_id) { if (!emote_id) - { HandleEmoteState(0); } + { + HandleEmoteState(0); + } else if (EmotesEntry const* emoteEntry = sEmotesStore.LookupEntry(emote_id)) { if (emoteEntry->EmoteType) // 1,2 states, 0 command - { HandleEmoteState(emote_id); } + { + HandleEmoteState(emote_id); + } else { HandleEmoteCommand(emote_id); } } @@ -2282,7 +2434,9 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) } if (armor < 0.0f) - { armor = 0.0f; } + { + armor = 0.0f; + } float levelModifier = (float)getLevel(); if (levelModifier > 59) @@ -2292,9 +2446,13 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) tmpvalue = tmpvalue / (1.0f + tmpvalue); if (tmpvalue < 0.0f) - { tmpvalue = 0.0f; } + { + tmpvalue = 0.0f; + } if (tmpvalue > 0.75f) - { tmpvalue = 0.75f; } + { + tmpvalue = 0.75f; + } newdamage = uint32(damage - (damage * tmpvalue)); @@ -2304,7 +2462,9 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32* absorb, uint32* resist, bool canReflect) { if (!pCaster || !IsAlive() || !damage) - { return; } + { + return; + } // Magic damage, check for resists if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) @@ -2319,9 +2479,13 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM tmpvalue2 *= (float)(0.15f / getLevel()); if (tmpvalue2 < 0.0f) - { tmpvalue2 = 0.0f; } + { + tmpvalue2 = 0.0f; + } if (tmpvalue2 > 0.75f) - { tmpvalue2 = 0.75f; } + { + tmpvalue2 = 0.75f; + } uint32 ran = urand(0, 100); float faq[4] = {24.0f, 6.0f, 4.0f, 6.0f}; uint8 m = 0; @@ -2330,16 +2494,22 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM { Binom += 2400 * (powf(tmpvalue2, float(i)) * powf((1 - tmpvalue2), float(4 - i))) / faq[i]; if (ran > Binom) - { ++m; } + { + ++m; + } else { break; } } if (damagetype == DOT && m == 4) - { *resist += uint32(damage - 1); } + { + *resist += uint32(damage - 1); + } else { *resist += uint32(damage * m / 4); } if (*resist > damage) - { *resist = damage; } + { + *resist = damage; + } } else { *resist = 0; } @@ -2620,7 +2790,9 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM // currentAbsorb - damage can be absorbed by shield // If need absorb less damage if (RemainingDamage < currentAbsorb) - { currentAbsorb = RemainingDamage; } + { + currentAbsorb = RemainingDamage; + } RemainingDamage -= currentAbsorb; @@ -2632,10 +2804,14 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM // Reduce shield amount mod->m_amount -= currentAbsorb; if ((*i)->GetHolder()->DropAuraCharge()) - { mod->m_amount = 0; } + { + mod->m_amount = 0; + } // Need remove it later if (mod->m_amount <= 0) - { existExpired = true; } + { + existExpired = true; + } } // Remove all expired absorb auras @@ -2668,11 +2844,15 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM // check damage school mask if (((*i)->GetModifier()->m_miscvalue & schoolMask) == 0) - { continue; } + { + continue; + } int32 currentAbsorb; if (RemainingDamage >= (*i)->GetModifier()->m_amount) - { currentAbsorb = (*i)->GetModifier()->m_amount; } + { + currentAbsorb = (*i)->GetModifier()->m_amount; + } else { currentAbsorb = RemainingDamage; } @@ -2681,11 +2861,15 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM if (float manaMultiplier = (spellEffect ? spellEffect->EffectMultipleValue : 0)) { if (Player* modOwner = GetSpellModOwner()) - { modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); } + { + modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); + } int32 maxAbsorb = int32(GetPower(POWER_MANA) / manaMultiplier); if (currentAbsorb > maxAbsorb) - { currentAbsorb = maxAbsorb; } + { + currentAbsorb = maxAbsorb; + } int32 manaReduction = int32(currentAbsorb * manaMultiplier); ApplyPowerMod(POWER_MANA, manaReduction, false); @@ -3941,7 +4125,7 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell) m_currentSpells[CSpellType] = pSpell; pSpell->SetReferencedFromCurrent(true); - pSpell->SetSelfContainer(&(m_currentSpells[pSpell->GetCurrentContainer()])); // this works, but is not safe - + pSpell->SetSelfContainer(&(m_currentSpells[pSpell->GetCurrentContainer()])); // this works, but is not safe - // original and faulty code - delete once the above has been proven to work // pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]); // m_selfContainer is not accessible, due to being a protected member @@ -8529,23 +8713,31 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) { // only alive units can be in combat if (!IsAlive()) - { return; } + { + return; + } if (PvP) - { m_CombatTimer = 5000; } + { + m_CombatTimer = 5000; + } bool creatureNotInCombat = GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); if (IsCharmed() || (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->IsPet())) - { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); } + { + SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); + } // interrupt all delayed non-combat casts for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i))) if (IsNonCombatSpell(spell->m_spellInfo)) - { InterruptSpell(CurrentSpellTypes(i), false); } + { + InterruptSpell(CurrentSpellTypes(i), false); + } if (getRace() == RACE_WORGEN && !IsInWorgenForm(true) && HasWorgenForm()) CastSpell(this, 97709, true); // cast Altered Form @@ -8562,17 +8754,25 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) Creature* pCreature = (Creature*)this; if (pCreature->AI()) - { pCreature->AI()->EnterCombat(enemy); } + { + pCreature->AI()->EnterCombat(enemy); + } // Some bosses are set into combat with zone if (GetMap()->IsDungeon() && (pCreature->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_AGGRO_ZONE) && enemy && enemy->IsControlledByPlayer()) - { pCreature->SetInCombatWithZone(); } + { + pCreature->SetInCombatWithZone(); + } if (InstanceData* mapInstance = GetInstanceData()) - { mapInstance->OnCreatureEnterCombat(pCreature); } + { + mapInstance->OnCreatureEnterCombat(pCreature); + } if (m_isCreatureLinkingTrigger) - { GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_AGGRO, pCreature, enemy); } + { + GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_AGGRO, pCreature, enemy); + } } // Used by Eluna @@ -8588,7 +8788,9 @@ void Unit::ClearInCombat() RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); if (IsCharmed() || (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->IsPet())) - { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); } + { + RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); + } // Used by Eluna #ifdef ENABLE_ELUNA diff --git a/src/game/Object/Unit.h b/src/game/Object/Unit.h index 82ff5258a..3d24d1295 100644 --- a/src/game/Object/Unit.h +++ b/src/game/Object/Unit.h @@ -2779,7 +2779,9 @@ class Unit : public WorldObject ObjectGuid const& GetCharmerOrOwnerOrOwnGuid() const { if (ObjectGuid const& guid = GetCharmerOrOwnerGuid()) - { return guid; } + { + return guid; + } return GetObjectGuid(); } /** @@ -2839,7 +2841,9 @@ class Unit : public WorldObject Unit* GetCharmerOrOwnerOrSelf() { if (Unit* u = GetCharmerOrOwner()) - { return u; } + { + return u; + } return this; } @@ -3658,29 +3662,39 @@ void Unit::CallForAllControlledUnits(Func const& func, uint32 controlledMask) { if (controlledMask & CONTROLLED_PET) if (Pet* pet = GetPet()) - { func(pet); } + { + func(pet); + } if (controlledMask & CONTROLLED_MINIPET) if (Pet* mini = GetMiniPet()) - { func(mini); } + { + func(mini); + } if (controlledMask & CONTROLLED_GUARDIANS) { for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end();) if (Pet* guardian = _GetPet(*(itr++))) - { func(guardian); } + { + func(guardian); + } } if (controlledMask & CONTROLLED_TOTEMS) { for (int i = 0; i < MAX_TOTEM_SLOT; ++i) if (Unit* totem = _GetTotem(TotemSlot(i))) - { func(totem); } + { + func(totem); + } } if (controlledMask & CONTROLLED_CHARM) if (Unit* charm = GetCharm()) - { func(charm); } + { + func(charm); + } } @@ -3690,19 +3704,25 @@ bool Unit::CheckAllControlledUnits(Func const& func, uint32 controlledMask) cons if (controlledMask & CONTROLLED_PET) if (Pet const* pet = GetPet()) if (func(pet)) - { return true; } + { + return true; + } if (controlledMask & CONTROLLED_MINIPET) if (Pet const* mini = GetMiniPet()) if (func(mini)) - { return true; } + { + return true; + } if (controlledMask & CONTROLLED_GUARDIANS) { for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end();) if (Pet const* guardian = _GetPet(*(itr++))) if (func(guardian)) - { return true; } + { + return true; + } } if (controlledMask & CONTROLLED_TOTEMS) @@ -3710,13 +3730,17 @@ bool Unit::CheckAllControlledUnits(Func const& func, uint32 controlledMask) cons for (int i = 0; i < MAX_TOTEM_SLOT; ++i) if (Unit const* totem = _GetTotem(TotemSlot(i))) if (func(totem)) - { return true; } + { + return true; + } } if (controlledMask & CONTROLLED_CHARM) if (Unit const* charm = GetCharm()) if (func(charm)) - { return true; } + { + return true; + } return false; } diff --git a/src/game/OutdoorPvP/OutdoorPvP.cpp b/src/game/OutdoorPvP/OutdoorPvP.cpp index 7d339b99b..509904fa5 100644 --- a/src/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvP.cpp @@ -53,7 +53,9 @@ void OutdoorPvP::HandlePlayerLeaveZone(Player* player, bool isMainZone) { // remove the world state information from the player if (isMainZone && !player->GetSession()->PlayerLogout()) - { SendRemoveWorldStates(player); } + { + SendRemoveWorldStates(player); + } sLog.outDebug("Player %s left an Outdoor PvP zone", player->GetName()); } @@ -71,10 +73,14 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value) { // only send world state update to main zone if (!itr->second) - { continue; } + { + continue; + } if (Player* player = sObjectMgr.GetPlayer(itr->first)) - { player->SendUpdateWorldState(field, value); } + { + player->SendUpdateWorldState(field, value); + } } } @@ -117,23 +123,31 @@ void OutdoorPvP::HandlePlayerKill(Player* killer, Player* victim) Player* groupMember = itr->getSource(); if (!groupMember) - { continue; } + { + continue; + } // skip if too far away if (!groupMember->IsAtGroupRewardDistance(victim)) - { continue; } + { + continue; + } // creature kills must be notified, even if not inside objective / not outdoor pvp active // player kills only count if active and inside objective if (groupMember->CanUseCapturePoint()) - { HandlePlayerKillInsideArea(groupMember); } + { + HandlePlayerKillInsideArea(groupMember); + } } } else { // creature kills must be notified, even if not inside objective / not outdoor pvp active if (killer && killer->CanUseCapturePoint()) - { HandlePlayerKillInsideArea(killer); } + { + HandlePlayerKillInsideArea(killer); + } } } @@ -146,7 +160,9 @@ void OutdoorPvP::BuffTeam(Team team, uint32 spellId, bool remove /*= false*/) if (player && player->GetTeam() == team) { if (remove) - { player->RemoveAurasDueToSpell(spellId); } + { + player->RemoveAurasDueToSpell(spellId); + } else { player->CastSpell(player, spellId, true); } } @@ -169,7 +185,9 @@ uint32 OutdoorPvP::GetBannerArtKit(Team team, uint32 artKitAlliance /*= CAPTURE_ void OutdoorPvP::SetBannerVisual(const WorldObject* objRef, ObjectGuid goGuid, uint32 artKit, uint32 animId) { if (GameObject* go = objRef->GetMap()->GetGameObject(goGuid)) - { SetBannerVisual(go, artKit, animId); } + { + SetBannerVisual(go, artKit, animId); + } } void OutdoorPvP::SetBannerVisual(GameObject* go, uint32 artKit, uint32 animId) @@ -186,7 +204,9 @@ void OutdoorPvP::RespawnGO(const WorldObject* objRef, ObjectGuid goGuid, bool re go->SetRespawnTime(7 * DAY); if (respawn) - { go->Refresh(); } + { + go->Refresh(); + } else if (go->isSpawned()) { go->SetLootState(GO_JUST_DEACTIVATED); } } diff --git a/src/game/OutdoorPvP/OutdoorPvPEP.cpp b/src/game/OutdoorPvP/OutdoorPvPEP.cpp index 508917e10..4379317f0 100644 --- a/src/game/OutdoorPvP/OutdoorPvPEP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPEP.cpp @@ -75,11 +75,15 @@ void OutdoorPvPEP::HandlePlayerEnterZone(Player* player, bool isMainZone) { case ALLIANCE: if (m_towersAlliance > 0) - { player->CastSpell(player, plaguelandsTowerBuffs[m_towersAlliance - 1].spellIdAlliance, true); } + { + player->CastSpell(player, plaguelandsTowerBuffs[m_towersAlliance - 1].spellIdAlliance, true); + } break; case HORDE: if (m_towersHorde > 0) - { player->CastSpell(player, plaguelandsTowerBuffs[m_towersHorde - 1].spellIdHorde, true); } + { + player->CastSpell(player, plaguelandsTowerBuffs[m_towersHorde - 1].spellIdHorde, true); + } break; default: break; @@ -134,7 +138,9 @@ void OutdoorPvPEP::HandleGameObjectCreate(GameObject* go) case GO_TOWER_BANNER: // sort banners if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_NORTHPASS][0], plaguelandsTowerLocations[TOWER_ID_NORTHPASS][1], 50.0f)) - { InitBanner(go, TOWER_ID_NORTHPASS); } + { + 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); } else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_EASTWALL][0], plaguelandsTowerLocations[TOWER_ID_EASTWALL][1], 50.0f)) @@ -202,7 +208,9 @@ bool OutdoorPvPEP::HandleEvent(uint32 eventId, GameObject* go) if (plaguelandsTowerEvents[i][j].team != m_towerOwner[i]) { if (plaguelandsTowerEvents[i][j].defenseMessage) - { sWorld.SendDefenseMessage(ZONE_ID_EASTERN_PLAGUELANDS, plaguelandsTowerEvents[i][j].defenseMessage); } + { + sWorld.SendDefenseMessage(ZONE_ID_EASTERN_PLAGUELANDS, plaguelandsTowerEvents[i][j].defenseMessage); + } return ProcessCaptureEvent(go, i, plaguelandsTowerEvents[i][j].team, plaguelandsTowerEvents[i][j].worldState); } @@ -259,7 +267,9 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team SendUpdateWorldState(WORLD_STATE_EP_TOWER_COUNT_ALLIANCE, m_towersAlliance); if (m_towersAlliance == 0) - { BuffTeam(ALLIANCE, plaguelandsTowerBuffs[0].spellIdAlliance, true); } + { + BuffTeam(ALLIANCE, plaguelandsTowerBuffs[0].spellIdAlliance, true); + } } else { @@ -268,7 +278,9 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team SendUpdateWorldState(WORLD_STATE_EP_TOWER_COUNT_HORDE, m_towersHorde); if (m_towersHorde == 0) - { BuffTeam(HORDE, plaguelandsTowerBuffs[0].spellIdHorde, true); } + { + BuffTeam(HORDE, plaguelandsTowerBuffs[0].spellIdHorde, true); + } } } @@ -291,7 +303,9 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team case TOWER_ID_EASTWALL: // Return false - allow the DB to handle summons if (m_towerOwner[TOWER_ID_NORTHPASS] != team) - { eventHandled = false; } + { + eventHandled = false; + } break; case TOWER_ID_PLAGUEWOOD: // Return false - allow the DB to handle summons @@ -335,7 +349,9 @@ bool OutdoorPvPEP::HandleGameObjectUse(Player* /*player*/, GameObject* go) { // prevent despawning after go use if (go->GetEntry() == GO_LORDAERON_SHRINE_ALLIANCE || go->GetEntry() == GO_LORDAERON_SHRINE_HORDE) - { go->SetRespawnTime(0); } + { + go->SetRespawnTime(0); + } return false; } @@ -350,7 +366,9 @@ void OutdoorPvPEP::InitBanner(GameObject* go, uint32 towerId) void OutdoorPvPEP::UnsummonFlightMaster(const WorldObject* objRef) { if (Creature* flightMaster = objRef->GetMap()->GetCreature(m_flightMaster)) - { flightMaster->ForcedDespawn(); } + { + flightMaster->ForcedDespawn(); + } } // Handle the unsummon of the soldiers when the Eastwall tower is lost @@ -359,7 +377,9 @@ void OutdoorPvPEP::UnsummonSoldiers(const WorldObject* objRef) for (GuidList::const_iterator itr = m_soldiers.begin(); itr != m_soldiers.end(); ++itr) { if (Creature* soldier = objRef->GetMap()->GetCreature(*itr)) - { soldier->ForcedDespawn(); } + { + soldier->ForcedDespawn(); + } } m_soldiers.clear(); diff --git a/src/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/game/OutdoorPvP/OutdoorPvPMgr.cpp index 946575b77..36cde03b3 100644 --- a/src/game/OutdoorPvP/OutdoorPvPMgr.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPMgr.cpp @@ -139,7 +139,9 @@ OutdoorPvP* OutdoorPvPMgr::GetScriptOfAffectedZone(uint32 zoneId) void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneId) { if (OutdoorPvP* script = GetScript(zoneId)) - { script->HandlePlayerEnterZone(player, true); } + { + script->HandlePlayerEnterZone(player, true); + } else if (OutdoorPvP* affectedScript = GetScriptOfAffectedZone(zoneId)) affectedScript->HandlePlayerEnterZone(player, false); } @@ -154,7 +156,9 @@ void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneId) { // teleport: called once from Player::CleanupsBeforeDelete, once from Player::UpdateZone if (OutdoorPvP* script = GetScript(zoneId)) - { script->HandlePlayerLeaveZone(player, true); } + { + script->HandlePlayerLeaveZone(player, true); + } else if (OutdoorPvP* affectedScript = GetScriptOfAffectedZone(zoneId)) affectedScript->HandlePlayerLeaveZone(player, false); } @@ -163,11 +167,15 @@ void OutdoorPvPMgr::Update(uint32 diff) { m_updateTimer.Update(diff); if (!m_updateTimer.Passed()) - { return; } + { + return; + } for (uint8 i = 0; i < MAX_OPVP_ID; ++i) if (m_scripts[i]) - { m_scripts[i]->Update(m_updateTimer.GetCurrent()); } + { + m_scripts[i]->Update(m_updateTimer.GetCurrent()); + } m_updateTimer.Reset(); } diff --git a/src/game/OutdoorPvP/OutdoorPvPSI.cpp b/src/game/OutdoorPvP/OutdoorPvPSI.cpp index feda4df30..edd0150b2 100644 --- a/src/game/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPSI.cpp @@ -56,7 +56,9 @@ void OutdoorPvPSI::HandlePlayerEnterZone(Player* player, bool isMainZone) // buff the player if same team is controlling the zone if (player->GetTeam() == m_zoneOwner) - { player->CastSpell(player, SPELL_CENARION_FAVOR, true); } + { + player->CastSpell(player, SPELL_CENARION_FAVOR, true); + } } // Remove buffs when player leaves zone @@ -72,13 +74,17 @@ void OutdoorPvPSI::HandlePlayerLeaveZone(Player* player, bool isMainZone) bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 triggerId) { if (player->isGameMaster() || player->IsDead()) - { return false; } + { + return false; + } switch (triggerId) { case AREATRIGGER_SILITHUS_ALLIANCE: if (player->GetTeam() != ALLIANCE || !player->HasAura(SPELL_SILITHYST)) - { return false; } + { + return false; + } // update counter ++ m_resourcesAlliance; @@ -104,11 +110,15 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 triggerId) // give quest credit if necessary if (player->GetQuestStatus(QUEST_SCOURING_DESERT_ALLIANCE) == QUEST_STATUS_INCOMPLETE) - { player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_ALLIANCE); } + { + player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_ALLIANCE); + } break; case AREATRIGGER_SILITHUS_HORDE: if (player->GetTeam() != HORDE || !player->HasAura(SPELL_SILITHYST)) - { return false; } + { + return false; + } // update counter ++ m_resourcesHorde; @@ -134,7 +144,9 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 triggerId) // give quest credit if necessary if (player->GetQuestStatus(QUEST_SCOURING_DESERT_HORDE) == QUEST_STATUS_INCOMPLETE) - { player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_HORDE); } + { + player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_HORDE); + } break; default: return false; @@ -167,7 +179,9 @@ static SilithusSpawnLocation silithusFlagDropLocations[2] = bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) { if (spellId != SPELL_SILITHYST) - { return false; } + { + return false; + } // don't drop flag at area trigger // we are checking distance from the AT hard-coded coordinates because it's much faster than checking the area trigger store @@ -175,11 +189,15 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) { case ALLIANCE: if (player->IsWithinDist3d(silithusFlagDropLocations[0].x, silithusFlagDropLocations[0].y, silithusFlagDropLocations[0].z, 5.0f)) - { return false; } + { + return false; + } break; case HORDE: if (player->IsWithinDist3d(silithusFlagDropLocations[1].x, silithusFlagDropLocations[1].y, silithusFlagDropLocations[1].z, 5.0f)) - { return false; } + { + return false; + } break; default: break; diff --git a/src/game/References/ThreatManager.cpp b/src/game/References/ThreatManager.cpp index 8decaa961..35c35b747 100644 --- a/src/game/References/ThreatManager.cpp +++ b/src/game/References/ThreatManager.cpp @@ -40,18 +40,26 @@ float ThreatCalcHelper::CalcThreat(Unit* pHatedUnit, Unit* /*pHatingUnit*/, floa { // all flat mods applied early if (!threat) - { return 0.0f; } + { + return 0.0f; + } if (pThreatSpell) { if (pThreatSpell->HasAttribute(SPELL_ATTR_EX_NO_THREAT)) - { return 0.0f; } + { + return 0.0f; + } if (Player* modOwner = pHatedUnit->GetSpellModOwner()) - { modOwner->ApplySpellMod(pThreatSpell->Id, SPELLMOD_THREAT, threat); } + { + modOwner->ApplySpellMod(pThreatSpell->Id, SPELLMOD_THREAT, threat); + } if (crit) - { threat *= pHatedUnit->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRITICAL_THREAT, schoolMask); } + { + threat *= pHatedUnit->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRITICAL_THREAT, schoolMask); + } } threat = pHatedUnit->ApplyTotalThreatModifier(threat, schoolMask); @@ -100,7 +108,9 @@ void HostileReference::sourceObjectDestroyLink() void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent) { if (getSource()) - { getSource()->processThreatEvent(&pThreatRefStatusChangeEvent); } + { + getSource()->processThreatEvent(&pThreatRefStatusChangeEvent); + } } //============================================================ @@ -114,7 +124,9 @@ void HostileReference::addThreat(float pMod) // the threat is changed. Source and target unit have to be availabe // if the link was cut before relink it again if (!isOnline()) - { updateOnlineStatus(); } + { + updateOnlineStatus(); + } if (pMod != 0.0f) { ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, pMod); @@ -140,7 +152,9 @@ void HostileReference::updateOnlineStatus() if (!isValid()) { if (Unit* target = ObjectAccessor::GetUnit(*getSourceUnit(), getUnitGuid())) - { link(target, getSource()); } + { + link(target, getSource()); + } } // only check for online status if // ref is valid @@ -251,7 +265,9 @@ HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat) { HostileReference* ref = getReferenceByTarget(pVictim); if (ref) - { ref->addThreat(pThreat); } + { + ref->addThreat(pThreat); + } return ref; } @@ -318,7 +334,9 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile if (!onlySecondChoiceTargetsFound && pAttacker->IsSecondChoiceTarget(pTarget, pCurrentRef == pCurrentVictim)) { if (iter != lastRef) - { ++iter; } + { + ++iter; + } else { // if we reached to this point, everyone in the threatlist is a second choice target. In such a situation the target with the highest threat should be attacked. @@ -328,7 +346,9 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile // current victim is a second choice target, so don't compare threat with it below if (pCurrentRef == pCurrentVictim) - { pCurrentVictim = NULL; } + { + pCurrentVictim = NULL; + } // second choice targets are only handled threat dependend if we have only have second choice targets continue; @@ -385,7 +405,9 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile ++iter; } if (!found) - { pCurrentRef = NULL; } + { + pCurrentRef = NULL; + } return pCurrentRef; } @@ -421,15 +443,21 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho // not to self if (pVictim == getOwner()) - { return; } + { + return; + } // not to GM if (!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster())) - { return; } + { + return; + } // not to dead and not for dead if (!pVictim->IsAlive() || !getOwner()->IsAlive()) - { return; } + { + return; + } MANGOS_ASSERT(getOwner()->GetTypeId() == TYPEID_UNIT); @@ -588,7 +616,9 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat else { if (getCurrentVictim() && hostileReference->getThreat() > (1.1f * getCurrentVictim()->getThreat())) - { setDirty(true); } + { + setDirty(true); + } iThreatContainer.addReference(hostileReference); iUpdateNeed = true; iThreatOfflineContainer.remove(hostileReference); diff --git a/src/game/Server/DBCStores.cpp b/src/game/Server/DBCStores.cpp index 856002e82..7566c7ce9 100644 --- a/src/game/Server/DBCStores.cpp +++ b/src/game/Server/DBCStores.cpp @@ -260,7 +260,9 @@ bool IsAcceptableClientBuild(uint32 build) int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD; for (int i = 0; accepted_versions[i]; ++i) if (int(build) == accepted_versions[i]) - { return true; } + { + return true; + } return false; } diff --git a/src/game/Server/SharedDefines.h b/src/game/Server/SharedDefines.h index 28667433b..a235b7646 100644 --- a/src/game/Server/SharedDefines.h +++ b/src/game/Server/SharedDefines.h @@ -237,7 +237,9 @@ inline SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask) { for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) if (mask & (1 << i)) - { return SpellSchools(i); } + { + return SpellSchools(i); + } return SPELL_SCHOOL_NORMAL; } diff --git a/src/game/Server/WorldSession.cpp b/src/game/Server/WorldSession.cpp index 55247ddc0..6a7b096c3 100644 --- a/src/game/Server/WorldSession.cpp +++ b/src/game/Server/WorldSession.cpp @@ -65,12 +65,16 @@ static bool MapSessionFilterHelper(WorldSession* session, OpcodeHandler const& o { // we do not process thread-unsafe packets if (opHandle.packetProcessing == PROCESS_THREADUNSAFE) - { return false; } + { + return false; + } // we do not process not loggined player packets Player* plr = session->GetPlayer(); if (!plr) - { return false; } + { + return false; + } // in Map::Update() we do not process packets where player is not in world! return plr->IsInWorld(); @@ -81,7 +85,9 @@ bool MapSessionFilter::Process(WorldPacket* packet) { OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; if (opHandle.packetProcessing == PROCESS_INPLACE) - { return true; } + { + return true; + } // let's check if our opcode can be really processed in Map::Update() return MapSessionFilterHelper(m_pSession, opHandle); @@ -94,7 +100,9 @@ bool WorldSessionFilter::Process(WorldPacket* packet) OpcodeHandler const& opHandle = opcodeTable[packet->GetOpcode()]; // check if packet handler is supposed to be safe if (opHandle.packetProcessing == PROCESS_INPLACE) - { return true; } + { + return true; + } // let's check if our opcode can't be processed in Map::Update() return !MapSessionFilterHelper(m_pSession, opHandle); @@ -119,7 +127,9 @@ WorldSession::~WorldSession() { ///- unload player if not unloaded if (_player) - { LogoutPlayer(true); } + { + LogoutPlayer(true); + } /// - If have unclosed socket, close it if (m_Socket) @@ -165,7 +175,9 @@ void WorldSession::SendPacket(WorldPacket const* packet) #endif if (!m_Socket) - { return; } + { + return; + } if (opcodeTable[packet->GetOpcode()].status == STATUS_UNHANDLED) { @@ -212,7 +224,9 @@ void WorldSession::SendPacket(WorldPacket const* packet) #endif // !MANGOS_DEBUG if (m_Socket->SendPacket(*packet) == -1) - { m_Socket->CloseSocket(); } + { + m_Socket->CloseSocket(); + } } /// Add an incoming packet to the queue @@ -263,7 +277,9 @@ bool WorldSession::Update(PacketFilter& updater) { // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets if (!m_playerRecentlyLogout) - { LogUnexpectedOpcode(packet, "the player has not logged in yet"); } + { + LogUnexpectedOpcode(packet, "the player has not logged in yet"); + } } else if (_player->IsInWorld()) { ExecuteOpcode(opHandle, packet); } @@ -286,7 +302,9 @@ bool WorldSession::Update(PacketFilter& updater) break; case STATUS_TRANSFER: if (!_player) - { LogUnexpectedOpcode(packet, "the player has not logged in yet"); } + { + LogUnexpectedOpcode(packet, "the player has not logged in yet"); + } else if (_player->IsInWorld()) { LogUnexpectedOpcode(packet, "the player is still in world"); } else @@ -369,7 +387,9 @@ bool WorldSession::Update(PacketFilter& updater) ///- If necessary, log the player out time_t currTime = time(NULL); if (!m_Socket || (ShouldLogOut(currTime) && !m_playerLoading)) - { LogoutPlayer(true); } + { + LogoutPlayer(true); + } // WARDEN ISSUE - commented out to stop crash // if (m_Socket && GetPlayer() && _warden) // _warden->Update(); @@ -414,7 +434,9 @@ void WorldSession::LogoutPlayer(bool Save) sLog.outChar("Account: %d (IP: %s) Logout Character:[%s] (guid: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName() , _player->GetGUIDLow()); if (ObjectGuid lootGuid = GetPlayer()->GetLootGuid()) - { DoLootRelease(lootGuid); } + { + DoLootRelease(lootGuid); + } #ifdef ENABLE_PLAYERBOTS if (_player->GetPlayerbotMgr()) @@ -444,7 +466,9 @@ void WorldSession::LogoutPlayer(bool Save) if (owner) { if (owner->GetTypeId() == TYPEID_PLAYER) - { aset.insert((Player*)owner); } + { + aset.insert((Player*)owner); + } } else if ((*itr)->GetTypeId() == TYPEID_PLAYER) { aset.insert((Player*)(*itr)); } @@ -463,7 +487,9 @@ void WorldSession::LogoutPlayer(bool Save) // this can't be called for all attackers. if (!aset.empty()) if (BattleGround* bg = _player->GetBattleGround()) - { bg->HandleKillPlayer(_player, *aset.begin()); } + { + bg->HandleKillPlayer(_player, *aset.begin()); + } } else if (_player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) { @@ -476,7 +502,9 @@ void WorldSession::LogoutPlayer(bool Save) } // drop a flag if player is carrying it if (BattleGround* bg = _player->GetBattleGround()) - { bg->EventPlayerLoggedOut(_player); } + { + bg->EventPlayerLoggedOut(_player); + } ///- Teleport to home if the player is in an invalid instance if (!_player->m_InstanceValid && !_player->isGameMaster()) @@ -538,7 +566,9 @@ void WorldSession::LogoutPlayer(bool Save) ///- empty buyback items and save the player in the database // some save parts only correctly work in case player present in map/player_lists (pets, etc) if (Save) - { _player->SaveToDB(); } + { + _player->SaveToDB(); + } ///- Leave all channels before player delete... _player->CleanupChannels(); @@ -549,11 +579,15 @@ void WorldSession::LogoutPlayer(bool Save) // remove player from the group if he is: // a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected) if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket) - { _player->RemoveFromGroup(); } + { + _player->RemoveFromGroup(); + } #endif ///- Send update to group if (_player->GetGroup()) - { _player->GetGroup()->SendUpdate(); } + { + _player->GetGroup()->SendUpdate(); + } ///- Broadcast a logout message to the player's friends sSocialMgr.SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetObjectGuid(), true); @@ -613,7 +647,9 @@ void WorldSession::LogoutPlayer(bool Save) void WorldSession::KickPlayer() { if (m_Socket) - { m_Socket->CloseSocket(); } + { + m_Socket->CloseSocket(); + } } /// Cancel channeling handler @@ -1152,7 +1188,9 @@ void WorldSession::ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* pac // need prevent do internal far teleports in handlers because some handlers do lot steps // or call code that can do far teleports in some conditions unexpectedly for generic way work code if (_player) - { _player->SetCanDelayTeleport(true); } + { + _player->SetCanDelayTeleport(true); + } (this->*opHandle.handler)(*packet); @@ -1164,11 +1202,15 @@ void WorldSession::ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* pac // we should execute delayed teleports only for alive(!) players // because we don't want player's ghost teleported from graveyard if (_player->IsHasDelayedTeleport()) - { _player->TeleportTo(_player->m_teleport_dest, _player->m_teleport_options); } + { + _player->TeleportTo(_player->m_teleport_dest, _player->m_teleport_options); + } } if (packet->rpos() < packet->wpos() && sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) - { LogUnprocessedTail(packet); } + { + LogUnprocessedTail(packet); + } } void WorldSession::InitWarden(uint16 build, BigNumber* k, std::string const& os) @@ -1185,4 +1227,4 @@ void WorldSession::InitWarden(uint16 build, BigNumber* k, std::string const& os) _warden = new WardenMac(); _warden->Init(this, k); } -} \ No newline at end of file +} diff --git a/src/game/Server/WorldSession.h b/src/game/Server/WorldSession.h index bce132349..5ae7243cf 100644 --- a/src/game/Server/WorldSession.h +++ b/src/game/Server/WorldSession.h @@ -400,7 +400,9 @@ class WorldSession { m_Tutorials[intId] = value; if (m_tutorialState == TUTORIALDATA_UNCHANGED) - { m_tutorialState = TUTORIALDATA_CHANGED; } + { + m_tutorialState = TUTORIALDATA_CHANGED; + } } } // used with item_page table diff --git a/src/game/Server/WorldSocket.cpp b/src/game/Server/WorldSocket.cpp index 9604e8ed8..07d89b2db 100644 --- a/src/game/Server/WorldSocket.cpp +++ b/src/game/Server/WorldSocket.cpp @@ -129,7 +129,9 @@ WorldSocket::~WorldSocket(void) delete m_RecvWPct; if (m_OutBuffer) - { m_OutBuffer->release(); } + { + m_OutBuffer->release(); + } closing_ = true; @@ -147,7 +149,9 @@ void WorldSocket::CloseSocket(void) ACE_GUARD(LockType, Guard, m_OutBufferLock); if (closing_) - { return; } + { + return; + } closing_ = true; peer().close_writer(); @@ -170,7 +174,9 @@ int WorldSocket::SendPacket(const WorldPacket& pct) ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1); if (closing_) - { return -1; } + { + return -1; + } // Dump outgoing packet. sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false); @@ -232,7 +238,9 @@ int WorldSocket::open(void* a) // Prevent double call to this func. if (m_OutBuffer) - { return -1; } + { + return -1; + } // This will also prevent the socket from being Updated // while we are initializing it. @@ -240,7 +248,9 @@ int WorldSocket::open(void* a) // Hook for the manager. if (sWorldSocketMgr->OnSocketOpen(this) == -1) - { return -1; } + { + return -1; + } // Allocate the buffer. ACE_NEW_RETURN(m_OutBuffer, ACE_Message_Block(m_OutBufferSize), -1); @@ -273,7 +283,9 @@ int WorldSocket::open(void* a) packet << uint8(1); if (SendPacket(packet) == -1) - { return -1; } + { + return -1; + } // Register with ACE Reactor if (reactor()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1) @@ -309,7 +321,9 @@ int WorldSocket::close(int) int WorldSocket::handle_input(ACE_HANDLE) { if (closing_) - { return -1; } + { + return -1; + } switch (handle_input_missing_data()) { @@ -347,7 +361,9 @@ int WorldSocket::handle_output(ACE_HANDLE) ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1); if (closing_) - { return -1; } + { + return -1; + } const size_t send_len = m_OutBuffer->length(); @@ -361,11 +377,15 @@ int WorldSocket::handle_output(ACE_HANDLE) #endif // MSG_NOSIGNAL if (n == 0) - { return -1; } + { + return -1; + } else if (n == -1) { if (errno == EWOULDBLOCK || errno == EAGAIN) - { return schedule_wakeup_output(Guard); } + { + return schedule_wakeup_output(Guard); + } return -1; } @@ -458,7 +478,9 @@ int WorldSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask) closing_ = true; if (h == ACE_INVALID_HANDLE) - { peer().close_writer(); } + { + peer().close_writer(); + } } // Critical section @@ -475,10 +497,14 @@ int WorldSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask) int WorldSocket::Update(void) { if (closing_) - { return -1; } + { + return -1; + } if (m_OutActive || (m_OutBuffer->length() == 0 && msg_queue()->is_empty())) - { return 0; } + { + return 0; + } int ret; do @@ -545,7 +571,9 @@ int WorldSocket::handle_input_payload(void) m_Header.reset(); if (ret == -1) - { errno = EINVAL; } + { + errno = EINVAL; + } return ret; } @@ -572,7 +600,9 @@ int WorldSocket::handle_input_missing_data(void) recv_size); if (n <= 0) - { return (int)n; } + { + return (int)n; + } message_block.wr_ptr(n); @@ -642,7 +672,9 @@ int WorldSocket::handle_input_missing_data(void) int WorldSocket::cancel_wakeup_output(GuardType& g) { if (!m_OutActive) - { return 0; } + { + return 0; + } m_OutActive = false; @@ -662,7 +694,9 @@ int WorldSocket::cancel_wakeup_output(GuardType& g) int WorldSocket::schedule_wakeup_output(GuardType& g) { if (m_OutActive) - { return 0; } + { + return 0; + } m_OutActive = true; @@ -688,7 +722,9 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) const ACE_UINT16 opcode = new_pct->GetOpcode(); if (closing_) - { return -1; } + { + return -1; + } // Dump received packet. sLog.outWorldPacketDump(uint32(get_handle()), new_pct->GetOpcode(), new_pct->GetOpcodeName(), new_pct, true); @@ -917,7 +953,9 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) id = fields[0].GetUInt32(); security = fields[1].GetUInt16(); if (security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB - { security = SEC_ADMINISTRATOR; } + { + security = SEC_ADMINISTRATOR; + } K.SetHexStr(fields[2].GetString()); @@ -925,7 +963,9 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket) locale = LocaleConstant(fields[9].GetUInt8()); if (locale >= MAX_LOCALE) - { locale = LOCALE_enUS; } + { + locale = LOCALE_enUS; + } delete result; diff --git a/src/game/Server/WorldSocketMgr.cpp b/src/game/Server/WorldSocketMgr.cpp index 7913a4a7d..d68863aea 100644 --- a/src/game/Server/WorldSocketMgr.cpp +++ b/src/game/Server/WorldSocketMgr.cpp @@ -67,7 +67,9 @@ int WorldSocketMgr::svc() { ACE_Time_Value interval(0, 10000); if (reactor_->run_reactor_event_loop(interval) == -1) - { break; } + { + break; + } for (i = sockets_->begin(); i != sockets_->end();) { diff --git a/src/game/Tools/CharacterDatabaseCleaner.cpp b/src/game/Tools/CharacterDatabaseCleaner.cpp index 5f9ee0953..e1d38e101 100644 --- a/src/game/Tools/CharacterDatabaseCleaner.cpp +++ b/src/game/Tools/CharacterDatabaseCleaner.cpp @@ -33,14 +33,18 @@ void CharacterDatabaseCleaner::CleanDatabase() { // config to disable if (!sWorld.getConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB)) - { return; } + { + return; + } sLog.outString("Cleaning character database..."); // check flags which clean ups are necessary QueryResult* result = CharacterDatabase.PQuery("SELECT cleaning_flags FROM saved_variables"); if (!result) - { return; } + { + return; + } uint32 flags = (*result)[0].GetUInt32(); delete result; @@ -48,9 +52,13 @@ void CharacterDatabaseCleaner::CleanDatabase() if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS) CleanCharacterAchievementProgress(); if (flags & CLEANING_FLAG_SKILLS) - { CleanCharacterSkills(); } + { + CleanCharacterSkills(); + } if (flags & CLEANING_FLAG_SPELLS) - { CleanCharacterSpell(); } + { + CleanCharacterSpell(); + } if (flags & CLEANING_FLAG_TALENTS) CleanCharacterTalent(); CharacterDatabase.Execute("UPDATE saved_variables SET cleaning_flags = 0"); diff --git a/src/game/Tools/PlayerDump.cpp b/src/game/Tools/PlayerDump.cpp index 1da3d4ec0..11add1c18 100644 --- a/src/game/Tools/PlayerDump.cpp +++ b/src/game/Tools/PlayerDump.cpp @@ -80,7 +80,9 @@ static bool findtoknth(std::string& str, int n, std::string::size_type& s, std:: std::string::size_type size = str.size(); for (i = 1; s < size && i < n; ++s) if (str[s] == ' ') { ++i; } if (i < n) - { return false; } + { + return false; + } e = str.find(' ', s); @@ -91,7 +93,9 @@ std::string gettoknth(std::string& str, int n) { std::string::size_type s = 0, e = 0; if (!findtoknth(str, n, s, e)) - { return ""; } + { + return ""; + } return str.substr(s, e - s); } @@ -100,13 +104,17 @@ bool findnth(std::string& str, int n, std::string::size_type& s, std::string::si { s = str.find("VALUES ('") + 9; if (s == std::string::npos) - { return false; } + { + return false; + } do { e = str.find("'", s); if (e == std::string::npos) - { return false; } + { + return false; + } } while (str[e - 1] == '\\'); @@ -117,7 +125,9 @@ bool findnth(std::string& str, int n, std::string::size_type& s, std::string::si s = e + 4; e = str.find("'", s); if (e == std::string::npos) - { return false; } + { + return false; + } } while (str[e - 1] == '\\'); } @@ -129,7 +139,9 @@ std::string gettablename(std::string& str) std::string::size_type s = 13; std::string::size_type e = str.find(_TABLE_SIM_, s); if (e == std::string::npos) - { return ""; } + { + return ""; + } return str.substr(s, e - s); } @@ -138,12 +150,16 @@ bool changenth(std::string& str, int n, const char* with, bool insert = false, b { std::string::size_type s, e; if (!findnth(str, n, s, e)) - { return false; } + { + return false; + } if (nonzero && str.substr(s, e - s) == "0") { return true; } // not an error if (!insert) - { str.replace(s, e - s, with); } + { + str.replace(s, e - s, with); + } else { str.insert(s, with); } @@ -154,7 +170,9 @@ std::string getnth(std::string& str, int n) { std::string::size_type s, e; if (!findnth(str, n, s, e)) - { return ""; } + { + return ""; + } return str.substr(s, e - s); } @@ -163,11 +181,15 @@ bool changetoknth(std::string& str, int n, const char* with, bool insert = false { std::string::size_type s = 0, e = 0; if (!findtoknth(str, n, s, e)) - { return false; } + { + return false; + } if (nonzero && str.substr(s, e - s) == "0") { return true; } // not an error if (!insert) - { str.replace(s, e - s, with); } + { + str.replace(s, e - s, with); + } else { str.insert(s, with); } @@ -178,7 +200,9 @@ uint32 registerNewGuid(uint32 oldGuid, std::map& guidMap, uint32 { std::map::const_iterator itr = guidMap.find(oldGuid); if (itr != guidMap.end()) - { return itr->second; } + { + return itr->second; + } uint32 newguid = hiGuid + guidMap.size(); guidMap[oldGuid] = newguid; @@ -214,7 +238,9 @@ bool changetokGuid(std::string& str, int n, std::map& guidMap, u std::string CreateDumpString(char const* tableName, QueryResult* result) { if (!tableName || !result) - { return ""; } + { + return ""; + } std::ostringstream ss; ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; @@ -222,10 +248,14 @@ std::string CreateDumpString(char const* tableName, QueryResult* result) for (uint32 i = 0; i < result->GetFieldCount(); ++i) { if (i != 0) - { ss << ", "; } + { + ss << ", "; + } if (fields[i].IsNULL()) - { ss << "NULL"; } + { + ss << "NULL"; + } else { std::string s = fields[i].GetCppString(); @@ -261,7 +291,9 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g GUIDs::const_iterator itr2 = itr; if (++itr2 != guids.end()) - { wherestr << "','"; } + { + wherestr << "','"; + } } wherestr << "')"; return wherestr.str(); @@ -272,7 +304,9 @@ void StoreGUID(QueryResult* result, uint32 field, std::set& guids) Field* fields = result->Fetch(); uint32 guid = fields[field].GetUInt32(); if (guid) - { guids.insert(guid); } + { + guids.insert(guid); + } } void StoreGUID(QueryResult* result, uint32 data, uint32 field, std::set& guids) @@ -281,7 +315,9 @@ void StoreGUID(QueryResult* result, uint32 data, uint32 field, std::set& std::string dataStr = fields[data].GetCppString(); uint32 guid = atoi(gettoknth(dataStr, field).c_str()); if (guid) - { guids.insert(guid); } + { + guids.insert(guid); + } } // Writing - High-level functions @@ -310,20 +346,26 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con // setup for guids case start position GUIDs::const_iterator guids_itr; if (guids) - { guids_itr = guids->begin(); } + { + guids_itr = guids->begin(); + } do { std::string wherestr; if (guids) // set case, get next guids string - { wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); } + { + wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); + } else // not set case, get single guid string { wherestr = GenerateWhereStr(fieldname, guid); } QueryResult* result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str()); if (!result) - { return; } + { + return; + } do { @@ -399,7 +441,9 @@ DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid) { FILE* fout = fopen(file.c_str(), "w"); if (!fout) - { return DUMP_FILE_OPEN_ERROR; } + { + return DUMP_FILE_OPEN_ERROR; + } std::string dump = GetDump(guid); @@ -418,11 +462,15 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s // check character count uint32 charcount = sAccountMgr.GetCharactersCount(account); if (charcount >= 10) - { return DUMP_TOO_MANY_CHARS; } + { + return DUMP_TOO_MANY_CHARS; + } FILE* fin = fopen(file.c_str(), "r"); if (!fin) - { return DUMP_FILE_OPEN_ERROR; } + { + return DUMP_FILE_OPEN_ERROR; + } QueryResult* result = NULL; char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20]; @@ -489,17 +537,23 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s // skip empty strings size_t nw_pos = line.find_first_not_of(" \t\n\r\7"); if (nw_pos == std::string::npos) - { continue; } + { + continue; + } // skip NOTE if (line.substr(nw_pos, 15) == "IMPORTANT NOTE:") - { continue; } + { + continue; + } // add required_ check if (line.substr(nw_pos, 41) == "UPDATE character_db_version SET required_") { if (!CharacterDatabase.Execute(line.c_str())) - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } continue; } @@ -536,7 +590,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s { case DTT_CHAR_TABLE: if (!changenth(line, 1, newguid)) // character_*.guid update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } break; case DTT_CHAR_NAME_TABLE: @@ -553,10 +609,14 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s case DTT_CHARACTER: { if (!changenth(line, 1, newguid)) // characters.guid update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } if (!changenth(line, 2, chraccount)) // characters.account update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } if (name.empty()) { @@ -570,7 +630,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s delete result; if (!changenth(line, 36, "1")) // characters.at_login set to "rename on login" - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } nameInvalidated = true; } @@ -578,7 +640,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s else { if (!changenth(line, 3, name.c_str())) // characters.name update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } nameInvalidated = true; } @@ -588,7 +652,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s case DTT_INVENTORY: { if (!changenth(line, 1, newguid)) // character_inventory.guid update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed(), true)) { ROLLBACK(DUMP_FILE_BROKEN); } // character_inventory.bag update @@ -602,20 +668,26 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changeGuid(line, 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) { ROLLBACK(DUMP_FILE_BROKEN); } // item_instance.guid update if (!changenth(line, 2, newguid)) // item_instance.owner_guid update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } std::string vals = getnth(line, 3); // item_instance.data get if (!changetokGuid(vals, OBJECT_FIELD_GUID + 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) { ROLLBACK(DUMP_FILE_BROKEN); } // item_instance.data.OBJECT_FIELD_GUID update if (!changetoknth(vals, ITEM_FIELD_OWNER + 1, newguid)) { ROLLBACK(DUMP_FILE_BROKEN); } // item_instance.data.ITEM_FIELD_OWNER update if (!changenth(line, 3, vals.c_str())) // item_instance.data update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } break; } case DTT_ITEM_GIFT: { if (!changenth(line, 1, newguid)) // character_gifts.guid update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) { ROLLBACK(DUMP_FILE_BROKEN); } // character_gifts.item_guid update break; @@ -626,7 +698,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changeGuid(line, 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) { ROLLBACK(DUMP_FILE_BROKEN); } // item_loot.guid update if (!changenth(line, 2, newguid)) // item_Loot.owner_guid update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } break; } case DTT_PET: @@ -634,7 +708,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s // store a map of old pet id to new inserted pet id for use by type 5 tables snprintf(currpetid, 20, "%s", getnth(line, 1).c_str()); if (strlen(lastpetid) == 0) - { snprintf(lastpetid, 20, "%s", currpetid); } + { + snprintf(lastpetid, 20, "%s", currpetid); + } if (strcmp(lastpetid, currpetid) != 0) { @@ -650,9 +726,13 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s } if (!changenth(line, 1, newpetid)) // character_pet.id update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } if (!changenth(line, 3, newguid)) // character_pet.owner update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } break; } @@ -663,12 +743,16 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s // lookup currpetid and match to new inserted pet id std::map :: const_iterator petids_iter = petids.find(atoi(currpetid)); if (petids_iter == petids.end()) // couldn't find new inserted id - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } snprintf(newpetid, 20, "%d", petids_iter->second); if (!changenth(line, 1, newpetid)) // pet_*.guid -> petid in fact - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } break; } @@ -696,7 +780,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changeGuid(line, 1, mails, sObjectMgr.m_MailIds.GetNextAfterMaxUsed())) { ROLLBACK(DUMP_FILE_BROKEN); } // mail.id update if (!changenth(line, 6, newguid)) // mail.receiver update - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } break; } case DTT_MAIL_ITEM: // mail_items @@ -706,7 +792,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) { ROLLBACK(DUMP_FILE_BROKEN); } // mail_items.item_guid if (!changenth(line, 4, newguid)) // mail_items.receiver - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } break; } case DTT_EQSET_TABLE: @@ -726,7 +814,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s } if (execute_ok && !CharacterDatabase.Execute(line.c_str())) - { ROLLBACK(DUMP_FILE_BROKEN); } + { + ROLLBACK(DUMP_FILE_BROKEN); + } } CharacterDatabase.CommitTransaction(); @@ -737,7 +827,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s sObjectMgr.m_EquipmentSetIds.Set(sObjectMgr.m_EquipmentSetIds.GetNextAfterMaxUsed() + eqsets.size()); if (incHighest) - { sObjectMgr.m_CharGuids.Set(sObjectMgr.m_CharGuids.GetNextAfterMaxUsed() + 1); } + { + sObjectMgr.m_CharGuids.Set(sObjectMgr.m_CharGuids.GetNextAfterMaxUsed() + 1); + } fclose(fin); diff --git a/src/game/WorldHandlers/AccountMgr.cpp b/src/game/WorldHandlers/AccountMgr.cpp index 63b6977a5..f03362aa3 100644 --- a/src/game/WorldHandlers/AccountMgr.cpp +++ b/src/game/WorldHandlers/AccountMgr.cpp @@ -132,10 +132,14 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname, delete result; if (utf8length(new_uname) > MAX_ACCOUNT_STR) - { return AOR_NAME_TOO_LONG; } + { + return AOR_NAME_TOO_LONG; + } if (utf8length(new_passwd) > MAX_ACCOUNT_STR) - { return AOR_PASS_TOO_LONG; } + { + return AOR_PASS_TOO_LONG; + } normalizeString(new_uname); normalizeString(new_passwd); @@ -158,7 +162,9 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd) { return AOR_NAME_NOT_EXIST; } // account doesn't exist if (utf8length(new_passwd) > MAX_ACCOUNT_STR) - { return AOR_PASS_TOO_LONG; } + { + return AOR_PASS_TOO_LONG; + } normalizeString(new_passwd); @@ -175,7 +181,9 @@ uint32 AccountMgr::GetId(std::string username) LoginDatabase.escape_string(username); QueryResult* result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str()); if (!result) - { return 0; } + { + return 0; + } else { uint32 id = (*result)[0].GetUInt32(); @@ -229,7 +237,9 @@ bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) { std::string username; if (!GetName(accid, username)) - { return false; } + { + return false; + } normalizeString(passwd); normalizeString(username); @@ -250,7 +260,9 @@ bool AccountMgr::normalizeString(std::string& utf8str) size_t wstr_len = MAX_ACCOUNT_STR; if (!Utf8toWStr(utf8str, wstr_buf, wstr_len)) - { return false; } + { + return false; + } for (uint32 i = 0; i <= wstr_len; ++i) wstr_buf[i] = wcharToUpperOnlyLatin(wstr_buf[i]); diff --git a/src/game/WorldHandlers/ChatHandler.cpp b/src/game/WorldHandlers/ChatHandler.cpp index d33078d53..dcc0bca04 100644 --- a/src/game/WorldHandlers/ChatHandler.cpp +++ b/src/game/WorldHandlers/ChatHandler.cpp @@ -243,13 +243,19 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recv_data) msg = recv_data.ReadString(msgLength); if (msg.empty()) - { break; } + { + break; + } if (ChatHandler(this).ParseCommands(msg.c_str())) - { break; } + { + break; + } if (!processChatmessageFurtherAfterSecurityChecks(msg, lang)) - { return; } + { + return; + } if (!normalizePlayerName(to)) { diff --git a/src/game/WorldHandlers/GridDefines.h b/src/game/WorldHandlers/GridDefines.h index 9a487d785..5df852373 100644 --- a/src/game/WorldHandlers/GridDefines.h +++ b/src/game/WorldHandlers/GridDefines.h @@ -97,7 +97,9 @@ struct CoordPair void operator<<(const uint32 val) { if (x_coord > val) - { x_coord -= val; } + { + x_coord -= val; + } else { x_coord = 0; } } @@ -105,7 +107,9 @@ struct CoordPair void operator>>(const uint32 val) { if (x_coord + val < LIMIT) - { x_coord += val; } + { + x_coord += val; + } else { x_coord = LIMIT - 1; } } @@ -113,7 +117,9 @@ struct CoordPair void operator-=(const uint32 val) { if (y_coord > val) - { y_coord -= val; } + { + y_coord -= val; + } else { y_coord = 0; } } @@ -121,7 +127,9 @@ struct CoordPair void operator+=(const uint32 val) { if (y_coord + val < LIMIT) - { y_coord += val; } + { + y_coord += val; + } else { y_coord = LIMIT - 1; } } @@ -167,7 +175,9 @@ namespace MaNGOS inline void NormalizeMapCoord(float& c) { if (c > MAP_HALFSIZE - 0.5) - { c = MAP_HALFSIZE - 0.5; } + { + c = MAP_HALFSIZE - 0.5; + } else if (c < -(MAP_HALFSIZE - 0.5)) { c = -(MAP_HALFSIZE - 0.5); } } diff --git a/src/game/WorldHandlers/GroupHandler.cpp b/src/game/WorldHandlers/GroupHandler.cpp index a354bc9a3..ec2fac370 100644 --- a/src/game/WorldHandlers/GroupHandler.cpp +++ b/src/game/WorldHandlers/GroupHandler.cpp @@ -787,7 +787,9 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) - { *data << int32(aura->GetModifier()->m_amount); } + { + *data << int32(aura->GetModifier()->m_amount); + } else { *data << int32(0); } } @@ -884,7 +886,9 @@ void WorldSession::BuildPartyMemberStatsChangedPacket(Player* player, WorldPacke for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) - { *data << int32(aura->GetModifier()->m_amount); } + { + *data << int32(aura->GetModifier()->m_amount); + } else { *data << int32(0); } } @@ -1018,7 +1022,9 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data) for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) - { data << int32(aura->GetModifier()->m_amount); } + { + data << int32(aura->GetModifier()->m_amount); + } else { data << int32(0); } } @@ -1057,7 +1063,9 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data) for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { if (Aura* aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) - { data << int32(aura->GetModifier()->m_amount); } + { + data << int32(aura->GetModifier()->m_amount); + } else { data << int32(0); } } @@ -1130,4 +1138,4 @@ void WorldSession::HandleGroupRequestJoinUpdates(WorldPacket& recv_data) data << uint32(group->GetMembersCount() - 1); data << ObjectGuid(group->GetLeaderGuid()); SendPacket(&data); -} \ No newline at end of file +} diff --git a/src/game/WorldHandlers/InstanceData.cpp b/src/game/WorldHandlers/InstanceData.cpp index 9090e97ce..fff46bc5e 100644 --- a/src/game/WorldHandlers/InstanceData.cpp +++ b/src/game/WorldHandlers/InstanceData.cpp @@ -32,16 +32,22 @@ void InstanceData::SaveToDB() const { // no reason to save BGs/Arenas if (instance->IsBattleGroundOrArena()) - { return; } + { + return; + } if (!Save()) - { return; } + { + return; + } std::string data = Save(); CharacterDatabase.escape_string(data); if (instance->Instanceable()) - { CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%u'", data.c_str(), instance->GetInstanceId()); } + { + 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()); } } diff --git a/src/game/WorldHandlers/Map.cpp b/src/game/WorldHandlers/Map.cpp index 127cf83ea..6804df48a 100644 --- a/src/game/WorldHandlers/Map.cpp +++ b/src/game/WorldHandlers/Map.cpp @@ -59,7 +59,9 @@ Map::~Map() UnloadAll(true); if (!m_scriptSchedule.empty()) - { sScriptMgr.DecreaseScheduledScriptCount(m_scriptSchedule.size()); } + { + sScriptMgr.DecreaseScheduledScriptCount(m_scriptSchedule.size()); + } if (m_persistentState) { m_persistentState->SetUsedByMapState(NULL); } // field pointer can be deleted after this @@ -77,7 +79,9 @@ Map::~Map() // release reference count if (m_TerrainData->Release()) - { sTerrainMgr.UnloadTerrain(m_TerrainData->GetMapId()); } + { + sTerrainMgr.UnloadTerrain(m_TerrainData->GetMapId()); + } delete m_weatherSystem; m_weatherSystem = NULL; @@ -86,10 +90,14 @@ Map::~Map() void Map::LoadMapAndVMap(int gx, int gy) { if (m_bLoadedGrids[gx][gy]) - { return; } + { + return; + } if (m_TerrainData->Load(gx, gy)) - { m_bLoadedGrids[gx][gy] = true; } + { + m_bLoadedGrids[gx][gy] = true; + } } Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode) @@ -245,7 +253,9 @@ Map::EnsureGridCreated(const GridPair& p) int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord; if (!m_bLoadedGrids[gx][gy]) - { LoadMapAndVMap(gx, gy); } + { + LoadMapAndVMap(gx, gy); + } } } @@ -274,7 +284,9 @@ Map::EnsureGridLoadedAtEnter(const Cell& cell, Player* player) { grid = getNGrid(cell.GridX(), cell.GridY()); } if (player) - { AddToGrid(player, grid, cell); } + { + AddToGrid(player, grid, cell); + } } bool Map::EnsureGridLoaded(const Cell& cell) @@ -337,7 +349,9 @@ bool Map::Add(Player* player) #endif /* ENABLE_ELUNA */ if (i_data) - { i_data->OnPlayerEnter(player); } + { + i_data->OnPlayerEnter(player); + } return true; } @@ -359,7 +373,9 @@ Map::Add(T* obj) Cell cell(p); if (obj->IsActiveObject()) - { EnsureGridLoadedAtEnter(cell); } + { + EnsureGridLoadedAtEnter(cell); + } else { EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); } @@ -370,7 +386,9 @@ Map::Add(T* obj) obj->AddToWorld(); if (obj->IsActiveObject()) - { AddToActive(obj); } + { + AddToActive(obj); + } DEBUG_LOG("%s enters grid[%u,%u]", obj->GetGuidStr().c_str(), cell.GridX(), cell.GridY()); @@ -394,7 +412,9 @@ void Map::MessageBroadcast(Player const* player, WorldPacket* msg, bool to_self) cell.SetNoCreate(); if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) - { return; } + { + return; + } MaNGOS::MessageDeliverer post_man(*player, msg, to_self); TypeContainerVisitor message(post_man); @@ -415,7 +435,9 @@ void Map::MessageBroadcast(WorldObject const* obj, WorldPacket* msg) cell.SetNoCreate(); if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) - { return; } + { + return; + } // TODO: currently on continents when Visibility.Distance.InFlight > Visibility.Distance.Continents // we have alot of blinking mobs because monster move packet send is broken... @@ -438,7 +460,9 @@ void Map::MessageDistBroadcast(Player const* player, WorldPacket* msg, float dis cell.SetNoCreate(); if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) - { return; } + { + return; + } MaNGOS::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only); TypeContainerVisitor message(post_man); @@ -459,7 +483,9 @@ void Map::MessageDistBroadcast(WorldObject const* obj, WorldPacket* msg, float d cell.SetNoCreate(); if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) - { return; } + { + return; + } MaNGOS::ObjectMessageDistDeliverer post_man(*obj, msg, dist); TypeContainerVisitor message(post_man); @@ -515,7 +541,9 @@ void Map::Update(const uint32& t_diff) Player* plr = m_mapRefIter->getSource(); if (!plr->IsInWorld() || !plr->IsPositionValid()) - { continue; } + { + continue; + } // lets update mobs/objects in ALL visible cells around player! CellArea area = Cell::CalculateCellArea(plr->GetPositionX(), plr->GetPositionY(), GetVisibilityDistance()); @@ -553,7 +581,9 @@ void Map::Update(const uint32& t_diff) ++m_activeNonPlayersIter; if (!obj->IsInWorld() || !obj->IsPositionValid()) - { continue; } + { + continue; + } // lets update mobs/objects in ALL visible cells around player! CellArea area = Cell::CalculateCellArea(obj->GetPositionX(), obj->GetPositionY(), GetVisibilityDistance()); @@ -598,14 +628,18 @@ void Map::Update(const uint32& t_diff) ///- Process necessary scripts if (!m_scriptSchedule.empty()) - { ScriptsProcess(); } + { + ScriptsProcess(); + } #ifdef ENABLE_ELUNA sEluna->OnUpdate(this, t_diff); #endif /* ENABLE_ELUNA */ if (i_data) - { i_data->Update(t_diff); } + { + i_data->Update(t_diff); + } m_weatherSystem->UpdateWeathers(t_diff); } @@ -617,10 +651,14 @@ void Map::Remove(Player* player, bool remove) #endif /* ENABLE_ELUNA */ if (i_data) - { i_data->OnPlayerLeave(player); } + { + i_data->OnPlayerLeave(player); + } if (remove) - { player->CleanupsBeforeDelete(); } + { + player->CleanupsBeforeDelete(); + } else { player->RemoveFromWorld(); } @@ -630,7 +668,9 @@ void Map::Remove(Player* player, bool remove) // nocheck_prev will return the padding element of the RefManager // instead of NULL in the case of prev if (m_mapRefIter == player->GetMapRef()) - { m_mapRefIter = m_mapRefIter->nocheck_prev(); } + { + m_mapRefIter = m_mapRefIter->nocheck_prev(); + } player->GetMapRef().unlink(); CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) @@ -639,7 +679,9 @@ void Map::Remove(Player* player, bool remove) player->ResetMap(); if (remove) - { DeleteFromWorld(player); } + { + DeleteFromWorld(player); + } return; } @@ -663,7 +705,9 @@ void Map::Remove(Player* player, bool remove) player->ResetMap(); if (remove) - { DeleteFromWorld(player); } + { + DeleteFromWorld(player); + } } template @@ -679,17 +723,23 @@ Map::Remove(T* obj, bool remove) Cell cell(p); if (!loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y))) - { return; } + { + return; + } DEBUG_LOG("Remove object (GUID: %u TypeId:%u) from grid[%u,%u]", obj->GetGUIDLow(), obj->GetTypeId(), cell.data.Part.grid_x, cell.data.Part.grid_y); NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); MANGOS_ASSERT(grid != NULL); if (obj->IsActiveObject()) - { RemoveFromActive(obj); } + { + RemoveFromActive(obj); + } if (remove) - { obj->CleanupsBeforeDelete(); } + { + obj->CleanupsBeforeDelete(); + } else { obj->RemoveFromWorld(); } @@ -701,7 +751,9 @@ Map::Remove(T* obj, bool remove) { // if option set then object already saved at this moment if (!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) - { obj->SaveRespawnTime(); } + { + obj->SaveRespawnTime(); + } // Note: In case resurrectable corpse and pet its removed from global lists in own destructor delete obj; @@ -728,7 +780,9 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY()); RemoveFromGrid(player, oldGrid, old_cell); if (!old_cell.DiffGrid(new_cell)) - { AddToGrid(player, oldGrid, new_cell); } + { + AddToGrid(player, oldGrid, new_cell); + } else { EnsureGridLoadedAtEnter(new_cell, player); } @@ -828,7 +882,9 @@ bool Map::UnloadGrid(const uint32& x, const uint32& y, bool pForce) { if (!pForce && ActiveObjectsNearGrid(x, y)) - { return false; } + { + return false; + } DEBUG_FILTER_LOG(LOG_FILTER_MAP_LOADING, "Unloading grid[%u,%u] for map %u", x, y, i_id); ObjectGridUnloader unloader(*grid); @@ -969,7 +1025,9 @@ void Map::SendInitTransports(Player* player) // no transports at map if (tmap.find(player->GetMapId()) == tmap.end()) - { return; } + { + return; + } UpdateData transData(player->GetMapId()); @@ -1001,7 +1059,9 @@ void Map::SendRemoveTransports(Player* player) // no transports at map if (tmap.find(player->GetMapId()) == tmap.end()) - { return; } + { + return; + } UpdateData transData(player->GetMapId()); @@ -1010,7 +1070,9 @@ void Map::SendRemoveTransports(Player* player) // except used transport for (MapManager::TransportSet::const_iterator i = tset.begin(); i != tset.end(); ++i) if ((*i) != player->GetTransport() && (*i)->GetMapId() != i_id) - { (*i)->BuildOutOfRangeUpdateBlock(&transData); } + { + (*i)->BuildOutOfRangeUpdateBlock(&transData); + } WorldPacket packet; transData.BuildPacket(&packet); @@ -1052,7 +1114,9 @@ void Map::AddObjectToRemoveList(WorldObject* obj) void Map::RemoveAllObjectsInRemoveList() { if (i_objectsToRemove.empty()) - { return; } + { + return; + } // DEBUG_LOG("Object remover 1 check."); while (!i_objectsToRemove.empty()) @@ -1067,7 +1131,9 @@ void Map::RemoveAllObjectsInRemoveList() // ??? WTF Corpse* corpse = GetCorpse(obj->GetObjectGuid()); if (!corpse) - { sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); } + { + sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); + } else { Remove(corpse, true); } break; @@ -1094,7 +1160,9 @@ uint32 Map::GetPlayersCountExceptGMs() const uint32 count = 0; for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) if (!itr->getSource()->isGameMaster()) - { ++count; } + { + ++count; + } return count; } @@ -1175,7 +1243,9 @@ void Map::AddToActive(WorldObject* obj) c->GetRespawnCoord(x, y, z); GridPair p = MaNGOS::ComputeGridPair(x, y); if (getNGrid(p.x_coord, p.y_coord)) - { getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock(); } + { + getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock(); + } else { GridPair p2 = MaNGOS::ComputeGridPair(c->GetPositionX(), c->GetPositionY()); @@ -1193,10 +1263,14 @@ void Map::RemoveFromActive(WorldObject* obj) { ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj); if (itr == m_activeNonPlayersIter) - { ++m_activeNonPlayersIter; } + { + ++m_activeNonPlayersIter; + } if (itr != m_activeNonPlayers.end()) - { m_activeNonPlayers.erase(itr); } + { + m_activeNonPlayers.erase(itr); + } } else { m_activeNonPlayers.erase(obj); } @@ -1212,7 +1286,9 @@ void Map::RemoveFromActive(WorldObject* obj) c->GetRespawnCoord(x, y, z); GridPair p = MaNGOS::ComputeGridPair(x, y); if (getNGrid(p.x_coord, p.y_coord)) - { getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock(); } + { + getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock(); + } else { GridPair p2 = MaNGOS::ComputeGridPair(c->GetPositionX(), c->GetPositionY()); @@ -1431,7 +1507,9 @@ bool DungeonMap::Add(Player* player) // Is it needed? if (!CanEnter(player)) - { return false; } + { + return false; + } // check for existing instance binds InstancePlayerBind* playerBind = player->GetBoundInstance(GetId(), GetDifficulty()); @@ -1479,7 +1557,9 @@ bool DungeonMap::Add(Player* player) // bind to the group or keep using the group save if (!groupBind) - { pGroup->BindToInstance(GetPersistanceState(), false); } + { + pGroup->BindToInstance(GetPersistanceState(), false); + } else { // can not jump to a different instance without resetting it @@ -1495,7 +1575,9 @@ bool DungeonMap::Add(Player* player) GetPersistanceState()->GetPlayerCount(), GetPersistanceState()->GetGroupCount()); if (groupBind->state) - { sLog.outError("GroupBind save players: %d, group count: %d", groupBind->state->GetPlayerCount(), groupBind->state->GetGroupCount()); } + { + sLog.outError("GroupBind save players: %d, group count: %d", groupBind->state->GetPlayerCount(), groupBind->state->GetGroupCount()); + } else { sLog.outError("GroupBind save NULL"); } MANGOS_ASSERT(false); @@ -1516,7 +1598,9 @@ bool DungeonMap::Add(Player* player) { // set up a solo bind or continue using it if (!playerBind) - { player->BindToInstance(GetPersistanceState(), false); } + { + player->BindToInstance(GetPersistanceState(), false); + } else // can not jump to a different instance without resetting it { MANGOS_ASSERT(playerBind->state == GetPersistentState()); } @@ -1550,7 +1634,9 @@ void DungeonMap::Remove(Player* player, bool remove) // if last player set unload timer if (!m_unloadTimer && m_mapRefManager.getSize() == 1) - { m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_UINT32_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); } + { + m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld.getConfig(CONFIG_UINT32_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); + } Map::Remove(player, remove); @@ -1620,7 +1706,9 @@ void DungeonMap::PermBindAllPlayers(Player* player) // if the leader is not in the instance the group will not get a perm bind if (group && group->GetLeaderGuid() == plr->GetObjectGuid()) - { group->BindToInstance(GetPersistanceState(), true); } + { + group->BindToInstance(GetPersistanceState(), true); + } } } @@ -1629,7 +1717,9 @@ void DungeonMap::UnloadAll(bool pForce) TeleportAllPlayersTo(TELEPORT_LOCATION_HOMEBIND); if (m_resetAfterUnload == true) - { GetPersistanceState()->DeleteRespawnTimes(); } + { + GetPersistanceState()->DeleteRespawnTimes(); + } Map::UnloadAll(pForce); } @@ -1689,10 +1779,14 @@ void BattleGroundMap::InitVisibilityDistance() bool BattleGroundMap::CanEnter(Player* player) { if (!Map::CanEnter(player)) - { return false; } + { + return false; + } if (player->GetBattleGroundId() != GetInstanceId()) - { return false; } + { + return false; + } // player number limit is checked in bgmgr, no need to do it here return true; @@ -1701,7 +1795,9 @@ bool BattleGroundMap::CanEnter(Player* player) bool BattleGroundMap::Add(Player* player) { if (!CanEnter(player)) - { return false; } + { + return false; + } // reset instance validity, battleground maps do not homebind player->m_InstanceValid = true; @@ -1750,11 +1846,15 @@ bool Map::ScriptsStart(DBScriptType type, uint32 id, Object* source, Object* tar ///- Find the script chain map ScriptChainMap const *scm = sScriptMgr.GetScriptChainMap(type); if (!scm) - { return false; } + { + return false; + } ScriptChainMap::const_iterator s = scm->find(id); if (s == scm->end()) - { return false; } + { + return false; + } // prepare static data ObjectGuid sourceGuid = source->GetObjectGuid(); @@ -1809,7 +1909,9 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou void Map::ScriptsProcess() { if (m_scriptSchedule.empty()) - { return; } + { + return; + } ///- Process overdue queued scripts ScriptScheduleMap::iterator iter = m_scriptSchedule.begin(); @@ -1942,7 +2044,9 @@ DynamicObject* Map::GetDynamicObject(ObjectGuid guid) Unit* Map::GetUnit(ObjectGuid guid) { if (guid.IsPlayer()) - { return GetPlayer(guid); } + { + return GetPlayer(guid); + } return GetAnyTypeCreature(guid); } @@ -2113,7 +2217,9 @@ void Map::PlayDirectSoundToMap(uint32 soundId, uint32 zoneId /*=0*/) const Map::PlayerList const& pList = GetPlayers(); for (PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) if (!zoneId || itr->getSource()->GetZoneId() == zoneId) - { itr->getSource()->SendDirectMessage(&data); } + { + itr->getSource()->SendDirectMessage(&data); + } } /** diff --git a/src/game/WorldHandlers/MoveMap.cpp b/src/game/WorldHandlers/MoveMap.cpp index d62b87d91..a5b938c58 100644 --- a/src/game/WorldHandlers/MoveMap.cpp +++ b/src/game/WorldHandlers/MoveMap.cpp @@ -42,7 +42,9 @@ namespace MMAP MMapManager* MMapFactory::createOrGetMMapManager() { if (g_MMapManager == NULL) - { g_MMapManager = new MMapManager(); } + { + g_MMapManager = new MMapManager(); + } return g_MMapManager; } @@ -50,7 +52,9 @@ namespace MMAP void MMapFactory::preventPathfindingOnMaps(const char* ignoreMapIds) { if (!g_mmapDisabledIds) - { g_mmapDisabledIds = new std::set(); } + { + g_mmapDisabledIds = new std::set(); + } uint32 strLenght = strlen(ignoreMapIds) + 1; char* mapList = new char[strLenght]; @@ -143,7 +147,9 @@ namespace MMAP { // we already have this map loaded? if (loadedMMaps.find(mapId) != loadedMMaps.end()) - { return true; } + { + return true; + } // load and init dtNavMesh - read parameters from file uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap") + 1; @@ -154,7 +160,9 @@ namespace MMAP if (!file) { if (MMapFactory::IsPathfindingEnabled(mapId)) - { sLog.outError("MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName); } + { + sLog.outError("MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName); + } delete[] fileName; return false; } @@ -194,7 +202,9 @@ namespace MMAP { // make sure the mmap is loaded and ready to load tiles if (!loadMapData(mapId)) - { return false; } + { + return false; + } // get this mmap data MMapData* mmap = loadedMMaps[mapId]; diff --git a/src/game/WorldHandlers/ScriptMgr.cpp b/src/game/WorldHandlers/ScriptMgr.cpp index 507b40c5d..60283bb55 100644 --- a/src/game/WorldHandlers/ScriptMgr.cpp +++ b/src/game/WorldHandlers/ScriptMgr.cpp @@ -117,17 +117,25 @@ bool ScriptMgr::CanSpellEffectStartDBScript(SpellEntry const* spellinfo, SpellEf { uint8 priority = GetSpellStartDBScriptPriority(spellinfo, effIdx); if (!priority) - { return false; } + { + return false; + } for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { uint8 currentPriority = GetSpellStartDBScriptPriority(spellinfo, SpellEffectIndex(i)); if (currentPriority < priority) // lower priority, continue checking - { continue; } + { + continue; + } if (currentPriority > priority) // take other index with higher priority - { return false; } + { + return false; + } if (i < effIdx) // same priority at lower index - { return false; } + { + return false; + } } return true; @@ -136,7 +144,9 @@ bool ScriptMgr::CanSpellEffectStartDBScript(SpellEntry const* spellinfo, SpellEf void ScriptMgr::LoadScripts(DBScriptType type) { if (IsScriptScheduled()) // function don't must be called in time scripts use. - { return; } + { + return; + } m_dbScripts[type].clear(); // need for reload support @@ -486,7 +496,9 @@ void ScriptMgr::LoadScripts(DBScriptType type) } } if (hasErrored) - { continue; } + { + continue; + } break; } case SCRIPT_COMMAND_PLAY_SOUND: // 16 @@ -499,9 +511,13 @@ void ScriptMgr::LoadScripts(DBScriptType type) } // bitmask: 0/1=target-player, 0/2=with distance dependent, 0/4=map wide, 0/8=zone wide if (tmp.playSound.flags & ~(1 | 2 | 4 | 8)) - { sLog.outErrorDb("Table `db_scripts [type = %d]` using unsupported sound flags (datalong2: %u) in SCRIPT_COMMAND_PLAY_SOUND for script id %u, unsupported flags will be ignored", type, tmp.playSound.flags, tmp.id); } + { + sLog.outErrorDb("Table `db_scripts [type = %d]` using unsupported sound flags (datalong2: %u) in SCRIPT_COMMAND_PLAY_SOUND for script id %u, unsupported flags will be ignored", type, tmp.playSound.flags, tmp.id); + } if ((tmp.playSound.flags & (1 | 2)) > 0 && (tmp.playSound.flags & (4 | 8)) > 0) - { sLog.outErrorDb("Table `db_scripts [type = %d]` uses sound flags (datalong2: %u) in SCRIPT_COMMAND_PLAY_SOUND for script id %u, combining (1|2) with (4|8) makes no sense", type, tmp.playSound.flags, tmp.id); } + { + sLog.outErrorDb("Table `db_scripts [type = %d]` uses sound flags (datalong2: %u) in SCRIPT_COMMAND_PLAY_SOUND for script id %u, combining (1|2) with (4|8) makes no sense", type, tmp.playSound.flags, tmp.id); + } break; } case SCRIPT_COMMAND_CREATE_ITEM: // 17 @@ -874,7 +890,9 @@ void ScriptMgr::LoadDbScriptStrings() for (int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i) if (sObjectMgr.GetMangosStringLocale(i)) - { ids.insert(i); } + { + ids.insert(i); + } CheckScriptTexts(ids); sWaypointMgr.CheckTextsExistance(ids); @@ -918,7 +936,9 @@ bool ScriptAction::GetScriptCommandObject(const ObjectGuid guid, bool includeIte resultObject = NULL; if (!guid) - { return true; } + { + return true; + } switch (guid.GetHigh()) { @@ -944,7 +964,9 @@ bool ScriptAction::GetScriptCommandObject(const ObjectGuid guid, bool includeIte if (includeItem) { if (Player* player = m_map->GetPlayer(m_ownerGuid)) - { resultObject = player->GetItemByGuid(guid); } + { + resultObject = player->GetItemByGuid(guid); + } break; } // else no break, but display error message @@ -955,7 +977,9 @@ bool ScriptAction::GetScriptCommandObject(const ObjectGuid guid, bool includeIte } if (resultObject && !resultObject->IsInWorld()) - { resultObject = NULL; } + { + resultObject = NULL; + } return true; } @@ -1013,7 +1037,9 @@ bool ScriptAction::GetScriptProcessTargets(WorldObject* pOrigSource, WorldObject // Prefer non-players as searcher WorldObject* pSearcher = pOrigSource ? pOrigSource : pOrigTarget; if (pSearcher->GetTypeId() == TYPEID_PLAYER && pOrigTarget && pOrigTarget->GetTypeId() != TYPEID_PLAYER) - { pSearcher = pOrigTarget; } + { + pSearcher = pOrigTarget; + } if (m_script->IsCreatureBuddy()) { @@ -1076,10 +1102,14 @@ bool ScriptAction::GetScriptProcessTargets(WorldObject* pOrigSource, WorldObject } if (m_script->data_flags & SCRIPT_FLAG_REVERSE_DIRECTION) - { std::swap(pFinalSource, pFinalTarget); } + { + std::swap(pFinalSource, pFinalTarget); + } if (m_script->data_flags & SCRIPT_FLAG_SOURCE_TARGETS_SELF) - { pFinalTarget = pFinalSource; } + { + pFinalTarget = pFinalSource; + } return true; } @@ -1147,9 +1177,13 @@ bool ScriptAction::HandleScriptStep() Object* source = NULL; Object* target = NULL; if (!GetScriptCommandObject(m_sourceGuid, true, source)) - { return false; } + { + return false; + } if (!GetScriptCommandObject(m_targetGuid, false, target)) - { return false; } + { + return false; + } // Give some debug log output for easier use DEBUG_LOG("DB-SCRIPTS: Process table `db_scripts [type = %d]` id %u, command %u for source %s (%sin world), target %s (%sin world)", m_type, m_script->id, m_script->command, m_sourceGuid.GetString().c_str(), source ? "" : "not ", m_targetGuid.GetString().c_str(), target ? "" : "not "); @@ -1158,7 +1192,9 @@ bool ScriptAction::HandleScriptStep() pSource = source && source->isType(TYPEMASK_WORLDOBJECT) ? (WorldObject*)source : NULL; pTarget = target && target->isType(TYPEMASK_WORLDOBJECT) ? (WorldObject*)target : NULL; if (!GetScriptProcessTargets(pSource, pTarget, pSource, pTarget)) - { return false; } + { + return false; + } pSourceOrItem = pSource ? pSource : (source && source->isType(TYPEMASK_ITEM) ? source : NULL); } @@ -1183,7 +1219,9 @@ bool ScriptAction::HandleScriptStep() for (; i < MAX_TEXT_ID; ++i) { if (!m_script->textId[i]) - { break; } + { + break; + } } // Use one random @@ -1191,20 +1229,26 @@ bool ScriptAction::HandleScriptStep() } if (!DoDisplayText(pSource, textId, unitTarget)) - { sLog.outErrorDb(" DB-SCRIPTS: Process table `db_scripts [type = %d]` id %u, could not display text %i properly", m_type, m_script->id, textId); } + { + sLog.outErrorDb(" DB-SCRIPTS: Process table `db_scripts [type = %d]` id %u, could not display text %i properly", m_type, m_script->id, textId); + } break; } case SCRIPT_COMMAND_EMOTE: // 1 { if (LogIfNotUnit(pSource)) - { break; } + { + break; + } std::vector emotes; emotes.push_back(m_script->emote.emoteId); for (int i = 0; i < MAX_TEXT_ID; ++i) { if (!m_script->textId[i]) - { break; } + { + break; + } emotes.push_back(uint32(m_script->textId[i])); } @@ -1228,7 +1272,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_MOVE_TO: // 3 { if (LogIfNotUnit(pSource)) - { break; } + { + break; + } // Just turn around if ((m_script->x == 0.0f && m_script->y == 0.0f && m_script->z == 0.0f) || @@ -1248,7 +1294,9 @@ bool ScriptAction::HandleScriptStep() // Normal Movement if (m_script->moveTo.travelSpeed) - { ((Unit*)pSource)->MonsterMoveWithSpeed(m_script->x, m_script->y, m_script->z, m_script->moveTo.travelSpeed * 0.01f); } + { + ((Unit*)pSource)->MonsterMoveWithSpeed(m_script->x, m_script->y, m_script->z, m_script->moveTo.travelSpeed * 0.01f); + } else { ((Unit*)pSource)->GetMotionMaster()->Clear(); @@ -1288,7 +1336,9 @@ bool ScriptAction::HandleScriptStep() { Player* pPlayer = GetPlayerTargetOrSourceAndLog(pSource, pTarget); if (!pPlayer) - { break; } + { + break; + } pPlayer->TeleportTo(m_script->teleportTo.mapId, m_script->x, m_script->y, m_script->z, m_script->o); break; @@ -1297,11 +1347,15 @@ bool ScriptAction::HandleScriptStep() { Player* pPlayer = GetPlayerTargetOrSourceAndLog(pSource, pTarget); if (!pPlayer) - { break; } + { + break; + } WorldObject* pWorldObject = NULL; if (pSource && pSource->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT)) - { pWorldObject = pSource; } + { + pWorldObject = pSource; + } else if (pTarget && pTarget->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT)) { pWorldObject = pTarget; } @@ -1315,13 +1369,17 @@ bool ScriptAction::HandleScriptStep() bool failQuest = false; // Creature must be alive for giving credit if (pWorldObject && pWorldObject->GetTypeId() == TYPEID_UNIT && !((Creature*)pWorldObject)->IsAlive()) - { failQuest = true; } + { + failQuest = true; + } else if (m_script->questExplored.distance != 0 && !pWorldObject->IsWithinDistInMap(pPlayer, float(m_script->questExplored.distance))) { failQuest = true; } // quest id and flags checked at script loading if (!failQuest) - { pPlayer->AreaExploredOrEventHappens(m_script->questExplored.questId); } + { + pPlayer->AreaExploredOrEventHappens(m_script->questExplored.questId); + } else { pPlayer->FailQuest(m_script->questExplored.questId); } @@ -1331,7 +1389,9 @@ bool ScriptAction::HandleScriptStep() { Player* pPlayer = GetPlayerTargetOrSourceAndLog(pSource, pTarget); if (!pPlayer) - { break; } + { + break; + } uint32 creatureEntry = m_script->killCredit.creatureEntry; WorldObject* pRewardSource = pSource && pSource->GetTypeId() == TYPEID_UNIT ? pSource : (pTarget && pTarget->GetTypeId() == TYPEID_UNIT ? pTarget : NULL); @@ -1340,7 +1400,9 @@ bool ScriptAction::HandleScriptStep() if (!creatureEntry) { if (pRewardSource) - { creatureEntry = pRewardSource->GetEntry(); } + { + creatureEntry = pRewardSource->GetEntry(); + } else { sLog.outErrorDb(" DB-SCRIPTS: Process table `db_scripts [type = %d]` id %u, command %u called for dynamic killcredit without creature partner, skipping.", m_type, m_script->id, m_script->command); @@ -1352,7 +1414,9 @@ bool ScriptAction::HandleScriptStep() { WorldObject* pSearcher = pRewardSource ? pRewardSource : (pSource ? pSource : pTarget); if (pSearcher != pRewardSource) - { sLog.outDebug(" DB-SCRIPTS: Process table `db_scripts [type = %d]` id %u, SCRIPT_COMMAND_KILL_CREDIT called for groupCredit without creature as searcher, script might need adjustment.", m_type, m_script->id); } + { + sLog.outDebug(" DB-SCRIPTS: Process table `db_scripts [type = %d]` id %u, SCRIPT_COMMAND_KILL_CREDIT called for groupCredit without creature as searcher, script might need adjustment.", m_type, m_script->id); + } pPlayer->RewardPlayerAndGroupAtEvent(creatureEntry, pSearcher); } else @@ -1377,7 +1441,9 @@ bool ScriptAction::HandleScriptStep() else { if (LogIfNotGameObject(pSource)) - { break; } + { + break; + } pGo = (GameObject*)pSource; } @@ -1435,7 +1501,9 @@ bool ScriptAction::HandleScriptStep() { GameObjectData const* goData = sObjectMgr.GetGOData(m_script->changeDoor.goGuid); if (!goData) // checked at load - { break; } + { + break; + } // TODO - Was a change, before random map pDoor = m_map->GetGameObject(ObjectGuid(HIGHGUID_GAMEOBJECT, goData->id, m_script->changeDoor.goGuid)); @@ -1443,7 +1511,9 @@ bool ScriptAction::HandleScriptStep() else { if (LogIfNotGameObject(pSource)) - { break; } + { + break; + } pDoor = (GameObject*)pSource; } @@ -1467,16 +1537,22 @@ bool ScriptAction::HandleScriptStep() pDoor->UseDoorOrButton(time_to_reset); if (pTarget && pTarget->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)pTarget)->GetGoType() == GAMEOBJECT_TYPE_BUTTON) - { ((GameObject*)pTarget)->UseDoorOrButton(time_to_reset); } + { + ((GameObject*)pTarget)->UseDoorOrButton(time_to_reset); + } break; } case SCRIPT_COMMAND_ACTIVATE_OBJECT: // 13 { if (LogIfNotUnit(pSource)) - { break; } + { + break; + } if (LogIfNotGameObject(pTarget)) - { break; } + { + break; + } ((GameObject*)pTarget)->Use((Unit*)pSource); break; @@ -1484,7 +1560,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_REMOVE_AURA: // 14 { if (LogIfNotUnit(pSource)) - { break; } + { + break; + } ((Unit*)pSource)->RemoveAurasDueToSpell(m_script->removeAura.spellId); break; @@ -1492,7 +1570,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_CAST_SPELL: // 15 { if (LogIfNotUnit(pTarget)) // TODO - Change when support for casting without victim will be supported - { break; } + { + break; + } // Select Spell uint32 spell = m_script->castSpell.spellId; @@ -1511,7 +1591,9 @@ bool ScriptAction::HandleScriptStep() } if (LogIfNotUnit(pSource)) - { break; } + { + break; + } ((Unit*)pSource)->CastSpell(((Unit*)pTarget), spell, (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) != 0); break; @@ -1530,7 +1612,9 @@ bool ScriptAction::HandleScriptStep() { pSoundTarget = GetPlayerTargetOrSourceAndLog(pSource, pTarget); if (!pSoundTarget) - { break; } + { + break; + } } if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) @@ -1538,7 +1622,9 @@ bool ScriptAction::HandleScriptStep() else { if (m_script->playSound.flags & 2) - { pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget); } + { + 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); } else @@ -1550,10 +1636,14 @@ bool ScriptAction::HandleScriptStep() { Player* pPlayer = GetPlayerTargetOrSourceAndLog(pSource, pTarget); if (!pPlayer) - { break; } + { + break; + } if (Item* pItem = pPlayer->StoreNewItemInInventorySlot(m_script->createItem.itemEntry, m_script->createItem.amount)) - { pPlayer->SendNewItem(pItem, m_script->createItem.amount, true, false); } + { + pPlayer->SendNewItem(pItem, m_script->createItem.amount, true, false); + } break; } @@ -1567,7 +1657,9 @@ bool ScriptAction::HandleScriptStep() } if (LogIfNotCreature(pTarget)) - { break; } + { + break; + } ((Creature*)pTarget)->ForcedDespawn(m_script->despawn.despawnDelay); @@ -1586,7 +1678,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_MOVEMENT: // 20 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } // Consider add additional checks for cases where creature should not change movementType // (pet? in combat? already using same MMgen as script try to apply?) @@ -1598,7 +1692,9 @@ bool ScriptAction::HandleScriptStep() break; case RANDOM_MOTION_TYPE: if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) - { ((Creature*)pSource)->GetMotionMaster()->MoveRandomAroundPoint(pSource->GetPositionX(), pSource->GetPositionY(), pSource->GetPositionZ(), float(m_script->movement.wanderDistance)); } + { + ((Creature*)pSource)->GetMotionMaster()->MoveRandomAroundPoint(pSource->GetPositionX(), pSource->GetPositionY(), pSource->GetPositionZ(), float(m_script->movement.wanderDistance)); + } else { float respX, respY, respZ, respO, wander_distance; @@ -1617,7 +1713,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_SET_ACTIVEOBJECT: // 21 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } ((Creature*)pSource)->SetActiveObjectState(m_script->activeObject.activate); break; @@ -1625,10 +1723,14 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_SET_FACTION: // 22 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } if (m_script->faction.factionId) - { ((Creature*)pSource)->SetFactionTemporary(m_script->faction.factionId, m_script->faction.flags); } + { + ((Creature*)pSource)->SetFactionTemporary(m_script->faction.factionId, m_script->faction.flags); + } else { ((Creature*)pSource)->ClearTemporaryFaction(); } @@ -1637,10 +1739,14 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_MORPH_TO_ENTRY_OR_MODEL: // 23 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } if (!m_script->morph.creatureOrModelEntry) - { ((Creature*)pSource)->DeMorph(); } + { + ((Creature*)pSource)->DeMorph(); + } else if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) { ((Creature*)pSource)->SetDisplayId(m_script->morph.creatureOrModelEntry); } else @@ -1656,10 +1762,14 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_MOUNT_TO_ENTRY_OR_MODEL: // 24 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } if (!m_script->mount.creatureOrModelEntry) - { ((Creature*)pSource)->Unmount(); } + { + ((Creature*)pSource)->Unmount(); + } else if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) { ((Creature*)pSource)->Mount(m_script->mount.creatureOrModelEntry); } else @@ -1675,7 +1785,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_SET_RUN: // 25 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } ((Creature*)pSource)->SetWalk(!m_script->run.run, true); @@ -1684,9 +1796,13 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_ATTACK_START: // 26 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } if (LogIfNotUnit(pTarget)) - { break; } + { + break; + } Creature* pAttacker = static_cast(pSource); Unit* unitTarget = static_cast(pTarget); @@ -1704,7 +1820,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_GO_LOCK_STATE: // 27 { if (LogIfNotGameObject(pSource)) - { break; } + { + break; + } GameObject* pGo = static_cast(pSource); @@ -1717,12 +1835,16 @@ bool ScriptAction::HandleScriptStep() // Lock or Unlock if (m_script->goLockState.lockState & 0x01) - { pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); } + { + pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_LOCKED); + } else if (m_script->goLockState.lockState & 0x02) { 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); } + { + pGo->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT); + } else if (m_script->goLockState.lockState & 0x08) { pGo->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_NO_INTERACT); } @@ -1731,7 +1853,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_STAND_STATE: // 28 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } // Must be safe cast to Unit* here ((Unit*)pSource)->SetStandState(m_script->standState.stand_state); @@ -1740,11 +1864,15 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_MODIFY_NPC_FLAGS: // 29 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } // Add Flags if (m_script->npcFlag.change_flag & 0x01) - { pSource->SetFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); } + { + pSource->SetFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); + } // Remove Flags else if (m_script->npcFlag.change_flag & 0x02) { pSource->RemoveFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); } @@ -1752,7 +1880,9 @@ bool ScriptAction::HandleScriptStep() else { if (pSource->HasFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag)) - { pSource->RemoveFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); } + { + pSource->RemoveFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); + } else { pSource->SetFlag(UNIT_NPC_FLAGS, m_script->npcFlag.flag); } } @@ -1764,7 +1894,9 @@ bool ScriptAction::HandleScriptStep() // only Player Player* pPlayer = GetPlayerTargetOrSourceAndLog(pSource, pTarget); if (!pPlayer) - { break; } + { + break; + } pPlayer->ActivateTaxiPathTo(m_script->sendTaxiPath.taxiPathId); break; @@ -1776,7 +1908,9 @@ bool ScriptAction::HandleScriptStep() { WorldObject* pSearcher = pSource ? pSource : pTarget; if (pSearcher->GetTypeId() == TYPEID_PLAYER && pTarget && pTarget->GetTypeId() != TYPEID_PLAYER) - { pSearcher = pTarget; } + { + pSearcher = pTarget; + } Creature* pCreatureBuddy = NULL; MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*pSearcher, m_script->terminateScript.npcEntry, true, false, m_script->terminateScript.searchDist, true); @@ -1803,7 +1937,9 @@ bool ScriptAction::HandleScriptStep() { Creature* cSource = static_cast(pSource); if (cSource->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) - { (static_cast* >(cSource->GetMotionMaster()->top()))->AddToWaypointPauseTime(m_script->textId[0]); } + { + (static_cast* >(cSource->GetMotionMaster()->top()))->AddToWaypointPauseTime(m_script->textId[0]); + } } return true; @@ -1814,9 +1950,13 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_PAUSE_WAYPOINTS: // 32 { if (LogIfNotCreature(pSource)) - { return false; } + { + return false; + } if (m_script->pauseWaypoint.doPause) - { ((Creature*)pSource)->addUnitState(UNIT_STAT_WAYPOINT_PAUSED); } + { + ((Creature*)pSource)->addUnitState(UNIT_STAT_WAYPOINT_PAUSED); + } else { ((Creature*)pSource)->clearUnitState(UNIT_STAT_WAYPOINT_PAUSED); } break; @@ -1839,7 +1979,9 @@ bool ScriptAction::HandleScriptStep() WorldObject* second = pSource; // First case: target is player if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER) - { player = static_cast(pTarget); } + { + player = static_cast(pTarget); + } // Second case: source is player else if (pSource && pSource->GetTypeId() == TYPEID_PLAYER) { @@ -1849,7 +1991,9 @@ bool ScriptAction::HandleScriptStep() bool terminateResult; if (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) - { 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); + } else { terminateResult = sObjectMgr.IsPlayerMeetToCondition(m_script->terminateCond.conditionId, player, m_map, second, CONDITION_FROM_DBSCRIPTS); } @@ -1861,13 +2005,17 @@ bool ScriptAction::HandleScriptStep() { Player* member = groupRef->getSource(); if (member->GetQuestStatus(m_script->terminateCond.failQuest) == QUEST_STATUS_INCOMPLETE) - { member->FailQuest(m_script->terminateCond.failQuest); } + { + member->FailQuest(m_script->terminateCond.failQuest); + } } } else { if (player->GetQuestStatus(m_script->terminateCond.failQuest) == QUEST_STATUS_INCOMPLETE) - { player->FailQuest(m_script->terminateCond.failQuest); } + { + player->FailQuest(m_script->terminateCond.failQuest); + } } } return terminateResult; @@ -1890,7 +2038,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_TURN_TO: // 36 { if (LogIfNotUnit(pSource)) - { break; } + { + break; + } ((Unit*)pSource)->SetFacingTo(pSource->GetAngle(pTarget)); break; @@ -2039,7 +2189,9 @@ bool ScriptAction::HandleScriptStep() case SCRIPT_COMMAND_CHANGE_ENTRY: // 45 { if (LogIfNotCreature(pSource)) - { break; } + { + break; + } ((Creature*)pSource)->UpdateEntry(m_script->changeEntry.creatureEntry); break; @@ -2224,13 +2376,17 @@ uint32 ScriptMgr::GetScriptId(const char* name) const // use binary search to find the script name in the sorted vector // assume "" is the first element if (!name) - { return 0; } + { + return 0; + } ScriptNameMap::const_iterator itr = std::lower_bound(m_scriptNames.begin(), m_scriptNames.end(), name); if (itr == m_scriptNames.end() || *itr != name) - { return 0; } + { + return 0; + } return uint32(itr - m_scriptNames.begin()); } @@ -2337,7 +2493,9 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 send #ifdef ENABLE_SD3 if (code) - { return SD3::GossipSelectWithCode(pPlayer, pCreature, sender, action, code); } + { + return SD3::GossipSelectWithCode(pPlayer, pCreature, sender, action, code); + } else { return SD3::GossipSelect(pPlayer, pCreature, sender, action); } #else @@ -2363,7 +2521,9 @@ bool ScriptMgr::OnGossipSelect(Player* pPlayer, GameObject* pGameObject, uint32 #ifdef ENABLE_SD3 if (code) - { return SD3::GOGossipSelectWithCode(pPlayer, pGameObject, sender, action, code); } + { + return SD3::GOGossipSelectWithCode(pPlayer, pGameObject, sender, action, code); + } else { return SD3::GOGossipSelect(pPlayer, pGameObject, sender, action); } #else @@ -2684,7 +2844,9 @@ void ScriptMgr::CollectPossibleEventIds(std::set& eventIds) if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT) { if (spell->EffectMiscValue[j]) - { eventIds.insert(spell->EffectMiscValue[j]); } + { + eventIds.insert(spell->EffectMiscValue[j]); + } } #endif } @@ -2715,7 +2877,9 @@ bool StartEvents_Event(Map* map, uint32 id, Object* source, Object* target, bool // Handle SD3 script if (sScriptMgr.OnProcessEvent(id, source, target, isStart)) - { return true; } + { + return true; + } // Handle PvP Calls if (forwardToPvp && source->GetTypeId() == TYPEID_GAMEOBJECT) @@ -2726,7 +2890,9 @@ bool StartEvents_Event(Map* map, uint32 id, Object* source, Object* target, bool { bg = ((Player*)forwardToPvp)->GetBattleGround(); if (!bg) - { opvp = sOutdoorPvPMgr.GetScript(((Player*)forwardToPvp)->GetCachedZoneId()); } + { + opvp = sOutdoorPvPMgr.GetScript(((Player*)forwardToPvp)->GetCachedZoneId()); + } } else { @@ -2741,15 +2907,21 @@ bool StartEvents_Event(Map* map, uint32 id, Object* source, Object* target, bool } if (bg && bg->HandleEvent(id, static_cast(source))) - { return true; } + { + return true; + } if (opvp && opvp->HandleEvent(id, static_cast(source))) - { return true; } + { + return true; + } } Map::ScriptExecutionParam execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE_TARGET; if (source->isType(TYPEMASK_CREATURE_OR_GAMEOBJECT)) - { execParam = Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE; } + { + 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; } diff --git a/src/game/WorldHandlers/Spell.cpp b/src/game/WorldHandlers/Spell.cpp index 55b13d1bc..180cf1ff2 100644 --- a/src/game/WorldHandlers/Spell.cpp +++ b/src/game/WorldHandlers/Spell.cpp @@ -5331,7 +5331,9 @@ SpellCastResult Spell::CheckCast(bool strict) } if (!m_IsTriggeredSpell && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_ATTR_EX2_IGNORE_LOS) && VMAP::VMapFactory::checkSpellForLoS(m_spellInfo->Id) && !m_caster->IsWithinLOSInMap(target)) - { return SPELL_FAILED_LINE_OF_SIGHT; } + { + return SPELL_FAILED_LINE_OF_SIGHT; + } // auto selection spell rank implemented in WorldSession::HandleCastSpellOpcode // this case can be triggered if rank not found (too low-level target for first rank) @@ -7658,7 +7660,9 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) return false; if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !corpse->IsWithinLOSInMap(m_caster)) - { return false; } + { + return false; + } } // all ok by some way or another, skip normal check @@ -7668,7 +7672,9 @@ bool Spell::CheckTarget(Unit* target, SpellEffectIndex eff) if (target != m_caster) if (WorldObject* caster = GetCastingObject()) if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !target->IsWithinLOSInMap(caster)) - { return false; } + { + return false; + } break; } } diff --git a/src/game/WorldHandlers/SpellAuras.cpp b/src/game/WorldHandlers/SpellAuras.cpp index 47046cb63..35ab7ec88 100644 --- a/src/game/WorldHandlers/SpellAuras.cpp +++ b/src/game/WorldHandlers/SpellAuras.cpp @@ -457,7 +457,9 @@ Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBas int32 damage; if (!caster) - { damage = m_currentBasePoints; } + { + damage = m_currentBasePoints; + } else { damage = caster->CalculateSpellDamage(target, spellproto, m_effIndex, &m_currentBasePoints); @@ -498,7 +500,9 @@ Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBas // Apply periodic time mod if (modOwner && m_modifier.periodictime) - { modOwner->ApplySpellMod(spellproto->Id, SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime); } + { + modOwner->ApplySpellMod(spellproto->Id, SPELLMOD_ACTIVATION_TIME, m_modifier.periodictime); + } // Start periodic on next tick or at aura apply if (!spellproto->HasAttribute(SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY)) @@ -520,7 +524,9 @@ AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* cu m_radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellEffect->GetRadiusIndex())); if (Player* modOwner = caster_ptr->GetSpellModOwner()) - { modOwner->ApplySpellMod(spellproto->Id, SPELLMOD_RADIUS, m_radius); } + { + modOwner->ApplySpellMod(spellproto->Id, SPELLMOD_RADIUS, m_radius); + } switch(m_spellEffect->Effect) { @@ -557,7 +563,9 @@ AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* cu // totems are immune to any kind of area auras if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->IsTotem()) - { m_modifier.m_auraname = SPELL_AURA_NONE; } + { + m_modifier.m_auraname = SPELL_AURA_NONE; + } } AreaAura::~AreaAura() @@ -578,7 +586,9 @@ SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, Spell Unit* caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem) { if (caster) - { m_castersTargetGuid = caster->GetTypeId() == TYPEID_PLAYER ? ((Player*)caster)->GetSelectionGuid() : caster->GetTargetGuid(); } + { + m_castersTargetGuid = caster->GetTypeId() == TYPEID_PLAYER ? ((Player*)caster)->GetSelectionGuid() : caster->GetTargetGuid(); + } } SingleEnemyTargetAura::~SingleEnemyTargetAura() @@ -595,7 +605,9 @@ Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* curr SpellEffectEntry const* effectEntry = spellproto->GetSpellEffect(eff); if (effectEntry && IsAreaAuraEffect(effectEntry->Effect)) - { return new AreaAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); } + { + return new AreaAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); + } uint32 triggeredSpellId = effectEntry ? effectEntry->EffectTriggerSpell : 0; @@ -650,7 +662,9 @@ void AreaAura::Update(uint32 diff) { Unit* owner = caster->GetCharmerOrOwner(); if (!owner) - { owner = caster; } + { + owner = caster; + } Spell::UnitList targets; switch (m_areaAuraType) @@ -660,7 +674,9 @@ void AreaAura::Update(uint32 diff) Group* pGroup = NULL; if (owner->GetTypeId() == TYPEID_PLAYER) - { pGroup = ((Player*)owner)->GetGroup(); } + { + pGroup = ((Player*)owner)->GetGroup(); + } if (pGroup) { @@ -671,10 +687,14 @@ void AreaAura::Update(uint32 diff) if (Target && Target->IsAlive() && Target->GetSubGroup() == subgroup && caster->IsFriendlyTo(Target)) { if (caster->IsWithinDistInMap(Target, m_radius)) - { targets.push_back(Target); } + { + targets.push_back(Target); + } Pet* pet = Target->GetPet(); if (pet && pet->IsAlive() && caster->IsWithinDistInMap(pet, m_radius)) - { targets.push_back(pet); } + { + targets.push_back(pet); + } } } } @@ -682,11 +702,15 @@ void AreaAura::Update(uint32 diff) { // add owner if (owner != caster && caster->IsWithinDistInMap(owner, m_radius)) - { targets.push_back(owner); } + { + targets.push_back(owner); + } // add caster's pet Unit* pet = caster->GetPet(); if (pet && caster->IsWithinDistInMap(pet, m_radius)) - { targets.push_back(pet); } + { + targets.push_back(pet); + } } break; } @@ -742,7 +766,9 @@ void AreaAura::Update(uint32 diff) case AREA_AURA_PET: { if (owner != caster && caster->IsWithinDistInMap(owner, m_radius)) - { targets.push_back(owner); } + { + targets.push_back(owner); + } break; } } @@ -926,7 +952,9 @@ void PersistentAreaAura::Update(uint32 diff) Aura::Update(diff); if (remove) - { GetTarget()->RemoveAura(GetId(), GetEffIndex()); } + { + GetTarget()->RemoveAura(GetId(), GetEffIndex()); + } } void Aura::ApplyModifier(bool apply, bool Real) @@ -936,7 +964,9 @@ void Aura::ApplyModifier(bool apply, bool Real) GetHolder()->SetInUse(true); SetInUse(true); if (aura < TOTAL_AURAS) - { (*this.*AuraHandler [aura])(apply, Real); } + { + (*this.*AuraHandler [aura])(apply, Real); + } SetInUse(false); GetHolder()->SetInUse(false); @@ -974,7 +1004,9 @@ bool Aura::CanProcFrom(SpellEntry const* spell, uint32 /*procFlag*/, uint32 Even { // No extra req, so can trigger only for active (damage/healing present) and hit/crit if (((procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) && active) || procEx == PROC_EX_CAST_END) - { return true; } + { + return true; + } else { return false; } } @@ -982,7 +1014,9 @@ bool Aura::CanProcFrom(SpellEntry const* spell, uint32 /*procFlag*/, uint32 Even { // Passive spells can`t trigger if need hit (exclude cases when procExtra include non-active flags) if ((EventProcEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT) & procEx) && !active) - { return false; } + { + return false; + } } } return true; @@ -1060,7 +1094,9 @@ void Aura::ReapplyAffectedPassiveAuras() { // not reapply spell mods with charges (use original value because processed and at remove) if (GetSpellProto()->GetProcCharges()) - { return; } + { + return; + } // not reapply some spell mods ops (mostly speedup case) switch (m_modifier.m_miscvalue) @@ -1096,10 +1132,14 @@ void Aura::ReapplyAffectedPassiveAuras() void Aura::HandleAddModifier(bool apply, bool Real) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER || !Real) - { return; } + { + return; + } if (m_modifier.m_miscvalue >= MAX_SPELLMOD) - { return; } + { + return; + } if (apply) { @@ -1149,7 +1189,9 @@ void Aura::TriggerSpell() Unit* triggerTarget = GetTriggerTarget(); if (!casterGUID || !triggerTarget) - { return; } + { + return; + } // generic casting code with custom spells and target/caster customs uint32 trigger_spell_id = m_spellEffect->EffectTriggerSpell; @@ -1348,7 +1390,9 @@ void Aura::TriggerSpell() float newAngle = target->GetOrientation(); if (auraId == 26009) - { newAngle += M_PI_F / 40; } + { + newAngle += M_PI_F / 40; + } else { newAngle -= M_PI_F / 40; } @@ -1976,7 +2020,9 @@ void Aura::TriggerSpell() int32 lRage = target->GetPower(POWER_RAGE); if (lRage > 100) // rage stored as rage*10 - { lRage = 100; } + { + lRage = 100; + } target->ModifyPower(POWER_RAGE, -lRage); int32 FRTriggerBasePoints = int32(lRage * LifePerRage / 10); target->CastCustomSpell(target, 22845, &FRTriggerBasePoints, NULL, NULL, true, NULL, this); @@ -2076,7 +2122,9 @@ void Aura::TriggerSpell() if (WorldObject* channelTarget = target->GetMap()->GetWorldObject(target->GetChannelObjectGuid())) { if (channelTarget->isType(TYPEMASK_UNIT)) - { triggerTarget = (Unit*)channelTarget; } + { + triggerTarget = (Unit*)channelTarget; + } else { triggerTargetObject = channelTarget; } } @@ -2098,11 +2146,15 @@ void Aura::TriggerSpell() case 9347: // Mortal Strike { if (target->GetTypeId() != TYPEID_UNIT) - { return; } + { + return; + } // expected selection current fight target triggerTarget = ((Creature*)target)->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 0, triggeredSpellInfo); if (!triggerTarget) - { return; } + { + return; + } break; } @@ -2116,7 +2168,9 @@ void Aura::TriggerSpell() // prevent cast by triggered auras if (casterGUID == triggerTarget->GetObjectGuid()) - { return; } + { + return; + } // stop triggering after each affected stats lost > 90 int32 intelectLoss = 0; @@ -2137,7 +2191,9 @@ void Aura::TriggerSpell() } if (intelectLoss <= -90 && spiritLoss <= -90) - { return; } + { + return; + } break; } @@ -2224,7 +2280,9 @@ void Aura::TriggerSpell() if (Unit* caster = GetCaster()) { if (triggerTarget->GetTypeId() != TYPEID_UNIT || !sScriptMgr.OnEffectDummy(caster, GetId(), GetEffIndex(), (Creature*)triggerTarget, ObjectGuid())) - { sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?", GetId(), GetEffIndex()); } + { + sLog.outError("Aura::TriggerSpell: Spell %u have 0 in EffectTriggered[%d], not handled custom case?", GetId(), GetEffIndex()); + } } } } @@ -3469,7 +3527,9 @@ void Aura::HandleAuraMounted(bool apply, bool Real) { // only at real add/remove aura if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -3489,7 +3549,9 @@ void Aura::HandleAuraMounted(bool apply, bool Real) uint32 display_id = Creature::ChooseDisplayId(ci); CreatureModelInfo const* minfo = sObjectMgr.GetCreatureModelRandomGender(display_id); if (minfo) - { display_id = minfo->modelid; } + { + display_id = minfo->modelid; + } if (ci->VehicleTemplateId) { @@ -3526,7 +3588,9 @@ void Aura::HandleAuraWaterWalk(bool apply, bool Real) { // only at real add/remove aura if (!Real) - { return; } + { + return; + } GetTarget()->SetWaterWalk(apply); } @@ -3553,7 +3617,9 @@ void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/) { // update timers in client if (GetTarget()->GetTypeId() == TYPEID_PLAYER) - { ((Player*)GetTarget())->UpdateMirrorTimers(); } + { + ((Player*)GetTarget())->UpdateMirrorTimers(); + } } void Aura::HandleAuraModShapeshift(bool apply, bool Real) @@ -4035,7 +4101,9 @@ void Aura::HandleAuraTransform(bool apply, bool Real) if (Unit* caster = GetCaster()) { if (caster->HasAura(52648)) // Glyph of the Penguin - { model_id = 26452; } + { + model_id = 26452; + } else if (caster->HasAura(57927)) // Glyph of the Monkey { model_id = 21362; } } @@ -4120,10 +4188,14 @@ void Aura::HandleAuraTransform(bool apply, bool Real) void Aura::HandleForceReaction(bool apply, bool Real) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } if (!Real) - { return; } + { + return; + } Player* player = (Player*)GetTarget(); @@ -4135,13 +4207,17 @@ void Aura::HandleForceReaction(bool apply, bool Real) // stop fighting if at apply forced rank friendly or at remove real rank friendly if ((apply && faction_rank >= REP_FRIENDLY) || (!apply && player->GetReputationRank(faction_id) >= REP_FRIENDLY)) - { player->StopAttackFaction(faction_id); } + { + player->StopAttackFaction(faction_id); + } } void Aura::HandleAuraModSkill(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } uint32 prot = m_spellEffect->EffectMiscValue; int32 points = GetModifier()->m_amount; @@ -4159,18 +4235,26 @@ void Aura::HandleChannelDeathItem(bool apply, bool Real) if (Real && !apply) { if (m_removeMode != AURA_REMOVE_BY_DEATH) - { return; } + { + return; + } // Item amount if (m_modifier.m_amount <= 0) - { return; } + { + return; + } if(m_spellEffect->EffectItemType == 0) - { return; } + { + return; + } Unit* victim = GetTarget(); Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // Soul Shard (target req.) if (m_spellEffect->EffectItemType == 6265) @@ -4192,7 +4276,9 @@ void Aura::HandleChannelDeathItem(bool apply, bool Real) count -= noSpaceForCount; ((Player*)caster)->SendEquipError( msg, NULL, NULL, m_spellEffect->EffectItemType ); if (count == 0) - { return; } + { + return; + } } Item* newitem = ((Player*)caster)->StoreNewItem(dest, m_spellEffect->EffectItemType, true); @@ -4212,11 +4298,15 @@ void Aura::HandleBindSight(bool apply, bool /*Real*/) { Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Camera& camera = ((Player*)caster)->GetCamera(); if (apply) - { camera.SetView(GetTarget()); } + { + camera.SetView(GetTarget()); + } else { camera.ResetView(); } } @@ -4225,11 +4315,15 @@ void Aura::HandleFarSight(bool apply, bool /*Real*/) { Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Camera& camera = ((Player*)caster)->GetCamera(); if (apply) - { camera.SetView(GetTarget()); } + { + camera.SetView(GetTarget()); + } else { camera.ResetView(); } } @@ -4237,13 +4331,19 @@ void Aura::HandleFarSight(bool apply, bool /*Real*/) void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } if (apply) - { GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); } + { + GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); + } if (apply) - { GetTarget()->SetFlag(PLAYER_TRACK_CREATURES, uint32(1) << (m_modifier.m_miscvalue - 1)); } + { + 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)); } } @@ -4251,13 +4351,19 @@ void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/) void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } if (apply) - { GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); } + { + GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); + } if (apply) - { GetTarget()->SetFlag(PLAYER_TRACK_RESOURCES, uint32(1) << (m_modifier.m_miscvalue - 1)); } + { + 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)); } } @@ -4265,10 +4371,14 @@ void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/) void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } if (apply) - { GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); } + { + GetTarget()->RemoveNoStackAurasDueToAuraHolder(GetHolder()); + } GetTarget()->ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_TRACK_STEALTHED, apply); } @@ -4363,17 +4473,23 @@ void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real) void Aura::HandleModCharm(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); // not charm yourself if (GetCasterGuid() == target->GetObjectGuid()) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster) - { return; } + { + return; + } if (apply) { @@ -4431,7 +4547,9 @@ void Aura::HandleModCharm(bool apply, bool Real) } if (caster->GetTypeId() == TYPEID_PLAYER) - { ((Player*)caster)->CharmSpellInitialize(); } + { + ((Player*)caster)->CharmSpellInitialize(); + } } else { @@ -4447,7 +4565,9 @@ void Aura::HandleModCharm(bool apply, bool Real) if (((Creature*)target)->IsPet()) { if (Unit* owner = target->GetOwner()) - { target->setFaction(owner->getFaction()); } + { + target->setFaction(owner->getFaction()); + } else if (cinfo) target->setFaction(cinfo->FactionAlliance); } @@ -4461,7 +4581,9 @@ void Aura::HandleModCharm(bool apply, bool Real) // m_target->SetByteValue(UNIT_FIELD_BYTES_0, 1, cinfo->UnitClass); if (target->GetCharmInfo()) - { target->GetCharmInfo()->SetPetNumber(0, true); } + { + 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()); } } @@ -4470,7 +4592,9 @@ void Aura::HandleModCharm(bool apply, bool Real) caster->SetCharm(NULL); if (caster->GetTypeId() == TYPEID_PLAYER) - { ((Player*)caster)->RemovePetActionBar(); } + { + ((Player*)caster)->RemovePetActionBar(); + } target->CombatStop(true); target->DeleteThreatList(); @@ -4487,7 +4611,9 @@ void Aura::HandleModCharm(bool apply, bool Real) void Aura::HandleModConfuse(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } GetTarget()->SetConfused(apply, GetCasterGuid(), GetId()); } @@ -4495,7 +4621,9 @@ void Aura::HandleModConfuse(bool apply, bool Real) void Aura::HandleModFear(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } GetTarget()->SetFeared(apply, GetCasterGuid(), GetId()); } @@ -4503,7 +4631,9 @@ void Aura::HandleModFear(bool apply, bool Real) void Aura::HandleFeignDeath(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } GetTarget()->SetFeignDeath(apply, GetCasterGuid(), GetId()); } @@ -4511,12 +4641,16 @@ void Aura::HandleFeignDeath(bool apply, bool Real) void Aura::HandleAuraModDisarm(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); if (!apply && target->HasAuraType(GetModifier()->m_auraname)) - { return; } + { + return; + } uint32 flags; uint32 field; @@ -4551,11 +4685,15 @@ void Aura::HandleAuraModDisarm(bool apply, bool Real) target->ApplyModFlag(field, flags, apply); if (target->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // main-hand attack speed already set to special value for feral form already and don't must change and reset at remove. if (target->IsInFeralForm()) - { return; } + { + return; + } if (apply) target->SetAttackTime(attack_type, BASE_ATTACK_TIME); @@ -4568,7 +4706,9 @@ void Aura::HandleAuraModDisarm(bool apply, bool Real) void Aura::HandleAuraModStun(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -4576,7 +4716,9 @@ void Aura::HandleAuraModStun(bool apply, bool Real) { // Frost stun aura -> freeze/unfreeze target if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) - { target->ModifyAuraState(AURA_STATE_FROZEN, apply); } + { + target->ModifyAuraState(AURA_STATE_FROZEN, apply); + } target->addUnitState(UNIT_STAT_STUNNED); target->SetTargetGuid(ObjectGuid()); @@ -4628,16 +4770,22 @@ void Aura::HandleAuraModStun(bool apply, bool Real) } } if (found_another) - { break; } + { + break; + } } if (!found_another) - { target->ModifyAuraState(AURA_STATE_FROZEN, apply); } + { + target->ModifyAuraState(AURA_STATE_FROZEN, apply); + } } // Real remove called after current aura remove from lists, check if other similar auras active if (target->HasAuraType(SPELL_AURA_MOD_STUN)) - { return; } + { + return; + } target->clearUnitState(UNIT_STAT_STUNNED); target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); @@ -4645,7 +4793,9 @@ void Aura::HandleAuraModStun(bool apply, bool Real) if (!target->hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect { if (target->getVictim() && target->IsAlive()) - { target->SetTargetGuid(target->getVictim()->GetObjectGuid()); } + { + target->SetTargetGuid(target->getVictim()->GetObjectGuid()); + } target->SetRoot(false); } @@ -4656,7 +4806,9 @@ void Aura::HandleAuraModStun(bool apply, bool Real) { Unit* caster = GetCaster(); if (!caster || caster->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } uint32 spell_id = 0; @@ -4676,7 +4828,9 @@ void Aura::HandleAuraModStun(bool apply, bool Real) SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) - { return; } + { + return; + } caster->CastSpell(target, spellInfo, true, NULL, this); return; @@ -4823,7 +4977,9 @@ void Aura::HandleInvisibility(bool apply, bool Real) { // if have stealth aura then already have stealth visibility if (!target->HasAuraType(SPELL_AURA_MOD_STEALTH)) - { target->SetVisibility(VISIBILITY_ON); } + { + target->SetVisibility(VISIBILITY_ON); + } } } @@ -4849,7 +5005,9 @@ void Aura::HandleInvisibilityDetect(bool apply, bool Real) { target->m_detectInvisibilityMask |= (1 << (*itr)->GetModifier()->m_miscvalue); } } if (Real && target->GetTypeId() == TYPEID_PLAYER) - { ((Player*)target)->GetCamera().UpdateVisibilityForOwner(); } + { + ((Player*)target)->GetCamera().UpdateVisibilityForOwner(); + } } void Aura::HandleDetectAmore(bool apply, bool /*real*/) @@ -4861,7 +5019,9 @@ void Aura::HandleAuraModRoot(bool apply, bool Real) { // only at real add/remove aura if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -4869,7 +5029,9 @@ void Aura::HandleAuraModRoot(bool apply, bool Real) { // Frost root aura -> freeze/unfreeze target if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_FROST) - { target->ModifyAuraState(AURA_STATE_FROZEN, apply); } + { + target->ModifyAuraState(AURA_STATE_FROZEN, apply); + } target->SetTargetGuid(ObjectGuid()); @@ -4901,11 +5063,15 @@ void Aura::HandleAuraModRoot(bool apply, bool Real) } } if (found_another) - { break; } + { + break; + } } if (!found_another) - { target->ModifyAuraState(AURA_STATE_FROZEN, apply); } + { + target->ModifyAuraState(AURA_STATE_FROZEN, apply); + } } // Real remove called after current aura remove from lists, check if other similar auras active @@ -4925,7 +5091,9 @@ void Aura::HandleAuraModSilence(bool apply, bool Real) { // only at real add/remove aura if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -4943,7 +5111,9 @@ void Aura::HandleAuraModSilence(bool apply, bool Real) { // Real remove called after current aura remove from lists, check if other similar auras active if (target->HasAuraType(SPELL_AURA_MOD_SILENCE)) - { return; } + { + return; + } target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED); } @@ -4953,12 +5123,16 @@ void Aura::HandleModThreat(bool apply, bool Real) { // only at real add/remove aura if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); if (!target->IsAlive()) - { return; } + { + return; + } int level_diff = 0; int multiplier = 0; @@ -4977,29 +5151,39 @@ void Aura::HandleModThreat(bool apply, bool Real) } if (level_diff > 0) - { m_modifier.m_amount += multiplier * level_diff; } + { + m_modifier.m_amount += multiplier * level_diff; + } if (target->GetTypeId() == TYPEID_PLAYER) for (int8 x = 0; x < MAX_SPELL_SCHOOL; ++x) if (m_modifier.m_miscvalue & int32(1 << x)) - { ApplyPercentModFloatVar(target->m_threatModifier[x], float(m_modifier.m_amount), apply); } + { + ApplyPercentModFloatVar(target->m_threatModifier[x], float(m_modifier.m_amount), apply); + } } void Aura::HandleAuraModTotalThreat(bool apply, bool Real) { // only at real add/remove aura if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); if (!target->IsAlive() || target->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster || !caster->IsAlive()) - { return; } + { + return; + } float threatMod = apply ? float(m_modifier.m_amount) : float(-m_modifier.m_amount); @@ -5010,20 +5194,28 @@ void Aura::HandleModTaunt(bool apply, bool Real) { // only at real add/remove aura if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); if (!target->IsAlive() || !target->CanHaveThreatList()) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster || !caster->IsAlive()) - { return; } + { + return; + } if (apply) - { target->TauntApply(caster); } + { + target->TauntApply(caster); + } else { // When taunt aura fades out, mob will switch to previous target if current has less than 1.1 * secondthreat @@ -5057,7 +5249,9 @@ void Aura::HandleAuraModIncreaseSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if (!Real) - { return; } + { + return; + } GetTarget()->UpdateSpeed(MOVE_RUN, true); } @@ -5066,7 +5260,9 @@ void Aura::HandleAuraModIncreaseMountedSpeed(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -5141,7 +5337,9 @@ void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if (!Real) - { return; } + { + return; + } GetTarget()->UpdateSpeed(MOVE_SWIM, true); } @@ -5150,7 +5348,9 @@ void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -5173,7 +5373,9 @@ void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) { // all applied/removed only at real aura add/remove if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -5240,7 +5442,9 @@ void Aura::HandleModMechanicImmunityMask(bool apply, bool /*Real*/) uint32 mechanic = m_modifier.m_miscvalue; if (apply && GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) - { GetTarget()->RemoveAurasAtMechanicImmunity(mechanic, GetId()); } + { + GetTarget()->RemoveAurasAtMechanicImmunity(mechanic, GetId()); + } // check implemented in Unit::IsImmuneToSpell and Unit::IsImmuneToSpellEffect } @@ -5256,7 +5460,9 @@ void Aura::HandleAuraModEffectImmunity(bool apply, bool /*Real*/) { Player* player = (Player*)target; if (BattleGround* bg = player->GetBattleGround()) - { bg->EventPlayerDroppedFlag(player); } + { + bg->EventPlayerDroppedFlag(player); + } else if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(player->GetCachedZoneId())) { outdoorPvP->HandleDropFlag(player, GetSpellProto()->Id); } } @@ -5291,7 +5497,9 @@ void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) // remove all flag auras (they are positive, but they must be removed when you are immune) if (GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY) && GetSpellProto()->HasAttribute(SPELL_ATTR_EX2_DAMAGE_REDUCED_SHIELD)) - { target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); } + { + target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); + } // TODO: optimalize this cycle - use RemoveAurasWithInterruptFlags call or something else if (Real && apply @@ -5312,7 +5520,9 @@ void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) { target->RemoveAurasDueToSpell(spell->Id); if (Auras.empty()) - { break; } + { + break; + } else { next = Auras.begin(); } } @@ -5321,7 +5531,9 @@ void Aura::HandleAuraModSchoolImmunity(bool apply, bool Real) if( Real && GetSpellProto()->GetMechanic() == MECHANIC_BANISH ) { if (apply) - { target->addUnitState(UNIT_STAT_ISOLATED); } + { + target->addUnitState(UNIT_STAT_ISOLATED); + } else { target->clearUnitState(UNIT_STAT_ISOLATED); } } @@ -5336,7 +5548,9 @@ void Aura::HandleAuraModDispelImmunity(bool apply, bool Real) { // all applied/removed only at real aura add/remove if (!Real) - { return; } + { + return; + } GetTarget()->ApplySpellDispelImmunity(GetSpellProto(), DispelType(m_modifier.m_miscvalue), apply); } @@ -5344,7 +5558,9 @@ void Aura::HandleAuraModDispelImmunity(bool apply, bool Real) void Aura::HandleAuraProcTriggerSpell(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -5373,7 +5589,9 @@ void Aura::HandleAuraModStalked(bool apply, bool /*Real*/) { // used by spells: Hunter's Mark, Mind Vision, Syndicate Tracker (MURP) DND if (apply) - { GetTarget()->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); } + { + GetTarget()->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); + } else { GetTarget()->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TRACK_UNIT); } } @@ -5545,11 +5763,15 @@ void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/) if (apply) { if (loading) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster) - { return; } + { + return; + } // Gift of the Naaru (have diff spellfamilies) if (GetSpellProto()->SpellIconID == 329 && GetSpellProto()->SpellVisual[0] == 7625) @@ -5609,7 +5831,9 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } m_isPeriodic = apply; @@ -5624,11 +5848,15 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) if (apply) { if (loading) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster) - { return; } + { + return; + } if(!classOptions) return; @@ -5754,11 +5982,15 @@ void Aura::HandlePeriodicLeech(bool apply, bool /*Real*/) if (apply) { if (loading) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster) - { return; } + { + return; + } m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); } @@ -5780,11 +6012,15 @@ void Aura::HandlePeriodicHealthFunnel(bool apply, bool /*Real*/) if (apply) { if (loading) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster) - { return; } + { + return; + } m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); } @@ -5831,14 +6067,18 @@ void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/) { // pets only have base armor if (((Creature*)GetTarget())->IsPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) - { GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply); } + { + GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR, BASE_PCT, float(m_modifier.m_amount), apply); + } } else { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; ++x) { if (m_modifier.m_miscvalue & int32(1 << x)) - { GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply); } + { + GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply); + } } } } @@ -5868,13 +6108,17 @@ void Aura::HandleModBaseResistance(bool apply, bool /*Real*/) { // only pets have base stats if (((Creature*)GetTarget())->IsPet() && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)) - { GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply); } + { + GetTarget()->HandleStatModifier(UNIT_MOD_ARMOR, TOTAL_VALUE, float(m_modifier.m_amount), apply); + } } else { for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) if (m_modifier.m_miscvalue & (1 << i)) - { GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); } + { + GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); + } } } @@ -5913,19 +6157,25 @@ void Aura::HandleModPercentStat(bool apply, bool /*Real*/) // only players have base stats if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } for (int32 i = STAT_STRENGTH; i < MAX_STATS; ++i) { if (m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1) - { GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply); } + { + GetTarget()->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + i), BASE_PCT, float(m_modifier.m_amount), apply); + } } } void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // Magic damage modifiers implemented in Unit::SpellDamageBonusDone // This information for client side use only @@ -5936,7 +6186,9 @@ void Aura::HandleModSpellDamagePercentFromStat(bool /*apply*/, bool /*Real*/) void Aura::HandleModSpellHealingPercentFromStat(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // Recalculate bonus ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); @@ -5974,7 +6226,9 @@ void Aura::HandleModSpellHealingPercentFromAttackPower(bool /*apply*/, bool /*Re void Aura::HandleModHealingDone(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // implemented in Unit::SpellHealingBonusDone // this information is for client side only ((Player*)GetTarget())->UpdateSpellDamageAndHealingBonus(); @@ -6013,7 +6267,9 @@ void Aura::HandleModTotalPercentStat(bool apply, bool /*Real*/) void Aura::HandleAuraModResistenceOfStatPercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } if (m_modifier.m_miscvalue != SPELL_SCHOOL_MASK_NORMAL) { @@ -6038,7 +6294,9 @@ void Aura::HandleAuraModTotalHealthPercentRegen(bool apply, bool /*Real*/) void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool /*Real*/) { if (m_modifier.periodictime == 0) - { m_modifier.periodictime = 1000; } + { + m_modifier.periodictime = 1000; + } if (!GetSpellProto()->HasAttribute(SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY)) m_periodicTimer = m_modifier.periodictime; @@ -6049,7 +6307,9 @@ void Aura::HandleAuraModTotalManaPercentRegen(bool apply, bool /*Real*/) void Aura::HandleModRegen(bool apply, bool /*Real*/) // eating { if (m_modifier.periodictime == 0) - { m_modifier.periodictime = 5000; } + { + m_modifier.periodictime = 5000; + } if (!GetSpellProto()->HasAttribute(SPELL_ATTR_EX5_START_PERIODIC_AT_APPLY)) m_periodicTimer = 5000; @@ -6060,14 +6320,18 @@ void Aura::HandleModRegen(bool apply, bool /*Real*/) // eating void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking { if (!Real) - { return; } + { + return; + } Powers pt = GetTarget()->GetPowerType(); if (m_modifier.periodictime == 0) { // Anger Management (only spell use this aura for rage) if (pt == POWER_RAGE) - { m_modifier.periodictime = 3000; } + { + m_modifier.periodictime = 3000; + } else { m_modifier.periodictime = 2000; } } @@ -6075,7 +6339,9 @@ void Aura::HandleModPowerRegen(bool apply, bool Real) // drinking m_periodicTimer = 5000; if (GetTarget()->GetTypeId() == TYPEID_PLAYER && m_modifier.m_miscvalue == POWER_MANA) - { ((Player*)GetTarget())->UpdateManaRegen(); } + { + ((Player*)GetTarget())->UpdateManaRegen(); + } m_isPeriodic = apply; } @@ -6084,14 +6350,20 @@ void Aura::HandleModPowerRegenPCT(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // Update manaregen value if (m_modifier.m_miscvalue == POWER_MANA) - { ((Player*)GetTarget())->UpdateManaRegen(); } + { + ((Player*)GetTarget())->UpdateManaRegen(); + } } void Aura::HandleModManaRegen(bool /*apply*/, bool Real) @@ -6153,7 +6425,9 @@ void Aura::HandleAuraModIncreaseHealth(bool apply, bool Real) else { if (int32(target->GetHealth()) > m_modifier.m_amount) - { target->ModifyHealth(-m_modifier.m_amount); } + { + target->ModifyHealth(-m_modifier.m_amount); + } else { target->SetHealth(1); } target->HandleStatModifier(UNIT_MOD_HEALTH, TOTAL_VALUE, float(m_modifier.m_amount), apply); @@ -6191,7 +6465,9 @@ void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real) Unit* target = GetTarget(); Powers powerType = target->GetPowerType(); if (int32(powerType) != m_modifier.m_miscvalue) - { return; } + { + return; + } UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); @@ -6215,7 +6491,9 @@ void Aura::HandleAuraModIncreaseEnergyPercent(bool apply, bool /*Real*/) { Powers powerType = GetTarget()->GetPowerType(); if (int32(powerType) != m_modifier.m_miscvalue) - { return; } + { + return; + } UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); @@ -6253,7 +6531,9 @@ void Aura::HandleAuraIncreaseBaseHealthPercent(bool apply, bool /*Real*/) void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } ((Player*)GetTarget())->UpdateParryPercentage(); } @@ -6261,7 +6541,9 @@ void Aura::HandleAuraModParryPercent(bool /*apply*/, bool /*Real*/) void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } ((Player*)GetTarget())->UpdateDodgePercentage(); // sLog.outError("BONUS DODGE CHANCE: + %f", float(m_modifier.m_amount)); @@ -6270,7 +6552,9 @@ void Aura::HandleAuraModDodgePercent(bool /*apply*/, bool /*Real*/) void Aura::HandleAuraModBlockChancePercent(bool /*apply*/, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } ((Player*)GetTarget())->UpdateBlockPercentage(); // sLog.outError("BONUS BLOCK CHANCE: + %f", float(m_modifier.m_amount)); @@ -6280,10 +6564,14 @@ void Aura::HandleAuraModRegenInterrupt(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } ((Player*)GetTarget())->UpdateManaRegen(); } @@ -6293,14 +6581,18 @@ void Aura::HandleAuraModCritPercent(bool apply, bool Real) Unit* target = GetTarget(); if (target->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } // apply item specific bonuses for already equipped weapon if (Real) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) - { ((Player*)target)->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply); } + { + ((Player*)target)->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply); + } } // mods must be applied base at equipped weapon class and subclass comparison @@ -6351,7 +6643,9 @@ void Aura::HandleModSpellCritChance(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } if (GetTarget()->GetTypeId() == TYPEID_PLAYER) { @@ -6367,14 +6661,20 @@ void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } for (int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school) if (m_modifier.m_miscvalue & (1 << school)) - { ((Player*)GetTarget())->UpdateSpellCritChance(school); } + { + ((Player*)GetTarget())->UpdateSpellCritChance(school); + } } /********************************/ @@ -6423,7 +6723,9 @@ void Aura::HandleAuraModRangedHaste(bool apply, bool /*Real*/) void Aura::HandleRangedAmmoHaste(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } GetTarget()->ApplyAttackTimePercentMod(RANGED_ATTACK, float(m_modifier.m_amount), apply); } @@ -6439,7 +6741,9 @@ void Aura::HandleAuraModAttackPower(bool apply, bool /*Real*/) void Aura::HandleAuraModRangedAttackPower(bool apply, bool /*Real*/) { if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS) != 0) - { return; } + { + return; + } GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); } @@ -6453,7 +6757,9 @@ void Aura::HandleAuraModAttackPowerPercent(bool apply, bool /*Real*/) void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool /*Real*/) { if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS) != 0) - { return; } + { + return; + } // UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1 GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_PCT, float(m_modifier.m_amount), apply); @@ -6481,7 +6787,9 @@ void Aura::HandleModDamageDone(bool apply, bool Real) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) - { ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); } + { + ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); + } } // m_modifier.m_miscvalue is bitmask of spell schools @@ -6512,7 +6820,9 @@ void Aura::HandleModDamageDone(bool apply, bool Real) if (target->GetTypeId() == TYPEID_PLAYER) { if (m_positive) - { target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS, m_modifier.m_amount, apply); } + { + 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); } } @@ -6520,7 +6830,9 @@ void Aura::HandleModDamageDone(bool apply, bool Real) // Skip non magic case for speedup if ((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) - { return; } + { + return; + } if( equippedItems && (equippedItems->EquippedItemClass != -1 || equippedItems->EquippedItemInventoryTypeMask != 0) ) { @@ -6540,7 +6852,9 @@ void Aura::HandleModDamageDone(bool apply, bool Real) for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { if ((m_modifier.m_miscvalue & (1 << i)) != 0) - { target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, m_modifier.m_amount, apply); } + { + target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, m_modifier.m_amount, apply); + } } } else @@ -6548,12 +6862,16 @@ void Aura::HandleModDamageDone(bool apply, bool Real) for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { if ((m_modifier.m_miscvalue & (1 << i)) != 0) - { target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, m_modifier.m_amount, apply); } + { + target->ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, m_modifier.m_amount, apply); + } } } Pet* pet = target->GetPet(); if (pet) - { pet->UpdateAttackPowerAndDamage(); } + { + pet->UpdateAttackPowerAndDamage(); + } } } @@ -6567,7 +6885,9 @@ void Aura::HandleModDamagePercentDone(bool apply, bool Real) { for (int i = 0; i < MAX_ATTACK; ++i) if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) - { ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); } + { + ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); + } } // m_modifier.m_miscvalue is bitmask of spell schools @@ -6596,12 +6916,16 @@ void Aura::HandleModDamagePercentDone(bool apply, bool Real) } // For show in client if (target->GetTypeId() == TYPEID_PLAYER) - { target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, m_modifier.m_amount / 100.0f, apply); } + { + target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT, m_modifier.m_amount / 100.0f, apply); + } } // Skip non magic case for speedup if ((m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_MAGIC) == 0) - { return; } + { + return; + } if( equippedItems && (equippedItems->EquippedItemClass != -1 || equippedItems->EquippedItemInventoryTypeMask != 0) ) { @@ -6623,7 +6947,9 @@ void Aura::HandleModOffhandDamagePercent(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "AURA MOD OFFHAND DAMAGE"); @@ -6638,23 +6964,31 @@ void Aura::HandleModPowerCostPCT(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } float amount = m_modifier.m_amount / 100.0f; for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) if (m_modifier.m_miscvalue & (1 << i)) - { GetTarget()->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply); } + { + GetTarget()->ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply); + } } void Aura::HandleModPowerCost(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) if (m_modifier.m_miscvalue & (1 << i)) - { GetTarget()->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, m_modifier.m_amount, apply); } + { + GetTarget()->ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, m_modifier.m_amount, apply); + } } void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real) @@ -6774,9 +7108,13 @@ void Aura::HandleShapeshiftBoosts(bool apply) if (apply) { if (spellId1) - { target->CastSpell(target, spellId1, true, NULL, this); } + { + target->CastSpell(target, spellId1, true, NULL, this); + } if (spellId2) - { target->CastSpell(target, spellId2, true, NULL, this); } + { + target->CastSpell(target, spellId2, true, NULL, this); + } if (target->GetTypeId() == TYPEID_PLAYER) { @@ -6787,7 +7125,9 @@ void Aura::HandleShapeshiftBoosts(bool apply) if (itr->first == spellId1 || itr->first == spellId2) { continue; } SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (!spellInfo || !IsNeedCastSpellAtFormApply(spellInfo, form)) - { continue; } + { + continue; + } target->CastSpell(target, itr->first, true, NULL, this); } // remove auras that do not require shapeshift, but are not active in this specific form (like Improved Barkskin) @@ -6825,7 +7165,9 @@ void Aura::HandleShapeshiftBoosts(bool apply) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(24932); if (spellInfo && spellInfo->GetStances() & (1<<(form-1))) - { target->CastSpell(target, 24932, true, NULL, this); } + { + target->CastSpell(target, 24932, true, NULL, this); + } } // Savage Roar @@ -6898,9 +7240,13 @@ void Aura::HandleShapeshiftBoosts(bool apply) else { if (spellId1) - { target->RemoveAurasDueToSpell(spellId1); } + { + target->RemoveAurasDueToSpell(spellId1); + } if (spellId2) - { target->RemoveAurasDueToSpell(spellId2); } + { + target->RemoveAurasDueToSpell(spellId2); + } if (MasterShaperSpellId) target->RemoveAurasDueToSpell(MasterShaperSpellId); @@ -6947,7 +7293,9 @@ void Aura::HandleAuraEmpathy(bool apply, bool /*Real*/) void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/) { if (apply) - { GetTarget()->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); } + { + GetTarget()->SetByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); + } else { GetTarget()->RemoveByteFlag(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_UNTRACKABLE); } } @@ -6955,7 +7303,9 @@ void Aura::HandleAuraUntrackable(bool apply, bool /*Real*/) void Aura::HandleAuraModPacify(bool apply, bool /*Real*/) { if (apply) - { GetTarget()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); } + { + GetTarget()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); + } else { GetTarget()->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED); } } @@ -6969,7 +7319,9 @@ void Aura::HandleAuraModPacifyAndSilence(bool apply, bool Real) void Aura::HandleAuraGhost(bool apply, bool /*Real*/) { if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } if (apply) { @@ -7064,10 +7416,14 @@ void Aura::HandleAuraRetainComboPoints(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } if (GetTarget()->GetTypeId() != TYPEID_PLAYER) - { return; } + { + return; + } Player* target = (Player*)GetTarget(); @@ -7075,7 +7431,9 @@ void Aura::HandleAuraRetainComboPoints(bool apply, bool Real) // remove only if aura expire by time (in case combo points amount change aura removed without combo points lost) if (!apply && m_removeMode == AURA_REMOVE_BY_EXPIRE && target->GetComboTargetGuid()) if (Unit* unit = ObjectAccessor::GetUnit(*GetTarget(), target->GetComboTargetGuid())) - { target->AddComboPoints(unit, -m_modifier.m_amount); } + { + target->AddComboPoints(unit, -m_modifier.m_amount); + } } void Aura::HandleModUnattackable(bool Apply, bool Real) @@ -7092,7 +7450,9 @@ void Aura::HandleSpiritOfRedemption(bool apply, bool Real) { // spells required only Real aura add/remove if (!Real) - { return; } + { + return; + } Unit* target = GetTarget(); @@ -7106,7 +7466,9 @@ void Aura::HandleSpiritOfRedemption(bool apply, bool Real) // set stand state (expected in this form) if (!target->IsStandState()) - { target->SetStandState(UNIT_STAND_STATE_STAND); } + { + target->SetStandState(UNIT_STAND_STATE_STAND); + } } target->SetHealth(1); @@ -7119,11 +7481,15 @@ void Aura::HandleSpiritOfRedemption(bool apply, bool Real) void Aura::HandleSchoolAbsorb(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } Unit* caster = GetCaster(); if (!caster) - { return; } + { + return; + } Unit* target = GetTarget(); SpellEntry const* spellProto = GetSpellProto(); @@ -7277,11 +7643,15 @@ void Aura::PeriodicTick() { // don't damage target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } Unit* pCaster = GetCaster(); if (!pCaster) - { return; } + { + return; + } if( spellProto->GetSpellEffectIdByIndex(GetEffIndex()) == SPELL_EFFECT_PERSISTENT_AREA_AURA && pCaster->SpellHitResult(target, spellProto, false) != SPELL_MISS_NONE) @@ -7289,7 +7659,9 @@ void Aura::PeriodicTick() // Check for immune (not use charges) if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) - { return; } + { + return; + } // some auras remove at specific health level or more if (m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) @@ -7335,14 +7707,18 @@ void Aura::PeriodicTick() uint32 pdamage; if (m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) - { pdamage = amount; } + { + pdamage = amount; + } else { pdamage = uint32(target->GetMaxHealth() * amount / 100); } // SpellDamageBonus for magic spells uint32 dmgClass = spellProto->GetDmgClass(); if(dmgClass == SPELL_DAMAGE_CLASS_NONE || dmgClass == SPELL_DAMAGE_CLASS_MAGIC) - { pdamage = target->SpellDamageBonusTaken(pCaster, spellProto, pdamage, DOT, GetStackAmount()); } + { + pdamage = target->SpellDamageBonusTaken(pCaster, spellProto, pdamage, DOT, GetStackAmount()); + } // MeleeDamagebonus for weapon based spells else { @@ -7365,7 +7741,9 @@ void Aura::PeriodicTick() { // 1..4 ticks, 1/2 from normal tick damage if (GetAuraTicks() <= 4) - { pdamage = pdamage / 2; } + { + pdamage = pdamage / 2; + } // 9..12 ticks, 3/2 from normal tick damage else if (GetAuraTicks() >= 9) { pdamage += (pdamage + 1) / 2; } // +1 prevent 0.5 damage possible lost at 1..4 ticks @@ -7407,7 +7785,9 @@ void Aura::PeriodicTick() target->SendPeriodicAuraLog(&pInfo); if (pdamage) - { procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; } + { + procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; + } pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, procEx, pdamage, BASE_ATTACK, spellProto); @@ -7432,14 +7812,20 @@ void Aura::PeriodicTick() { // don't damage target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } Unit* pCaster = GetCaster(); if (!pCaster) - { return; } + { + return; + } if (!pCaster->IsAlive()) - { return; } + { + return; + } if( spellProto->GetSpellEffectIdByIndex(GetEffIndex()) == SPELL_EFFECT_PERSISTENT_AREA_AURA && pCaster->SpellHitResult(target, spellProto, false) != SPELL_MISS_NONE) @@ -7447,7 +7833,9 @@ void Aura::PeriodicTick() // Check for immune if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) - { return; } + { + return; + } uint32 absorb = 0; uint32 resist = 0; @@ -7498,7 +7886,9 @@ void Aura::PeriodicTick() pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage - absorb - resist); if (pdamage) - { procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; } + { + procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; + } pCaster->ProcDamageAndSpell(target, procAttacker, procVictim, procEx, pdamage, BASE_ATTACK, spellProto); int32 new_damage = pCaster->DealDamage(target, pdamage, &cleanDamage, DOT, GetSpellSchoolMask(spellProto), spellProto, false); @@ -7507,7 +7897,9 @@ void Aura::PeriodicTick() for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = pCaster->GetCurrentSpell(CurrentSpellTypes(i))) if (spell->m_spellInfo->Id == GetId()) - { spell->cancel(); } + { + spell->cancel(); + } if (Player* modOwner = pCaster->GetSpellModOwner()) { @@ -7632,23 +8024,33 @@ void Aura::PeriodicTick() { // don't damage target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS) - { return; } + { + return; + } Powers power = Powers(m_modifier.m_miscvalue); // power type might have changed between aura applying and tick (druid's shapeshift) if (target->GetPowerType() != power) - { return; } + { + return; + } Unit* pCaster = GetCaster(); if (!pCaster) - { return; } + { + return; + } if (!pCaster->IsAlive()) - { return; } + { + return; + } if( GetSpellProto()->GetSpellEffectIdByIndex(GetEffIndex()) == SPELL_EFFECT_PERSISTENT_AREA_AURA && pCaster->SpellHitResult(target, spellProto, false) != SPELL_MISS_NONE) @@ -7656,7 +8058,9 @@ void Aura::PeriodicTick() // Check for immune (not use charges) if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) - { return; } + { + return; + } // ignore non positive values (can be result apply spellmods to aura damage uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; @@ -7690,7 +8094,9 @@ void Aura::PeriodicTick() gain_multiplier = m_spellEffect->EffectMultipleValue; if (Player* modOwner = pCaster->GetSpellModOwner()) - { modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier); } + { + modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, gain_multiplier); + } } SpellPeriodicAuraLogInfo pInfo(this, drain_amount, 0, 0, 0, gain_multiplier); @@ -7749,7 +8155,9 @@ void Aura::PeriodicTick() { // don't energize target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } // ignore non positive values (can be result apply spellmods to aura damage uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; @@ -7758,12 +8166,16 @@ void Aura::PeriodicTick() GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); if (m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS) - { break; } + { + break; + } Powers power = Powers(m_modifier.m_miscvalue); if (target->GetMaxPower(power) == 0) - { break; } + { + break; + } SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f); target->SendPeriodicAuraLog(&pInfo); @@ -7778,7 +8190,9 @@ void Aura::PeriodicTick() { // don't energize target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } // ignore non positive values (can be result apply spellmods to aura damage uint32 amount = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; @@ -7789,7 +8203,9 @@ void Aura::PeriodicTick() GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); if (target->GetMaxPower(POWER_MANA) == 0) - { break; } + { + break; + } SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f); target->SendPeriodicAuraLog(&pInfo); @@ -7804,22 +8220,30 @@ void Aura::PeriodicTick() { // don't mana burn target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } Unit* pCaster = GetCaster(); if (!pCaster) - { return; } + { + return; + } // Check for immune (not use charges) if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) - { return; } + { + return; + } int32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; Powers powerType = Powers(m_modifier.m_miscvalue); if (!target->IsAlive() || target->GetPowerType() != powerType) - { return; } + { + return; + } // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) if (powerType == POWER_MANA) @@ -7844,7 +8268,9 @@ void Aura::PeriodicTick() uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT; uint32 procEx = createProcExtendMask(&damageInfo, SPELL_MISS_NONE); if (damageInfo.damage) - { procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; } + { + procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; + } pCaster->ProcDamageAndSpell(damageInfo.target, procAttacker, procVictim, procEx, damageInfo.damage, BASE_ATTACK, spellProto); @@ -7855,7 +8281,9 @@ void Aura::PeriodicTick() { // don't heal target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } int32 gain = target->ModifyHealth(m_modifier.m_amount); if (Unit* caster = GetCaster()) @@ -7866,11 +8294,15 @@ void Aura::PeriodicTick() { // don't energize target if not alive, possible death persistent effects if (!target->IsAlive()) - { return; } + { + return; + } Powers powerType = target->GetPowerType(); if (int32(powerType) != m_modifier.m_miscvalue) - { return; } + { + return; + } if ( spellProto->GetAuraInterruptFlags() & AURA_INTERRUPT_FLAG_NOT_SEATED ) { @@ -8613,13 +9045,17 @@ void Aura::PeriodicDummyTick() void Aura::HandlePreventFleeing(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } Unit::AuraList const& fearAuras = GetTarget()->GetAurasByType(SPELL_AURA_MOD_FEAR); if (!fearAuras.empty()) { if (apply) - { GetTarget()->SetFeared(false, fearAuras.front()->GetCasterGuid()); } + { + GetTarget()->SetFeared(false, fearAuras.front()->GetCasterGuid()); + } else { GetTarget()->SetFeared(true); } } @@ -8628,7 +9064,9 @@ void Aura::HandlePreventFleeing(bool apply, bool Real) void Aura::HandleManaShield(bool apply, bool Real) { if (!Real) - { return; } + { + return; + } // prevent double apply bonuses if (apply && (GetTarget()->GetTypeId() != TYPEID_PLAYER || !((Player*)GetTarget())->GetSession()->PlayerLoading())) @@ -9048,7 +9486,9 @@ SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit* target, Wor MANGOS_ASSERT(spellproto && spellproto == sSpellStore.LookupEntry(spellproto->Id) && "`info` must be pointer to sSpellStore element"); if (!caster) - { m_casterGuid = target->GetObjectGuid(); } + { + m_casterGuid = target->GetObjectGuid(); + } else { // remove this assert when not unit casters will be supported @@ -9072,12 +9512,16 @@ SpellAuraHolder::SpellAuraHolder(SpellEntry const* spellproto, Unit* target, Wor m_duration = m_maxDuration = CalculateSpellDuration(spellproto, unitCaster); if (m_maxDuration == -1 || (m_isPassive && spellproto->DurationIndex == 0)) - { m_permanent = true; } + { + m_permanent = true; + } if (unitCaster) { if (Player* modOwner = unitCaster->GetSpellModOwner()) - { modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges); } + { + modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges); + } } // some custom stack values at aura holder create @@ -9121,15 +9565,21 @@ void SpellAuraHolder::ApplyAuraModifiers(bool apply, bool real) { for (int32 i = 0; i < MAX_EFFECT_INDEX && !IsDeleted(); ++i) if (Aura* aur = GetAuraByEffectIndex(SpellEffectIndex(i))) - { aur->ApplyModifier(apply, real); } + { + aur->ApplyModifier(apply, real); + } } void SpellAuraHolder::_AddSpellAuraHolder() { if (!GetId()) - { return; } + { + return; + } if (!m_target) - { return; } + { + return; + } // Try find slot for aura uint8 slot = NULL_AURA_SLOT; @@ -9266,7 +9716,9 @@ void SpellAuraHolder::_RemoveSpellAuraHolder() // Remove all triggered by aura spells vs unlimited duration // except same aura replace case if (m_removeMode != AURA_REMOVE_BY_STACK) - { CleanupTriggeredSpells(); } + { + CleanupTriggeredSpells(); + } Unit* caster = GetCaster(); @@ -9288,14 +9740,20 @@ void SpellAuraHolder::_RemoveSpellAuraHolder() uint8 slot = GetAuraSlot(); if (slot >= MAX_AURAS) // slot not set - { return; } + { + return; + } if (!m_target->GetVisibleAura(slot)) - { return; } + { + return; + } // unregister aura diminishing (and store last time) if (getDiminishGroup() != DIMINISHING_NONE) - { m_target->ApplyDiminishingAura(getDiminishGroup(), false); } + { + m_target->ApplyDiminishingAura(getDiminishGroup(), false); + } SetAuraFlags(AFLAG_NONE); SetAuraLevel(0); @@ -9390,7 +9848,9 @@ void SpellAuraHolder::_RemoveSpellAuraHolder() // this has been last aura if (!found) - { m_target->ModifyAuraState(AuraState(removeState), false); } + { + m_target->ModifyAuraState(AuraState(removeState), false); + } } // reset cooldown state for spells @@ -9412,18 +9872,26 @@ void SpellAuraHolder::CleanupTriggeredSpells() continue; if (!spellEffect->EffectApplyAuraName) - { continue; } + { + continue; + } uint32 tSpellId = spellEffect->EffectTriggerSpell; if (!tSpellId) - { continue; } + { + continue; + } SpellEntry const* tProto = sSpellStore.LookupEntry(tSpellId); if (!tProto) - { continue; } + { + continue; + } if (GetSpellDuration(tProto) != -1) - { continue; } + { + continue; + } // needed for spell 43680, maybe others // TODO: is there a spell flag, which can solve this in a more sophisticated way? @@ -9441,12 +9909,16 @@ bool SpellAuraHolder::ModStackAmount(int32 num) // Can`t mod if (!protoStackAmount) - { return true; } + { + return true; + } // Modify stack but limit it int32 stackAmount = m_stackAmount + num; if (stackAmount > (int32)protoStackAmount) - { stackAmount = protoStackAmount; } + { + stackAmount = protoStackAmount; + } else if (stackAmount <= 0) // Last aura from stack removed { m_stackAmount = 0; @@ -9463,7 +9935,9 @@ void SpellAuraHolder::SetStackAmount(uint32 stackAmount) Unit* target = GetTarget(); Unit* caster = GetCaster(); if (!target || !caster) - { return; } + { + return; + } bool refresh = stackAmount >= m_stackAmount; if (stackAmount != m_stackAmount) @@ -9498,7 +9972,9 @@ void SpellAuraHolder::SetStackAmount(uint32 stackAmount) Unit* SpellAuraHolder::GetCaster() const { if (GetCasterGuid() == m_target->GetObjectGuid()) - { return m_target; } + { + return m_target; + } return ObjectAccessor::GetUnit(*m_target, m_casterGuid);// player will search at any maps } @@ -9507,27 +9983,39 @@ bool SpellAuraHolder::IsWeaponBuffCoexistableWith(SpellAuraHolder const* ref) co { // only item casted spells if (!GetCastItemGuid()) - { return false; } + { + return false; + } // Exclude Debuffs if (!IsPositive()) - { return false; } + { + return false; + } // Exclude Non-generic Buffs [ie: Runeforging] and Executioner-Enchant if (GetSpellProto()->GetSpellFamilyName() != SPELLFAMILY_GENERIC || GetId() == 42976) - { return false; } + { + return false; + } // Exclude Stackable Buffs [ie: Blood Reserve] if (GetSpellProto()->GetStackAmount()) - { return false; } + { + return false; + } // only self applied player buffs if (m_target->GetTypeId() != TYPEID_PLAYER || m_target->GetObjectGuid() != GetCasterGuid()) - { return false; } + { + return false; + } Item* castItem = ((Player*)m_target)->GetItemByGuid(GetCastItemGuid()); if (!castItem) - { return false; } + { + return false; + } // Limit to Weapon-Slots if (!castItem->IsEquipped() || @@ -9591,7 +10079,9 @@ void SpellAuraHolder::BuildUpdatePacket(WorldPacket& data) const if (auraFlags & (1 << i)) { if (Aura const* aura = m_auras[i]) - { data << int32(aura->GetModifier()->m_amount); } + { + data << int32(aura->GetModifier()->m_amount); + } else { data << int32(0); } } @@ -10292,24 +10782,40 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if (apply || cast_at_remove) { if (spellId1) - { m_target->CastSpell(m_target, spellId1, true, NULL, NULL, GetCasterGuid()); } + { + m_target->CastSpell(m_target, spellId1, true, NULL, NULL, GetCasterGuid()); + } if (spellId2 && !IsDeleted()) - { m_target->CastSpell(m_target, spellId2, true, NULL, NULL, GetCasterGuid()); } + { + m_target->CastSpell(m_target, spellId2, true, NULL, NULL, GetCasterGuid()); + } if (spellId3 && !IsDeleted()) - { m_target->CastSpell(m_target, spellId3, true, NULL, NULL, GetCasterGuid()); } + { + m_target->CastSpell(m_target, spellId3, true, NULL, NULL, GetCasterGuid()); + } if (spellId4 && !IsDeleted()) - { m_target->CastSpell(m_target, spellId4, true, NULL, NULL, GetCasterGuid()); } + { + m_target->CastSpell(m_target, spellId4, true, NULL, NULL, GetCasterGuid()); + } } else { if (spellId1) - { m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGuid()); } + { + m_target->RemoveAurasByCasterSpell(spellId1, GetCasterGuid()); + } if (spellId2) - { m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGuid()); } + { + m_target->RemoveAurasByCasterSpell(spellId2, GetCasterGuid()); + } if (spellId3) - { m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGuid()); } + { + m_target->RemoveAurasByCasterSpell(spellId3, GetCasterGuid()); + } if (spellId4) - { m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGuid()); } + { + m_target->RemoveAurasByCasterSpell(spellId4, GetCasterGuid()); + } } SetInUse(false); @@ -10320,7 +10826,9 @@ SpellAuraHolder::~SpellAuraHolder() // note: auras in delete list won't be affected since they clear themselves from holder when adding to deletedAuraslist for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) - { delete aur; } + { + delete aur; + } } void SpellAuraHolder::Update(uint32 diff) @@ -10400,7 +10908,9 @@ void SpellAuraHolder::SetAuraMaxDuration(int32 duration) if (duration > 0) { if (!(IsPassive() && GetSpellProto()->DurationIndex == 0)) - { SetPermanent(false); } + { + SetPermanent(false); + } SetAuraFlags(GetAuraFlags() | AFLAG_DURATION); } @@ -10411,7 +10921,9 @@ void SpellAuraHolder::SetAuraMaxDuration(int32 duration) bool SpellAuraHolder::HasMechanic(uint32 mechanic) const { if (mechanic == m_spellProto->GetMechanic()) - { return true; } + { + return true; + } for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { @@ -10427,7 +10939,9 @@ bool SpellAuraHolder::HasMechanic(uint32 mechanic) const bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const { if (mechanicMask & (1 << (m_spellProto->GetMechanic() - 1))) - { return true; } + { + return true; + } for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { @@ -10445,7 +10959,9 @@ bool SpellAuraHolder::IsPersistent() const for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) if (aur->IsPersistent()) - { return true; } + { + return true; + } return false; } @@ -10454,7 +10970,9 @@ bool SpellAuraHolder::IsAreaAura() const for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) if (aur->IsAreaAura()) - { return true; } + { + return true; + } return false; } @@ -10463,7 +10981,9 @@ bool SpellAuraHolder::IsPositive() const for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (Aura* aur = m_auras[i]) if (!aur->IsPositive()) - { return false; } + { + return false; + } return true; } @@ -10471,7 +10991,9 @@ bool SpellAuraHolder::IsEmptyHolder() const { for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_auras[i]) - { return false; } + { + return false; + } return true; } @@ -10479,12 +11001,16 @@ void SpellAuraHolder::UnregisterAndCleanupTrackedAuras() { TrackedAuraType trackedType = GetTrackedAuraType(); if (!trackedType) - { return; } + { + return; + } if (trackedType == TRACK_AURA_TYPE_SINGLE_TARGET) { if (Unit* caster = GetCaster()) - { caster->GetTrackedAuraTargets(trackedType).erase(GetSpellProto()); } + { + caster->GetTrackedAuraTargets(trackedType).erase(GetSpellProto()); + } } else if (trackedType == TRACK_AURA_TYPE_CONTROL_VEHICLE) { diff --git a/src/game/movement/MoveSpline.cpp b/src/game/movement/MoveSpline.cpp index 5c5d16b43..bcd378fa1 100644 --- a/src/game/movement/MoveSpline.cpp +++ b/src/game/movement/MoveSpline.cpp @@ -40,7 +40,9 @@ namespace Movement float u = 1.f; int32 seg_time = spline.length(point_Idx, point_Idx + 1); if (seg_time > 0) - { u = (time_passed - spline.length(point_Idx)) / (float)seg_time; } + { + u = (time_passed - spline.length(point_Idx)) / (float)seg_time; + } Location c; c.orientation = initialOrientation; spline.evaluate_percent(point_Idx, u, c); @@ -55,7 +57,9 @@ namespace Movement if (splineflags.done && splineflags.isFacing()) { if (splineflags.final_angle) - { c.orientation = facing.angle; } + { + c.orientation = facing.angle; + } else if (splineflags.final_point) { c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x); } // nothing to do for MoveSplineFlag::Final_Target flag @@ -93,7 +97,9 @@ namespace Movement float z_now = spline.getPoint(spline.first()).z - Movement::computeFallElevation(MSToSec(time_passed)); float final_z = FinalDestination().z; if (z_now < final_z) - { el = final_z; } + { + el = final_z; + } else { el = z_now; } } @@ -301,7 +307,9 @@ namespace Movement str << "spline Id: " << GetId() << std::endl; str << "flags: " << splineflags.ToString() << std::endl; if (splineflags.final_angle) - { str << "facing angle: " << facing.angle; } + { + str << "facing angle: " << facing.angle; + } else if (splineflags.final_target) { str << "facing target: " << facing.target; } else if (splineflags.final_point) @@ -326,7 +334,9 @@ namespace Movement { int32 point = point_Idx_offset + point_Idx - spline.first() + (int)Finalized(); if (isCyclic()) - { point = point % (spline.last() - spline.first()); } + { + point = point % (spline.last() - spline.first()); + } return point; } } diff --git a/src/game/movement/MoveSplineInit.cpp b/src/game/movement/MoveSplineInit.cpp index 07a3b08a3..b35d2848e 100644 --- a/src/game/movement/MoveSplineInit.cpp +++ b/src/game/movement/MoveSplineInit.cpp @@ -42,7 +42,9 @@ namespace Movement else if (moveFlags & MOVEFLAG_SWIMMING) { if (moveFlags & MOVEFLAG_BACKWARD /*&& speed_obj.swim >= speed_obj.swim_back*/) - { return MOVE_SWIM_BACK; } + { + return MOVE_SWIM_BACK; + } else { return MOVE_SWIM; } } @@ -71,7 +73,9 @@ namespace Movement // there is a big chance that current position is unknown if current state is not finalized, need compute it // this also allows calculate spline position and update map position in much greater intervals if (!move_spline.Finalized() && !transportInfo) - { real_position = move_spline.ComputePosition(); } + { + real_position = move_spline.ComputePosition(); + } if (args.path.empty()) { @@ -92,10 +96,14 @@ namespace Movement moveFlags |= MOVEFLAG_FORWARD; if (args.velocity == 0.f) - { args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags)); } + { + args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags)); + } if (!args.Validate(&unit)) - { return 0; } + { + return 0; + } unit.m_movementInfo.SetMovementFlags((MovementFlags)moveFlags); move_spline.Initialize(args); diff --git a/src/game/movement/packet_builder.cpp b/src/game/movement/packet_builder.cpp index 5a1dfb415..3350a54ec 100644 --- a/src/game/movement/packet_builder.cpp +++ b/src/game/movement/packet_builder.cpp @@ -131,7 +131,9 @@ namespace Movement if (splineflags & MoveSplineFlag::UncompressedPath) { if (splineflags.cyclic) - { WriteCatmullRomCyclicPath(spline, data); } + { + WriteCatmullRomCyclicPath(spline, data); + } else { WriteCatmullRomPath(spline, data); } } diff --git a/src/game/movement/spline.cpp b/src/game/movement/spline.cpp index 775309d9d..a662eadf0 100644 --- a/src/game/movement/spline.cpp +++ b/src/game/movement/spline.cpp @@ -233,7 +233,9 @@ namespace Movement // first and last two indexes are space for special 'virtual points' // these points are required for proper C_Evaluate and C_Evaluate_Derivative methtod work if (cyclic) - { points[count] = controls[cyclic_point]; } + { + points[count] = controls[cyclic_point]; + } else { points[count] = controls[count - 1]; } @@ -257,7 +259,9 @@ namespace Movement if (cyclic) { if (cyclic_point == 0) - { points[0] = controls[count - 1]; } + { + points[0] = controls[count - 1]; + } else { points[0] = controls[0].lerp(controls[1], -1); } diff --git a/src/game/movement/typedefs.h b/src/game/movement/typedefs.h index 29814d0d8..dfbab29fa 100644 --- a/src/game/movement/typedefs.h +++ b/src/game/movement/typedefs.h @@ -84,7 +84,9 @@ namespace Movement void Increase() { if (m_counter == limit) - { init(); } + { + init(); + } else { ++m_counter; } } diff --git a/src/game/movement/util.cpp b/src/game/movement/util.cpp index 4b3c5ffc6..8ebed148c 100644 --- a/src/game/movement/util.cpp +++ b/src/game/movement/util.cpp @@ -41,20 +41,26 @@ namespace Movement float computeFallTime(float path_length, bool isSafeFall) { if (path_length < 0.f) - { return 0.f; } + { + return 0.f; + } float time; if (isSafeFall) { if (path_length >= terminal_savefall_length) - { time = (path_length - terminal_savefall_length) / terminalSavefallVelocity + terminalSavefallVelocity / gravity; } + { + time = (path_length - terminal_savefall_length) / terminalSavefallVelocity + terminalSavefallVelocity / gravity; + } else { time = sqrtf(2.f * path_length / gravity); } } else { if (path_length >= terminal_length) - { time = (path_length - terminal_length) / terminalVelocity + terminalFallTime; } + { + time = (path_length - terminal_length) / terminalVelocity + terminalFallTime; + } else { time = sqrtf(2.f * path_length / gravity); } } @@ -68,12 +74,16 @@ namespace Movement float result; if (isSafeFall) - { termVel = terminalSavefallVelocity; } + { + termVel = terminalSavefallVelocity; + } else { termVel = terminalVelocity; } if (start_velocity > termVel) - { start_velocity = termVel; } + { + start_velocity = termVel; + } float terminal_time = terminalFallTime - start_velocity / gravity; // the time that needed to reach terminalVelocity @@ -201,7 +211,9 @@ namespace Movement for (int i = 0; i < N; ++i) { if ((t & (Flags)(1 << i)) && names[i] != NULL) - { str.append(" ").append(names[i]); } + { + str.append(" ").append(names[i]); + } } } diff --git a/src/game/vmap/BIH.cpp b/src/game/vmap/BIH.cpp index e2e5ed93e..021c1cc7b 100644 --- a/src/game/vmap/BIH.cpp +++ b/src/game/vmap/BIH.cpp @@ -59,7 +59,9 @@ void BIH::subdivide(int left, int right, std::vector& tempTree, buildDat // perform quick consistency checks Vector3 d(gridBox.hi - gridBox.lo); if (d.x < 0 || d.y < 0 || d.z < 0) - { throw std::logic_error("negative node extents"); } + { + throw std::logic_error("negative node extents"); + } for (int i = 0; i < 3; ++i) { if (nodeBox.hi[i] < gridBox.lo[i] || nodeBox.lo[i] > gridBox.hi[i]) @@ -88,7 +90,9 @@ void BIH::subdivide(int left, int right, std::vector& tempTree, buildDat // stay left ++i; if (clipL < maxb) - { clipL = maxb; } + { + clipL = maxb; + } } else { @@ -98,7 +102,9 @@ void BIH::subdivide(int left, int right, std::vector& tempTree, buildDat dat.indices[right] = t; --right; if (clipR > minb) - { clipR = minb; } + { + clipR = minb; + } } nodeL = std::min(nodeL, minb); nodeR = std::max(nodeR, maxb); @@ -245,11 +251,15 @@ void BIH::subdivide(int left, int right, std::vector& tempTree, buildDat nodeBoxR.lo[axis] = clipR; // recurse if (nl > 0) - { subdivide(left, right, tempTree, dat, gridBoxL, nodeBoxL, nextIndex, depth + 1, stats); } + { + subdivide(left, right, tempTree, dat, gridBoxL, nodeBoxL, nextIndex, depth + 1, stats); + } else { stats.updateLeaf(depth + 1, 0); } if (nr > 0) - { subdivide(right + 1, rightOrig, tempTree, dat, gridBoxR, nodeBoxR, nextIndex + 3, depth + 1, stats); } + { + subdivide(right + 1, rightOrig, tempTree, dat, gridBoxR, nodeBoxR, nextIndex + 3, depth + 1, stats); + } else { stats.updateLeaf(depth + 1, 0); } } diff --git a/src/game/vmap/BIH.h b/src/game/vmap/BIH.h index 312233fb4..c8dbbb60f 100644 --- a/src/game/vmap/BIH.h +++ b/src/game/vmap/BIH.h @@ -154,7 +154,9 @@ class BIH BuildStats stats; buildHierarchy(tempTree, dat, stats); if (printStats) - { stats.printStats(); } + { + stats.printStats(); + } objects.resize(dat.numPrims); for (uint32 i = 0; i < dat.numPrims; ++i) @@ -195,20 +197,30 @@ class BIH float t1 = (bounds.low()[i] - org[i]) * invDir[i]; float t2 = (bounds.high()[i] - org[i]) * invDir[i]; if (t1 > t2) - { std::swap(t1, t2); } + { + std::swap(t1, t2); + } if (t1 > intervalMin) - { intervalMin = t1; } + { + intervalMin = t1; + } if (t2 < intervalMax || intervalMax < 0.f) - { intervalMax = t2; } + { + intervalMax = t2; + } // intervalMax can only become smaller for other axis, // and intervalMin only larger respectively, so stop early if (intervalMax <= 0 || intervalMin >= maxDist) - { return; } + { + return; + } } } if (intervalMin > intervalMax) - { return; } + { + return; + } intervalMin = std::max(intervalMin, 0.f); intervalMax = std::min(intervalMax, maxDist); @@ -251,7 +263,9 @@ class BIH float tb = (intBitsToFloat(tree[node + offsetBack[axis]]) - org[axis]) * invDir[axis]; // ray passes between clip zones if (tf < intervalMin && tb > intervalMax) - { break; } + { + break; + } int back = offset + offsetBack3[axis]; node = back; // ray passes through far node only @@ -301,7 +315,9 @@ class BIH intervalMin = (tf >= intervalMin) ? tf : intervalMin; intervalMax = (tb <= intervalMax) ? tb : intervalMax; if (intervalMin > intervalMax) - { break; } + { + break; + } continue; } } // traversal loop @@ -309,12 +325,16 @@ class BIH { // stack is empty? if (stackPos == 0) - { return; } + { + return; + } // move back up the stack --stackPos; intervalMin = stack[stackPos].tnear; if (maxDist < intervalMin) - { continue; } + { + continue; + } node = stack[stackPos].node; intervalMax = stack[stackPos].tfar; break; @@ -333,7 +353,9 @@ class BIH void intersectPoint(const Vector3& p, IsectCallback& intersectCallback) const { if (!bounds.contains(p)) - { return; } + { + return; + } StackNode stack[MAX_STACK_SIZE]; int stackPos = 0; @@ -356,7 +378,9 @@ class BIH float tr = intBitsToFloat(tree[node + 2]); // point is between clip zones if (tl < p[axis] && tr > p[axis]) - { break; } + { + break; + } int right = offset + 3; node = right; // point is in right node only @@ -397,14 +421,18 @@ class BIH float tr = intBitsToFloat(tree[node + 2]); node = offset; if (tl > p[axis] || tr < p[axis]) - { break; } + { + break; + } continue; } } // traversal loop // stack is empty? if (stackPos == 0) - { return; } + { + return; + } // move back up the stack --stackPos; node = stack[stackPos].node; diff --git a/src/game/vmap/BIHWrap.h b/src/game/vmap/BIHWrap.h index 398c4b14a..0fa9e827d 100644 --- a/src/game/vmap/BIHWrap.h +++ b/src/game/vmap/BIHWrap.h @@ -67,10 +67,14 @@ class BIHWrap bool operator()(const Ray& r, uint32 Idx, float& MaxDist, bool /*stopAtFirst*/) { if (Idx >= objects_size) - { return false; } + { + return false; + } if (const T* obj = objects[Idx]) - { return cb(r, *obj, MaxDist/*, stopAtFirst*/); } + { + return cb(r, *obj, MaxDist/*, stopAtFirst*/); + } return false; } @@ -83,10 +87,14 @@ class BIHWrap void operator()(const Vector3& p, uint32 Idx) { if (Idx >= objects_size) - { return; } + { + return; + } if (const T* obj = objects[Idx]) - { cb(p, *obj); } + { + cb(p, *obj); + } } }; @@ -132,7 +140,9 @@ class BIHWrap uint32 Idx = 0; const T* temp; if (m_obj2Idx.getRemove(&obj, temp, Idx)) - { m_objects[Idx] = NULL; } + { + m_objects[Idx] = NULL; + } else { m_objects_to_push.remove(&obj); } } @@ -144,7 +154,9 @@ class BIHWrap void balance() { if (unbalanced_times == 0) - { return; } + { + return; + } unbalanced_times = 0; m_objects.fastClear(); diff --git a/src/game/vmap/DynamicTree.cpp b/src/game/vmap/DynamicTree.cpp index 6fac301fd..ff9fe35b4 100644 --- a/src/game/vmap/DynamicTree.cpp +++ b/src/game/vmap/DynamicTree.cpp @@ -90,14 +90,18 @@ struct DynTreeImpl : public ParentTree/*, public Intersectable*/ void update(uint32 difftime) { if (!size()) - { return; } + { + return; + } rebalance_timer.Update(difftime); if (rebalance_timer.Passed()) { rebalance_timer.Reset(CHECK_TREE_PERIOD); if (unbalanced_times > 0) - { balance(); } + { + balance(); + } } } @@ -191,7 +195,9 @@ bool DynamicMapTree::getIntersectionTime(const uint32 phasemask, const G3D::Ray& DynamicTreeIntersectionCallback callback(phasemask); impl.intersectRay(ray, callback, distance, endPos); if (callback.didHit()) - { pMaxDist = distance; } + { + pMaxDist = distance; + } return callback.didHit(); } //========================================================= @@ -263,7 +269,9 @@ bool DynamicMapTree::isInLineOfSight(float x1, float y1, float z1, float x2, flo float maxDist = (v2 - v1).magnitude(); if (!G3D::fuzzyGt(maxDist, 0)) - { return true; } + { + return true; + } G3D::Ray r(v1, (v2 - v1) / maxDist); DynamicTreeIntersectionCallback callback(phasemask); @@ -280,7 +288,9 @@ float DynamicMapTree::getHeight(float x, float y, float z, float maxSearchDist, impl.intersectZAllignedRay(r, callback, maxSearchDist); if (callback.didHit()) - { return v.z - maxSearchDist; } + { + return v.z - maxSearchDist; + } else { return -G3D::inf(); } } diff --git a/src/game/vmap/GameObjectModel.cpp b/src/game/vmap/GameObjectModel.cpp index 6f22f4ce3..37de78aa6 100644 --- a/src/game/vmap/GameObjectModel.cpp +++ b/src/game/vmap/GameObjectModel.cpp @@ -49,7 +49,9 @@ void LoadGameObjectModelList() { FILE* model_list_file = fopen((sWorld.GetDataPath() + "vmaps/" + VMAP::GAMEOBJECT_MODELS).c_str(), "rb"); if (!model_list_file) - { return; } + { + return; + } uint32 name_length, displayId; char buff[500]; @@ -98,14 +100,18 @@ void LoadGameObjectModelList() GameObjectModel::~GameObjectModel() { if (iModel) - { ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->releaseModelInstance(name); } + { + ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->releaseModelInstance(name); + } } bool GameObjectModel::initialize(const GameObject* const pGo, const GameObjectDisplayInfoEntry* const pDisplayInfo) { ModelList::const_iterator it = model_list.find(pDisplayInfo->Displayid); if (it == model_list.end()) - { return false; } + { + return false; + } G3D::AABox mdl_box(it->second.bound); // ignore models with no bounds @@ -118,7 +124,9 @@ bool GameObjectModel::initialize(const GameObject* const pGo, const GameObjectDi iModel = ((VMAP::VMapManager2*)VMAP::VMapFactory::createOrGetVMapManager())->acquireModelInstance(sWorld.GetDataPath() + "vmaps/", it->second.name); if (!iModel) - { return false; } + { + return false; + } name = it->second.name; iPos = Vector3(pGo->GetPositionX(), pGo->GetPositionY(), pGo->GetPositionZ()); @@ -156,7 +164,9 @@ GameObjectModel* GameObjectModel::construct(const GameObject* const pGo) { const GameObjectDisplayInfoEntry* info = sGameObjectDisplayInfoStore.LookupEntry(pGo->GetDisplayId()); if (!info) - { return NULL; } + { + return NULL; + } GameObjectModel* mdl = new GameObjectModel(); if (!mdl->initialize(pGo, info)) @@ -171,11 +181,15 @@ GameObjectModel* GameObjectModel::construct(const GameObject* const pGo) bool GameObjectModel::intersectRay(const G3D::Ray& ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const { if (!(phasemask & ph_mask)) - { return false; } + { + return false; + } float time = ray.intersectionTime(iBound); if (time == G3D::inf()) - { return false; } + { + return false; + } // child bounds are defined in object space: Vector3 p = iInvRot * (ray.origin() - iPos) * iInvScale; diff --git a/src/game/vmap/MapTree.cpp b/src/game/vmap/MapTree.cpp index 70ad94328..17f9664f5 100644 --- a/src/game/vmap/MapTree.cpp +++ b/src/game/vmap/MapTree.cpp @@ -46,7 +46,9 @@ namespace VMAP { bool result = prims[entry].intersectRay(ray, distance, pStopAtFirstHit); if (result) - { hit = true; } + { + hit = true; + } return result; } bool didHit() { return hit; } @@ -81,7 +83,9 @@ namespace VMAP DEBUG_LOG("trying to intersect '%s'", prims[entry].name.c_str()); #endif if (prims[entry].GetLocationInfo(point, locInfo)) - { result = true; } + { + result = true; + } } ModelInstance* prims; @@ -153,7 +157,9 @@ namespace VMAP MapRayCallback intersectionCallBack(iTreeValues); iTree.intersectRay(pRay, intersectionCallBack, distance, pStopAtFirstHit); if (intersectionCallBack.didHit()) - { pMaxDist = distance; } + { + pMaxDist = distance; + } return intersectionCallBack.didHit(); } //========================================================= @@ -170,11 +176,15 @@ namespace VMAP MANGOS_ASSERT(maxDist < std::numeric_limits::max()); // prevent NaN values which can cause BIH intersection to enter infinite loop if (maxDist < 1e-10f) - { return true; } + { + return true; + } // direction with length of 1 G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1) / maxDist); if (getIntersectionTime(ray, maxDist, true)) - { return false; } + { + return false; + } return true; } @@ -248,12 +258,16 @@ namespace VMAP { std::string basePath = vmapPath; if (basePath.length() > 0 && (basePath[basePath.length() - 1] != '/' || basePath[basePath.length() - 1] != '\\')) - { basePath.append("/"); } + { + basePath.append("/"); + } std::string fullname = basePath + VMapManager2::getMapFileName(mapID); bool success = true; FILE* rf = fopen(fullname.c_str(), "rb"); if (!rf) - { return false; } + { + return false; + } // TODO: check magic number when implemented... char tiled; char chunk[8]; @@ -267,11 +281,15 @@ namespace VMAP std::string tilefile = basePath + getTileFileName(mapID, tileX, tileY); FILE* tf = fopen(tilefile.c_str(), "rb"); if (!tf) - { success = false; } + { + success = false; + } else { if (!readChunk(tf, chunk, VMAP_MAGIC, 8)) - { success = false; } + { + success = false; + } fclose(tf); } } @@ -288,7 +306,9 @@ namespace VMAP std::string fullname = iBasePath + fname; FILE* rf = fopen(fullname.c_str(), "rb"); if (!rf) - { return false; } + { + return false; + } else { char chunk[8]; @@ -373,10 +393,14 @@ namespace VMAP { char chunk[8]; if (!readChunk(tf, chunk, VMAP_MAGIC, 8)) - { result = false; } + { + result = false; + } uint32 numSpawns = 0; if (result && fread(&numSpawns, sizeof(uint32), 1, tf) != 1) - { result = false; } + { + result = false; + } for (uint32 i = 0; i < numSpawns && result; ++i) { // read model spawns @@ -387,7 +411,9 @@ namespace VMAP // acquire model instance WorldModel* model = vm->acquireModelInstance(iBasePath, spawn.name); if (!model) - { ERROR_LOG("StaticMapTree::LoadMapTile() could not acquire WorldModel pointer for '%s'!", spawn.name.c_str()); } + { + ERROR_LOG("StaticMapTree::LoadMapTile() could not acquire WorldModel pointer for '%s'!", spawn.name.c_str()); + } // update tree uint32 referencedVal; @@ -410,7 +436,9 @@ namespace VMAP ++iLoadedSpawns[referencedVal]; #ifdef VMAP_DEBUG if (iTreeValues[referencedVal].ID != spawn.ID) - { DEBUG_LOG("Error: trying to load wrong spawn in node!"); } + { + 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); } #endif @@ -445,10 +473,14 @@ namespace VMAP bool result = true; char chunk[8]; if (!readChunk(tf, chunk, VMAP_MAGIC, 8)) - { result = false; } + { + result = false; + } uint32 numSpawns; if (fread(&numSpawns, sizeof(uint32), 1, tf) != 1) - { result = false; } + { + result = false; + } for (uint32 i = 0; i < numSpawns && result; ++i) { // read model spawns diff --git a/src/game/vmap/ModelInstance.cpp b/src/game/vmap/ModelInstance.cpp index e4a80dd28..f756edee6 100644 --- a/src/game/vmap/ModelInstance.cpp +++ b/src/game/vmap/ModelInstance.cpp @@ -80,9 +80,13 @@ namespace VMAP // M2 files don't contain area info, only WMO files if (flags & MOD_M2) - { return; } + { + return; + } if (!iBound.contains(p)) - { return; } + { + return; + } // child bounds are defined in object space: Vector3 pModel = iInvRot * (p - iPos) * iInvScale; Vector3 zDirModel = iInvRot * Vector3(0.f, 0.f, -1.f); @@ -114,9 +118,13 @@ namespace VMAP // M2 files don't contain area info, only WMO files if (flags & MOD_M2) - { return false; } + { + return false; + } if (!iBound.contains(p)) - { return false; } + { + return false; + } // child bounds are defined in object space: Vector3 pModel = iInvRot * (p - iPos) * iInvScale; Vector3 zDirModel = iInvRot * Vector3(0.f, 0.f, -1.f); @@ -164,7 +172,9 @@ namespace VMAP if (!check) { if (ferror(rf)) - { ERROR_LOG("Error reading ModelSpawn!"); } + { + ERROR_LOG("Error reading ModelSpawn!"); + } return false; } check += fread(&spawn.adtId, sizeof(uint16), 1, rf); diff --git a/src/game/vmap/RegularGrid.h b/src/game/vmap/RegularGrid.h index 41fca217e..75b08f384 100644 --- a/src/game/vmap/RegularGrid.h +++ b/src/game/vmap/RegularGrid.h @@ -145,7 +145,9 @@ class RegularGrid2D for (int x = 0; x < CELL_NUMBER; ++x) for (int y = 0; y < CELL_NUMBER; ++y) if (Node* n = nodes[x][y]) - { n->balance(); } + { + n->balance(); + } } /** @@ -222,7 +224,9 @@ class RegularGrid2D { MANGOS_ASSERT(x < CELL_NUMBER && y < CELL_NUMBER); if (!nodes[x][y]) - { nodes[x][y] = NodeCreatorFunc::makeNode(x, y); } + { + nodes[x][y] = NodeCreatorFunc::makeNode(x, y); + } return *nodes[x][y]; } @@ -252,14 +256,18 @@ class RegularGrid2D { Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y); if (!cell.isValid()) - { return; } + { + return; + } Cell last_cell = Cell::ComputeCell(end.x, end.y); if (cell == last_cell) { if (Node* node = nodes[cell.x][cell.y]) - { node->intersectRay(ray, intersectCallback, max_dist); } + { + node->intersectRay(ray, intersectCallback, max_dist); + } return; } @@ -308,7 +316,9 @@ class RegularGrid2D node->intersectRay(ray, intersectCallback, max_dist); } if (cell == last_cell) - { break; } + { + break; + } if (tMaxX < tMaxY) { tMaxX += tDeltaX; @@ -335,9 +345,13 @@ class RegularGrid2D { Cell cell = Cell::ComputeCell(point.x, point.y); if (!cell.isValid()) - { return; } + { + return; + } if (Node* node = nodes[cell.x][cell.y]) - { node->intersectPoint(point, intersectCallback); } + { + node->intersectPoint(point, intersectCallback); + } } template @@ -352,9 +366,13 @@ class RegularGrid2D { Cell cell = Cell::ComputeCell(ray.origin().x, ray.origin().y); if (!cell.isValid()) - { return; } + { + return; + } if (Node* node = nodes[cell.x][cell.y]) - { node->intersectRay(ray, intersectCallback, max_dist); } + { + node->intersectRay(ray, intersectCallback, max_dist); + } } }; diff --git a/src/game/vmap/TileAssembler.cpp b/src/game/vmap/TileAssembler.cpp index bc22dd65a..043af0903 100644 --- a/src/game/vmap/TileAssembler.cpp +++ b/src/game/vmap/TileAssembler.cpp @@ -78,7 +78,9 @@ namespace VMAP { bool success = readMapSpawns(); if (!success) - { return false; } + { + return false; + } // export Map data for (MapData::iterator map_iter = mapData.begin(); map_iter != mapData.end() && success; ++map_iter) @@ -93,7 +95,9 @@ namespace VMAP if (entry->second.flags & MOD_M2) { if (!calculateTransformedBound(entry->second)) - { break; } + { + break; + } } else if (entry->second.flags & MOD_WORLDSPAWN) // WMO maps and terrain maps use different origin, so we need to adapt :/ { @@ -153,7 +157,9 @@ namespace VMAP { const ModelSpawn& spawn = map_iter->second->UniqueEntries[tile->second]; if (spawn.flags & MOD_WORLDSPAWN) // WDT spawn, saved as tile 65/65 currently... - { continue; } + { + continue; + } uint32 nSpawns = tileEntries.count(tile->first); std::stringstream tilefilename; tilefilename.fill('0'); @@ -170,7 +176,9 @@ namespace VMAP for (uint32 s = 0; s < nSpawns; ++s) { if (s && tile != tileEntries.end()) - { ++tile; } + { + ++tile; + } const ModelSpawn& spawn2 = map_iter->second->UniqueEntries[tile->second]; success = success && ModelSpawn::writeToFile(tilefile, spawn2); // MapTree nodes to update when loading tile: @@ -225,11 +233,15 @@ namespace VMAP // read mapID, tileX, tileY, Flags, adtID, ID, Pos, Rot, Scale, Bound_lo, Bound_hi, name check += fread(&mapID, sizeof(uint32), 1, dirf); if (check == 0) // EoF... - { break; } + { + break; + } check += fread(&tileX, sizeof(uint32), 1, dirf); check += fread(&tileY, sizeof(uint32), 1, dirf); if (!ModelSpawn::readFromFile(dirf, spawn)) - { break; } + { + break; + } MapSpawns* current; MapData::iterator map_iter = mapData.find(mapID); @@ -257,11 +269,15 @@ namespace VMAP WorldModel_Raw raw_model; if (!raw_model.Read(modelFilename.c_str())) - { return false; } + { + return false; + } uint32 groups = raw_model.groupsArray.size(); if (groups != 1) - { printf("Warning: '%s' does not seem to be a M2 model!\n", modelFilename.c_str()); } + { + printf("Warning: '%s' does not seem to be a M2 model!\n", modelFilename.c_str()); + } AABox modelBound; bool boundEmpty = true; @@ -280,7 +296,9 @@ namespace VMAP { Vector3 v = modelPosition.transform(vertices[i]); if (boundEmpty) - { modelBound = AABox(v, v), boundEmpty = false; } + { + modelBound = AABox(v, v), boundEmpty = false; + } else { modelBound.merge(v); } } @@ -304,12 +322,16 @@ namespace VMAP bool success = true; std::string filename = iSrcDir; if (filename.length() > 0) - { filename.append("/"); } + { + filename.append("/"); + } filename.append(pModelFilename); WorldModel_Raw raw_model; if (!raw_model.Read(filename.c_str())) - { return false; } + { + return false; + } // write WorldModel WorldModel model; @@ -340,7 +362,9 @@ namespace VMAP { FILE* model_list = fopen((iSrcDir + "/" + GAMEOBJECT_MODELS).c_str(), "rb"); if (!model_list) - { return; } + { + return; + } FILE* model_list_copy = fopen((iDestDir + "/" + GAMEOBJECT_MODELS).c_str(), "wb"); if (!model_list_copy) @@ -380,7 +404,9 @@ namespace VMAP WorldModel_Raw raw_model; if (!raw_model.Read((iSrcDir + "/" + model_name).c_str())) - { continue; } + { + continue; + } spawnedModelFiles.insert(model_name); @@ -395,7 +421,9 @@ namespace VMAP { Vector3& v = vertices[i]; if (boundEmpty) - { bounds = AABox(v, v), boundEmpty = false; } + { + bounds = AABox(v, v), boundEmpty = false; + } else { bounds.merge(v); } } diff --git a/src/game/vmap/VMapFactory.cpp b/src/game/vmap/VMapFactory.cpp index c9c85f80d..2a59e5a8d 100644 --- a/src/game/vmap/VMapFactory.cpp +++ b/src/game/vmap/VMapFactory.cpp @@ -94,7 +94,9 @@ namespace VMAP void VMapFactory::preventSpellsFromBeingTestedForLoS(const char* pSpellIdString) { if (!iIgnoreSpellIds) - { iIgnoreSpellIds = new Table(); } + { + iIgnoreSpellIds = new Table(); + } if (pSpellIdString != NULL) { unsigned int pos = 0; diff --git a/src/game/vmap/VMapManager2.cpp b/src/game/vmap/VMapManager2.cpp index 763b9daaf..21218048f 100644 --- a/src/game/vmap/VMapManager2.cpp +++ b/src/game/vmap/VMapManager2.cpp @@ -86,7 +86,9 @@ namespace VMAP if (isMapLoadingEnabled()) { if (_loadMap(pMapId, pBasePath, x, y)) - { result = VMAP_LOAD_RESULT_OK; } + { + result = VMAP_LOAD_RESULT_OK; + } else { result = VMAP_LOAD_RESULT_ERROR; } } @@ -104,7 +106,9 @@ namespace VMAP std::string mapFileName = getMapFileName(pMapId); StaticMapTree* newTree = new StaticMapTree(pMapId, basePath); if (!newTree->InitMap(mapFileName, this)) - { return false; } + { + return false; + } instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(pMapId, newTree)).first; } return instanceTree->second->LoadMapTile(tileX, tileY, this); @@ -248,9 +252,13 @@ namespace VMAP floor = info.ground_Z; type = info.hitModel->GetLiquidType(); if (ReqLiquidType && !(type & ReqLiquidType)) - { return false; } + { + return false; + } if (info.hitInstance->GetLiquidLevel(pos, info, level)) - { return true; } + { + return true; + } } } } diff --git a/src/game/vmap/WorldModel.cpp b/src/game/vmap/WorldModel.cpp index 9530157af..66e19ac41 100644 --- a/src/game/vmap/WorldModel.cpp +++ b/src/game/vmap/WorldModel.cpp @@ -135,7 +135,9 @@ namespace VMAP WmoLiquid& WmoLiquid::operator=(const WmoLiquid& other) { if (this == &other) - { return *this; } + { + return *this; + } iTilesX = other.iTilesX; iTilesY = other.iTilesY; @@ -167,16 +169,22 @@ namespace VMAP float tx_f = (pos.x - iCorner.x) / LIQUID_TILE_SIZE; uint32 tx = uint32(tx_f); if (tx_f < 0.0f || tx >= iTilesX) - { return false; } + { + return false; + } float ty_f = (pos.y - iCorner.y) / LIQUID_TILE_SIZE; uint32 ty = uint32(ty_f); if (ty_f < 0.0f || ty >= iTilesY) - { return false; } + { + return false; + } // check if tile shall be used for liquid level // checking for 0x08 *might* be enough, but disabled tiles always are 0x?F: if ((iFlags[tx + ty * iTilesX] & 0x0F) == 0x0F) - { return false; } + { + return false; + } // (dx, dy) coordinates inside tile, in [0,1]^2 float dx = tx_f - (float)tx; @@ -264,7 +272,9 @@ namespace VMAP vertices(other.vertices), triangles(other.triangles), meshTree(other.meshTree), iLiquid(0) { if (other.iLiquid) - { iLiquid = new WmoLiquid(*other.iLiquid); } + { + iLiquid = new WmoLiquid(*other.iLiquid); + } } void GroupModel::setMeshData(std::vector& vert, std::vector& tri) @@ -291,7 +301,9 @@ namespace VMAP if (result && fwrite(&chunkSize, sizeof(uint32), 1, wf) != 1) { result = false; } if (result && fwrite(&count, sizeof(uint32), 1, wf) != 1) { result = false; } if (!count) // models without (collision) geometry end here, unsure if they are useful - { return result; } + { + return result; + } if (result && fwrite(&vertices[0], sizeof(Vector3), count, wf) != count) { result = false; } // write triangle mesh @@ -337,7 +349,9 @@ namespace VMAP if (result && fread(&chunkSize, sizeof(uint32), 1, rf) != 1) { result = false; } if (result && fread(&count, sizeof(uint32), 1, rf) != 1) { result = false; } if (!count) // models without (collision) geometry end here, unsure if they are useful - { return result; } + { + return result; + } if (result) { vertices.resize(count); } if (result && fread(&vertices[0], sizeof(Vector3), count, rf) != count) { result = false; } @@ -359,7 +373,9 @@ namespace VMAP if (result && !readChunk(rf, chunk, "LIQU", 4)) { result = false; } if (result && fread(&chunkSize, sizeof(uint32), 1, rf) != 1) { result = false; } if (result && chunkSize > 0) - { result = WmoLiquid::readFromFile(rf, iLiquid); } + { + result = WmoLiquid::readFromFile(rf, iLiquid); + } return result; } @@ -381,7 +397,9 @@ namespace VMAP bool GroupModel::IntersectRay(const G3D::Ray& ray, float& distance, bool stopAtFirstHit) const { if (triangles.empty()) - { return false; } + { + return false; + } GModelRayCallback callback(triangles, vertices); meshTree.intersectRay(ray, callback, distance, stopAtFirstHit); return callback.hit; @@ -390,28 +408,36 @@ namespace VMAP bool GroupModel::IsInsideObject(const Vector3& pos, const Vector3& down, float& z_dist) const { if (triangles.empty() || !iBound.contains(pos)) - { return false; } + { + return false; + } GModelRayCallback callback(triangles, vertices); Vector3 rPos = pos - 0.1f * down; float dist = G3D::inf(); G3D::Ray ray(rPos, down); bool hit = IntersectRay(ray, dist, false); if (hit) - { z_dist = dist - 0.1f; } + { + z_dist = dist - 0.1f; + } return hit; } bool GroupModel::GetLiquidLevel(const Vector3& pos, float& liqHeight) const { if (iLiquid) - { return iLiquid->GetLiquidHeight(pos, liqHeight); } + { + return iLiquid->GetLiquidHeight(pos, liqHeight); + } return false; } uint32 GroupModel::GetLiquidType() const { if (iLiquid) - { return iLiquid->GetType(); } + { + return iLiquid->GetType(); + } return 0; } @@ -441,7 +467,9 @@ namespace VMAP // small M2 workaround, maybe better make separate class with virtual intersection funcs // in any case, there's no need to use a bound tree if we only have one submodel if (groupModels.size() == 1) - { return groupModels[0].IntersectRay(ray, distance, stopAtFirstHit); } + { + return groupModels[0].IntersectRay(ray, distance, stopAtFirstHit); + } WModelRayCallBack isc(groupModels); groupTree.intersectRay(ray, isc, distance, stopAtFirstHit); @@ -489,7 +517,9 @@ namespace VMAP bool WorldModel::IntersectPoint(const G3D::Vector3& p, const G3D::Vector3& down, float& dist, AreaInfo& info) const { if (groupModels.empty()) - { return false; } + { + return false; + } WModelAreaCallback callback(groupModels, down); groupTree.intersectPoint(p, callback); if (callback.hit != groupModels.end()) @@ -507,7 +537,9 @@ namespace VMAP bool WorldModel::GetLocationInfo(const G3D::Vector3& p, const G3D::Vector3& down, float& dist, LocationInfo& info) const { if (groupModels.empty()) - { return false; } + { + return false; + } WModelAreaCallback callback(groupModels, down); groupTree.intersectPoint(p, callback); if (callback.hit != groupModels.end()) @@ -523,7 +555,9 @@ namespace VMAP { FILE* wf = fopen(filename.c_str(), "wb"); if (!wf) - { return false; } + { + return false; + } uint32 chunkSize, count; bool result = fwrite(VMAP_MAGIC, 1, 8, wf) == 8; @@ -556,7 +590,9 @@ namespace VMAP { FILE* rf = fopen(filename.c_str(), "rb"); if (!rf) - { return false; } + { + return false; + } bool result = true; uint32 chunkSize = 0; diff --git a/src/mangosd/SOAP/SoapThread.cpp b/src/mangosd/SOAP/SoapThread.cpp index b25fd88bb..0dffe3424 100644 --- a/src/mangosd/SOAP/SoapThread.cpp +++ b/src/mangosd/SOAP/SoapThread.cpp @@ -197,7 +197,9 @@ int ns1__executeCommand(soap* soap, char* command, char** result) } if (!command || !*command) - { return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string"); } + { + return soap_sender_fault(soap, "Command mustn't be empty", "The supplied command was an empty string"); + } DEBUG_LOG("MaNGOSsoap: got command '%s'", command); SOAPCommand connection; diff --git a/src/shared/Auth/BigNumber.cpp b/src/shared/Auth/BigNumber.cpp index 8bc67895c..8bf413d85 100644 --- a/src/shared/Auth/BigNumber.cpp +++ b/src/shared/Auth/BigNumber.cpp @@ -180,7 +180,9 @@ uint8* BigNumber::AsByteArray(int minSize) // If we need more bytes than length of BigNumber set the rest to 0 if (length > GetNumBytes()) - { memset((void*)_array, 0, length); } + { + memset((void*)_array, 0, length); + } BN_bn2bin(_bn, (unsigned char*)_array); diff --git a/src/shared/Common/Common.cpp b/src/shared/Common/Common.cpp index 1634fecfc..503518ef9 100644 --- a/src/shared/Common/Common.cpp +++ b/src/shared/Common/Common.cpp @@ -57,7 +57,9 @@ LocaleConstant GetLocaleByName(const std::string& name) { for (LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr) if (name == itr->name) - { return itr->locale; } + { + return itr->locale; + } return LOCALE_enUS; // including enGB case } diff --git a/src/shared/Config/Config.cpp b/src/shared/Config/Config.cpp index 1f59b8c0d..4b6fc8d90 100644 --- a/src/shared/Config/Config.cpp +++ b/src/shared/Config/Config.cpp @@ -37,7 +37,9 @@ INSTANTIATE_SINGLETON_1(Config); static bool GetValueHelper(ACE_Configuration_Heap* mConf, const char* name, ACE_TString& result) { if (!mConf) - { return false; } + { + return false; + } ACE_TString section_name; ACE_Configuration_Section_Key section_key; @@ -48,7 +50,9 @@ static bool GetValueHelper(ACE_Configuration_Heap* mConf, const char* name, ACE_ { mConf->open_section(root_key, section_name.c_str(), 0, section_key); if (mConf->get_string_value(section_key, name, result) == 0) - { return true; } + { + return true; + } ++i; } @@ -81,7 +85,9 @@ bool Config::Reload() { ACE_Ini_ImpExp config_importer(*mConf); if (config_importer.import_config(mFilename.c_str()) == 0) - { return true; } + { + return true; + } } delete mConf; @@ -99,7 +105,9 @@ bool Config::GetBoolDefault(const char* name, bool def) { ACE_TString val; if (!GetValueHelper(mConf, name, val)) - { return def; } + { + return def; + } const char* str = val.c_str(); if (strcmp(str, "true") == 0 || strcmp(str, "TRUE") == 0 || diff --git a/src/shared/DataStores/DB2FileLoader.cpp b/src/shared/DataStores/DB2FileLoader.cpp index ebbacb48d..799cae273 100644 --- a/src/shared/DataStores/DB2FileLoader.cpp +++ b/src/shared/DataStores/DB2FileLoader.cpp @@ -228,7 +228,9 @@ uint32 DB2FileLoader::GetFormatRecordSize(const char * format,int32* index_pos) } if (index_pos) - { *index_pos = i; } + { + *index_pos = i; + } return recordsize; } @@ -258,7 +260,9 @@ char* DB2FileLoader::AutoProduceData(const char* format, uint32& records, char** typedef char* ptr; if (strlen(format) != fieldCount) - { return NULL; } + { + return NULL; + } // get struct size and index pos int32 i; @@ -272,7 +276,9 @@ char* DB2FileLoader::AutoProduceData(const char* format, uint32& records, char** { uint32 ind = getRecord(y).getUInt(i); if (ind > maxi) - { maxi = ind; } + { + maxi = ind; + } } ++maxi; @@ -342,7 +348,9 @@ static char const* const nullStr = ""; char* DB2FileLoader::AutoProduceStringsArrayHolders(const char* format, char* dataTable) { if (strlen(format) != fieldCount) - { return NULL; } + { + return NULL; + } // we store flat holders pool as single memory block size_t stringFields = GetFormatStringsFields(format); diff --git a/src/shared/DataStores/DBCFileLoader.cpp b/src/shared/DataStores/DBCFileLoader.cpp index 46ee11146..ad990bfda 100644 --- a/src/shared/DataStores/DBCFileLoader.cpp +++ b/src/shared/DataStores/DBCFileLoader.cpp @@ -41,7 +41,9 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt) FILE* f = fopen(filename, "rb"); if (!f) - { return false; } + { + return false; + } if (fread(&header, 4, 1, f) != 1) // Number of records { @@ -94,7 +96,9 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt) { fieldsOffset[i] = fieldsOffset[i - 1]; if (fmt[i - 1] == 'b' || fmt[i - 1] == 'X') // byte fields - { fieldsOffset[i] += 1; } + { + fieldsOffset[i] += 1; + } else // 4 byte fields (int32/float/strings) { fieldsOffset[i] += 4; } } @@ -164,7 +168,9 @@ uint32 DBCFileLoader::GetFormatRecordSize(const char* format, int32* index_pos) } if (index_pos) - { *index_pos = i; } + { + *index_pos = i; + } return recordsize; } @@ -194,7 +200,9 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char** typedef char* ptr; if (strlen(format) != fieldCount) - { return NULL; } + { + return NULL; + } // get struct size and index pos int32 i; @@ -208,7 +216,9 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char** { uint32 ind = getRecord(y).getUInt(i); if (ind > maxi) - { maxi = ind; } + { + maxi = ind; + } } ++maxi; @@ -337,7 +347,9 @@ char* DBCFileLoader::AutoProduceStringsArrayHolders(const char* format, char* da char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable, LocaleConstant loc) { if (strlen(format) != fieldCount) - { return NULL; } + { + 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/DBCStore.h b/src/shared/DataStores/DBCStore.h index 99f95e151..0783af1c1 100644 --- a/src/shared/DataStores/DBCStore.h +++ b/src/shared/DataStores/DBCStore.h @@ -100,7 +100,9 @@ class DBCStorage DBCFileLoader dbc; // Check if load was sucessful, only then continue if (!dbc.Load(fn, fmt)) - { return false; } + { + return false; + } fieldCount = dbc.GetCols(); @@ -143,12 +145,16 @@ class DBCStorage { // DBC must be already loaded using Load if (!indexTable) - { return false; } + { + return false; + } DBCFileLoader dbc; // Check if load was successful, only then continue if (!dbc.Load(fn, fmt)) - { return false; } + { + return false; + } // load strings from another locale dbc data m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable,loc)); @@ -169,7 +175,9 @@ class DBCStorage } if (!indexTable) - { return; } + { + return; + } delete[]((char*)indexTable); indexTable = NULL; diff --git a/src/shared/Database/Database.cpp b/src/shared/Database/Database.cpp index 9a7053bfb..10e0851ab 100644 --- a/src/shared/Database/Database.cpp +++ b/src/shared/Database/Database.cpp @@ -71,7 +71,9 @@ SqlPreparedStatement* SqlConnection::GetStmt(uint32 nIndex) { // resize stmt container if (m_holder.size() <= nIndex) - { m_holder.resize(nIndex + 1, NULL); } + { + m_holder.resize(nIndex + 1, NULL); + } SqlPreparedStatement* pStmt = NULL; @@ -102,7 +104,9 @@ SqlPreparedStatement* SqlConnection::GetStmt(uint32 nIndex) bool SqlConnection::ExecuteStmt(int nIndex, const SqlStmtParameters& id) { if (nIndex == -1) - { return false; } + { + return false; + } // get prepared statement object SqlPreparedStatement* pStmt = GetStmt(nIndex); @@ -127,7 +131,9 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/) if (!m_logsDir.empty()) { if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\')) - { m_logsDir.append("/"); } + { + m_logsDir.append("/"); + } } m_pingIntervallms = sConfig.GetIntDefault("MaxPingTime", 30) * (MINUTE * 1000); @@ -136,7 +142,9 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/) // setup connection pool size if (nConns < MIN_CONNECTION_POOL_SIZE) - { m_nQueryConnPoolSize = MIN_CONNECTION_POOL_SIZE; } + { + m_nQueryConnPoolSize = MIN_CONNECTION_POOL_SIZE; + } else if (nConns > MAX_CONNECTION_POOL_SIZE) { m_nQueryConnPoolSize = MAX_CONNECTION_POOL_SIZE; } else @@ -158,7 +166,9 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/) // create and initialize connection for async requests m_pAsyncConn = CreateConnection(); if (!m_pAsyncConn->Initialize(infoString)) - { return false; } + { + return false; + } m_pResultQueue = new SqlResultQueue; @@ -222,13 +232,17 @@ void Database::ThreadEnd() void Database::ProcessResultQueue() { if (m_pResultQueue) - { m_pResultQueue->Update(); } + { + m_pResultQueue->Update(); + } } void Database::escape_string(std::string& str) { if (str.empty()) - { return; } + { + return; + } char* buf = new char[str.size() * 2 + 1]; // we don't care what connection to use - escape string will be the same @@ -242,7 +256,9 @@ SqlConnection* Database::getQueryConnection() int nCount = 0; if (m_nQueryCounter == long(1 << 31)) - { m_nQueryCounter = 0; } + { + m_nQueryCounter = 0; + } else { nCount = ++m_nQueryCounter; } @@ -268,7 +284,9 @@ void Database::Ping() bool Database::PExecuteLog(const char* format, ...) { if (!format) - { return false; } + { + return false; + } va_list ap; char szQuery [MAX_QUERY_LEN]; @@ -350,7 +368,9 @@ QueryNamedResult* Database::PQueryNamed(const char* format, ...) bool Database::Execute(const char* sql) { if (!m_pAsyncConn) - { return false; } + { + return false; + } SqlTransaction* pTrans = (*m_TransStorage)->get(); if (pTrans) @@ -362,7 +382,9 @@ bool Database::Execute(const char* sql) { // if async execution is not available if (!m_bAllowAsyncTransactions) - { return DirectExecute(sql); } + { + return DirectExecute(sql); + } // Simple sql statement m_threadBody->Delay(new SqlPlainRequest(sql)); @@ -374,7 +396,9 @@ bool Database::Execute(const char* sql) bool Database::PExecute(const char* format, ...) { if (!format) - { return false; } + { + return false; + } va_list ap; char szQuery [MAX_QUERY_LEN]; @@ -394,7 +418,9 @@ bool Database::PExecute(const char* format, ...) bool Database::DirectPExecute(const char* format, ...) { if (!format) - { return false; } + { + return false; + } va_list ap; char szQuery [MAX_QUERY_LEN]; @@ -414,7 +440,9 @@ bool Database::DirectPExecute(const char* format, ...) bool Database::BeginTransaction() { if (!m_pAsyncConn) - { return false; } + { + return false; + } // initiate transaction on current thread // currently we do not support queued transactions @@ -425,15 +453,21 @@ bool Database::BeginTransaction() bool Database::CommitTransaction() { if (!m_pAsyncConn) - { return false; } + { + return false; + } // check if we have pending transaction if (!(*m_TransStorage)->get()) - { return false; } + { + return false; + } // if async execution is not available if (!m_bAllowAsyncTransactions) - { return CommitTransactionDirect(); } + { + return CommitTransactionDirect(); + } // add SqlTransaction to the async queue m_threadBody->Delay((*m_TransStorage)->detach()); @@ -443,11 +477,15 @@ bool Database::CommitTransaction() bool Database::CommitTransactionDirect() { if (!m_pAsyncConn) - { return false; } + { + return false; + } // check if we have pending transaction if (!(*m_TransStorage)->get()) - { return false; } + { + return false; + } // directly execute SqlTransaction SqlTransaction* pTrans = (*m_TransStorage)->detach(); @@ -460,10 +498,14 @@ bool Database::CommitTransactionDirect() bool Database::RollbackTransaction() { if (!m_pAsyncConn) - { return false; } + { + return false; + } if (!(*m_TransStorage)->get()) - { return false; } + { + return false; + } // remove scheduled transaction (*m_TransStorage)->reset(); @@ -554,7 +596,9 @@ bool Database::CheckDatabaseVersion(DatabaseTypes database) bool Database::ExecuteStmt(const SqlStatementID& id, SqlStmtParameters* params) { if (!m_pAsyncConn) - { return false; } + { + return false; + } SqlTransaction* pTrans = (*m_TransStorage)->get(); if (pTrans) @@ -566,7 +610,9 @@ bool Database::ExecuteStmt(const SqlStatementID& id, SqlStmtParameters* params) { // if async execution is not available if (!m_bAllowAsyncTransactions) - { return DirectExecuteStmt(id, params); } + { + return DirectExecuteStmt(id, params); + } // Simple sql statement m_threadBody->Delay(new SqlPreparedRequest(id.ID(), params)); @@ -617,13 +663,17 @@ std::string Database::GetStmtString(const int stmtId) const LOCK_GUARD _guard(m_stmtGuard); if (stmtId == -1 || stmtId > m_iStmtIndex) - { return std::string(); } + { + return std::string(); + } PreparedStmtRegistry::const_iterator iter_last = m_stmtRegistry.end(); for (PreparedStmtRegistry::const_iterator iter = m_stmtRegistry.begin(); iter != iter_last; ++iter) { if (iter->second == stmtId) - { return iter->first; } + { + return iter->first; + } } return std::string(); diff --git a/src/shared/Database/Database.h b/src/shared/Database/Database.h index 3c9ce7dd3..a25cc108d 100644 --- a/src/shared/Database/Database.h +++ b/src/shared/Database/Database.h @@ -296,7 +296,9 @@ class Database inline bool DirectExecute(const char* sql) { if (!m_pAsyncConn) - { return false; } + { + return false; + } SqlConnection::Lock guard(m_pAsyncConn); return guard->Execute(sql); diff --git a/src/shared/Database/DatabaseMysql.cpp b/src/shared/Database/DatabaseMysql.cpp index 0113df6ab..80a4d1d1e 100644 --- a/src/shared/Database/DatabaseMysql.cpp +++ b/src/shared/Database/DatabaseMysql.cpp @@ -102,15 +102,25 @@ bool MySQLConnection::Initialize(const char* infoString) iter = tokens.begin(); if (iter != tokens.end()) - { host = *iter++; } + { + host = *iter++; + } if (iter != tokens.end()) - { port_or_socket = *iter++; } + { + port_or_socket = *iter++; + } if (iter != tokens.end()) - { user = *iter++; } + { + user = *iter++; + } if (iter != tokens.end()) - { password = *iter++; } + { + password = *iter++; + } if (iter != tokens.end()) - { database = *iter++; } + { + database = *iter++; + } mysql_options(mysqlInit, MYSQL_SET_CHARSET_NAME, "utf8"); mysql_options(mysqlInit, MYSQL_OPT_RECONNECT, "1"); @@ -170,7 +180,9 @@ bool MySQLConnection::Initialize(const char* infoString) // LEAVE 'AUTOCOMMIT' MODE ALWAYS ENABLED!!! // W/O IT EVEN 'SELECT' QUERIES WOULD REQUIRE TO BE WRAPPED INTO 'START TRANSACTION'<>'COMMIT' CLAUSES!!! if (!mysql_autocommit(mMysql, 1)) - { DETAIL_LOG("AUTOCOMMIT SUCCESSFULLY SET TO 1"); } + { + DETAIL_LOG("AUTOCOMMIT SUCCESSFULLY SET TO 1"); + } else { DETAIL_LOG("AUTOCOMMIT NOT SET TO 1"); } /*-------------------------------------*/ @@ -186,7 +198,9 @@ bool MySQLConnection::Initialize(const char* infoString) bool MySQLConnection::_Query(const char* sql, MYSQL_RES** pResult, MYSQL_FIELD** pFields, uint64* pRowCount, uint32* pFieldCount) { if (!mMysql) - { return 0; } + { + return 0; + } uint32 _s = WorldTimer::getMSTime(); @@ -206,7 +220,9 @@ bool MySQLConnection::_Query(const char* sql, MYSQL_RES** pResult, MYSQL_FIELD** *pFieldCount = mysql_field_count(mMysql); if (!*pResult) - { return false; } + { + return false; + } if (!*pRowCount) { @@ -226,7 +242,9 @@ QueryResult* MySQLConnection::Query(const char* sql) uint32 fieldCount = 0; if (!_Query(sql, &result, &fields, &rowCount, &fieldCount)) - { return NULL; } + { + return NULL; + } QueryResultMysql* queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount); @@ -242,7 +260,9 @@ QueryNamedResult* MySQLConnection::QueryNamed(const char* sql) uint32 fieldCount = 0; if (!_Query(sql, &result, &fields, &rowCount, &fieldCount)) - { return NULL; } + { + return NULL; + } QueryFieldNames names(fieldCount); for (uint32 i = 0; i < fieldCount; ++i) @@ -257,7 +277,9 @@ QueryNamedResult* MySQLConnection::QueryNamed(const char* sql) bool MySQLConnection::Execute(const char* sql) { if (!mMysql) - { return false; } + { + return false; + } { uint32 _s = WorldTimer::getMSTime(); @@ -311,7 +333,9 @@ bool MySQLConnection::RollbackTransaction() unsigned long MySQLConnection::escape_string(char* to, const char* from, unsigned long length) { if (!mMysql || !to || !from || !length) - { return 0; } + { + return 0; + } return(mysql_real_escape_string(mMysql, to, from, length)); } @@ -336,7 +360,9 @@ MySqlPreparedStatement::~MySqlPreparedStatement() bool MySqlPreparedStatement::prepare() { if (isPrepared()) - { return true; } + { + return true; + } // remove old binds RemoveBinds(); @@ -402,7 +428,9 @@ void MySqlPreparedStatement::bind(const SqlStmtParameters& holder) // finalize adding params if (!m_pInputArgs) - { return; } + { + return; + } // verify if we bound all needed input parameters if (m_nParams != holder.boundParams()) @@ -450,7 +478,9 @@ void MySqlPreparedStatement::addParam(unsigned int nIndex, const SqlStmtFieldDat void MySqlPreparedStatement::RemoveBinds() { if (!m_stmt) - { return; } + { + return; + } delete[] m_pInputArgs; delete[] m_pResult; @@ -469,7 +499,9 @@ void MySqlPreparedStatement::RemoveBinds() bool MySqlPreparedStatement::execute() { if (!isPrepared()) - { return false; } + { + return false; + } if (mysql_stmt_execute(m_stmt)) { diff --git a/src/shared/Database/DatabasePostgre.cpp b/src/shared/Database/DatabasePostgre.cpp index 6c38a65ba..d07c697b3 100644 --- a/src/shared/Database/DatabasePostgre.cpp +++ b/src/shared/Database/DatabasePostgre.cpp @@ -72,18 +72,30 @@ bool PostgreSQLConnection::Initialize(const char* infoString) iter = tokens.begin(); if (iter != tokens.end()) - { host = *iter++; } + { + host = *iter++; + } if (iter != tokens.end()) - { port_or_socket_dir = *iter++; } + { + port_or_socket_dir = *iter++; + } if (iter != tokens.end()) - { user = *iter++; } + { + user = *iter++; + } if (iter != tokens.end()) - { password = *iter++; } + { + password = *iter++; + } if (iter != tokens.end()) - { database = *iter++; } + { + database = *iter++; + } if (host == ".") - { 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()); } + { + 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()); } @@ -105,13 +117,17 @@ bool PostgreSQLConnection::Initialize(const char* infoString) bool PostgreSQLConnection::_Query(const char* sql, PGresult** pResult, uint64* pRowCount, uint32* pFieldCount) { if (!mPGconn) - { return false; } + { + return false; + } uint32 _s = WorldTimer::getMSTime(); // Send the query *pResult = PQexec(mPGconn, sql); if (!*pResult) - { return false; } + { + return false; + } if (PQresultStatus(*pResult) != PGRES_TUPLES_OK) { @@ -141,14 +157,18 @@ bool PostgreSQLConnection::_Query(const char* sql, PGresult** pResult, uint64* p QueryResult* PostgreSQLConnection::Query(const char* sql) { if (!mPGconn) - { return NULL; } + { + return NULL; + } PGresult* result = NULL; uint64 rowCount = 0; uint32 fieldCount = 0; if (!_Query(sql, &result, &rowCount, &fieldCount)) - { return NULL; } + { + return NULL; + } QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount); @@ -159,14 +179,18 @@ QueryResult* PostgreSQLConnection::Query(const char* sql) QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql) { if (!mPGconn) - { return NULL; } + { + return NULL; + } PGresult* result = NULL; uint64 rowCount = 0; uint32 fieldCount = 0; if (!_Query(sql, &result, &rowCount, &fieldCount)) - { return NULL; } + { + return NULL; + } QueryFieldNames names(fieldCount); for (uint32 i = 0; i < fieldCount; ++i) @@ -181,7 +205,9 @@ QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql) bool PostgreSQLConnection::Execute(const char* sql) { if (!mPGconn) - { return false; } + { + return false; + } uint32 _s = WorldTimer::getMSTime(); @@ -204,7 +230,9 @@ bool PostgreSQLConnection::Execute(const char* sql) bool PostgreSQLConnection::_TransactionCmd(const char* sql) { if (!mPGconn) - { return false; } + { + return false; + } PGresult* res = PQexec(mPGconn, sql); if (PQresultStatus(res) != PGRES_COMMAND_OK) @@ -238,7 +266,9 @@ bool PostgreSQLConnection::RollbackTransaction() unsigned long PostgreSQLConnection::escape_string(char* to, const char* from, unsigned long length) { if (!mPGconn || !to || !from || !length) - { return 0; } + { + return 0; + } return PQescapeString(to, from, length); } diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index 1cf48548f..6db8bdb5d 100644 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -154,7 +154,9 @@ class Field { uint64 value = 0; if (!mValue || sscanf(mValue, UI64FMTD, &value) == -1) - { return 0; } + { + return 0; + } return value; } diff --git a/src/shared/Database/QueryResult.h b/src/shared/Database/QueryResult.h index 9f6635ddb..2c15ee066 100644 --- a/src/shared/Database/QueryResult.h +++ b/src/shared/Database/QueryResult.h @@ -176,7 +176,9 @@ class QueryNamedResult for (size_t idx = 0; idx < mFieldNames.size(); ++idx) { if (mFieldNames[idx] == name) - { return idx; } + { + return idx; + } } MANGOS_ASSERT(false && "unknown field name"); return uint32(-1); diff --git a/src/shared/Database/QueryResultMysql.cpp b/src/shared/Database/QueryResultMysql.cpp index 811924b2a..829df2356 100644 --- a/src/shared/Database/QueryResultMysql.cpp +++ b/src/shared/Database/QueryResultMysql.cpp @@ -47,7 +47,9 @@ bool QueryResultMysql::NextRow() MYSQL_ROW row; if (!mResult) - { return false; } + { + return false; + } row = mysql_fetch_row(mResult); if (!row) diff --git a/src/shared/Database/QueryResultPostgre.cpp b/src/shared/Database/QueryResultPostgre.cpp index 366ce4690..744e33b36 100644 --- a/src/shared/Database/QueryResultPostgre.cpp +++ b/src/shared/Database/QueryResultPostgre.cpp @@ -45,7 +45,9 @@ QueryResultPostgre::~QueryResultPostgre() bool QueryResultPostgre::NextRow() { if (!mResult) - { return false; } + { + return false; + } if (mTableIndex >= mRowCount) { @@ -58,7 +60,9 @@ bool QueryResultPostgre::NextRow() { pPQgetvalue = PQgetvalue(mResult, mTableIndex, j); if (pPQgetvalue && !(*pPQgetvalue)) - { pPQgetvalue = NULL; } + { + pPQgetvalue = NULL; + } mCurrentRow[j].SetValue(pPQgetvalue); } diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index 588f3e6bb..f386be43c 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -75,7 +75,9 @@ void SQLStorageBase::prepareToLoad(uint32 maxEntry, uint32 recordCount, uint32 r void SQLStorageBase::Free() { if (!m_data) - { return; } + { + return; + } uint32 offset = 0; for (uint32 x = 0; x < m_dstFieldCount; ++x) @@ -193,7 +195,9 @@ void SQLHashStorage::EraseEntry(uint32 id) // do not erase from m_records RecordMap::iterator find = m_indexMap.find(id); if (find != m_indexMap.end()) - { find->second = NULL; } + { + find->second = NULL; + } } SQLHashStorage::SQLHashStorage(const char* fmt, const char* _entry_field, const char* sqlname) diff --git a/src/shared/Database/SQLStorage.h b/src/shared/Database/SQLStorage.h index 86a6c38c4..9c5b82be1 100644 --- a/src/shared/Database/SQLStorage.h +++ b/src/shared/Database/SQLStorage.h @@ -298,7 +298,9 @@ class SQLStorage : public SQLStorageBase T const* LookupEntry(uint32 id) const { if (id >= GetMaxEntry()) - { return NULL; } + { + return NULL; + } return reinterpret_cast(m_Index[id]); } @@ -390,7 +392,9 @@ class SQLHashStorage : public SQLStorageBase { RecordMap::const_iterator find = m_indexMap.find(id); if (find != m_indexMap.end()) - { return reinterpret_cast(find->second); } + { + return reinterpret_cast(find->second); + } return NULL; } diff --git a/src/shared/Database/SQLStorageImpl.h b/src/shared/Database/SQLStorageImpl.h index 1a50ec313..4f927e2c7 100644 --- a/src/shared/Database/SQLStorageImpl.h +++ b/src/shared/Database/SQLStorageImpl.h @@ -266,7 +266,9 @@ void SQLStorageLoaderBase::Load(StorageClass& store if (!result) { if (error_at_empty) - { sLog.outError("%s table is empty!\n", store.GetTableName()); } + { + sLog.outError("%s table is empty!\n", store.GetTableName()); + } else { sLog.outString("%s table is empty!\n", store.GetTableName()); } @@ -348,7 +350,9 @@ void SQLStorageLoaderBase::Load(StorageClass& store // It is required that the input has at least as many columns set as the output requires if (y >= store.GetSrcFieldCount()) - { assert(false && "SQL storage has too few columns!"); } + { + assert(false && "SQL storage has too few columns!"); + } switch (store.GetSrcFormat(y)) { diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index 985cb7503..8ba3f179a 100644 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -50,7 +50,9 @@ SqlTransaction::~SqlTransaction() bool SqlTransaction::Execute(SqlConnection* conn) { if (m_queue.empty()) - { return true; } + { + return true; + } LOCK_DB_CONN(conn); @@ -91,7 +93,9 @@ bool SqlPreparedRequest::Execute(SqlConnection* conn) bool SqlQuery::Execute(SqlConnection* conn) { if (!m_callback || !m_queue) - { return false; } + { + return false; + } LOCK_DB_CONN(conn); /// execute the query and store the result in the callback @@ -116,7 +120,9 @@ void SqlResultQueue::Update() bool SqlQueryHolder::Execute(MaNGOS::IQueryCallback* callback, SqlDelayThread* thread, SqlResultQueue* queue) { if (!callback || !thread || !queue) - { return false; } + { + return false; + } /// delay the execution of the queries, sync them with the delay thread /// which will in turn resync on execution (via the queue) and call back @@ -189,7 +195,9 @@ void SqlQueryHolder::SetResult(size_t index, QueryResult* result) { /// store the result in the holder if (index < m_queries.size()) - { m_queries[index].second = result; } + { + m_queries[index].second = result; + } } SqlQueryHolder::~SqlQueryHolder() @@ -215,7 +223,9 @@ void SqlQueryHolder::SetSize(size_t size) bool SqlQueryHolderEx::Execute(SqlConnection* conn) { if (!m_holder || !m_callback || !m_queue) - { return false; } + { + return false; + } LOCK_DB_CONN(conn); /// we can do this, we are friends diff --git a/src/shared/Database/SqlPreparedStatement.cpp b/src/shared/Database/SqlPreparedStatement.cpp index 2291b8fec..a5d319d5e 100644 --- a/src/shared/Database/SqlPreparedStatement.cpp +++ b/src/shared/Database/SqlPreparedStatement.cpp @@ -28,7 +28,9 @@ SqlStmtParameters::SqlStmtParameters(uint32 nParams) { // reserve memory if needed if (nParams > 0) - { m_params.reserve(nParams); } + { + m_params.reserve(nParams); + } } void SqlStmtParameters::reset(const SqlStatement& stmt) @@ -36,7 +38,9 @@ void SqlStmtParameters::reset(const SqlStatement& stmt) m_params.clear(); // reserve memory if needed if (stmt.arguments() > 0) - { m_params.reserve(stmt.arguments()); } + { + m_params.reserve(stmt.arguments()); + } } ////////////////////////////////////////////////////////////////////////// @@ -51,7 +55,9 @@ SqlStatement& SqlStatement::operator=(const SqlStatement& index) m_pParams = NULL; if (index.m_pParams) - { m_pParams = new SqlStmtParameters(*(index.m_pParams)); } + { + m_pParams = new SqlStmtParameters(*(index.m_pParams)); + } } return *this; @@ -132,7 +138,9 @@ void SqlPlainPreparedStatement::bind(const SqlStmtParameters& holder) bool SqlPlainPreparedStatement::execute() { if (m_szPlainRequest.empty()) - { return false; } + { + return false; + } return m_pConn.Execute(m_szPlainRequest.c_str()); } diff --git a/src/shared/Database/SqlPreparedStatement.h b/src/shared/Database/SqlPreparedStatement.h index ab604c9e8..c2a1ab755 100644 --- a/src/shared/Database/SqlPreparedStatement.h +++ b/src/shared/Database/SqlPreparedStatement.h @@ -446,7 +446,9 @@ class SqlStatement SqlStatement(const SqlStatement& index) : m_index(index.m_index), m_pDB(index.m_pDB), m_pParams(NULL) { if (index.m_pParams) - { m_pParams = new SqlStmtParameters(*(index.m_pParams)); } + { + m_pParams = new SqlStmtParameters(*(index.m_pParams)); + } } /** @@ -655,7 +657,9 @@ class SqlStatement SqlStmtParameters* get() { if (!m_pParams) - { m_pParams = new SqlStmtParameters(arguments()); } + { + m_pParams = new SqlStmtParameters(arguments()); + } return m_pParams; } diff --git a/src/shared/LockedQueue/LockedQueue.h b/src/shared/LockedQueue/LockedQueue.h index 33a498c21..7a5e850f9 100644 --- a/src/shared/LockedQueue/LockedQueue.h +++ b/src/shared/LockedQueue/LockedQueue.h @@ -86,7 +86,9 @@ namespace ACE_Based ACE_GUARD_RETURN(LockType, g, this->_lock, false); if (_queue.empty()) - { return false; } + { + return false; + } result = _queue.front(); _queue.pop_front(); @@ -107,11 +109,15 @@ namespace ACE_Based ACE_GUARD_RETURN(LockType, g, this->_lock, false); if (_queue.empty()) - { return false; } + { + return false; + } result = _queue.front(); if (!check.Process(result)) - { return false; } + { + return false; + } _queue.pop_front(); return true; diff --git a/src/shared/Log/Log.cpp b/src/shared/Log/Log.cpp index 7c87a1ef0..c502b7884 100644 --- a/src/shared/Log/Log.cpp +++ b/src/shared/Log/Log.cpp @@ -100,10 +100,14 @@ void Log::InitColors(const std::string& str) ss >> color[i]; if (!ss) - { return; } + { + return; + } if (color[i] < 0 || color[i] >= Color_count) - { return; } + { + return; + } } for (int i = 0; i < LogType_count; ++i) @@ -197,7 +201,9 @@ void Log::SetLogLevel(char* level) int32 newLevel = atoi((char*)level); if (newLevel < LOG_LVL_MINIMAL) - { newLevel = LOG_LVL_MINIMAL; } + { + newLevel = LOG_LVL_MINIMAL; + } else if (newLevel > LOG_LVL_DEBUG) { newLevel = LOG_LVL_DEBUG; } @@ -211,7 +217,9 @@ void Log::SetLogFileLevel(char* level) int32 newLevel = atoi((char*)level); if (newLevel < LOG_LVL_MINIMAL) - { newLevel = LOG_LVL_MINIMAL; } + { + newLevel = LOG_LVL_MINIMAL; + } else if (newLevel > LOG_LVL_DEBUG) { newLevel = LOG_LVL_DEBUG; } @@ -227,7 +235,9 @@ void Log::Initialize() if (!m_logsDir.empty()) { if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\')) - { m_logsDir.append("/"); } + { + m_logsDir.append("/"); + } } m_logsTimestamp = "_" + GetTimestampStr(); @@ -237,7 +247,9 @@ void Log::Initialize() m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount", false); if (!m_gmlog_per_account) - { gmLogfile = openLogFile("GMLogFile", "GmLogTimestamp", "a"); } + { + gmLogfile = openLogFile("GMLogFile", "GmLogTimestamp", "a"); + } else { // GM log settings for per account case @@ -250,7 +262,9 @@ void Log::Initialize() if (dot_pos != m_gmlog_filename_format.npos) { if (m_gmlog_timestamp) - { m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp); } + { + m_gmlog_filename_format.insert(dot_pos, m_logsTimestamp); + } m_gmlog_filename_format.insert(dot_pos, "_#%u"); } @@ -259,7 +273,9 @@ void Log::Initialize() m_gmlog_filename_format += "_#%u"; if (m_gmlog_timestamp) - { m_gmlog_filename_format += m_logsTimestamp; } + { + m_gmlog_filename_format += m_logsTimestamp; + } } m_gmlog_filename_format = m_logsDir + m_gmlog_filename_format; @@ -286,7 +302,9 @@ void Log::Initialize() for (int i = 0; i < LOG_FILTER_COUNT; ++i) if (*logFilterData[i].name) if (sConfig.GetBoolDefault(logFilterData[i].configName, logFilterData[i].defaultState)) - { m_logFilter |= (1 << i); } + { + m_logFilter |= (1 << i); + } // Char log settings m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false); @@ -296,13 +314,17 @@ FILE* Log::openLogFile(char const* configFileName, char const* configTimeStampFl { std::string logfn = sConfig.GetStringDefault(configFileName, ""); if (logfn.empty()) - { return NULL; } + { + return NULL; + } if (configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag, false)) { size_t dot_pos = logfn.find_last_of("."); if (dot_pos != logfn.npos) - { logfn.insert(dot_pos, m_logsTimestamp); } + { + logfn.insert(dot_pos, m_logsTimestamp); + } else { logfn += m_logsTimestamp; } } @@ -313,7 +335,9 @@ FILE* Log::openLogFile(char const* configFileName, char const* configTimeStampFl FILE* Log::openGmlogPerAccount(uint32 account) { if (m_gmlog_filename_format.empty()) - { return NULL; } + { + return NULL; + } char namebuf[MANGOS_PATH_MAX]; snprintf(namebuf, MANGOS_PATH_MAX, m_gmlog_filename_format.c_str(), account); @@ -364,7 +388,9 @@ std::string Log::GetTimestampStr() void Log::outString() { if (m_includeTime) - { outTime(); } + { + outTime(); + } printf("\n"); if (logfile) { @@ -379,13 +405,19 @@ void Log::outString() void Log::outString(const char* str, ...) { if (!str) - { return; } + { + return; + } if (m_colored) - { SetColor(true, m_colors[LogNormal]); } + { + SetColor(true, m_colors[LogNormal]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; @@ -394,7 +426,9 @@ void Log::outString(const char* str, ...) va_end(ap); if (m_colored) - { ResetColor(true); } + { + ResetColor(true); + } printf("\n"); @@ -461,7 +495,9 @@ void Log::outError(const char* err, ...) void Log::outErrorDb() { if (m_includeTime) - { outTime(); } + { + outTime(); + } fprintf(stderr, "\n"); @@ -485,13 +521,19 @@ void Log::outErrorDb() void Log::outErrorDb(const char* err, ...) { if (!err) - { return; } + { + return; + } if (m_colored) - { SetColor(false, m_colors[LogError]); } + { + SetColor(false, m_colors[LogError]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; @@ -500,7 +542,9 @@ void Log::outErrorDb(const char* err, ...) va_end(ap); if (m_colored) - { ResetColor(false); } + { + ResetColor(false); + } fprintf(stderr, "\n"); @@ -621,7 +665,9 @@ void Log::outErrorEluna(const char* err, ...) {} void Log::outErrorEventAI() { if (m_includeTime) - { outTime(); } + { + outTime(); + } fprintf(stderr, "\n"); @@ -645,13 +691,19 @@ void Log::outErrorEventAI() void Log::outErrorEventAI(const char* err, ...) { if (!err) - { return; } + { + return; + } if (m_colored) - { SetColor(false, m_colors[LogError]); } + { + SetColor(false, m_colors[LogError]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; @@ -660,7 +712,9 @@ void Log::outErrorEventAI(const char* err, ...) va_end(ap); if (m_colored) - { ResetColor(false); } + { + ResetColor(false); + } fprintf(stderr, "\n"); @@ -696,15 +750,21 @@ void Log::outErrorEventAI(const char* err, ...) void Log::outBasic(const char* str, ...) { if (!str) - { return; } + { + return; + } if (m_logLevel >= LOG_LVL_BASIC) { if (m_colored) - { SetColor(true, m_colors[LogDetails]); } + { + SetColor(true, m_colors[LogDetails]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; va_start(ap, str); @@ -712,7 +772,9 @@ void Log::outBasic(const char* str, ...) va_end(ap); if (m_colored) - { ResetColor(true); } + { + ResetColor(true); + } printf("\n"); } @@ -734,15 +796,21 @@ void Log::outBasic(const char* str, ...) void Log::outDetail(const char* str, ...) { if (!str) - { return; } + { + return; + } if (m_logLevel >= LOG_LVL_DETAIL) { if (m_colored) - { SetColor(true, m_colors[LogDetails]); } + { + SetColor(true, m_colors[LogDetails]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; va_start(ap, str); @@ -750,7 +818,9 @@ void Log::outDetail(const char* str, ...) va_end(ap); if (m_colored) - { ResetColor(true); } + { + ResetColor(true); + } printf("\n"); } @@ -775,15 +845,21 @@ void Log::outDebug(const char* str, ...) { #ifdef MANGOS_DEBUG if (!str) - { return; } + { + return; + } if (m_logLevel >= LOG_LVL_DEBUG) { if (m_colored) - { SetColor(true, m_colors[LogDebug]); } + { + SetColor(true, m_colors[LogDebug]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; va_start(ap, str); @@ -791,7 +867,9 @@ void Log::outDebug(const char* str, ...) va_end(ap); if (m_colored) - { ResetColor(true); } + { + ResetColor(true); + } printf("\n"); } @@ -816,15 +894,21 @@ void Log::outDebug(const char* str, ...) void Log::outCommand(uint32 account, const char* str, ...) { if (!str) - { return; } + { + return; + } if (m_logLevel >= LOG_LVL_DETAIL) { if (m_colored) - { SetColor(true, m_colors[LogDetails]); } + { + SetColor(true, m_colors[LogDetails]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; va_start(ap, str); @@ -832,7 +916,9 @@ void Log::outCommand(uint32 account, const char* str, ...) va_end(ap); if (m_colored) - { ResetColor(true); } + { + ResetColor(true); + } printf("\n"); } @@ -941,7 +1027,9 @@ void Log::outWarden(const char* str, ...) void Log::outChar(const char* str, ...) { if (!str) - { return; } + { + return; + } if (charLogfile) { @@ -958,7 +1046,9 @@ void Log::outChar(const char* str, ...) void Log::outErrorScriptLib() { if (m_includeTime) - { outTime(); } + { + outTime(); + } fprintf(stderr, "\n"); @@ -966,7 +1056,9 @@ void Log::outErrorScriptLib() { outTimestamp(logfile); if (m_scriptLibName) - { fprintf(logfile, "<%s ERROR:> ", m_scriptLibName); } + { + fprintf(logfile, "<%s ERROR:> ", m_scriptLibName); + } else { fprintf(logfile, ": "); } fflush(logfile); @@ -985,13 +1077,19 @@ void Log::outErrorScriptLib() void Log::outErrorScriptLib(const char* err, ...) { if (!err) - { return; } + { + return; + } if (m_colored) - { SetColor(false, m_colors[LogError]); } + { + SetColor(false, m_colors[LogError]); + } if (m_includeTime) - { outTime(); } + { + outTime(); + } va_list ap; @@ -1000,7 +1098,9 @@ void Log::outErrorScriptLib(const char* err, ...) va_end(ap); if (m_colored) - { ResetColor(false); } + { + ResetColor(false); + } fprintf(stderr, "\n"); @@ -1008,7 +1108,9 @@ void Log::outErrorScriptLib(const char* err, ...) { outTimestamp(logfile); if (m_scriptLibName) - { fprintf(logfile, "<%s ERROR>: ", m_scriptLibName); } + { + fprintf(logfile, "<%s ERROR>: ", m_scriptLibName); + } else { fprintf(logfile, ": "); } @@ -1039,7 +1141,9 @@ void Log::outErrorScriptLib(const char* err, ...) void Log::outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming) { if (!worldLogfile) - { return; } + { + return; + } ACE_GUARD(ACE_Thread_Mutex, GuardObj, m_worldLogMtx); @@ -1074,7 +1178,9 @@ void Log::outCharDump(const char* str, uint32 account_id, uint32 guid, const cha void Log::outRALog(const char* str, ...) { if (!str) - { return; } + { + return; + } if (raLogfile) { @@ -1118,7 +1224,9 @@ void Log::setScriptLibraryErrorFile(char const* fname, char const* libName) m_scriptLibName = libName; if (scriptErrLogFile) - { fclose(scriptErrLogFile); } + { + fclose(scriptErrLogFile); + } if (!fname) { @@ -1134,7 +1242,9 @@ void Log::setScriptLibraryErrorFile(char const* fname, char const* libName) void outstring_log(const char* str, ...) { if (!str) - { return; } + { + return; + } char buf[256]; va_list ap; @@ -1148,7 +1258,9 @@ void outstring_log(const char* str, ...) void detail_log(const char* str, ...) { if (!str) - { return; } + { + return; + } char buf[256]; va_list ap; @@ -1162,7 +1274,9 @@ void detail_log(const char* str, ...) void debug_log(const char* str, ...) { if (!str) - { return; } + { + return; + } char buf[256]; va_list ap; @@ -1176,7 +1290,9 @@ void debug_log(const char* str, ...) void error_log(const char* str, ...) { if (!str) - { return; } + { + return; + } char buf[256]; va_list ap; @@ -1190,7 +1306,9 @@ void error_log(const char* str, ...) void error_db_log(const char* str, ...) { if (!str) - { return; } + { + return; + } char buf[256]; va_list ap; @@ -1209,7 +1327,9 @@ void setScriptLibraryErrorFile(char const* fname, char const* libName) void script_error_log(const char* str, ...) { if (!str) - { return; } + { + return; + } char buf[256]; va_list ap; diff --git a/src/shared/Log/Log.h b/src/shared/Log/Log.h index ac871e629..e41c2ece5 100644 --- a/src/shared/Log/Log.h +++ b/src/shared/Log/Log.h @@ -133,19 +133,27 @@ class Log : public MaNGOS::Singleton Realtime) - { p = Realtime; } + { + p = Realtime; + } return m_priority[p]; } @@ -115,7 +123,9 @@ Thread::Thread(Runnable* instance) : m_iThreadId(0), m_hThreadHandle(0), m_task( { // register reference to m_task to prevent it deeltion until destructor if (m_task) - { m_task->incReference(); } + { + m_task->incReference(); + } bool _start = start(); MANGOS_ASSERT(_start); @@ -127,7 +137,9 @@ Thread::~Thread() // deleted runnable object (if no other references) if (m_task) - { m_task->decReference(); } + { + m_task->decReference(); + } } // initialize Thread's class static member @@ -137,7 +149,9 @@ ThreadPriority Thread::m_TpEnum; bool Thread::start() { if (m_task == 0 || m_iThreadId != 0) - { return false; } + { + return false; + } // incRef before spawing the thread, otherwise Thread::ThreadTask() might call decRef and delete m_task m_task->incReference(); @@ -147,7 +161,9 @@ bool Thread::start() bool res = (ACE_Thread::spawn(&Thread::ThreadTask, (void*)m_task, THREADFLAG, &m_iThreadId, &m_hThreadHandle) == 0); if (res) - { m_task->decReference(); } + { + m_task->decReference(); + } return res; } @@ -155,7 +171,9 @@ bool Thread::start() bool Thread::wait() { if (!m_hThreadHandle || !m_task) - { return false; } + { + return false; + } ACE_THR_FUNC_RETURN _value = ACE_THR_FUNC_RETURN(-1); int _res = ACE_Thread::join(m_hThreadHandle, &_value); @@ -171,10 +189,14 @@ bool Thread::wait() void Thread::destroy() { if (!m_iThreadId || !m_task) - { return; } + { + return; + } if (ACE_Thread::kill(m_iThreadId, -1) != 0) - { return; } + { + return; + } m_iThreadId = 0; m_hThreadHandle = 0; diff --git a/src/shared/Threading/Threading.h b/src/shared/Threading/Threading.h index c567fdfe0..73f6bae22 100644 --- a/src/shared/Threading/Threading.h +++ b/src/shared/Threading/Threading.h @@ -62,7 +62,9 @@ namespace ACE_Based void decReference() { if (!--m_refs) - { delete this; } + { + delete this; + } } private: ACE_Atomic_Op m_refs; /**< TODO */ diff --git a/src/shared/Utilities/ByteBuffer.h b/src/shared/Utilities/ByteBuffer.h index b488fbc33..f83d16b1f 100644 --- a/src/shared/Utilities/ByteBuffer.h +++ b/src/shared/Utilities/ByteBuffer.h @@ -645,7 +645,9 @@ class ByteBuffer { char c = read(); if (c == 0) - { break; } + { + break; + } value += c; } return *this; @@ -726,7 +728,9 @@ class ByteBuffer { ResetBitReader(); if (_rpos + skip > size()) - { throw ByteBufferException(false, _rpos, skip, size()); } + { + throw ByteBufferException(false, _rpos, skip, size()); + } _rpos += skip; return *this; @@ -754,7 +758,9 @@ class ByteBuffer template T read(size_t pos) const { if (pos + sizeof(T) > size()) - { throw ByteBufferException(false, pos, sizeof(T), size()); } + { + throw ByteBufferException(false, pos, sizeof(T), size()); + } T val = *((T const*)&_storage[pos]); EndianConvert(val); return val; @@ -770,7 +776,9 @@ class ByteBuffer { ResetBitReader(); if (_rpos + len > size()) - { throw ByteBufferException(false, _rpos, len, size()); } + { + throw ByteBufferException(false, _rpos, len, size()); + } memcpy(dest, &_storage[_rpos], len); _rpos += len; @@ -929,7 +937,9 @@ class ByteBuffer void reserve(size_t ressize) { if (ressize > size()) - { _storage.reserve(ressize); } + { + _storage.reserve(ressize); + } } /** @@ -978,7 +988,9 @@ class ByteBuffer MANGOS_ASSERT(size() < 10000000); if (_storage.size() < _wpos + cnt) - { _storage.resize(_wpos + cnt); } + { + _storage.resize(_wpos + cnt); + } memcpy(&_storage[_wpos], src, cnt); _wpos += cnt; @@ -1049,7 +1061,9 @@ class ByteBuffer void put(size_t pos, const uint8* src, size_t cnt) { if (pos + cnt > size()) - { throw ByteBufferException(true, pos, cnt, size()); } + { + throw ByteBufferException(true, pos, cnt, size()); + } memcpy(&_storage[pos], src, cnt); } diff --git a/src/shared/Utilities/ProgressBar.cpp b/src/shared/Utilities/ProgressBar.cpp index b8802228b..1235db56c 100644 --- a/src/shared/Utilities/ProgressBar.cpp +++ b/src/shared/Utilities/ProgressBar.cpp @@ -44,7 +44,9 @@ BarGoLink::BarGoLink(int row_count) BarGoLink::~BarGoLink() { if (!m_showOutput) - { return; } + { + return; + } printf("\n"); fflush(stdout); @@ -58,7 +60,9 @@ void BarGoLink::init(int row_count) num_rec = row_count; if (!m_showOutput) - { return; } + { + return; + } #ifdef _WIN32 printf("\x3D"); @@ -77,7 +81,9 @@ void BarGoLink::init(int row_count) void BarGoLink::step() { if (!m_showOutput) - { return; } + { + return; + } int i, n; diff --git a/src/shared/Utilities/Timer.h b/src/shared/Utilities/Timer.h index fd0e227c6..98b96208a 100644 --- a/src/shared/Utilities/Timer.h +++ b/src/shared/Utilities/Timer.h @@ -129,7 +129,9 @@ class IntervalTimer { _current += diff; if (_current < 0) - { _current = 0; } + { + _current = 0; + } } /** * @brief @@ -144,7 +146,9 @@ class IntervalTimer void Reset() { if (_current >= _interval) - { _current -= _interval; } + { + _current -= _interval; + } } /** @@ -213,7 +217,9 @@ class ShortIntervalTimer void Reset() { if (_current >= _interval) - { _current -= _interval; } + { + _current -= _interval; + } } /** diff --git a/src/shared/Utilities/Util.cpp b/src/shared/Utilities/Util.cpp index 17b609266..22120d62f 100644 --- a/src/shared/Utilities/Util.cpp +++ b/src/shared/Utilities/Util.cpp @@ -148,7 +148,9 @@ Tokens StrSplit(const std::string& src, const std::string& sep) uint32 GetUInt32ValueFromArray(Tokens const& data, uint16 index) { if (index >= data.size()) - { return 0; } + { + return 0; + } return (uint32)atoi(data[index].c_str()); } @@ -197,7 +199,9 @@ void stripLineInvisibleChars(std::string& str) else { if (wpos != pos) - { str[wpos++] = str[pos]; } + { + str[wpos++] = str[pos]; + } else { ++wpos; } space = false; @@ -205,7 +209,9 @@ void stripLineInvisibleChars(std::string& str) } if (wpos < str.size()) - { str.erase(wpos, str.size()); } + { + str.erase(wpos, str.size()); + } } std::string secsToTimeString(time_t timeInSecs, bool shortText, bool hoursOnly) @@ -217,15 +223,23 @@ std::string secsToTimeString(time_t timeInSecs, bool shortText, bool hoursOnly) std::ostringstream ss; if (days) - { ss << days << (shortText ? "d" : " Day(s) "); } + { + ss << days << (shortText ? "d" : " Day(s) "); + } if (hours || hoursOnly) - { ss << hours << (shortText ? "h" : " Hour(s) "); } + { + ss << hours << (shortText ? "h" : " Hour(s) "); + } if (!hoursOnly) { if (minutes) - { ss << minutes << (shortText ? "m" : " Minute(s) "); } + { + ss << minutes << (shortText ? "m" : " Minute(s) "); + } if (secs || (!days && !hours && !minutes)) - { ss << secs << (shortText ? "s" : " Second(s)."); } + { + ss << secs << (shortText ? "s" : " Second(s)."); + } } return ss.str(); @@ -311,7 +325,9 @@ std::string MoneyToString(uint64 money) bool IsIPAddress(char const* ipaddress) { if (!ipaddress) - { return false; } + { + return false; + } // Let the big boys do it. // Drawback: all valid ip address formats are recognized e.g.: 12.23,121234,0xABCD) @@ -338,7 +354,9 @@ uint32 CreatePIDFile(const std::string& filename) { FILE* pid_file = fopen(filename.c_str(), "w"); if (pid_file == NULL) - { return 0; } + { + return 0; + } #ifdef WIN32 DWORD pid = GetCurrentProcessId(); @@ -371,7 +389,9 @@ void utf8truncate(std::string& utf8str, size_t len) { size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size()); if (wlen <= len) - { return; } + { + return; + } std::wstring wstr; wstr.resize(wlen); @@ -405,7 +425,9 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) if (len > wsize) { if (wsize > 0) - { wstr[0] = L'\0'; } + { + wstr[0] = L'\0'; + } wsize = 0; return false; } @@ -417,7 +439,9 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) catch (std::exception) { if (wsize > 0) - { wstr[0] = L'\0'; } + { + wstr[0] = L'\0'; + } wsize = 0; return false; } @@ -433,7 +457,9 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr) wstr.resize(len); if (len) - { utf8::utf8to16(utf8str.c_str(), utf8str.c_str() + utf8str.size(), &wstr[0]); } + { + utf8::utf8to16(utf8str.c_str(), utf8str.c_str() + utf8str.size(), &wstr[0]); + } } catch (std::exception) { @@ -490,7 +516,9 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) { // supported only Cyrillic cases if (wname.size() < 1 || !isCyrillicCharacter(wname[0]) || declension > 5) - { return wname; } + { + return wname; + } // Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently) @@ -526,7 +554,9 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) size_t len = size_t((*itr)[-1]); // get length from string size field if (wname.substr(wname.size() - len, len) == *itr) - { return wname.substr(0, wname.size() - len); } + { + return wname.substr(0, wname.size() - len); + } } return wname; @@ -538,7 +568,9 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr) #if PLATFORM == PLATFORM_WINDOWS std::wstring wstr; if (!Utf8toWStr(utf8str, wstr)) - { return false; } + { + return false; + } conStr.resize(wstr.size()); CharToOemBuffW(&wstr[0], &conStr[0], wstr.size()); @@ -570,13 +602,17 @@ bool Utf8FitTo(const std::string& str, std::wstring search) std::wstring temp; if (!Utf8toWStr(str, temp)) - { return false; } + { + return false; + } // converting to lower case wstrToLower(temp); if (temp.find(search) == std::wstring::npos) - { return false; } + { + return false; + } return true; } @@ -609,7 +645,9 @@ void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result) unsigned char nibble = 0x0F & (bytes[i] >> ((1 - j) * 4)); char encodedNibble; if (nibble < 0x0A) - { encodedNibble = '0' + nibble; } + { + encodedNibble = '0' + nibble; + } else { encodedNibble = 'A' + nibble - 0x0A; } ss << encodedNibble; @@ -673,7 +711,9 @@ void utf8print(void* /*arg*/, const char* str) wchar_t wtemp_buf[6000]; size_t wtemp_len = 6000 - 1; if (!Utf8toWStr(str, strlen(str), wtemp_buf, wtemp_len)) - { return; } + { + return; + } char temp_buf[6000]; CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len + 1); @@ -796,4 +836,4 @@ void print_banner() "\n"); break; } -} \ No newline at end of file +} diff --git a/src/shared/Utilities/Util.h b/src/shared/Utilities/Util.h index 38653eb5e..b02d3dfd3 100644 --- a/src/shared/Utilities/Util.h +++ b/src/shared/Utilities/Util.h @@ -234,7 +234,9 @@ inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply) int32 cur = var; cur += (apply ? val : -val); if (cur < 0) - { cur = 0; } + { + cur = 0; + } var = cur; } @@ -249,7 +251,9 @@ inline void ApplyModFloatVar(float& var, float val, bool apply) { var += (apply ? val : -val); if (var < 0) - { var = 0; } + { + var = 0; + } } /** @@ -262,7 +266,9 @@ inline void ApplyModFloatVar(float& var, float val, bool apply) inline void ApplyPercentModFloatVar(float& var, float val, bool apply) { if (val == -100.0f) // prevent set var to zero - { val = -99.99f; } + { + val = -99.99f; + } var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val)); } @@ -347,9 +353,13 @@ void utf8truncate(std::string& utf8str, size_t len); inline bool isBasicLatinCharacter(wchar_t wchar) { if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z - { return true; } + { + return true; + } if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z - { return true; } + { + return true; + } return false; } @@ -362,21 +372,37 @@ inline bool isBasicLatinCharacter(wchar_t wchar) inline bool isExtendedLatinCharacter(wchar_t wchar) { if (isBasicLatinCharacter(wchar)) - { return true; } + { + return true; + } if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS - { return true; } + { + return true; + } if (wchar >= 0x00D8 && wchar <= 0x00DF) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN - { return true; } + { + return true; + } if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S - { return true; } + { + return true; + } if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS - { return true; } + { + return true; + } if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN - { return true; } + { + return true; + } if (wchar >= 0x0100 && wchar <= 0x012F) // LATIN CAPITAL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK - { return true; } + { + return true; + } if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S - { return true; } + { + return true; + } return false; } @@ -389,9 +415,13 @@ inline bool isExtendedLatinCharacter(wchar_t wchar) inline bool isCyrillicCharacter(wchar_t wchar) { if (wchar >= 0x0410 && wchar <= 0x044F) // CYRILLIC CAPITAL LETTER A - CYRILLIC SMALL LETTER YA - { return true; } + { + return true; + } if (wchar == 0x0401 || wchar == 0x0451) // CYRILLIC CAPITAL LETTER IO, CYRILLIC SMALL LETTER IO - { return true; } + { + return true; + } return false; } @@ -404,21 +434,37 @@ inline bool isCyrillicCharacter(wchar_t wchar) inline bool isEastAsianCharacter(wchar_t wchar) { if (wchar >= 0x1100 && wchar <= 0x11F9) // Hangul Jamo - { return true; } + { + return true; + } if (wchar >= 0x3041 && wchar <= 0x30FF) // Hiragana + Katakana - { return true; } + { + return true; + } if (wchar >= 0x3131 && wchar <= 0x318E) // Hangul Compatibility Jamo - { return true; } + { + return true; + } if (wchar >= 0x31F0 && wchar <= 0x31FF) // Katakana Phonetic Ext. - { return true; } + { + return true; + } if (wchar >= 0x3400 && wchar <= 0x4DB5) // CJK Ideographs Ext. A - { return true; } + { + return true; + } if (wchar >= 0x4E00 && wchar <= 0x9FC3) // Unified CJK Ideographs - { return true; } + { + return true; + } if (wchar >= 0xAC00 && wchar <= 0xD7A3) // Hangul Syllables - { return true; } + { + return true; + } if (wchar >= 0xFF01 && wchar <= 0xFFEE) // Halfwidth forms - { return true; } + { + return true; + } return false; } @@ -476,7 +522,9 @@ inline bool isNumeric(char const* str) { for (char const* c = str; *c; ++c) if (!isNumeric(*c)) - { return false; } + { + return false; + } return true; } @@ -491,7 +539,9 @@ inline bool isNumeric(std::string const& str) { for (std::string::const_iterator itr = str.begin(); itr != str.end(); ++itr) if (!isNumeric(*itr)) - { return false; } + { + return false; + } return true; } @@ -506,7 +556,9 @@ inline bool isNumeric(std::wstring const& str) { for (std::wstring::const_iterator itr = str.begin(); itr != str.end(); ++itr) if (!isNumeric(*itr)) - { return false; } + { + return false; + } return true; } @@ -522,7 +574,9 @@ inline bool isBasicLatinString(const std::wstring &wstr, bool numericOrSpace) { for (size_t i = 0; i < wstr.size(); ++i) if (!isBasicLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) - { return false; } + { + return false; + } return true; } @@ -537,7 +591,9 @@ inline bool isExtendedLatinString(const std::wstring &wstr, bool numericOrSpace) { for (size_t i = 0; i < wstr.size(); ++i) if (!isExtendedLatinCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) - { return false; } + { + return false; + } return true; } @@ -552,7 +608,9 @@ inline bool isCyrillicString(const std::wstring &wstr, bool numericOrSpace) { for (size_t i = 0; i < wstr.size(); ++i) if (!isCyrillicCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) - { return false; } + { + return false; + } return true; } @@ -567,7 +625,9 @@ inline bool isEastAsianString(const std::wstring &wstr, bool numericOrSpace) { for (size_t i = 0; i < wstr.size(); ++i) if (!isEastAsianCharacter(wstr[i]) && (!numericOrSpace || !isNumericOrSpace(wstr[i]))) - { return false; } + { + return false; + } return true; } @@ -600,22 +660,36 @@ inline void strToLower(std::string& str) inline wchar_t wcharToUpper(wchar_t wchar) { if (wchar >= L'a' && wchar <= L'z') // LATIN SMALL LETTER A - LATIN SMALL LETTER Z - { return wchar_t(uint16(wchar) - 0x0020); } + { + return wchar_t(uint16(wchar) - 0x0020); + } if (wchar == 0x00DF) // LATIN SMALL LETTER SHARP S - { return wchar_t(0x1E9E); } + { + return wchar_t(0x1E9E); + } if (wchar >= 0x00E0 && wchar <= 0x00F6) // LATIN SMALL LETTER A WITH GRAVE - LATIN SMALL LETTER O WITH DIAERESIS - { return wchar_t(uint16(wchar) - 0x0020); } + { + return wchar_t(uint16(wchar) - 0x0020); + } if (wchar >= 0x00F8 && wchar <= 0x00FE) // LATIN SMALL LETTER O WITH STROKE - LATIN SMALL LETTER THORN - { return wchar_t(uint16(wchar) - 0x0020); } + { + return wchar_t(uint16(wchar) - 0x0020); + } if (wchar >= 0x0101 && wchar <= 0x012F) // LATIN SMALL LETTER A WITH MACRON - LATIN SMALL LETTER I WITH OGONEK (only %2=1) { if (wchar % 2 == 1) - { return wchar_t(uint16(wchar) - 0x0001); } + { + return wchar_t(uint16(wchar) - 0x0001); + } } if (wchar >= 0x0430 && wchar <= 0x044F) // CYRILLIC SMALL LETTER A - CYRILLIC SMALL LETTER YA - { return wchar_t(uint16(wchar) - 0x0020); } + { + return wchar_t(uint16(wchar) - 0x0020); + } if (wchar == 0x0451) // CYRILLIC SMALL LETTER IO - { return wchar_t(0x0401); } + { + return wchar_t(0x0401); + } return wchar; } @@ -640,22 +714,36 @@ inline wchar_t wcharToUpperOnlyLatin(wchar_t wchar) inline wchar_t wcharToLower(wchar_t wchar) { if (wchar >= L'A' && wchar <= L'Z') // LATIN CAPITAL LETTER A - LATIN CAPITAL LETTER Z - { return wchar_t(uint16(wchar) + 0x0020); } + { + return wchar_t(uint16(wchar) + 0x0020); + } if (wchar >= 0x00C0 && wchar <= 0x00D6) // LATIN CAPITAL LETTER A WITH GRAVE - LATIN CAPITAL LETTER O WITH DIAERESIS - { return wchar_t(uint16(wchar) + 0x0020); } + { + return wchar_t(uint16(wchar) + 0x0020); + } if (wchar >= 0x00D8 && wchar <= 0x00DE) // LATIN CAPITAL LETTER O WITH STROKE - LATIN CAPITAL LETTER THORN - { return wchar_t(uint16(wchar) + 0x0020); } + { + return wchar_t(uint16(wchar) + 0x0020); + } if (wchar >= 0x0100 && wchar <= 0x012E) // LATIN CAPITAL LETTER A WITH MACRON - LATIN CAPITAL LETTER I WITH OGONEK (only %2=0) { if (wchar % 2 == 0) - { return wchar_t(uint16(wchar) + 0x0001); } + { + return wchar_t(uint16(wchar) + 0x0001); + } } if (wchar == 0x1E9E) // LATIN CAPITAL LETTER SHARP S - { return wchar_t(0x00DF); } + { + return wchar_t(0x00DF); + } if (wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO - { return wchar_t(0x0451); } + { + return wchar_t(0x0451); + } if (wchar >= 0x0410 && wchar <= 0x042F) // CYRILLIC CAPITAL LETTER A - CYRILLIC CAPITAL LETTER YA - { return wchar_t(uint16(wchar) + 0x0020); } + { + return wchar_t(uint16(wchar) + 0x0020); + } return wchar; } diff --git a/src/shared/Win/ServiceWin32.cpp b/src/shared/Win/ServiceWin32.cpp index 73ef42ec1..99310be55 100644 --- a/src/shared/Win/ServiceWin32.cpp +++ b/src/shared/Win/ServiceWin32.cpp @@ -167,7 +167,9 @@ bool WinServiceUninstall() if (QueryServiceStatus(service, &serviceStatus2)) { if (serviceStatus2.dwCurrentState == SERVICE_STOPPED) - { DeleteService(service); } + { + DeleteService(service); + } } CloseServiceHandle(service); diff --git a/src/shared/Win/WheatyExceptionReport.cpp b/src/shared/Win/WheatyExceptionReport.cpp index 4b20c07e2..6bb4a9ae4 100644 --- a/src/shared/Win/WheatyExceptionReport.cpp +++ b/src/shared/Win/WheatyExceptionReport.cpp @@ -60,7 +60,9 @@ WheatyExceptionReport::WheatyExceptionReport() // Constructor WheatyExceptionReport::~WheatyExceptionReport() { if (m_previousFilter) - { SetUnhandledExceptionFilter(m_previousFilter); } + { + SetUnhandledExceptionFilter(m_previousFilter); + } } //=========================================================== @@ -73,7 +75,9 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter( GetModuleFileName(0, module_folder_name, MAX_PATH); TCHAR* pos = _tcsrchr(module_folder_name, '\\'); if (!pos) - { return 0; } + { + return 0; + } pos[0] = '\0'; ++pos; @@ -82,7 +86,9 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter( if (!CreateDirectory(crash_folder_path, NULL)) { if (GetLastError() != ERROR_ALREADY_EXISTS) - { return 0; } + { + return 0; + } } SYSTEMTIME systime; @@ -109,7 +115,9 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter( } if (m_previousFilter) - { return m_previousFilter(pExceptionInfo); } + { + return m_previousFilter(pExceptionInfo); + } else { return EXCEPTION_EXECUTE_HANDLER/*EXCEPTION_CONTINUE_SEARCH*/; } } @@ -117,20 +125,26 @@ LONG WINAPI WheatyExceptionReport::WheatyUnhandledExceptionFilter( BOOL WheatyExceptionReport::_GetProcessorName(TCHAR* sProcessorName, DWORD maxcount) { if (!sProcessorName) - { return FALSE; } + { + return FALSE; + } HKEY hKey; LONG lRet; lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"), 0, KEY_QUERY_VALUE, &hKey); if (lRet != ERROR_SUCCESS) - { return FALSE; } + { + return FALSE; + } TCHAR szTmp[2048]; DWORD cntBytes = sizeof(szTmp); lRet = ::RegQueryValueEx(hKey, _T("ProcessorNameString"), NULL, NULL, (LPBYTE)szTmp, &cntBytes); if (lRet != ERROR_SUCCESS) - { return FALSE; } + { + return FALSE; + } ::RegCloseKey(hKey); sProcessorName[0] = '\0'; // Skip spaces @@ -153,7 +167,9 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) { osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); if (!::GetVersionEx((OSVERSIONINFO*)&osvi)) - { return FALSE; } + { + return FALSE; + } } *szVersion = _T('\0'); TCHAR wszTmp[128]; @@ -166,19 +182,25 @@ BOOL WheatyExceptionReport::_GetWindowsVersion(TCHAR* szVersion, DWORD cntMax) { default: // 2 if (osvi.wProductType == VER_NT_WORKSTATION) - { _tcsncat(szVersion, _T("Windows 8 "), cntMax); } + { + _tcsncat(szVersion, _T("Windows 8 "), cntMax); + } else { _tcsncat(szVersion, _T("Windows Server 2012 "), cntMax); } break; case 1: if (osvi.wProductType == VER_NT_WORKSTATION) - { _tcsncat(szVersion, _T("Windows 7 "), cntMax); } + { + _tcsncat(szVersion, _T("Windows 7 "), cntMax); + } else { _tcsncat(szVersion, _T("Windows Server 2008 R2 "), cntMax); } break; case 0: if (osvi.wProductType == VER_NT_WORKSTATION) - { _tcsncat(szVersion, _T("Windows Vista "), cntMax); } + { + _tcsncat(szVersion, _T("Windows Vista "), cntMax); + } else { _tcsncat(szVersion, _T("Windows Server 2008 "), cntMax); } break; @@ -234,7 +256,9 @@ void WheatyExceptionReport::PrintSystemInfo() SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys / 0x400, MemoryStatus.dwAvailPhys / 0x400, MemoryStatus.dwTotalPageFile / 0x400); if (_GetWindowsVersion(sString, countof(sString))) - { _tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString); } + { + _tprintf(_T("\r\n*** Operation System ***\r\n%s\r\n"), sString); + } else { _tprintf(_T("\r\n*** Operation System:\r\n\r\n")); } } @@ -250,7 +274,9 @@ void WheatyExceptionReport::printTracesForAllThreads() // Take a snapshot of all running threads hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); if (hThreadSnap == INVALID_HANDLE_VALUE) - { return; } + { + return; + } // Fill in the size of the structure before using it. te32.dwSize = sizeof(THREADENTRY32); @@ -455,12 +481,16 @@ BOOL WheatyExceptionReport::GetLogicalAddress( MEMORY_BASIC_INFORMATION mbi; if (!VirtualQuery(addr, &mbi, sizeof(mbi))) - { return FALSE; } + { + return FALSE; + } DWORD_PTR hMod = (DWORD_PTR)mbi.AllocationBase; if (!GetModuleFileName((HMODULE)hMod, szModule, len)) - { return FALSE; } + { + return FALSE; + } // Point to the DOS header in memory PIMAGE_DOS_HEADER pDosHdr = (PIMAGE_DOS_HEADER)hMod; @@ -667,13 +697,17 @@ bool WheatyExceptionReport::FormatSymbolValue( // Indicate if the variable is a local or parameter if (pSym->Flags & IMAGEHLP_SYMBOL_INFO_PARAMETER) - { pszCurrBuffer += sprintf(pszCurrBuffer, "Parameter "); } + { + pszCurrBuffer += sprintf(pszCurrBuffer, "Parameter "); + } else if (pSym->Flags & IMAGEHLP_SYMBOL_INFO_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 - { return false; } + { + return false; + } DWORD_PTR pVariable = 0; // Will point to the variable's data in memory @@ -753,7 +787,9 @@ char* WheatyExceptionReport::DumpTypeIndex( &dwChildrenCount); if (!dwChildrenCount) // If no children, we're done - { return pszCurrBuffer; } + { + return pszCurrBuffer; + } // Prepare to get an array of "TypeIds", representing each of the children. // SymGetTypeInfo(TI_FINDCHILDREN) expects more memory than just a @@ -839,7 +875,9 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer, { // Format appropriately (assuming it's a 1, 2, or 4 bytes (!!!) if (length == 1) - { pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PBYTE)pAddress); } + { + pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PBYTE)pAddress); + } else if (length == 2) { pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PWORD)pAddress); } else if (length == 4) diff --git a/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp b/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp index 5f1a1ba0b..5705fece3 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp +++ b/src/tools/Extractor_projects/Movemap-Generator/IntermediateValues.cpp @@ -62,15 +62,25 @@ namespace MMAP } while (false) if (heightfield) - { DEBUG_WRITE("hf", heightfield); } + { + DEBUG_WRITE("hf", heightfield); + } if (compactHeightfield) - { DEBUG_WRITE("chf", compactHeightfield); } + { + DEBUG_WRITE("chf", compactHeightfield); + } if (contours) - { DEBUG_WRITE("cs", contours); } + { + DEBUG_WRITE("cs", contours); + } if (polyMesh) - { DEBUG_WRITE("pmesh", polyMesh); } + { + DEBUG_WRITE("pmesh", polyMesh); + } if (polyMeshDetail) - { DEBUG_WRITE("dmesh", polyMeshDetail); } + { + DEBUG_WRITE("dmesh", polyMeshDetail); + } #undef DEBUG_WRITE } @@ -78,7 +88,9 @@ namespace MMAP void IntermediateValues::debugWrite(FILE* file, const rcHeightfield* mesh) { if (!file || !mesh) - { return; } + { + return; + } fwrite(&(mesh->cs), sizeof(float), 1, file); fwrite(&(mesh->ch), sizeof(float), 1, file); @@ -116,7 +128,9 @@ namespace MMAP void IntermediateValues::debugWrite(FILE* file, const rcCompactHeightfield* chf) { if (!file | !chf) - { return; } + { + return; + } fwrite(&(chf->width), sizeof(chf->width), 1, file); fwrite(&(chf->height), sizeof(chf->height), 1, file); @@ -143,19 +157,29 @@ namespace MMAP fwrite(&tmp, sizeof(tmp), 1, file); if (chf->cells) - { fwrite(chf->cells, sizeof(rcCompactCell), chf->width * chf->height, file); } + { + fwrite(chf->cells, sizeof(rcCompactCell), chf->width * chf->height, file); + } if (chf->spans) - { fwrite(chf->spans, sizeof(rcCompactSpan), chf->spanCount, file); } + { + fwrite(chf->spans, sizeof(rcCompactSpan), chf->spanCount, file); + } if (chf->dist) - { fwrite(chf->dist, sizeof(unsigned short), chf->spanCount, file); } + { + fwrite(chf->dist, sizeof(unsigned short), chf->spanCount, file); + } if (chf->areas) - { fwrite(chf->areas, sizeof(unsigned char), chf->spanCount, file); } + { + fwrite(chf->areas, sizeof(unsigned char), chf->spanCount, file); + } } void IntermediateValues::debugWrite(FILE* file, const rcContourSet* cs) { if (!file || !cs) - { return; } + { + return; + } fwrite(&(cs->cs), sizeof(float), 1, file); fwrite(&(cs->ch), sizeof(float), 1, file); @@ -176,7 +200,9 @@ namespace MMAP void IntermediateValues::debugWrite(FILE* file, const rcPolyMesh* mesh) { if (!file || !mesh) - { return; } + { + return; + } fwrite(&(mesh->cs), sizeof(float), 1, file); fwrite(&(mesh->ch), sizeof(float), 1, file); @@ -195,7 +221,9 @@ namespace MMAP void IntermediateValues::debugWrite(FILE* file, const rcPolyMeshDetail* mesh) { if (!file || !mesh) - { return; } + { + return; + } fwrite(&(mesh->nverts), sizeof(int), 1, file); fwrite(mesh->verts, sizeof(float), mesh->nverts * 3, file); diff --git a/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h b/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h index f89efa8dc..3286bf5c1 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h +++ b/src/tools/Extractor_projects/Movemap-Generator/MMapCommon.h @@ -55,7 +55,9 @@ namespace MMAP inline bool matchWildcardFilter(const char* filter, const char* str) { if (!filter || !str) - { return false; } + { + return false; + } // end on null character while (*filter && *str) @@ -63,12 +65,16 @@ namespace MMAP if (*filter == '*') { if (*++filter == '\0') // wildcard at end of filter means all remaing chars match - { return true; } + { + return true; + } while (true) { if (*filter == *str) - { break; } + { + break; + } if (*str == '\0') { return false; } // reached end of string without matching next filter character str++; @@ -115,12 +121,16 @@ namespace MMAP hFind = FindFirstFile(directory.c_str(), &findFileInfo); if (hFind == INVALID_HANDLE_VALUE) - { return LISTFILE_DIRECTORY_NOT_FOUND; } + { + return LISTFILE_DIRECTORY_NOT_FOUND; + } do { if (includeSubDirs || (findFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) - { fileList.push_back(string(findFileInfo.cFileName)); } + { + fileList.push_back(string(findFileInfo.cFileName)); + } } while (FindNextFile(hFind, &findFileInfo)); @@ -137,14 +147,18 @@ namespace MMAP if ((dp = readdir(dirp)) != NULL) { if (matchWildcardFilter(filter.c_str(), dp->d_name)) - { fileList.push_back(string(dp->d_name)); } + { + fileList.push_back(string(dp->d_name)); + } } else { break; } } if (dirp) - { closedir(dirp); } + { + closedir(dirp); + } else { return LISTFILE_DIRECTORY_NOT_FOUND; } #endif diff --git a/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp b/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp index 3333e1f88..3d0a41605 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp +++ b/src/tools/Extractor_projects/Movemap-Generator/MapBuilder.cpp @@ -127,7 +127,9 @@ namespace MMAP tileID = StaticMapTree::packTileID(tileX, tileY); if (tiles->insert(tileID).second) - { count++; } + { + count++; + } } } printf(" found %u.\n\n", count); @@ -138,7 +140,9 @@ namespace MMAP { TileList::iterator itr = m_tiles.find(mapID); if (itr != m_tiles.end()) - { return (*itr).second; } + { + return (*itr).second; + } set* tiles = new set(); m_tiles.insert(pair*>(mapID, tiles)); @@ -152,7 +156,9 @@ namespace MMAP { uint32 mapID = (*it).first; if (!shouldSkipMap(mapID)) - { buildMap(mapID); } + { + buildMap(mapID); + } } } @@ -192,7 +198,9 @@ namespace MMAP } if (!tiles->size()) - { return; } + { + return; + } // build navMesh dtNavMesh* navMesh = NULL; @@ -213,7 +221,9 @@ namespace MMAP StaticMapTree::unpackTileID((*it), tileX, tileY); if (shouldSkipTile(mapID, tileX, tileY)) - { continue; } + { + continue; + } buildTile(mapID, tileX, tileY, navMesh); } @@ -237,7 +247,9 @@ namespace MMAP // if there is no data, give up now if (!meshData.solidVerts.size() && !meshData.liquidVerts.size()) - { return; } + { + return; + } // remove unused vertices TerrainBuilder::cleanVertices(meshData.solidVerts, meshData.solidTris); @@ -249,7 +261,9 @@ namespace MMAP allVerts.append(meshData.solidVerts); if (!allVerts.size()) - { return; } + { + return; + } // get bounds of current tile float bmin[3], bmax[3]; @@ -278,11 +292,15 @@ namespace MMAP // make sure we process maps which don't have tiles // initialize the static tree, which loads WDT models if (!m_terrainBuilder->loadVMap(mapID, 64, 64, meshData)) - { return; } + { + return; + } // get the coord bounds of the model data if (meshData.solidVerts.size() + meshData.liquidVerts.size() == 0) - { return; } + { + return; + } // get the coord bounds of the model data if (meshData.solidVerts.size() && meshData.liquidVerts.size()) @@ -329,12 +347,16 @@ namespace MMAP StaticMapTree::unpackTileID((*it), tileX, tileY); if (tileX > tileXMax) - { tileXMax = tileX; } + { + tileXMax = tileX; + } else if (tileX < tileXMin) { tileXMin = tileX; } if (tileY > tileYMax) - { tileYMax = tileY; } + { + tileYMax = tileY; + } else if (tileY < tileYMin) { tileYMin = tileY; } } @@ -616,7 +638,9 @@ namespace MMAP // TODO: special flags for DYNAMIC polygons, ie surfaces that can be turned on and off for (int i = 0; i < iv.polyMesh->npolys; ++i) if (iv.polyMesh->areas[i] & RC_WALKABLE_AREA) - { iv.polyMesh->flags[i] = iv.polyMesh->areas[i]; } + { + iv.polyMesh->flags[i] = iv.polyMesh->areas[i]; + } // setup mesh parameters dtNavMeshCreateParams params; @@ -759,7 +783,9 @@ namespace MMAP { // this is for elevation if (verts && vertCount) - { rcCalcBounds(verts, vertCount, bmin, bmax); } + { + rcCalcBounds(verts, vertCount, bmin, bmax); + } else { bmin[1] = FLT_MIN; @@ -805,7 +831,9 @@ namespace MMAP return true; default: if (isTransportMap(mapID)) - { return true; } + { + return true; + } break; } @@ -897,17 +925,23 @@ namespace MMAP sprintf(fileName, "mmaps/%03u%02i%02i.mmtile", mapID, tileY, tileX); FILE* file = fopen(fileName, "rb"); if (!file) - { return false; } + { + return false; + } MmapTileHeader header; size_t file_read = fread(&header, sizeof(MmapTileHeader), 1, file); fclose(file); if (header.mmapMagic != MMAP_MAGIC || header.dtVersion != DT_NAVMESH_VERSION || file_read <= 0) - { return false; } + { + return false; + } if (header.mmapVersion != MMAP_VERSION) - { return false; } + { + return false; + } return true; } diff --git a/src/tools/Extractor_projects/Movemap-Generator/TerrainBuilder.cpp b/src/tools/Extractor_projects/Movemap-Generator/TerrainBuilder.cpp index 3f6cd26ab..8f5b45358 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/TerrainBuilder.cpp +++ b/src/tools/Extractor_projects/Movemap-Generator/TerrainBuilder.cpp @@ -90,7 +90,9 @@ namespace MMAP FILE* mapFile = fopen(mapFileName, "rb"); if (!mapFile) - { return false; } + { + return false; + } GridMapFileHeader fheader; fread(&fheader, sizeof(GridMapFileHeader), 1, mapFile); @@ -297,7 +299,9 @@ namespace MMAP int* ttris = ttriangles.getCArray(); if (ltriangles.size() + ttriangles.size() == 0) - { return false; } + { + return false; + } // make a copy of liquid vertices // used to pad right-bottom frame due to lost vertex data at extraction @@ -320,7 +324,9 @@ namespace MMAP // if there is no liquid, don't use liquid if (!liquid_type || !meshData.liquidVerts.size() || !ltriangles.size()) - { useLiquid = false; } + { + useLiquid = false; + } else { liquidType = getLiquidType(i, liquid_type); @@ -350,7 +356,9 @@ namespace MMAP // if there is no terrain, don't use terrain if (!ttriangles.size()) - { useTerrain = false; } + { + useTerrain = false; + } // while extracting ADT data we are losing right-bottom vertices // this code adds fair approximation of lost data @@ -376,18 +384,24 @@ namespace MMAP { float h = lverts[ltris[idx] * 3 + 1]; if (h == INVALID_MAP_LIQ_HEIGHT || h > INVALID_MAP_LIQ_HEIGHT_MAX) - { lverts[ltris[idx] * 3 + 1] = quadHeight; } + { + lverts[ltris[idx] * 3 + 1] = quadHeight; + } } } // no valid vertexes - don't use this poly at all if (validCount == 0) - { useLiquid = false; } + { + useLiquid = false; + } } // if there is a hole here, don't use the terrain if (useTerrain) - { useTerrain = !isHole(i, holes); } + { + useTerrain = !isHole(i, holes); + } // we use only one terrain kind per quad - pick higher one if (useTerrain && useLiquid) @@ -398,10 +412,14 @@ namespace MMAP { float h = lverts[ltris[x] * 3 + 1]; if (minLLevel > h) - { minLLevel = h; } + { + minLLevel = h; + } if (maxLLevel < h) - { maxLLevel = h; } + { + maxLLevel = h; + } } float maxTLevel = INVALID_MAP_LIQ_HEIGHT; @@ -410,19 +428,27 @@ namespace MMAP { float h = tverts[ttris[x] * 3 + 1]; if (maxTLevel < h) - { maxTLevel = h; } + { + maxTLevel = h; + } if (minTLevel > h) - { minTLevel = h; } + { + minTLevel = h; + } } // terrain under the liquid? if (minLLevel > maxTLevel) - { useTerrain = false; } + { + useTerrain = false; + } //liquid under the terrain? if (minTLevel > maxLLevel) - { useLiquid = false; } + { + useLiquid = false; + } } // store the result @@ -444,7 +470,9 @@ namespace MMAP } if (lverts_copy) - { delete [] lverts_copy; } + { + delete [] lverts_copy; + } return meshData.solidTris.size() || meshData.liquidTris.size(); } @@ -566,20 +594,26 @@ namespace MMAP do { if (result == VMAP_LOAD_RESULT_ERROR) - { break; } + { + break; + } InstanceTreeMap instanceTrees; ((VMapManager2*)vmapManager)->getInstanceMapTree(instanceTrees); if (!instanceTrees[mapID]) - { break; } + { + break; + } ModelInstance* models = NULL; uint32 count = 0; instanceTrees[mapID]->getModelInstances(models, count); if (!models) - { break; } + { + break; + } for (uint32 i = 0; i < count; ++i) { @@ -588,7 +622,9 @@ namespace MMAP // model instances exist in tree even though there are instances of that model in this tile WorldModel* worldModel = instance.getWorldModel(); if (!worldModel) - { continue; } + { + continue; + } // now we have a model to add to the meshdata retval = true; @@ -779,7 +815,9 @@ namespace MMAP for (int i = 0; i < tris.size(); ++i) { if (vertMap.find(t[i]) != vertMap.end()) - { continue; } + { + continue; + } vertMap.insert(std::pair(t[i], 0)); } @@ -803,7 +841,9 @@ namespace MMAP { map::iterator it; if ((it = vertMap.find(t[i])) == vertMap.end()) - { continue; } + { + continue; + } t[i] = (*it).second; } @@ -816,7 +856,9 @@ namespace MMAP { // no meshfile input given? if (offMeshFilePath == NULL) - { return; } + { + return; + } FILE* fp = fopen(offMeshFilePath, "rb"); if (!fp) diff --git a/src/tools/Extractor_projects/Movemap-Generator/generator.cpp b/src/tools/Extractor_projects/Movemap-Generator/generator.cpp index edd99491f..bb91817d2 100644 --- a/src/tools/Extractor_projects/Movemap-Generator/generator.cpp +++ b/src/tools/Extractor_projects/Movemap-Generator/generator.cpp @@ -106,11 +106,15 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } float maxangle = atof(param); if (maxangle <= 90.f && maxangle >= 45.f) - { maxAngle = maxangle; } + { + maxAngle = maxangle; + } else { printf("invalid option for '--maxAngle', using default\n"); } } @@ -118,7 +122,9 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } char* stileX = strtok(param, ","); char* stileY = strtok(NULL, ","); @@ -126,9 +132,13 @@ bool handleArgs(int argc, char** argv, int tiley = atoi(stileY); if ((tilex > 0 && tilex < 64) || (tilex == 0 && strcmp(stileX, "0") == 0)) - { tileX = tilex; } + { + tileX = tilex; + } if ((tiley > 0 && tiley < 64) || (tiley == 0 && strcmp(stileY, "0") == 0)) - { tileY = tiley; } + { + tileY = tiley; + } if (tileX < 0 || tileY < 0) { @@ -140,10 +150,14 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } if (strcmp(param, "true") == 0) - { skipLiquid = true; } + { + skipLiquid = true; + } else if (strcmp(param, "false") == 0) { skipLiquid = false; } else @@ -153,10 +167,14 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } if (strcmp(param, "true") == 0) - { skipContinents = true; } + { + skipContinents = true; + } else if (strcmp(param, "false") == 0) { skipContinents = false; } else @@ -166,10 +184,14 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } if (strcmp(param, "true") == 0) - { skipJunkMaps = true; } + { + skipJunkMaps = true; + } else if (strcmp(param, "false") == 0) { skipJunkMaps = false; } else @@ -179,10 +201,14 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } if (strcmp(param, "true") == 0) - { skipBattlegrounds = true; } + { + skipBattlegrounds = true; + } else if (strcmp(param, "false") == 0) { skipBattlegrounds = false; } else @@ -192,10 +218,14 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } if (strcmp(param, "true") == 0) - { debugOutput = true; } + { + debugOutput = true; + } else if (strcmp(param, "false") == 0) { debugOutput = false; } else @@ -209,10 +239,14 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } if (strcmp(param, "true") == 0) - { bigBaseUnit = true; } + { + bigBaseUnit = true; + } else if (strcmp(param, "false") == 0) { bigBaseUnit = false; } else @@ -222,7 +256,9 @@ bool handleArgs(int argc, char** argv, { param = argv[++i]; if (!param) - { return false; } + { + return false; + } offMeshInputPath = param; } @@ -235,7 +271,9 @@ bool handleArgs(int argc, char** argv, { int map = atoi(argv[i]); if (map > 0 || (map == 0 && (strcmp(argv[i], "0") == 0))) - { mapnum = map; } + { + mapnum = map; + } else { printf("invalid map id\n"); @@ -279,23 +317,31 @@ int main(int argc, char** argv) if (mapnum == -1 && debugOutput) { if (silent) - { return -2; } + { + return -2; + } printf(" You have specifed debug output, but didn't specify a map to generate.\n"); printf(" This will generate debug output for ALL maps.\n"); printf(" Are you sure you want to continue? (y/n) "); if (getchar() != 'y') - { return 0; } + { + return 0; + } } if (!checkDirectories(debugOutput)) - { return silent ? -3 : finish(" Press any key to close...", -3); } + { + return silent ? -3 : finish(" Press any key to close...", -3); + } MapBuilder builder(maxAngle, skipLiquid, skipContinents, skipJunkMaps, skipBattlegrounds, debugOutput, bigBaseUnit, offMeshInputPath); if (tileX > -1 && tileY > -1 && mapnum >= 0) - { builder.buildSingleTile(mapnum, tileX, tileY); } + { + builder.buildSingleTile(mapnum, tileX, tileY); + } else if (mapnum >= 0) builder.buildMap(uint32(mapnum)); else diff --git a/src/tools/Extractor_projects/map-extractor/System.cpp b/src/tools/Extractor_projects/map-extractor/System.cpp index 704655c49..f84d2b6eb 100644 --- a/src/tools/Extractor_projects/map-extractor/System.cpp +++ b/src/tools/Extractor_projects/map-extractor/System.cpp @@ -599,7 +599,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { adt_MCNK* cell = adt.cells[i][j]; if (!cell) - { continue; } + { + continue; + } // Height values for triangles stored in order: // 1 2 3 4 5 6 7 8 9 // 10 11 12 13 14 15 16 17 @@ -638,7 +640,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 // Get custom height adt_MCVT* v = cell->getMCVT(); if (!v) - { continue; } + { + continue; + } // get V9 height map for (int y = 0; y <= ADT_CELL_SIZE; y++) { @@ -691,15 +695,23 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 for (int y = 0; y < ADT_GRID_SIZE; y++) for (int x = 0; x < ADT_GRID_SIZE; x++) if (V8[y][x] < CONF_use_minHeight) - { V8[y][x] = CONF_use_minHeight; } + { + V8[y][x] = CONF_use_minHeight; + } for (int y = 0; y <= ADT_GRID_SIZE; y++) for (int x = 0; x <= ADT_GRID_SIZE; x++) if (V9[y][x] < CONF_use_minHeight) - { V9[y][x] = CONF_use_minHeight; } + { + V9[y][x] = CONF_use_minHeight; + } if (minHeight < CONF_use_minHeight) - { minHeight = CONF_use_minHeight; } + { + minHeight = CONF_use_minHeight; + } if (maxHeight < CONF_use_minHeight) - { maxHeight = CONF_use_minHeight; } + { + maxHeight = CONF_use_minHeight; + } } map.heightMapOffset = map.areaMapOffset + map.areaMapSize; @@ -712,11 +724,15 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 heightHeader.gridMaxHeight = maxHeight; if (maxHeight == minHeight) - { heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT; } + { + heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT; + } // Not need store if flat surface if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_height_delta_limit) - { heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT; } + { + heightHeader.flags |= MAP_HEIGHT_NO_HEIGHT; + } // Try store as packed in uint16 or uint8 values if (!(heightHeader.flags & MAP_HEIGHT_NO_HEIGHT)) @@ -770,12 +786,16 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { adt_MCNK* cell = adt.cells[i][j]; if (!cell) - { continue; } + { + continue; + } adt_MCLQ* liquid = cell->getMCLQ(); int count = 0; if (!liquid || cell->sizeMCLQ <= 8) - { continue; } + { + continue; + } for (int y = 0; y < ADT_CELL_SIZE; y++) { @@ -787,7 +807,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { liquid_show[cy][cx] = true; if (liquid->flags[y][x] & (1 << 7)) - { liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; } + { + liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; + } ++count; } } @@ -811,7 +833,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 } if (!count && liquid_flags[i][j]) - { fprintf(stderr, "Wrong liquid type detected in MCLQ chunk"); } + { + fprintf(stderr, "Wrong liquid type detected in MCLQ chunk"); + } for (int y = 0; y <= ADT_CELL_SIZE; y++) { @@ -835,7 +859,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { adt_liquid_header* h = h2o->getLiquidData(i, j); if (!h) - { continue; } + { + continue; + } int count = 0; uint64 show = h2o->getLiquidShowMap(h); @@ -870,11 +896,15 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { uint8* lm = h2o->getLiquidLightMap(h); if (!lm) - { liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; } + { + liquid_flags[i][j] |= MAP_LIQUID_TYPE_DARK_WATER; + } } if (!count && liquid_flags[i][j]) - { printf("Wrong liquid type detected in MH2O chunk"); } + { + printf("Wrong liquid type detected in MH2O chunk"); + } float* height = h2o->getLiquidHeightMap(h); int pos = 0; @@ -885,7 +915,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { int cx = j * ADT_CELL_SIZE + x + h->xOffset; if (height) - { liquid_height[cy][cx] = height[pos]; } + { + liquid_height[cy][cx] = height[pos]; + } else { liquid_height[cy][cx] = h->heightLevel1; } pos++; @@ -957,29 +989,41 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 liquidHeader.liquidLevel = minHeight; if (maxHeight == minHeight) - { liquidHeader.flags |= MAP_LIQUID_NO_HEIGHT; } + { + liquidHeader.flags |= MAP_LIQUID_NO_HEIGHT; + } // Not need store if flat surface if (CONF_allow_float_to_int && (maxHeight - minHeight) < CONF_flat_liquid_delta_limit) - { liquidHeader.flags |= MAP_LIQUID_NO_HEIGHT; } + { + liquidHeader.flags |= MAP_LIQUID_NO_HEIGHT; + } if (!fullType) - { liquidHeader.flags |= MAP_LIQUID_NO_TYPE; } + { + liquidHeader.flags |= MAP_LIQUID_NO_TYPE; + } if (liquidHeader.flags & MAP_LIQUID_NO_TYPE) - { liquidHeader.liquidType = type; } + { + liquidHeader.liquidType = type; + } else { map.liquidMapSize += sizeof(liquid_entry) + sizeof(liquid_flags); } if (!(liquidHeader.flags & MAP_LIQUID_NO_HEIGHT)) - { map.liquidMapSize += sizeof(float) * liquidHeader.width * liquidHeader.height; } + { + map.liquidMapSize += sizeof(float) * liquidHeader.width * liquidHeader.height; + } } // map hole info uint16 holes[ADT_CELLS_PER_GRID][ADT_CELLS_PER_GRID]; if (map.liquidMapOffset) - { map.holesOffset = map.liquidMapOffset + map.liquidMapSize; } + { + map.holesOffset = map.liquidMapOffset + map.liquidMapSize; + } else { map.holesOffset = map.heightMapOffset + map.heightMapSize; } @@ -992,7 +1036,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 { adt_MCNK* cell = adt.cells[i][j]; if (!cell) - { continue; } + { + continue; + } holes[i][j] = cell->holes; } } @@ -1008,7 +1054,9 @@ bool ConvertADT(char* filename, char* filename2, int cell_y, int cell_x, uint32 // Store area data fwrite(&areaHeader, sizeof(areaHeader), 1, output); if (!(areaHeader.flags & MAP_AREA_NO_AREA)) - { fwrite(area_flags, sizeof(area_flags), 1, output); } + { + fwrite(area_flags, sizeof(area_flags), 1, output); + } // Store height data fwrite(&heightHeader, sizeof(heightHeader), 1, output); @@ -1091,7 +1139,9 @@ void ExtractMapsFromMpq(uint32 build, const int locale) for (uint32 x = 0; x < WDT_MAP_SIZE; ++x) { if (!wdt.main->adt_list[y][x].exist) - { continue; } + { + continue; + } sprintf(mpq_filename, "World\\Maps\\%s\\%s_%u_%u.adt", map_ids[z].name, map_ids[z].name, x, y); sprintf(output_filename, "%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x); ConvertADT(mpq_filename, output_filename, y, x, build); @@ -1145,7 +1195,9 @@ void ExtractDBCFiles(int locale, bool basicLocale) filename += (iter->c_str() + strlen("DBFilesClient\\")); if (ExtractFile(iter->c_str(), filename)) - { ++count; } + { + ++count; + } } printf("Extracted %u DBC/DB2 files\n\n", count); } diff --git a/src/tools/Extractor_projects/map-extractor/dbcfile.cpp b/src/tools/Extractor_projects/map-extractor/dbcfile.cpp index 330a48789..d74596ef1 100644 --- a/src/tools/Extractor_projects/map-extractor/dbcfile.cpp +++ b/src/tools/Extractor_projects/map-extractor/dbcfile.cpp @@ -133,7 +133,9 @@ size_t DBCFile::getMaxId() for (size_t i = 0; i < getRecordCount(); ++i) { if (maxId < getRecord(i).getUInt(0)) - { maxId = getRecord(i).getUInt(0); } + { + maxId = getRecord(i).getUInt(0); + } } return maxId; } diff --git a/src/tools/Extractor_projects/vmap-extractor/model.cpp b/src/tools/Extractor_projects/vmap-extractor/model.cpp index f4157a6a6..9877d4894 100644 --- a/src/tools/Extractor_projects/vmap-extractor/model.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/model.cpp @@ -176,7 +176,9 @@ ModelInstance::ModelInstance(MPQFile& f, const char* ModelInstName, uint32 mapID fclose(input); if (nVertices == 0) - { return; } + { + return; + } uint16 adtId = 0;// not used for models uint32 flags = MOD_M2; diff --git a/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp b/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp index d021fe746..264909874 100644 --- a/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/vmapexport.cpp @@ -668,7 +668,9 @@ int main(int argc, char** argv) // Use command line arguments, when some if (!processArgv(argc, argv)) - { return 1; } + { + return 1; + } // some simple check if working dir is dirty else diff --git a/src/tools/Extractor_projects/vmap-extractor/wdtfile.cpp b/src/tools/Extractor_projects/vmap-extractor/wdtfile.cpp index 2f3a4dcc0..ad5c2911c 100644 --- a/src/tools/Extractor_projects/vmap-extractor/wdtfile.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/wdtfile.cpp @@ -133,7 +133,9 @@ WDTFile::~WDTFile(void) ADTFile* WDTFile::GetMap(int x, int z) { if (!(x >= 0 && z >= 0 && x < 64 && z < 64)) - { return NULL; } + { + return NULL; + } char name[512]; diff --git a/src/tools/Extractor_projects/vmap-extractor/wmo.cpp b/src/tools/Extractor_projects/vmap-extractor/wmo.cpp index 3f336c805..dc2388550 100644 --- a/src/tools/Extractor_projects/vmap-extractor/wmo.cpp +++ b/src/tools/Extractor_projects/vmap-extractor/wmo.cpp @@ -395,7 +395,9 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool pPrecis fwrite(VERT, 4, 3, output); for (uint32 i = 0; i < nVertices; ++i) if (IndexRenum[i] >= 0) - { check -= fwrite(MOVT + 3 * i, sizeof(float), 3, output); } + { + check -= fwrite(MOVT + 3 * i, sizeof(float), 3, output); + } assert(check == 0); @@ -412,7 +414,9 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool pPrecis // according to WoW.Dev Wiki: uint32 liquidEntry; if (rootWMO->liquidType & 4) - { liquidEntry = liquidType; } + { + liquidEntry = liquidType; + } else if (liquidType == 15) { liquidEntry = 0; } else @@ -431,11 +435,15 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, WMORoot* rootWMO, bool pPrecis { ++v2; if (v2 >= v1) - { break; } + { + break; + } } if (v2 < v1 && (LiquBytes[v2] & 0xF) != 15) - { liquidEntry = (LiquBytes[v2] & 0xF) + 1; } + { + liquidEntry = (LiquBytes[v2] & 0xF) + 1; + } } } @@ -533,7 +541,9 @@ WMOInstance::WMOInstance(MPQFile& f, const char* WmoInstName, uint32 mapID, uint fclose(input); if (nVertices == 0) - { return; } + { + return; + } float x, z; x = pos.x;