diff --git a/src/bindings/universal/ScriptMgr.cpp b/src/bindings/universal/ScriptMgr.cpp index aef958d20..5e55222d2 100644 --- a/src/bindings/universal/ScriptMgr.cpp +++ b/src/bindings/universal/ScriptMgr.cpp @@ -49,7 +49,7 @@ void ScriptsInit() { nrscripts = GetScriptNames().size(); for (int i = 0; i < MAX_SCRIPTS; ++i) - m_scripts[i]=NULL; + m_scripts[i] = NULL; // -- Inicialize the Scripts to be Added -- AddSC_default(); @@ -78,7 +78,7 @@ bool GossipHello(Player* player, Creature* _Creature) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pGossipHello(player,_Creature); + return tmpscript->pGossipHello(player, _Creature); } MANGOS_DLL_EXPORT @@ -94,9 +94,9 @@ bool GOGossipHello(Player* pPlayer, GameObject* pGo) } MANGOS_DLL_EXPORT -bool GossipSelect(Player* player, Creature* _Creature,uint32 sender, uint32 action) +bool GossipSelect(Player* player, Creature* _Creature, uint32 sender, uint32 action) { - debug_log("DEBUG: Gossip selection, sender: %d, action: %d",sender, action); + debug_log("DEBUG: Gossip selection, sender: %d, action: %d", sender, action); Script* tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pGossipSelect) @@ -104,7 +104,7 @@ bool GossipSelect(Player* player, Creature* _Creature,uint32 sender, uint32 acti player->PlayerTalkClass->ClearMenus(); - return tmpscript->pGossipSelect(player,_Creature,sender,action); + return tmpscript->pGossipSelect(player, _Creature, sender, action); } MANGOS_DLL_EXPORT @@ -124,7 +124,7 @@ bool GOGossipSelect(Player* pPlayer, GameObject* pGo, uint32 sender, uint32 acti MANGOS_DLL_EXPORT bool GossipSelectWithCode(Player* player, Creature* _Creature, uint32 sender, uint32 action, const char* sCode) { - debug_log("DEBUG: Gossip selection, sender: %d, action: %d",sender, action); + debug_log("DEBUG: Gossip selection, sender: %d, action: %d", sender, action); Script* tmpscript = m_scripts[_Creature->GetScriptId()]; if (!tmpscript || !tmpscript->pGossipSelectWithCode) @@ -132,7 +132,7 @@ bool GossipSelectWithCode(Player* player, Creature* _Creature, uint32 sender, ui player->PlayerTalkClass->ClearMenus(); - return tmpscript->pGossipSelectWithCode(player,_Creature,sender,action,sCode); + return tmpscript->pGossipSelectWithCode(player, _Creature, sender, action, sCode); } MANGOS_DLL_EXPORT @@ -158,7 +158,7 @@ bool QuestAccept(Player* player, Creature* _Creature, Quest* _Quest) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pQuestAccept(player,_Creature,_Quest); + return tmpscript->pQuestAccept(player, _Creature, _Quest); } MANGOS_DLL_EXPORT @@ -170,7 +170,7 @@ bool QuestSelect(Player* player, Creature* _Creature, Quest* _Quest) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pQuestSelect(player,_Creature,_Quest); + return tmpscript->pQuestSelect(player, _Creature, _Quest); } MANGOS_DLL_EXPORT @@ -182,7 +182,7 @@ bool QuestComplete(Player* player, Creature* _Creature, Quest* _Quest) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pQuestComplete(player,_Creature,_Quest); + return tmpscript->pQuestComplete(player, _Creature, _Quest); } MANGOS_DLL_EXPORT @@ -194,7 +194,7 @@ bool ChooseReward(Player* player, Creature* _Creature, Quest* _Quest, uint32 opt player->PlayerTalkClass->ClearMenus(); - return tmpscript->pChooseReward(player,_Creature,_Quest,opt); + return tmpscript->pChooseReward(player, _Creature, _Quest, opt); } MANGOS_DLL_EXPORT @@ -206,7 +206,7 @@ uint32 NPCDialogStatus(Player* player, Creature* _Creature) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pNPCDialogStatus(player,_Creature); + return tmpscript->pNPCDialogStatus(player, _Creature); } MANGOS_DLL_EXPORT @@ -218,7 +218,7 @@ uint32 GODialogStatus(Player* player, GameObject* _GO) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pGODialogStatus(player,_GO); + return tmpscript->pGODialogStatus(player, _GO); } MANGOS_DLL_EXPORT @@ -230,7 +230,7 @@ bool ItemHello(Player* player, Item* _Item, Quest* _Quest) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pItemHello(player,_Item,_Quest); + return tmpscript->pItemHello(player, _Item, _Quest); } MANGOS_DLL_EXPORT @@ -242,7 +242,7 @@ bool ItemQuestAccept(Player* player, Item* _Item, Quest* _Quest) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pItemQuestAccept(player,_Item,_Quest); + return tmpscript->pItemQuestAccept(player, _Item, _Quest); } MANGOS_DLL_EXPORT @@ -254,7 +254,7 @@ bool GOHello(Player* player, GameObject* _GO) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pGOHello(player,_GO); + return tmpscript->pGOHello(player, _GO); } MANGOS_DLL_EXPORT @@ -266,7 +266,7 @@ bool GOQuestAccept(Player* player, GameObject* _GO, Quest* _Quest) player->PlayerTalkClass->ClearMenus(); - return tmpscript->pGOQuestAccept(player,_GO,_Quest); + return tmpscript->pGOQuestAccept(player, _GO, _Quest); } MANGOS_DLL_EXPORT @@ -277,7 +277,7 @@ bool GOChooseReward(Player* player, GameObject* _GO, Quest* _Quest, uint32 opt) return false; player->PlayerTalkClass->ClearMenus(); - return tmpscript->pGOChooseReward(player,_GO,_Quest,opt); + return tmpscript->pGOChooseReward(player, _GO, _Quest, opt); } MANGOS_DLL_EXPORT @@ -308,7 +308,7 @@ bool ItemUse(Player* player, Item* _Item, SpellCastTargets const& targets) if (!tmpscript || !tmpscript->pItemUse) return false; - return tmpscript->pItemUse(player,_Item,targets); + return tmpscript->pItemUse(player, _Item, targets); } MANGOS_DLL_EXPORT diff --git a/src/bindings/universal/ScriptMgr.h b/src/bindings/universal/ScriptMgr.h index 97940d307..f4235651a 100644 --- a/src/bindings/universal/ScriptMgr.h +++ b/src/bindings/universal/ScriptMgr.h @@ -96,7 +96,7 @@ struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI // Is unit visible for MoveInLineOfSight bool IsVisible(Unit* who) const { - return !who->HasStealthAura() && m_creature->IsWithinDist(who,VISIBLE_RANGE); + return !who->HasStealthAura() && m_creature->IsWithinDist(who, VISIBLE_RANGE); } // Called at World update tick @@ -113,12 +113,12 @@ struct MANGOS_DLL_DECL ScriptedAI : public CreatureAI // Cast spell void DoCast(Unit* victim, uint32 spelId) { - m_creature->CastSpell(victim,spelId,true); + m_creature->CastSpell(victim, spelId, true); } - void DoCastSpell(Unit* who,SpellEntry* spellInfo) + void DoCastSpell(Unit* who, SpellEntry* spellInfo) { - m_creature->CastSpell(who,spellInfo,true); + m_creature->CastSpell(who, spellInfo, true); } void DoSay(int32 text_id, uint32 language) diff --git a/src/bindings/universal/Scripts/sc_default.cpp b/src/bindings/universal/Scripts/sc_default.cpp index c020e9f77..340890638 100644 --- a/src/bindings/universal/Scripts/sc_default.cpp +++ b/src/bindings/universal/Scripts/sc_default.cpp @@ -98,7 +98,7 @@ void AddSC_default() Script* newscript; newscript = new Script; - newscript->Name="default"; + newscript->Name = "default"; newscript->pGossipHello = &GossipHello_default; newscript->pQuestAccept = &QuestAccept_default; newscript->pGossipSelect = &GossipSelect_default; diff --git a/src/bindings/universal/Scripts/sc_defines.cpp b/src/bindings/universal/Scripts/sc_defines.cpp index acee8cee1..4f50b011d 100644 --- a/src/bindings/universal/Scripts/sc_defines.cpp +++ b/src/bindings/universal/Scripts/sc_defines.cpp @@ -20,7 +20,7 @@ #include "../../../game/Player.h" -uint32 GetSkillLevel(Player* player,uint32 trskill) +uint32 GetSkillLevel(Player* player, uint32 trskill) { // Returns the level of some tradetrskill known by player // Need to add missing spells diff --git a/src/bindings/universal/Scripts/sc_defines.h b/src/bindings/universal/Scripts/sc_defines.h index 9279f5727..c47c78f91 100644 --- a/src/bindings/universal/Scripts/sc_defines.h +++ b/src/bindings/universal/Scripts/sc_defines.h @@ -72,7 +72,7 @@ #define DEFAULT_GOSSIP_MESSAGE 0xffffff -extern uint32 GetSkillLevel(Player* player,uint32 skill); +extern uint32 GetSkillLevel(Player* player, uint32 skill); // Defined functions to use with player. diff --git a/src/framework/Dynamic/ObjectRegistry.h b/src/framework/Dynamic/ObjectRegistry.h index a17bed07d..21192a340 100644 --- a/src/framework/Dynamic/ObjectRegistry.h +++ b/src/framework/Dynamic/ObjectRegistry.h @@ -100,7 +100,7 @@ class MANGOS_DLL_DECL ObjectRegistry ObjectRegistry() {} ~ObjectRegistry() { - for (typename RegistryMapType::iterator iter=i_registeredObjects.begin(); iter != i_registeredObjects.end(); ++iter) + for (typename RegistryMapType::iterator iter = i_registeredObjects.begin(); iter != i_registeredObjects.end(); ++iter) delete iter->second; i_registeredObjects.clear(); } diff --git a/src/framework/GameSystem/GridLoader.h b/src/framework/GameSystem/GridLoader.h index 4a6d61073..7413a821d 100644 --- a/src/framework/GameSystem/GridLoader.h +++ b/src/framework/GameSystem/GridLoader.h @@ -47,7 +47,7 @@ class MANGOS_DLL_DECL GridLoader /** Loads the grid */ template - void Load(Grid& grid, LOADER& loader) + void Load(Grid& grid, LOADER& loader) { loader.Load(grid); } @@ -55,7 +55,7 @@ class MANGOS_DLL_DECL GridLoader /** Stop the grid */ template - void Stop(Grid& grid, STOPER& stoper) + void Stop(Grid& grid, STOPER& stoper) { stoper.Stop(grid); } @@ -63,7 +63,7 @@ class MANGOS_DLL_DECL GridLoader /** Unloads the grid */ template - void Unload(Grid& grid, UNLOADER& unloader) + void Unload(Grid& grid, UNLOADER& unloader) { unloader.Unload(grid); } diff --git a/src/framework/GameSystem/TypeContainerFunctions.h b/src/framework/GameSystem/TypeContainerFunctions.h index 6cd888b24..f7967857f 100644 --- a/src/framework/GameSystem/TypeContainerFunctions.h +++ b/src/framework/GameSystem/TypeContainerFunctions.h @@ -54,7 +54,7 @@ namespace MaNGOS template size_t Count(const ContainerMapList >& elements, SPECIFIC_TYPE* fake) { - return Count(elements._elements,fake); + return Count(elements._elements, fake); } template @@ -89,7 +89,7 @@ namespace MaNGOS template SPECIFIC_TYPE* Insert(ContainerMapList >& elements, SPECIFIC_TYPE* obj) { - SPECIFIC_TYPE* t= Insert(elements._elements, obj); + SPECIFIC_TYPE* t = Insert(elements._elements, obj); return (t != NULL ? t : Insert(elements._TailElements, obj)); } diff --git a/src/framework/GameSystem/TypeContainerFunctionsPtr.h b/src/framework/GameSystem/TypeContainerFunctionsPtr.h index 96cbad7d7..13d75a765 100644 --- a/src/framework/GameSystem/TypeContainerFunctionsPtr.h +++ b/src/framework/GameSystem/TypeContainerFunctionsPtr.h @@ -77,8 +77,8 @@ namespace MaNGOS template CountedPtr& Find(ContainerMapList >& elements, OBJECT_HANDLE hdl, CountedPtr* fake) { - CountedPtr& t = Find(elements._elements, hdl,fake); - return (!t ? Find(elements._TailElements, hdl,fake) : t); + CountedPtr& t = Find(elements._elements, hdl, fake); + return (!t ? Find(elements._TailElements, hdl, fake) : t); } // const find functions @@ -100,9 +100,9 @@ namespace MaNGOS template CountedPtr& Find(const ContainerMapList >& elements, OBJECT_HANDLE hdl, CountedPtr* fake) { - CountedPtr& t = Find(elements._elements, hdl,fake); + CountedPtr& t = Find(elements._elements, hdl, fake); if (!t) - t = Find(elements._TailElement, hdl,fake); + t = Find(elements._TailElement, hdl, fake); return t; } @@ -128,7 +128,7 @@ namespace MaNGOS // Recursion template CountedPtr& Insert(ContainerMapList >& elements, CountedPtr& obj, OBJECT_HANDLE hdl) { - CountedPtr& t= Insert(elements._elements, obj, hdl); + CountedPtr& t = Insert(elements._elements, obj, hdl); return (!t ? Insert(elements._TailElements, obj, hdl) : t); } diff --git a/src/framework/Utilities/ByteConverter.h b/src/framework/Utilities/ByteConverter.h index 1a1bbb2ed..0e1898077 100644 --- a/src/framework/Utilities/ByteConverter.h +++ b/src/framework/Utilities/ByteConverter.h @@ -32,7 +32,7 @@ namespace ByteConverter inline void convert(char* val) { std::swap(*val, *(val + T - 1)); - convert(val + 1); + convert < T - 2 > (val + 1); } template<> inline void convert<0>(char*) {} diff --git a/src/framework/Utilities/LinkedReference/Reference.h b/src/framework/Utilities/LinkedReference/Reference.h index 11859e1bb..96bd7b956 100644 --- a/src/framework/Utilities/LinkedReference/Reference.h +++ b/src/framework/Utilities/LinkedReference/Reference.h @@ -90,15 +90,15 @@ class Reference : public LinkedListElement return iRefTo != NULL; } - Reference* next() { return((Reference*) LinkedListElement::next()); } - Reference const* next() const { return((Reference const*) LinkedListElement::next()); } - Reference* prev() { return((Reference*) LinkedListElement::prev()); } - Reference const* prev() const { return((Reference const*) LinkedListElement::prev()); } + Reference* next() { return((Reference*) LinkedListElement::next()); } + Reference const* next() const { return((Reference const*) LinkedListElement::next()); } + Reference* prev() { return((Reference*) LinkedListElement::prev()); } + Reference const* prev() const { return((Reference const*) LinkedListElement::prev()); } - Reference* nocheck_next() { return((Reference*) LinkedListElement::nocheck_next()); } - Reference const* nocheck_next() const { return((Reference const*) LinkedListElement::nocheck_next()); } - Reference* nocheck_prev() { return((Reference*) LinkedListElement::nocheck_prev()); } - Reference const* nocheck_prev() const { return((Reference const*) LinkedListElement::nocheck_prev()); } + Reference* nocheck_next() { return((Reference*) LinkedListElement::nocheck_next()); } + Reference const* nocheck_next() const { return((Reference const*) LinkedListElement::nocheck_next()); } + Reference* nocheck_prev() { return((Reference*) LinkedListElement::nocheck_prev()); } + Reference const* nocheck_prev() const { return((Reference const*) LinkedListElement::nocheck_prev()); } TO* operator->() const { return iRefTo; } TO* getTarget() const { return iRefTo; } diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp index c3823507e..9f9ec7e7e 100644 --- a/src/game/AccountMgr.cpp +++ b/src/game/AccountMgr.cpp @@ -63,7 +63,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) delete result; // existing characters list - result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%u'",accid); + result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE account='%u'", accid); if (result) { do @@ -82,7 +82,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid) } // table realm specific but common for all characters of account for realm - CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'",accid); + CharacterDatabase.PExecute("DELETE FROM character_tutorial WHERE account = '%u'", accid); LoginDatabase.BeginTransaction(); @@ -190,7 +190,7 @@ uint32 AccountMgr::GetCharactersCount(uint32 acc_id) QueryResult* result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%u'", acc_id); if (result) { - Field* fields=result->Fetch(); + Field* fields = result->Fetch(); uint32 charcount = fields[0].GetUInt32(); delete result; return charcount; @@ -219,15 +219,15 @@ bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) bool AccountMgr::normalizeString(std::string& utf8str) { - wchar_t wstr_buf[MAX_ACCOUNT_STR+1]; + wchar_t wstr_buf[MAX_ACCOUNT_STR + 1]; size_t wstr_len = MAX_ACCOUNT_STR; - if (!Utf8toWStr(utf8str,wstr_buf,wstr_len)) + if (!Utf8toWStr(utf8str, wstr_buf, wstr_len)) return false; - std::transform(&wstr_buf[0], wstr_buf+wstr_len, &wstr_buf[0], wcharToUpperOnlyLatin); + std::transform(&wstr_buf[0], wstr_buf + wstr_len, &wstr_buf[0], wcharToUpperOnlyLatin); - return WStrToUtf8(wstr_buf,wstr_len,utf8str); + return WStrToUtf8(wstr_buf, wstr_len, utf8str); } std::string AccountMgr::CalculateShaPassHash(std::string& name, std::string& password) diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index 20123a54d..c05ab22aa 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -55,14 +55,14 @@ namespace MaNGOS : i_player(pl), i_msgtype(msgtype), i_textId(textId), i_achievementId(ach_id) {} void operator()(WorldPacket& data, int32 loc_idx) { - char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); + char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); data << uint8(i_msgtype); data << uint32(LANG_UNIVERSAL); data << i_player.GetObjectGuid(); data << uint32(5); data << i_player.GetObjectGuid(); - data << uint32(strlen(text)+1); + data << uint32(strlen(text) + 1); data << text; data << uint8(0); data << uint32(i_achievementId); @@ -116,7 +116,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (!creature.id || !ObjectMgr::GetCreatureTemplate(creature.id)) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent creature id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,creature.id); + criteria->ID, criteria->requiredType, requirementType, creature.id); return false; } return true; @@ -124,19 +124,19 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (!classRace.class_id && !classRace.race_id) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_CLASS_RACE (%u) must have not 0 in one from value fields, ignore.", - criteria->ID, criteria->requiredType,requirementType); + criteria->ID, criteria->requiredType, requirementType); return false; } - if (classRace.class_id && ((1 << (classRace.class_id-1)) & CLASSMASK_ALL_PLAYABLE)==0) + if (classRace.class_id && ((1 << (classRace.class_id - 1)) & CLASSMASK_ALL_PLAYABLE) == 0) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent class in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,classRace.class_id); + criteria->ID, criteria->requiredType, requirementType, classRace.class_id); return false; } - if (classRace.race_id && ((1 << (classRace.race_id-1)) & RACEMASK_ALL_PLAYABLE)==0) + if (classRace.race_id && ((1 << (classRace.race_id - 1)) & RACEMASK_ALL_PLAYABLE) == 0) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have nonexistent race in value2 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,classRace.race_id); + criteria->ID, criteria->requiredType, requirementType, classRace.race_id); return false; } return true; @@ -144,7 +144,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (health.percent < 1 || health.percent > 100) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_LESS_HEALTH (%u) have wrong percent value in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,health.percent); + criteria->ID, criteria->requiredType, requirementType, health.percent); return false; } return true; @@ -152,7 +152,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (player_dead.own_team_flag > 1) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD (%u) have wrong boolean value1 (%u).", - criteria->ID, criteria->requiredType,requirementType,player_dead.own_team_flag); + criteria->ID, criteria->requiredType, requirementType, player_dead.own_team_flag); return false; } return true; @@ -163,19 +163,19 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (!spellEntry) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id); + criteria->ID, criteria->requiredType, (requirementType == ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA ? "ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA" : "ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"), requirementType, aura.spell_id); return false; } if (aura.effect_idx >= MAX_EFFECT_INDEX) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell effect index in value2 (%u), ignore.", - criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.effect_idx); + criteria->ID, criteria->requiredType, (requirementType == ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA ? "ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA" : "ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"), requirementType, aura.effect_idx); return false; } if (!spellEntry->EffectApplyAuraName[aura.effect_idx]) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have non-aura spell effect (ID: %u Effect: %u), ignore.", - criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id,aura.effect_idx); + criteria->ID, criteria->requiredType, (requirementType == ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA ? "ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA" : "ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"), requirementType, aura.spell_id, aura.effect_idx); return false; } return true; @@ -184,7 +184,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (!GetAreaEntryByAreaID(area.id)) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA (%u) have wrong area id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,area.id); + criteria->ID, criteria->requiredType, requirementType, area.id); return false; } return true; @@ -192,7 +192,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (level.minlevel > STRONG_MAX_LEVEL) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL (%u) have wrong minlevel in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,level.minlevel); + criteria->ID, criteria->requiredType, requirementType, level.minlevel); return false; } return true; @@ -200,7 +200,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (gender.gender > GENDER_NONE) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER (%u) have wrong gender in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,gender.gender); + criteria->ID, criteria->requiredType, requirementType, gender.gender); return false; } return true; @@ -208,7 +208,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (difficulty.difficulty >= MAX_DIFFICULTY) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY (%u) have wrong difficulty in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,difficulty.difficulty); + criteria->ID, criteria->requiredType, requirementType, difficulty.difficulty); return false; } return true; @@ -216,7 +216,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (map_players.maxcount <= 0) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT (%u) have wrong max players count in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,map_players.maxcount); + criteria->ID, criteria->requiredType, requirementType, map_players.maxcount); return false; } return true; @@ -224,7 +224,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (team.team != ALLIANCE && team.team != HORDE) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM (%u) have unknown team in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,team.team); + criteria->ID, criteria->requiredType, requirementType, team.team); return false; } return true; @@ -232,7 +232,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (drunk.state >= MAX_DRUNKEN) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK (%u) have unknown drunken state in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,drunk.state); + criteria->ID, criteria->requiredType, requirementType, drunk.state); return false; } return true; @@ -240,7 +240,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (!sHolidaysStore.LookupEntry(holiday.id)) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY (%u) have unknown holiday in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,holiday.id); + criteria->ID, criteria->requiredType, requirementType, holiday.id); return false; } return true; @@ -248,7 +248,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri if (equipped_item.item_quality >= MAX_ITEM_QUALITY) { sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_EQUIPPED_ITEM_LVL (%u) have unknown quality state in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,requirementType,equipped_item.item_quality); + criteria->ID, criteria->requiredType, requirementType, equipped_item.item_quality); return false; } return true; @@ -264,7 +264,7 @@ bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* cri return true; } default: - sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) have data for not supported data type (%u), ignore.", criteria->ID, criteria->requiredType,requirementType); + sLog.outErrorDb("Table `achievement_criteria_requirement` (Entry: %u Type: %u) have data for not supported data type (%u), ignore.", criteria->ID, criteria->requiredType, requirementType); return false; } } @@ -276,11 +276,11 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou case ACHIEVEMENT_CRITERIA_REQUIRE_NONE: return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE: - if (!target || target->GetTypeId()!=TYPEID_UNIT) + if (!target || target->GetTypeId() != TYPEID_UNIT) return false; return target->GetEntry() == creature.id; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE: - if (!target || target->GetTypeId()!=TYPEID_PLAYER) + if (!target || target->GetTypeId() != TYPEID_PLAYER) return false; if (classRace.class_id && classRace.class_id != ((Player*)target)->getClass()) return false; @@ -288,24 +288,24 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou return false; return true; case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH: - if (!target || target->GetTypeId()!=TYPEID_PLAYER) + if (!target || target->GetTypeId() != TYPEID_PLAYER) return false; - return target->GetHealth()*100 <= health.percent*target->GetMaxHealth(); + return target->GetHealth() * 100 <= health.percent * target->GetMaxHealth(); case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD: if (!target || target->GetTypeId() != TYPEID_PLAYER || target->isAlive() || ((Player*)target)->GetDeathTimer() == 0) return false; // flag set == must be same team, not set == different team return (((Player*)target)->GetTeam() == source->GetTeam()) == (player_dead.own_team_flag != 0); case ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA: - return source->HasAura(aura.spell_id,SpellEffectIndex(aura.effect_idx)); + return source->HasAura(aura.spell_id, SpellEffectIndex(aura.effect_idx)); case ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA: { - uint32 zone_id,area_id; - source->GetZoneAndAreaId(zone_id,area_id); - return area.id==zone_id || area.id==area_id; + uint32 zone_id, area_id; + source->GetZoneAndAreaId(zone_id, area_id); + return area.id == zone_id || area.id == area_id; } case ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA: - return target && target->HasAura(aura.spell_id,SpellEffectIndex(aura.effect_idx)); + return target && target->HasAura(aura.spell_id, SpellEffectIndex(aura.effect_idx)); case ACHIEVEMENT_CRITERIA_REQUIRE_VALUE: return miscvalue1 >= value.minvalue; case ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL: @@ -319,7 +319,7 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou case ACHIEVEMENT_CRITERIA_REQUIRE_DISABLED: return false; // always fail case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY: - return source->GetMap()->GetSpawnMode()==difficulty.difficulty; + return source->GetMap()->GetSpawnMode() == difficulty.difficulty; case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT: return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount; case ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM: @@ -335,7 +335,7 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou BattleGround* bg = source->GetBattleGround(); if (!bg) return false; - return bg->IsTeamScoreInRange(source->GetTeam()==ALLIANCE ? HORDE : ALLIANCE,bg_loss_team_score.min_score,bg_loss_team_score.max_score); + return bg->IsTeamScoreInRange(source->GetTeam() == ALLIANCE ? HORDE : ALLIANCE, bg_loss_team_score.min_score, bg_loss_team_score.max_score); } case ACHIEVEMENT_CRITERIA_REQUIRE_INSTANCE_SCRIPT: { @@ -352,7 +352,7 @@ bool AchievementCriteriaRequirement::Meets(uint32 criteria_id, Player const* sou } case ACHIEVEMENT_CRITERIA_REQUIRE_S_EQUIPPED_ITEM_LVL: { - Item* item = source->GetItemByPos(INVENTORY_SLOT_BAG_0,miscvalue1); + Item* item = source->GetItemByPos(INVENTORY_SLOT_BAG_0, miscvalue1); if (!item) return false; ItemPrototype const* proto = item->GetProto(); @@ -403,16 +403,16 @@ AchievementMgr::~AchievementMgr() void AchievementMgr::Reset() { - for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) + for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter != m_completedAchievements.end(); ++iter) { - WorldPacket data(SMSG_ACHIEVEMENT_DELETED,4); + WorldPacket data(SMSG_ACHIEVEMENT_DELETED, 4); data << uint32(iter->first); m_player->SendDirectMessage(&data); } - for (CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) + for (CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter != m_criteriaProgress.end(); ++iter) { - WorldPacket data(SMSG_CRITERIA_DELETED,4); + WorldPacket data(SMSG_CRITERIA_DELETED, 4); data << uint32(iter->first); m_player->SendDirectMessage(&data); } @@ -433,7 +433,7 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin return; AchievementCriteriaEntryList const& achievementCriteriaList = sAchievementMgr.GetAchievementCriteriaByType(type); - for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i!=achievementCriteriaList.end(); ++i) + for (AchievementCriteriaEntryList::const_iterator i = achievementCriteriaList.begin(); i != achievementCriteriaList.end(); ++i) { AchievementCriteriaEntry const* achievementCriteria = (*i); @@ -441,7 +441,7 @@ void AchievementMgr::ResetAchievementCriteria(AchievementCriteriaTypes type, uin // Checked in LoadAchievementCriteriaList // don't update already completed criteria - if (IsCompletedCriteria(achievementCriteria,achievement)) + if (IsCompletedCriteria(achievementCriteria, achievement)) continue; switch (type) @@ -482,7 +482,7 @@ void AchievementMgr::SaveToDB() if (!m_completedAchievements.empty()) { //delete existing achievements in the loop - for (CompletedAchievementMap::iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) + for (CompletedAchievementMap::iterator iter = m_completedAchievements.begin(); iter != m_completedAchievements.end(); ++iter) { if (!iter->second.changed) continue; @@ -501,7 +501,7 @@ void AchievementMgr::SaveToDB() if (!m_criteriaProgress.empty()) { //insert achievements - for (CriteriaProgressMap::iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) + for (CriteriaProgressMap::iterator iter = m_criteriaProgress.begin(); iter != m_criteriaProgress.end(); ++iter) { if (!iter->second.changed) continue; @@ -568,8 +568,8 @@ void AchievementMgr::LoadFromDB(QueryResult* achievementResult, QueryResult* cri if (!criteria) { // we will remove nonexistent criteria for all characters - sLog.outError("Nonexistent achievement criteria %u data removed from table `character_achievement_progress`.",id); - CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE criteria = %u",id); + sLog.outError("Nonexistent achievement criteria %u data removed from table `character_achievement_progress`.", id); + CharacterDatabase.PExecute("DELETE FROM character_achievement_progress WHERE criteria = %u", id); continue; } @@ -621,15 +621,15 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) if (Guild* guild = sGuildMgr.GetGuildById(GetPlayer()->GetGuildId())) { - MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_GUILD_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED,achievement->ID); + MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_GUILD_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED, achievement->ID); MaNGOS::LocalizedPacketDo say_do(say_builder); - guild->BroadcastWorker(say_do,GetPlayer()); + guild->BroadcastWorker(say_do, GetPlayer()); } - if (achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL|ACHIEVEMENT_FLAG_REALM_FIRST_REACH)) + if (achievement->flags & (ACHIEVEMENT_FLAG_REALM_FIRST_KILL | ACHIEVEMENT_FLAG_REALM_FIRST_REACH)) { // broadcast realm first reached - WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetPlayer()->GetName())+1+8+4+4); + WorldPacket data(SMSG_SERVER_FIRST_ACHIEVEMENT, strlen(GetPlayer()->GetName()) + 1 + 8 + 4 + 4); data << GetPlayer()->GetName(); data << GetPlayer()->GetObjectGuid(); data << uint32(achievement->ID); @@ -639,14 +639,14 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) // if player is in world he can tell his friends about new achievement else if (GetPlayer()->IsInWorld()) { - MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED,achievement->ID); + MaNGOS::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED, achievement->ID); MaNGOS::LocalizedPacketDo say_do(say_builder); - MaNGOS::CameraDistWorker > say_worker(GetPlayer(),sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY),say_do); + MaNGOS::CameraDistWorker > say_worker(GetPlayer(), sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), say_do); Cell::VisitWorldObjects(GetPlayer(), say_worker, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY)); } - WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8+4+8); + WorldPacket data(SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 8); data << GetPlayer()->GetPackGUID(); data << uint32(achievement->ID); data << uint32(secsToTimeBitFields(time(NULL))); @@ -656,7 +656,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement) void AchievementMgr::SendCriteriaUpdate(uint32 id, CriteriaProgress const* progress) { - WorldPacket data(SMSG_CRITERIA_UPDATE, 8+4+8); + WorldPacket data(SMSG_CRITERIA_UPDATE, 8 + 4 + 8); data << uint32(id); time_t now = time(NULL); @@ -677,7 +677,7 @@ void AchievementMgr::SendCriteriaUpdate(uint32 id, CriteriaProgress const* progr void AchievementMgr::CheckAllAchievementCriteria() { // suppress sending packets - for (uint32 i=0; iMeets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(), unit)) continue; } // some hardcoded requirements @@ -946,7 +946,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(), unit)) continue; change = miscvalue2; @@ -1016,8 +1016,8 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui } case ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST_COUNT: { - uint32 counter =0; - for (QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr!=GetPlayer()->getQuestStatusMap().end(); ++itr) + uint32 counter = 0; + for (QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr != GetPlayer()->getQuestStatusMap().end(); ++itr) if (itr->second.m_rewarded) counter++; change = counter; @@ -1030,8 +1030,8 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (miscvalue1 && miscvalue1 != achievementCriteria->complete_quests_in_zone.zoneID) continue; - uint32 counter =0; - for (QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr!=GetPlayer()->getQuestStatusMap().end(); ++itr) + uint32 counter = 0; + for (QuestStatusMap::const_iterator itr = GetPlayer()->getQuestStatusMap().begin(); itr != GetPlayer()->getQuestStatusMap().end(); ++itr) { Quest const* quest = sObjectMgr.GetQuestTemplate(itr->first); if (itr->second.m_rewarded && quest->GetZoneOrSort() >= 0 && uint32(quest->GetZoneOrSort()) == achievementCriteria->complete_quests_in_zone.zoneID) @@ -1106,7 +1106,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (!achievIdForDungeon[j][2]) break; // for } - else if (GetPlayer()->GetDungeonDifficulty()==DUNGEON_DIFFICULTY_NORMAL) + else if (GetPlayer()->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL) { // dungeon in normal mode accepted if (!achievIdForDungeon[j][1]) @@ -1150,7 +1150,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // if team check required: must kill by opposition faction - if (achievement->ID==318 && miscvalue2==uint32(GetPlayer()->GetTeam())) + if (achievement->ID == 318 && miscvalue2 == uint32(GetPlayer()->GetTeam())) continue; change = 1; @@ -1164,7 +1164,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(), unit)) continue; // miscvalue1 is the ingame fallheight*100 as stored in dbc @@ -1208,7 +1208,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(), unit)) continue; break; } @@ -1235,7 +1235,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (!data) continue; - if (!data->Meets(GetPlayer(),unit)) + if (!data->Meets(GetPlayer(), unit)) continue; change = 1; @@ -1253,7 +1253,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (!data) continue; - if (!data->Meets(GetPlayer(),unit)) + if (!data->Meets(GetPlayer(), unit)) continue; change = 1; @@ -1261,7 +1261,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui break; } case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL: - if (miscvalue1 && miscvalue1!=achievementCriteria->learn_spell.spellID) + if (miscvalue1 && miscvalue1 != achievementCriteria->learn_spell.spellID) continue; if (!GetPlayer()->HasSpell(achievementCriteria->learn_spell.spellID)) @@ -1280,11 +1280,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // zone specific - if (achievementCriteria->loot_type.lootTypeCount==1) + if (achievementCriteria->loot_type.lootTypeCount == 1) { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(), unit)) continue; } @@ -1305,11 +1305,11 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // additional requirements - if (achievementCriteria->win_rated_arena.flag==ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) + if (achievementCriteria->win_rated_arena.flag == ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(),unit,miscvalue1)) + if (!data || !data->Meets(GetPlayer(), unit, miscvalue1)) { // reset the progress as we have a win without the requirement. SetCriteriaProgress(achievementCriteria, achievement, 0, PROGRESS_SET); @@ -1362,7 +1362,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; uint32 playerIndexOffset = uint32(exploreFlag) / 32; - uint32 mask = 1<< (uint32(exploreFlag) % 32); + uint32 mask = 1 << (uint32(exploreFlag) % 32); if (GetPlayer()->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + playerIndexOffset) & mask) { @@ -1416,12 +1416,12 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui // miscvalue1 = equip_slot+1 (for avoid use 0) if (!miscvalue1) continue; - uint32 item_slot = miscvalue1-1; + uint32 item_slot = miscvalue1 - 1; if (item_slot != achievementCriteria->equip_epic_item.itemSlot) continue; // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(),unit,item_slot)) + if (!data || !data->Meets(GetPlayer(), unit, item_slot)) continue; change = 1; progressType = PROGRESS_HIGHEST; @@ -1442,7 +1442,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (achievementCriteria->ID == 2412 || achievementCriteria->ID == 2358) requiredItemLevel = 185; - if (!pProto || pProto->ItemLevel ItemLevel < requiredItemLevel) continue; change = 1; progressType = PROGRESS_ACCUMULATE; @@ -1459,7 +1459,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui { // those requirements couldn't be found in the dbc AchievementCriteriaRequirementSet const* data = sAchievementMgr.GetCriteriaRequirementSet(achievementCriteria); - if (!data || !data->Meets(GetPlayer(),unit)) + if (!data || !data->Meets(GetPlayer(), unit)) continue; } @@ -1479,7 +1479,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // map specific case (BG in fact) expected player targeted damage/heal - if (!unit || unit->GetTypeId()!=TYPEID_PLAYER) + if (!unit || unit->GetTypeId() != TYPEID_PLAYER) continue; } @@ -1518,7 +1518,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (!data) continue; - if (!data->Meets(GetPlayer(),unit)) + if (!data->Meets(GetPlayer(), unit)) continue; change = 1; @@ -1567,7 +1567,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (!data) continue; - if (!data->Meets(GetPlayer(),unit)) + if (!data->Meets(GetPlayer(), unit)) continue; } @@ -1920,7 +1920,7 @@ void AchievementMgr::CompletedCriteriaFor(AchievementEntry const* achievement) return; // already completed and stored - if (m_completedAchievements.find(achievement->ID)!=m_completedAchievements.end()) + if (m_completedAchievements.find(achievement->ID) != m_completedAchievements.end()) return; if (IsCompletedAchievement(achievement)) @@ -2088,7 +2088,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* criteri { if (progress->counter < max_value) { - WorldPacket data(SMSG_CRITERIA_DELETED,4); + WorldPacket data(SMSG_CRITERIA_DELETED, 4); data << uint32(criteria->ID); m_player->SendDirectMessage(&data); } @@ -2108,7 +2108,7 @@ void AchievementMgr::SetCriteriaProgress(AchievementCriteriaEntry const* criteri void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) { DETAIL_LOG("AchievementMgr::CompletedAchievement(%u)", achievement->ID); - if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || m_completedAchievements.find(achievement->ID)!=m_completedAchievements.end()) + if (achievement->flags & ACHIEVEMENT_FLAG_COUNTER || m_completedAchievements.find(achievement->ID) != m_completedAchievements.end()) return; SendAchievementEarned(achievement); @@ -2183,7 +2183,7 @@ void AchievementMgr::IncompletedAchievement(AchievementEntry const* achievement) if (itr == m_completedAchievements.end()) return; - WorldPacket data(SMSG_ACHIEVEMENT_DELETED,4); + WorldPacket data(SMSG_ACHIEVEMENT_DELETED, 4); data << uint32(achievement->ID); m_player->SendDirectMessage(&data); @@ -2213,7 +2213,7 @@ void AchievementMgr::IncompletedAchievement(AchievementEntry const* achievement) void AchievementMgr::SendAllAchievementData() { // since we don't know the exact size of the packed GUIDs this is just an approximation - WorldPacket data(SMSG_ALL_ACHIEVEMENT_DATA, 4*2+m_completedAchievements.size()*4*2+m_completedAchievements.size()*7*4); + WorldPacket data(SMSG_ALL_ACHIEVEMENT_DATA, 4 * 2 + m_completedAchievements.size() * 4 * 2 + m_completedAchievements.size() * 7 * 4); BuildAllDataPacket(&data); GetPlayer()->GetSession()->SendPacket(&data); } @@ -2221,7 +2221,7 @@ void AchievementMgr::SendAllAchievementData() void AchievementMgr::SendRespondInspectAchievements(Player* player) { // since we don't know the exact size of the packed GUIDs this is just an approximation - WorldPacket data(SMSG_RESPOND_INSPECT_ACHIEVEMENTS, 4+4*2+m_completedAchievements.size()*4*2+m_completedAchievements.size()*7*4); + WorldPacket data(SMSG_RESPOND_INSPECT_ACHIEVEMENTS, 4 + 4 * 2 + m_completedAchievements.size() * 4 * 2 + m_completedAchievements.size() * 7 * 4); data << GetPlayer()->GetPackGUID(); BuildAllDataPacket(&data); player->GetSession()->SendPacket(&data); @@ -2232,7 +2232,7 @@ void AchievementMgr::SendRespondInspectAchievements(Player* player) */ void AchievementMgr::BuildAllDataPacket(WorldPacket* data) { - for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter!=m_completedAchievements.end(); ++iter) + for (CompletedAchievementMap::const_iterator iter = m_completedAchievements.begin(); iter != m_completedAchievements.end(); ++iter) { *data << uint32(iter->first); *data << uint32(secsToTimeBitFields(iter->second.date)); @@ -2240,7 +2240,7 @@ void AchievementMgr::BuildAllDataPacket(WorldPacket* data) *data << int32(-1); time_t now = time(NULL); - for (CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter!=m_criteriaProgress.end(); ++iter) + for (CriteriaProgressMap::const_iterator iter = m_criteriaProgress.begin(); iter != m_criteriaProgress.end(); ++iter) { *data << uint32(iter->first); data->appendPackGUID(iter->second.counter); @@ -2295,7 +2295,7 @@ AchievementRewardLocale const* AchievementGlobalMgr::GetAchievementRewardLocale( AchievementCriteriaRequirementSet const* AchievementGlobalMgr::GetCriteriaRequirementSet(AchievementCriteriaEntry const* achievementCriteria) { AchievementCriteriaRequirementMap::const_iterator iter = m_criteriaRequirementMap.find(achievementCriteria->ID); - return iter!=m_criteriaRequirementMap.end() ? &iter->second : NULL; + return iter != m_criteriaRequirementMap.end() ? &iter->second : NULL; } bool AchievementGlobalMgr::IsRealmCompleted(AchievementEntry const* achievement) const @@ -2310,7 +2310,7 @@ void AchievementGlobalMgr::SetRealmCompleted(AchievementEntry const* achievement void AchievementGlobalMgr::LoadAchievementCriteriaList() { - if (sAchievementCriteriaStore.GetNumRows()==0) + if (sAchievementCriteriaStore.GetNumRows() == 0) { BarGoLink bar(1); bar.step(); @@ -2352,7 +2352,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaList() void AchievementGlobalMgr::LoadAchievementReferenceList() { - if (sAchievementStore.GetNumRows()==0) + if (sAchievementStore.GetNumRows() == 0) { BarGoLink bar(1); bar.step(); @@ -2422,7 +2422,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() continue; } - AchievementCriteriaRequirement data(fields[1].GetUInt32(),fields[2].GetUInt32(),fields[3].GetUInt32()); + AchievementCriteriaRequirement data(fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetUInt32()); if (!data.IsValid(criteria)) { @@ -2487,25 +2487,25 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL: // any cases break; case ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA: // need skip generic cases - if (criteria->win_rated_arena.flag!=ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) + if (criteria->win_rated_arena.flag != ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) continue; break; case ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM: // any cases break; case ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE: // need skip generic cases - if (criteria->do_emote.count==0) + if (criteria->do_emote.count == 0) continue; break; case ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL:// any cases break; case ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL: // skip statistics - if (criteria->win_duel.duelCount==0) + if (criteria->win_duel.duelCount == 0) continue; break; case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2: // any cases break; case ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE: // need skip generic cases - if (criteria->loot_type.lootTypeCount!=1) + if (criteria->loot_type.lootTypeCount != 1) continue; break; default: // type not use DB data, ignore @@ -2517,7 +2517,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() } sLog.outString(); - sLog.outString(">> Loaded %u additional achievement criteria data (%u disabled).",count,disabled_count); + sLog.outString(">> Loaded %u additional achievement criteria data (%u disabled).", count, disabled_count); } void AchievementGlobalMgr::LoadCompletedAchievements() @@ -2544,8 +2544,8 @@ void AchievementGlobalMgr::LoadCompletedAchievements() if (!sAchievementStore.LookupEntry(achievement_id)) { // we will remove nonexistent achievement for all characters - sLog.outError("Nonexistent achievement %u data removed from table `character_achievement`.",achievement_id); - CharacterDatabase.PExecute("DELETE FROM character_achievement WHERE achievement = %u",achievement_id); + sLog.outError("Nonexistent achievement %u data removed from table `character_achievement`.", achievement_id); + CharacterDatabase.PExecute("DELETE FROM character_achievement WHERE achievement = %u", achievement_id); continue; } @@ -2556,7 +2556,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements() delete result; sLog.outString(); - sLog.outString(">> Loaded %lu realm completed achievements.",(unsigned long)m_allCompletedAchievements.size()); + sLog.outString(">> Loaded %lu realm completed achievements.", (unsigned long)m_allCompletedAchievements.size()); } void AchievementGlobalMgr::LoadRewards() @@ -2620,7 +2620,7 @@ void AchievementGlobalMgr::LoadRewards() if (dup) continue; - if ((reward.titleId[0]==0)!=(reward.titleId[1]==0)) + if ((reward.titleId[0] == 0) != (reward.titleId[1] == 0)) sLog.outErrorDb("Table `achievement_reward` (Entry: %u) has title (A: %u H: %u) only for one from teams.", entry, reward.titleId[0], reward.titleId[1]); // must be title or mail at least @@ -2718,7 +2718,7 @@ void AchievementGlobalMgr::LoadRewardLocales() uint32 entry = fields[0].GetUInt32(); - if (m_achievementRewards.find(entry)==m_achievementRewards.end()) + if (m_achievementRewards.find(entry) == m_achievementRewards.end()) { sLog.outErrorDb("Table `locales_achievement_reward` (Entry: %u) has locale strings for nonexistent achievement reward .", entry); continue; @@ -2749,26 +2749,26 @@ void AchievementGlobalMgr::LoadRewardLocales() for (int i = 1; i < MAX_LOCALE; ++i) { - std::string str = fields[2+2*(i-1)].GetCppString(); + std::string str = fields[2 + 2 * (i - 1)].GetCppString(); if (!str.empty()) { int idx = sObjectMgr.GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if (data.subject.size() <= size_t(idx)) - data.subject.resize(idx+1); + data.subject.resize(idx + 1); data.subject[idx] = str; } } - str = fields[2+2*(i-1)+1].GetCppString(); + str = fields[2 + 2 * (i - 1) + 1].GetCppString(); if (!str.empty()) { int idx = sObjectMgr.GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if (data.text.size() <= size_t(idx)) - data.text.resize(idx+1); + data.text.resize(idx + 1); data.text[idx] = str; } diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h index b30f1bb4a..1621d98cf 100644 --- a/src/game/AchievementMgr.h +++ b/src/game/AchievementMgr.h @@ -34,9 +34,9 @@ struct AchievementCriteriaEntry; typedef std::list AchievementCriteriaEntryList; typedef std::list AchievementEntryList; -typedef std::map AchievementCriteriaListByAchievement; -typedef std::map AchievementListByReferencedId; -typedef std::map AchievementCriteriaFailTimeMap; +typedef std::map AchievementCriteriaListByAchievement; +typedef std::map AchievementListByReferencedId; +typedef std::map AchievementCriteriaFailTimeMap; struct CriteriaProgress { @@ -52,7 +52,7 @@ enum AchievementCriteriaRequirementType ACHIEVEMENT_CRITERIA_REQUIRE_NONE = 0, // 0 0 ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE = 1, // creature_id 0 ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE = 2, // class_id race_id - ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH= 3, // health_percent 0 + ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH = 3, // health_percent 0 ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD = 4, // own_team 0 not corpse (not released body), own_team==false if enemy team expected ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA = 5, // spell_id effect_idx ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA = 6, // area id 0 @@ -216,7 +216,7 @@ struct AchievementCriteriaRequirementSet Storage storage; }; -typedef std::map AchievementCriteriaRequirementMap; +typedef std::map AchievementCriteriaRequirementMap; struct AchievementReward { @@ -264,10 +264,10 @@ class AchievementMgr static void DeleteFromDB(ObjectGuid guid); void LoadFromDB(QueryResult* achievementResult, QueryResult* criteriaResult); void SaveToDB(); - void ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0); + void ResetAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0); void StartTimedAchievementCriteria(AchievementCriteriaTypes type, uint32 timedRequirementId, time_t startTime = 0); void DoFailedTimedAchievementCriterias(); - void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit* unit=NULL, uint32 time=0); + void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, Unit* unit = NULL, uint32 time = 0); void CheckAllAchievementCriteria(); void SendAllAchievementData(); void SendRespondInspectAchievements(Player* player); diff --git a/src/game/AggressorAI.cpp b/src/game/AggressorAI.cpp index d7d7f0523..59506cac1 100644 --- a/src/game/AggressorAI.cpp +++ b/src/game/AggressorAI.cpp @@ -134,8 +134,8 @@ AggressorAI::UpdateAI(const uint32 /*diff*/) bool AggressorAI::IsVisible(Unit* pl) const { - return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER)) - && pl->isVisibleForOrDetect(m_creature,m_creature,true); + return m_creature->IsWithinDist(pl, sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER)) + && pl->isVisibleForOrDetect(m_creature, m_creature, true); } void @@ -144,7 +144,7 @@ AggressorAI::AttackStart(Unit* u) if (!u) return; - if (m_creature->Attack(u,true)) + if (m_creature->Attack(u, true)) { i_victimGuid = u->GetObjectGuid(); diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 88303fd49..550a93119 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -388,7 +388,7 @@ void ArenaTeam::Roster(WorldSession* session) void ArenaTeam::Query(WorldSession* session) { - WorldPacket data(SMSG_ARENA_TEAM_QUERY_RESPONSE, 4*7+GetName().size()+1); + WorldPacket data(SMSG_ARENA_TEAM_QUERY_RESPONSE, 4 * 7 + GetName().size() + 1); data << uint32(GetId()); // team id data << GetName(); // team name data << uint32(GetType()); // arena team type (2=2x2, 3=3x3 or 5=5x5) @@ -403,7 +403,7 @@ void ArenaTeam::Query(WorldSession* session) void ArenaTeam::Stats(WorldSession* session) { - WorldPacket data(SMSG_ARENA_TEAM_STATS, 4*7); + WorldPacket data(SMSG_ARENA_TEAM_STATS, 4 * 7); data << uint32(GetId()); // team id data << uint32(m_stats.rating); // rating data << uint32(m_stats.games_week); // games this week @@ -432,7 +432,7 @@ void ArenaTeam::InspectStats(WorldSession* session, ObjectGuid guid) if (!member) return; - WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8+1+4*6); + WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8 + 1 + 4 * 6); data << guid; // player guid data << uint8(GetSlot()); // slot (0...2) data << uint32(GetId()); // arena team id @@ -503,7 +503,7 @@ void ArenaTeam::BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, char cons { uint8 strCount = !str1 ? 0 : (!str2 ? 1 : (!str3 ? 2 : 3)); - WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1 + 1 + 1*strCount + (!guid ? 0 : 8)); + WorldPacket data(SMSG_ARENA_TEAM_EVENT, 1 + 1 + 1 * strCount + (!guid ? 0 : 8)); data << uint8(event); data << uint8(strCount); @@ -587,7 +587,7 @@ float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating) if (sWorld.getConfig(CONFIG_UINT32_ARENA_SEASON_ID) >= 6) if (enemy_rating < 1000) enemy_rating = 1000; - return 1.0f/(1.0f+exp(log(10.0f)*(float)((float)enemy_rating - (float)own_rating)/400.0f)); + return 1.0f / (1.0f + exp(log(10.0f) * (float)((float)enemy_rating - (float)own_rating) / 400.0f)); } void ArenaTeam::FinishGame(int32 mod) @@ -616,7 +616,7 @@ int32 ArenaTeam::WonAgainst(uint32 againstRating) float chance = GetChanceAgainst(m_stats.rating, againstRating); float K = (m_stats.rating < 1000) ? 48.0f : 32.0f; // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000) - int32 mod = (int32)floor(K* (1.0f - chance)); + int32 mod = (int32)floor(K * (1.0f - chance)); // modify the team stats accordingly FinishGame(mod); m_stats.wins_week += 1; @@ -700,7 +700,7 @@ void ArenaTeam::MemberWon(Player* plr, uint32 againstRating) float chance = GetChanceAgainst(itr->personal_rating, againstRating); float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f; // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000) - int32 mod = (int32)floor(K* (1.0f - chance)); + int32 mod = (int32)floor(K * (1.0f - chance)); itr->ModifyPersonalRating(plr, mod, GetSlot()); // update personal stats itr->games_week += 1; diff --git a/src/game/ArenaTeamHandler.cpp b/src/game/ArenaTeamHandler.cpp index 9f6e8f265..9f822bc06 100644 --- a/src/game/ArenaTeamHandler.cpp +++ b/src/game/ArenaTeamHandler.cpp @@ -142,7 +142,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket& recv_data) player->SetArenaTeamIdInvited(arenateam->GetId()); - WorldPacket data(SMSG_ARENA_TEAM_INVITE, (8+10)); + WorldPacket data(SMSG_ARENA_TEAM_INVITE, (8 + 10)); data << GetPlayer()->GetName(); data << arenateam->GetName(); player->GetSession()->SendPacket(&data); @@ -176,7 +176,7 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket& /*recv_data*/) if (!at->AddMember(_player->GetObjectGuid())) { // arena team not found - SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S,"","",ERR_ARENA_TEAM_INTERNAL); + SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_INTERNAL); return; } @@ -329,7 +329,7 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket& recv_data) void WorldSession::SendArenaTeamCommandResult(uint32 team_action, const std::string& team, const std::string& player, uint32 error_id) { - WorldPacket data(SMSG_ARENA_TEAM_COMMAND_RESULT, 4+team.length()+1+player.length()+1+4); + WorldPacket data(SMSG_ARENA_TEAM_COMMAND_RESULT, 4 + team.length() + 1 + player.length() + 1 + 4); data << uint32(team_action); data << team; data << player; @@ -339,7 +339,7 @@ void WorldSession::SendArenaTeamCommandResult(uint32 team_action, const std::str void WorldSession::SendNotInArenaTeamPacket(uint8 type) { - WorldPacket data(SMSG_ARENA_ERROR, 4+1); // 886 - You are not in a %uv%u arena team + WorldPacket data(SMSG_ARENA_ERROR, 4 + 1); // 886 - You are not in a %uv%u arena team uint32 unk = 0; data << uint32(unk); // unk(0) if (!unk) diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/game/AuctionHouseBot/AuctionHouseBot.cpp index 315d046db..0f87e56f6 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -122,23 +122,23 @@ class AHB_Seller_Config void SetMaxTime(uint32 value) { m_maxTime = value; } uint32 GetMaxTime() const { return m_maxTime; } // Data access classified by item class and item quality // - void SetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass, uint32 amount) { m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems=amount * m_ItemInfo[quality].ItemClassInfos[itemclass].Quantity; } + void SetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass, uint32 amount) { m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems = amount * m_ItemInfo[quality].ItemClassInfos[itemclass].Quantity; } uint32 GetItemsAmountPerClass(AuctionQuality quality, ItemClass itemclass) const { return m_ItemInfo[quality].ItemClassInfos[itemclass].AmountOfItems; } - void SetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass, uint32 qty) { m_ItemInfo[quality].ItemClassInfos[itemclass].Quantity=qty; } + void SetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass, uint32 qty) { m_ItemInfo[quality].ItemClassInfos[itemclass].Quantity = qty; } uint32 GetItemsQuantityPerClass(AuctionQuality quality, ItemClass itemclass) const { return m_ItemInfo[quality].ItemClassInfos[itemclass].Quantity; } 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; } uint32 GetMissedItemsPerClass(AuctionQuality quality, ItemClass itemclass) const { return m_ItemInfo[quality].ItemClassInfos[itemclass].MissItems; } // Data for every quality of item // - void SetItemsAmountPerQuality(AuctionQuality quality, uint32 cnt) { m_ItemInfo[quality].AmountOfItems=cnt; } + void SetItemsAmountPerQuality(AuctionQuality quality, uint32 cnt) { m_ItemInfo[quality].AmountOfItems = cnt; } uint32 GetItemsAmountPerQuality(AuctionQuality quality) const { return m_ItemInfo[quality].AmountOfItems; } - void SetPriceRatioPerQuality(AuctionQuality quality, uint32 value) { m_ItemInfo[quality].PriceRatio=value; } + void SetPriceRatioPerQuality(AuctionQuality quality, uint32 value) { m_ItemInfo[quality].PriceRatio = value; } uint32 GetPriceRatioPerQuality(AuctionQuality quality) const { return m_ItemInfo[quality].PriceRatio; } private: @@ -237,13 +237,13 @@ 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) && + 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) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_ALLIANCE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_HORDE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_NEUTRAL_ENABLED)) { sLog.outString("All feature of AuctionHouseBot are disabled! (If you want to use it please set config in 'ahbot.conf')"); 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)) + 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')"); if (!getConfig(CONFIG_BOOL_AHBOT_BUYER_ALLIANCE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_HORDE_ENABLED) && !getConfig(CONFIG_BOOL_AHBOT_BUYER_NEUTRAL_ENABLED)) @@ -256,7 +256,7 @@ bool AuctionBotConfig::Initialize() void AuctionBotConfig::setConfig(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue) { - setConfig(index, m_AhBotCfg.GetIntDefault(fieldname,defvalue)); + setConfig(index, m_AhBotCfg.GetIntDefault(fieldname, defvalue)); if (int32(getConfig(index)) < 0) { sLog.outError("AHBot: %s (%i) can't be negative. Using %u instead.", fieldname, int32(getConfig(index)), defvalue); @@ -266,7 +266,7 @@ void AuctionBotConfig::setConfig(AuctionBotConfigUInt32Values index, char const* void AuctionBotConfig::setConfigMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 maxvalue) { - setConfig(index, m_AhBotCfg.GetIntDefault(fieldname,defvalue)); + setConfig(index, m_AhBotCfg.GetIntDefault(fieldname, defvalue)); if (getConfig(index) > maxvalue) { sLog.outError("AHBot: %s (%u) must be in range 0...%u. Using %u instead.", fieldname, getConfig(index), maxvalue, maxvalue); @@ -276,7 +276,7 @@ void AuctionBotConfig::setConfigMax(AuctionBotConfigUInt32Values index, char con void AuctionBotConfig::setConfigMinMax(AuctionBotConfigUInt32Values index, char const* fieldname, uint32 defvalue, uint32 minvalue, uint32 maxvalue) { - setConfig(index, m_AhBotCfg.GetIntDefault(fieldname,defvalue)); + setConfig(index, m_AhBotCfg.GetIntDefault(fieldname, defvalue)); if (getConfig(index) > maxvalue) { sLog.outError("AHBot: %s (%u) must be in range %u...%u. Using %u instead.", fieldname, getConfig(index), minvalue, maxvalue, maxvalue); @@ -291,7 +291,7 @@ void AuctionBotConfig::setConfigMinMax(AuctionBotConfigUInt32Values index, char void AuctionBotConfig::setConfig(AuctionBotConfigBoolValues index, char const* fieldname, bool defvalue) { - setConfig(index, m_AhBotCfg.GetBoolDefault(fieldname,defvalue)); + setConfig(index, m_AhBotCfg.GetBoolDefault(fieldname, defvalue)); } //Get AuctionHousebot configuration file @@ -369,7 +369,7 @@ void AuctionBotConfig::GetConfigFromFile() setConfigMinMax(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_ALLIANCE, "AuctionHouseBot.Buyer.Alliance.Chance.Ratio", 3, 1, 100); setConfigMinMax(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_HORDE , "AuctionHouseBot.Buyer.Horde.Chance.Ratio" , 3, 1, 100); setConfigMinMax(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_NEUTRAL , "AuctionHouseBot.Buyer.Neutral.Chance.Ratio" , 3, 1, 100); - setConfigMinMax(CONFIG_UINT32_AHBOT_BUYER_RECHECK_INTERVAL , "AuctionHouseBot.Buyer.Recheck.Interval" , 20,1, DAY/MINUTE); + setConfigMinMax(CONFIG_UINT32_AHBOT_BUYER_RECHECK_INTERVAL , "AuctionHouseBot.Buyer.Recheck.Interval" , 20, 1, DAY / MINUTE); setConfig(CONFIG_BOOL_AHBOT_DEBUG_SELLER , "AuctionHouseBot.DEBUG.Seller" , false); setConfig(CONFIG_BOOL_AHBOT_DEBUG_BUYER , "AuctionHouseBot.DEBUG.Buyer" , false); @@ -441,8 +441,8 @@ uint32 AuctionBotConfig::getConfigItemQualityAmount(AuctionQuality quality) cons case AUCTION_QUALITY_WHITE: return getConfig(CONFIG_UINT32_AHBOT_ITEM_WHITE_AMOUNT); case AUCTION_QUALITY_GREEN: return getConfig(CONFIG_UINT32_AHBOT_ITEM_GREEN_AMOUNT); case AUCTION_QUALITY_BLUE: return getConfig(CONFIG_UINT32_AHBOT_ITEM_BLUE_AMOUNT); - case AUCTION_QUALITY_PURPLE:return getConfig(CONFIG_UINT32_AHBOT_ITEM_PURPLE_AMOUNT); - case AUCTION_QUALITY_ORANGE:return getConfig(CONFIG_UINT32_AHBOT_ITEM_ORANGE_AMOUNT); + case AUCTION_QUALITY_PURPLE: return getConfig(CONFIG_UINT32_AHBOT_ITEM_PURPLE_AMOUNT); + case AUCTION_QUALITY_ORANGE: return getConfig(CONFIG_UINT32_AHBOT_ITEM_ORANGE_AMOUNT); default: return getConfig(CONFIG_UINT32_AHBOT_ITEM_YELLOW_AMOUNT); } } @@ -489,19 +489,19 @@ void AuctionBotBuyer::LoadBuyerValues(AHB_Buyer_Config& config) switch (config.GetHouseType()) { case AUCTION_HOUSE_ALLIANCE: - config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_PRICE_RATIO)+50; + config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_ALLIANCE_PRICE_RATIO) + 50; FactionChance = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_ALLIANCE); break; case AUCTION_HOUSE_HORDE: - config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_HORDE_PRICE_RATIO)+50; + config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_HORDE_PRICE_RATIO) + 50; FactionChance = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_HORDE); break; default: - config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_PRICE_RATIO)+50; + config.BuyerPriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_PRICE_RATIO) + 50; FactionChance = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_BUYER_CHANCE_RATIO_NEUTRAL); break; } - config.FactionChance=5000*FactionChance; + config.FactionChance = 5000 * FactionChance; } void AuctionBotBuyer::LoadConfig() @@ -517,8 +517,8 @@ void AuctionBotBuyer::LoadConfig() uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config) { config.SameItemInfo.clear(); - uint32 count=0; - time_t Now=time(NULL); + uint32 count = 0; + time_t Now = time(NULL); AuctionHouseObject::AuctionEntryMapBounds bounds = sAuctionMgr.GetAuctionsMap(config.GetHouseType())->GetAuctionsBounds(); for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) @@ -531,45 +531,45 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config) if (prototype) { ++config.SameItemInfo[item->GetEntry()].ItemCount; // Structure constructor will make sure Element are correctly initialised if entry is created here. - config.SameItemInfo[item->GetEntry()].BuyPrice =config.SameItemInfo[item->GetEntry()].BuyPrice + (itr->second->buyout/item->GetCount()); - config.SameItemInfo[item->GetEntry()].BidPrice =config.SameItemInfo[item->GetEntry()].BidPrice + (itr->second->startbid/item->GetCount()); + config.SameItemInfo[item->GetEntry()].BuyPrice = config.SameItemInfo[item->GetEntry()].BuyPrice + (itr->second->buyout / item->GetCount()); + config.SameItemInfo[item->GetEntry()].BidPrice = config.SameItemInfo[item->GetEntry()].BidPrice + (itr->second->startbid / item->GetCount()); if (itr->second->buyout != 0) { - if (itr->second->buyout/item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBuyPrice) - config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout/item->GetCount(); + if (itr->second->buyout / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBuyPrice) + config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount(); else if (config.SameItemInfo[item->GetEntry()].MinBuyPrice == 0) - config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout/item->GetCount(); + config.SameItemInfo[item->GetEntry()].MinBuyPrice = itr->second->buyout / item->GetCount(); } - if (itr->second->startbid/item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBidPrice) - config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid/item->GetCount(); + if (itr->second->startbid / item->GetCount() < config.SameItemInfo[item->GetEntry()].MinBidPrice) + config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount(); else if (config.SameItemInfo[item->GetEntry()].MinBidPrice == 0) - config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid/item->GetCount(); + config.SameItemInfo[item->GetEntry()].MinBidPrice = itr->second->startbid / item->GetCount(); if (!Aentry->owner) { - if ((Aentry->bid!=0) && Aentry->bidder) // Add bided by player + if ((Aentry->bid != 0) && Aentry->bidder) // Add bided by player { - config.CheckedEntry[Aentry->Id].LastExist=Now; - config.CheckedEntry[Aentry->Id].AuctionId=Aentry->Id; + config.CheckedEntry[Aentry->Id].LastExist = Now; + config.CheckedEntry[Aentry->Id].AuctionId = Aentry->Id; ++count; } } else { - if (Aentry->bid!=0) + if (Aentry->bid != 0) { if (Aentry->bidder) { - config.CheckedEntry[Aentry->Id].LastExist=Now; - config.CheckedEntry[Aentry->Id].AuctionId=Aentry->Id; + config.CheckedEntry[Aentry->Id].LastExist = Now; + config.CheckedEntry[Aentry->Id].AuctionId = Aentry->Id; ++count; } } else { - config.CheckedEntry[Aentry->Id].LastExist=Now; - config.CheckedEntry[Aentry->Id].AuctionId=Aentry->Id; + config.CheckedEntry[Aentry->Id].LastExist = Now; + config.CheckedEntry[Aentry->Id].AuctionId = Aentry->Id; ++count; } } @@ -577,18 +577,18 @@ uint32 AuctionBotBuyer::GetBuyableEntry(AHB_Buyer_Config& config) } } - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: %u items added to buyable vector for ah type: %u",count, config.GetHouseType()); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: %u items added to buyable vector for ah type: %u", count, config.GetHouseType()); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: SameItemInfo size = " SIZEFMTD, config.SameItemInfo.size()); return count; } void AuctionBotBuyer::PrepareListOfEntry(AHB_Buyer_Config& config) { - time_t Now=time(NULL)-5; + time_t Now = time(NULL) - 5; - for (CheckEntryMap::iterator itr=config.CheckedEntry.begin(); itr != config.CheckedEntry.end();) + for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();) { - if (itr->second.LastExist < (Now-5)) + if (itr->second.LastExist < (Now - 5)) config.CheckedEntry.erase(itr++); else ++itr; @@ -599,13 +599,13 @@ void AuctionBotBuyer::PrepareListOfEntry(AHB_Buyer_Config& config) bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double InGame_BuyPrice, double MaxBuyablePrice, uint32 MinBuyPrice, uint32 MaxChance, uint32 ChanceRatio) { - double ratio=0; - uint32 Chance=0; + double ratio = 0; + uint32 Chance = 0; if (buyoutPrice <= MinBuyPrice) { if (buyoutPrice <= MaxBuyablePrice) - Chance=MaxChance; + Chance = MaxChance; else { @@ -613,15 +613,15 @@ bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double InGame_BuyPrice, { ratio = buyoutPrice / MaxBuyablePrice; if (ratio < 10) - Chance=MaxChance - (ratio*(MaxChance/10)); - else Chance=1; + Chance = MaxChance - (ratio * (MaxChance / 10)); + else Chance = 1; } } } else if (buyoutPrice <= InGame_BuyPrice) { if (buyoutPrice <= MaxBuyablePrice) - Chance=MaxChance/5; + Chance = MaxChance / 5; else { @@ -629,80 +629,80 @@ bool AuctionBotBuyer::IsBuyableEntry(uint32 buyoutPrice, double InGame_BuyPrice, { ratio = buyoutPrice / MaxBuyablePrice; if (ratio < 10) - Chance=(MaxChance/5) - (ratio*(MaxChance/50)); - else Chance=1; + Chance = (MaxChance / 5) - (ratio * (MaxChance / 50)); + else Chance = 1; } } } else if (buyoutPrice <= MaxBuyablePrice) - Chance = MaxChance/10; + Chance = MaxChance / 10; else { if ((buyoutPrice > 0) && (MaxBuyablePrice > 0)) { ratio = buyoutPrice / MaxBuyablePrice; if (ratio < 10) - Chance=(MaxChance/5) - (ratio*(MaxChance/50)); - else Chance=0; + Chance = (MaxChance / 5) - (ratio * (MaxChance / 50)); + else Chance = 0; } else Chance = 0; } - uint32 RandNum = urand(1,ChanceRatio); - if (RandNum<=Chance) + uint32 RandNum = urand(1, ChanceRatio); + if (RandNum <= Chance) { - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: WIN BUY! Chance = %u, num = %u.",Chance, RandNum); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: WIN BUY! Chance = %u, num = %u.", Chance, RandNum); return true; } else { - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot:LOOSE BUY! Chance = %u, num = %u.",Chance, RandNum); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot:LOOSE BUY! Chance = %u, num = %u.", Chance, RandNum); return false; } } bool AuctionBotBuyer::IsBidableEntry(uint32 bidPrice, double InGame_BuyPrice, double MaxBidablePrice, uint32 MinBidPrice, uint32 MaxChance, uint32 ChanceRatio) { - double ratio=0; - uint32 Chance=0; + double ratio = 0; + uint32 Chance = 0; if (bidPrice <= MinBidPrice) { if ((InGame_BuyPrice != 0) && (bidPrice < (InGame_BuyPrice - (InGame_BuyPrice / 30)))) - Chance=MaxChance; + Chance = MaxChance; else { if (bidPrice < MaxBidablePrice) { ratio = MaxBidablePrice / bidPrice; if (ratio < 3) - Chance = ((MaxChance/500)*ratio); + Chance = ((MaxChance / 500) * ratio); else - Chance = (MaxChance/500); + Chance = (MaxChance / 500); } } } else if (bidPrice < (InGame_BuyPrice - (InGame_BuyPrice / 30))) - Chance=(MaxChance/10); + Chance = (MaxChance / 10); else { if (bidPrice < MaxBidablePrice) { ratio = MaxBidablePrice / bidPrice; if (ratio < 4) - Chance = ((MaxChance/1000)*ratio); + Chance = ((MaxChance / 1000) * ratio); else - Chance = (MaxChance/1000); + Chance = (MaxChance / 1000); } } - uint32 RandNum = urand(1,ChanceRatio); - if (RandNum<=Chance) + uint32 RandNum = urand(1, ChanceRatio); + if (RandNum <= Chance) { - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: WIN BID! Chance = %u, num = %u.",Chance, RandNum); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: WIN BID! Chance = %u, num = %u.", Chance, RandNum); return true; } else { - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: LOOSE BID! Chance = %u, num = %u.",Chance, RandNum); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: LOOSE BID! Chance = %u, num = %u.", Chance, RandNum); return false; } } @@ -729,13 +729,13 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) uint32 BuyCycles; if (config.CheckedEntry.size() > sAuctionBotConfig.GetItemPerCycleBoost()) { - BuyCycles=sAuctionBotConfig.GetItemPerCycleBoost(); + BuyCycles = sAuctionBotConfig.GetItemPerCycleBoost(); BASIC_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Boost value used for Buyer! (if this happens often adjust both ItemsPerCycle in ahbot.conf)"); } else - BuyCycles=sAuctionBotConfig.GetItemPerCycleNormal(); + BuyCycles = sAuctionBotConfig.GetItemPerCycleNormal(); - for (CheckEntryMap::iterator itr =config.CheckedEntry.begin(); itr != config.CheckedEntry.end();) + for (CheckEntryMap::iterator itr = config.CheckedEntry.begin(); itr != config.CheckedEntry.end();) { AuctionEntry* auction = auctionHouse->GetAuction(itr->second.AuctionId); if (!auction || auction->moneyDeliveryTime) // is auction not active now @@ -757,7 +757,7 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) if (BuyCycles == 0) break; - uint32 MaxChance=5000; + uint32 MaxChance = 5000; Item* item = sAuctionMgr.GetAItem(auction->itemGuidLow); if (!item) // auction item not accessible, possible auction in payment pending mode @@ -771,45 +771,45 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) uint32 BasePrice = sAuctionBotConfig.getConfig(CONFIG_BOOL_AHBOT_BUYPRICE_BUYER) ? prototype->BuyPrice : prototype->SellPrice; BasePrice *= item->GetCount(); - double MaxBuyablePrice = (BasePrice * config.BuyerPriceRatio)/100; + double MaxBuyablePrice = (BasePrice * config.BuyerPriceRatio) / 100; BuyerItemInfoMap::iterator sameitem_itr = config.SameItemInfo.find(item->GetEntry()); - uint32 buyoutPrice = auction->buyout/item->GetCount(); + uint32 buyoutPrice = auction->buyout / item->GetCount(); uint32 bidPrice; uint32 bidPriceByItem; if (auction->bid >= auction->startbid) { bidPrice = auction->GetAuctionOutBid(); - bidPriceByItem = auction->bid/item->GetCount(); + bidPriceByItem = auction->bid / item->GetCount(); } else { bidPrice = auction->startbid; - bidPriceByItem = auction->startbid/item->GetCount(); + bidPriceByItem = auction->startbid / item->GetCount(); } double InGame_BuyPrice; double InGame_BidPrice; - if (sameitem_itr==config.SameItemInfo.end()) + if (sameitem_itr == config.SameItemInfo.end()) { - InGame_BuyPrice=0; - InGame_BidPrice=0; + InGame_BuyPrice = 0; + InGame_BidPrice = 0; } else { if (sameitem_itr->second.ItemCount == 1) MaxBuyablePrice = MaxBuyablePrice * 5; // if only one item exist can be buyed if the price is high too. - InGame_BuyPrice=sameitem_itr->second.BuyPrice/sameitem_itr->second.ItemCount; - InGame_BidPrice=sameitem_itr->second.BidPrice/sameitem_itr->second.ItemCount; + InGame_BuyPrice = sameitem_itr->second.BuyPrice / sameitem_itr->second.ItemCount; + InGame_BidPrice = sameitem_itr->second.BidPrice / sameitem_itr->second.ItemCount; } double MaxBidablePrice = MaxBuyablePrice - (MaxBuyablePrice / 30); // Max Bidable price defined to 70% of max buyable price DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Auction added with data:"); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: MaxPrice of Entry %u is %.1fg.", itr->second.AuctionId, MaxBuyablePrice / 10000); - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: GamePrice buy=%.1fg, bid=%.1fg.",InGame_BuyPrice/10000, InGame_BidPrice / 10000); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: GamePrice buy=%.1fg, bid=%.1fg.", InGame_BuyPrice / 10000, InGame_BidPrice / 10000); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Minimal price see in AH Buy=%ug, Bid=%ug.", - sameitem_itr->second.MinBuyPrice / 10000,sameitem_itr->second.MinBidPrice / 10000); - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice/ 10000); + sameitem_itr->second.MinBuyPrice / 10000, sameitem_itr->second.MinBidPrice / 10000); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Actual Entry price, Buy=%ug, Bid=%ug.", buyoutPrice / 10000, bidPrice / 10000); if (!auction->owner) // Original auction owner { @@ -819,19 +819,19 @@ void AuctionBotBuyer::addNewAuctionBuyerBotBid(AHB_Buyer_Config& config) { if (IsBuyableEntry(buyoutPrice, InGame_BuyPrice, MaxBuyablePrice, sameitem_itr->second.MinBuyPrice, MaxChance, config.FactionChance)) { - if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance/2, config.FactionChance)) - if (urand(0,5)==0) PlaceBidToEntry(auction, bidPrice); else BuyEntry(auction); + if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance / 2, config.FactionChance)) + if (urand(0, 5) == 0) PlaceBidToEntry(auction, bidPrice); else BuyEntry(auction); else BuyEntry(auction); } else { - if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance/2, config.FactionChance)) + if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance / 2, config.FactionChance)) PlaceBidToEntry(auction, bidPrice); } } else // buyout = 0 mean only bid are possible - if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice,MaxChance, config.FactionChance)) + if (IsBidableEntry(bidPriceByItem, InGame_BuyPrice, MaxBidablePrice, sameitem_itr->second.MinBidPrice, MaxChance, config.FactionChance)) PlaceBidToEntry(auction, bidPrice); itr->second.LastChecked = Now; @@ -879,14 +879,14 @@ bool AuctionBotSeller::Initialize() { std::stringstream includeStream(sAuctionBotConfig.GetAHBotIncludes()); std::string temp; - while (getline(includeStream,temp, ',')) + while (getline(includeStream, temp, ',')) includeItems.push_back(atoi(temp.c_str())); } { std::stringstream excludeStream(sAuctionBotConfig.GetAHBotExcludes()); std::string temp; - while (getline(excludeStream,temp, ',')) + while (getline(excludeStream, temp, ',')) excludeItems.push_back(atoi(temp.c_str())); } @@ -973,7 +973,7 @@ bool AuctionBotSeller::Initialize() // forced exclude filter bool isExcludeItem = false; for (size_t i = 0; (i < excludeItems.size() && (!isExcludeItem)); ++i) - if (itemID ==excludeItems[i]) + if (itemID == excludeItems[i]) isExcludeItem = true; if (isExcludeItem) continue; @@ -1116,7 +1116,7 @@ bool AuctionBotSeller::Initialize() break; } case ITEM_CLASS_MISC: - if (prototype->SubClass==ITEM_SUBCLASS_JUNK_MOUNT) + if (prototype->SubClass == ITEM_SUBCLASS_JUNK_MOUNT) { if (uint32 value = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_CLASS_MISC_MOUNT_MIN_REQ_LEVEL)) if (prototype->RequiredLevel < value) @@ -1379,13 +1379,13 @@ void AuctionBotSeller::LoadSellerValues(AHB_Seller_Config& config) PriceRatio = sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_NEUTRAL_PRICE_RATIO); break; } - config.SetPriceRatioPerQuality(AUCTION_QUALITY_GREY,PriceRatio); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_WHITE,PriceRatio); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_GREEN,PriceRatio); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_BLUE,PriceRatio); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_PURPLE,PriceRatio); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_ORANGE,PriceRatio); - config.SetPriceRatioPerQuality(AUCTION_QUALITY_YELLOW,PriceRatio); + config.SetPriceRatioPerQuality(AUCTION_QUALITY_GREY, PriceRatio); + config.SetPriceRatioPerQuality(AUCTION_QUALITY_WHITE, PriceRatio); + config.SetPriceRatioPerQuality(AUCTION_QUALITY_GREEN, PriceRatio); + config.SetPriceRatioPerQuality(AUCTION_QUALITY_BLUE, PriceRatio); + config.SetPriceRatioPerQuality(AUCTION_QUALITY_PURPLE, PriceRatio); + config.SetPriceRatioPerQuality(AUCTION_QUALITY_ORANGE, PriceRatio); + config.SetPriceRatioPerQuality(AUCTION_QUALITY_YELLOW, PriceRatio); //load min and max auction times config.SetMinTime(sAuctionBotConfig.getConfig(CONFIG_UINT32_AHBOT_MINTIME)); @@ -1394,7 +1394,7 @@ void AuctionBotSeller::LoadSellerValues(AHB_Seller_Config& config) DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: minTime = %u", config.GetMinTime()); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: maxTime = %u", config.GetMaxTime()); - DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: For AH type %u",config.GetHouseType()); + DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: For AH type %u", config.GetHouseType()); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: GreyItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_GREY)); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: WhiteItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_WHITE)); DEBUG_FILTER_LOG(LOG_FILTER_AHBOT_SELLER, "AHBot: GreenItems = %u", config.GetItemsAmountPerQuality(AUCTION_QUALITY_GREEN)); @@ -1428,18 +1428,18 @@ uint32 AuctionBotSeller::SetStat(AHB_Seller_Config& config) } } } - uint32 count=0; - for (uint32 j=0; j >& addedItem) { ra.clear(); - bool Ok=false; + bool Ok = false; for (uint32 j = 0; j < MAX_AUCTION_QUALITY; ++j) { @@ -1471,7 +1471,7 @@ bool AuctionBotSeller::getRandomArray(AHB_Seller_Config& config, RandomArray& ra miss_item.color = j; miss_item.itemclass = i; ra.push_back(miss_item); - Ok=true; + Ok = true; } } } @@ -1485,10 +1485,10 @@ void AuctionBotSeller::SetPricesOfItem(ItemPrototype const* itemProto, AHB_Selle (itemQuality < MAX_AUCTION_QUALITY ? config.GetPriceRatioPerQuality(AuctionQuality(itemQuality)) : 1) ; double randrange = temp_buyp * 0.4; - buyp = (urand(temp_buyp-randrange, temp_buyp+randrange)/100)+1; - double urandrange=buyp*40; - double temp_bidp = buyp*50; - bidp = (urand(temp_bidp-urandrange, temp_bidp+urandrange)/100)+1; + buyp = (urand(temp_buyp - randrange, temp_buyp + randrange) / 100) + 1; + double urandrange = buyp * 40; + double temp_bidp = buyp * 50; + bidp = (urand(temp_bidp - urandrange, temp_bidp + urandrange) / 100) + 1; } void AuctionBotSeller::SetItemsRatio(uint32 al, uint32 ho, uint32 ne) @@ -1538,8 +1538,8 @@ void AuctionBotSeller::SetItemsAmountForQuality(AuctionQuality quality, uint32 v case AUCTION_QUALITY_WHITE: sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_WHITE_AMOUNT, val); break; case AUCTION_QUALITY_GREEN: sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_GREEN_AMOUNT, val); break; case AUCTION_QUALITY_BLUE: sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_BLUE_AMOUNT, val); break; - case AUCTION_QUALITY_PURPLE:sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_PURPLE_AMOUNT, val); break; - case AUCTION_QUALITY_ORANGE:sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_ORANGE_AMOUNT, val); break; + case AUCTION_QUALITY_PURPLE: sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_PURPLE_AMOUNT, val); break; + case AUCTION_QUALITY_ORANGE: sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_ORANGE_AMOUNT, val); break; default: sAuctionBotConfig.setConfig(CONFIG_UINT32_AHBOT_ITEM_YELLOW_AMOUNT, val); break; } @@ -1556,10 +1556,10 @@ void AuctionBotSeller::addNewAuctions(AHB_Seller_Config& config) // If there is large amount of items missed we can use boost value to get fast filled AH if (config.LastMissedItem > sAuctionBotConfig.GetItemPerCycleBoost()) { - items=sAuctionBotConfig.GetItemPerCycleBoost(); + items = sAuctionBotConfig.GetItemPerCycleBoost(); BASIC_FILTER_LOG(LOG_FILTER_AHBOT_BUYER, "AHBot: Boost value used to fill AH! (if this happens often adjust both ItemsPerCycle in ahbot.conf)"); } - else items=sAuctionBotConfig.GetItemPerCycleNormal(); + else items = sAuctionBotConfig.GetItemPerCycleNormal(); uint32 houseid; switch (config.GetHouseType()) @@ -1574,18 +1574,18 @@ void AuctionBotSeller::addNewAuctions(AHB_Seller_Config& config) AuctionHouseObject* auctionHouse = sAuctionMgr.GetAuctionsMap(config.GetHouseType()); RandomArray randArray; - std::vector > ItemsAdded(MAX_AUCTION_QUALITY,std::vector (MAX_ITEM_CLASS)); + std::vector > ItemsAdded(MAX_AUCTION_QUALITY, std::vector (MAX_ITEM_CLASS)); // Main loop // getRandomArray will give what categories of items should be added (return true if there is at least 1 items missed) - while (getRandomArray(config,randArray, ItemsAdded) && (items>0)) + while (getRandomArray(config, randArray, ItemsAdded) && (items > 0)) { --items; // Select random position from missed items table - uint32 pos = (urand(0,randArray.size()-1)); + uint32 pos = (urand(0, randArray.size() - 1)); // Set itemID with random item ID for selected categories and color, from m_ItemPool table - uint32 itemID = m_ItemPool[randArray[pos].color][randArray[pos].itemclass][urand(0,m_ItemPool[randArray[pos].color][randArray[pos].itemclass].size()-1)]; + uint32 itemID = m_ItemPool[randArray[pos].color][randArray[pos].itemclass][urand(0, m_ItemPool[randArray[pos].color][randArray[pos].itemclass].size() - 1)]; ++ ItemsAdded[randArray[pos].color][randArray[pos].itemclass]; // Helper table to avoid rescan from DB in this loop. (has we add item in random orders) if (!itemID) @@ -1763,7 +1763,7 @@ void AuctionHouseBot::Update() return; // scan all possible update cases until first success - for (uint32 count = 0; count < 2*MAX_AUCTION_HOUSE_TYPE; ++count) + for (uint32 count = 0; count < 2 * MAX_AUCTION_HOUSE_TYPE; ++count) { bool successStep = false; @@ -1779,7 +1779,7 @@ void AuctionHouseBot::Update() } ++m_OperationSelector; - if (m_OperationSelector >= 2*MAX_AUCTION_HOUSE_TYPE) + if (m_OperationSelector >= 2 * MAX_AUCTION_HOUSE_TYPE) m_OperationSelector = 0; // one success update per call diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.h b/src/game/AuctionHouseBot/AuctionHouseBot.h index 767288617..933950f68 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.h +++ b/src/game/AuctionHouseBot/AuctionHouseBot.h @@ -116,8 +116,8 @@ class AuctionBotConfig uint32 getConfig(AuctionBotConfigUInt32Values index) const { return m_configUint32Values[index]; } bool getConfig(AuctionBotConfigBoolValues index) const { return m_configBoolValues[index]; } - void setConfig(AuctionBotConfigBoolValues index, bool value) { m_configBoolValues[index]=value; } - void setConfig(AuctionBotConfigUInt32Values index, uint32 value) { m_configUint32Values[index]=value; } + void setConfig(AuctionBotConfigBoolValues index, bool value) { m_configBoolValues[index] = value; } + void setConfig(AuctionBotConfigUInt32Values index, uint32 value) { m_configUint32Values[index] = value; } uint32 getConfigItemAmountRatio(AuctionHouseType houseType) const; bool getConfigBuyerEnabled(AuctionHouseType houseType) const; @@ -160,8 +160,8 @@ class AuctionBotAgent AuctionBotAgent() {} virtual ~AuctionBotAgent() {} public: - virtual bool Initialize() =0; - virtual bool Update(AuctionHouseType houseType) =0; + virtual bool Initialize() = 0; + virtual bool Update(AuctionHouseType houseType) = 0; }; struct AuctionHouseBotStatusInfoPerType diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index 9844b6d5b..dcdb6ffb5 100644 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -84,7 +84,7 @@ void WorldSession::SendAuctionCommandResult(AuctionEntry* auc, AuctionAction Act data << uint32(invError); break; case AUCTION_ERR_HIGHER_BID: - data << ObjectGuid(HIGHGUID_PLAYER,auc->bidder);// new bidder guid + data << ObjectGuid(HIGHGUID_PLAYER, auc->bidder); // new bidder guid data << uint32(auc->bid); // new bid data << uint32(auc->GetAuctionOutBid()); // new AuctionOutBid? break; @@ -98,7 +98,7 @@ void WorldSession::SendAuctionCommandResult(AuctionEntry* auc, AuctionAction Act // this function sends notification, if bidder is online void WorldSession::SendAuctionBidderNotification(AuctionEntry* auction) { - WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8*4)); + WorldPacket data(SMSG_AUCTION_BIDDER_NOTIFICATION, (8 * 4)); data << uint32(auction->GetHouseId()); data << uint32(auction->Id); data << ObjectGuid(HIGHGUID_PLAYER, auction->bidder); @@ -115,7 +115,7 @@ void WorldSession::SendAuctionBidderNotification(AuctionEntry* auction) // this void causes on client to display: "Your auction sold" void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction) { - WorldPacket data(SMSG_AUCTION_OWNER_NOTIFICATION, (7*4)); + WorldPacket data(SMSG_AUCTION_OWNER_NOTIFICATION, (7 * 4)); data << uint32(auction->Id); data << uint32(auction->bid); // if 0, client shows ERR_AUCTION_EXPIRED_S, else ERR_AUCTION_SOLD_S (works only when guid==0) data << uint32(auction->GetAuctionOutBid()); // AuctionOutBid? @@ -140,7 +140,7 @@ void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction) // shows ERR_AUCTION_REMOVED_S void WorldSession::SendAuctionRemovedNotification(AuctionEntry* auction) { - WorldPacket data(SMSG_AUCTION_REMOVED_NOTIFICATION, (3*4)); + WorldPacket data(SMSG_AUCTION_REMOVED_NOTIFICATION, (3 * 4)); data << uint32(auction->Id); data << uint32(auction->itemTemplate); data << uint32(auction->itemRandomPropertyId); @@ -207,7 +207,7 @@ AuctionHouseEntry const* WorldSession::GetCheckedAuctionHouseForAuctioneer(Objec { // command case will return only if player have real access to command // using special access modes (1,-1) done at mode set in command, so not need recheck - if (GetPlayer()->GetAuctionAccessMode()==0 && !ChatHandler(GetPlayer()).FindCommand("auction")) + if (GetPlayer()->GetAuctionAccessMode() == 0 && !ChatHandler(GetPlayer()).FindCommand("auction")) { DEBUG_LOG("%s attempt open auction in cheating way.", guid.GetString().c_str()); return NULL; @@ -340,7 +340,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket& recv_data) if (GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(GetAccountId(),"GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)", + sLog.outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)", GetPlayerName(), GetAccountId(), it->GetProto()->Name1, it->GetEntry(), it->GetCount()); } @@ -553,7 +553,7 @@ void WorldSession::HandleAuctionListBidderItems(WorldPacket& recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4+4+4)); + WorldPacket data(SMSG_AUCTION_BIDDER_LIST_RESULT, (4 + 4 + 4)); Player* pl = GetPlayer(); data << uint32(0); // add 0 as count uint32 count = 0; @@ -600,7 +600,7 @@ void WorldSession::HandleAuctionListOwnerItems(WorldPacket& recv_data) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - WorldPacket data(SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4)); + WorldPacket data(SMSG_AUCTION_OWNER_LIST_RESULT, (4 + 4 + 4)); data << uint32(0); // amount place holder uint32 count = 0; @@ -675,7 +675,7 @@ void WorldSession::HandleAuctionListItems(WorldPacket& recv_data) //DEBUG_LOG("Auctionhouse search %s list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u", // auctioneerGuid.GetString().c_str(), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable); - WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4)); + WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4 + 4 + 4)); uint32 count = 0; uint32 totalcount = 0; data << uint32(0); diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 3184a0b85..bf9661ff9 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -124,7 +124,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction) uint32 owner_accid = sObjectMgr.GetPlayerAccountIdByGUID(ownerGuid); - sLog.outCommand(bidder_accId,"GM %s (Account: %u) won item in auction (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", + sLog.outCommand(bidder_accId, "GM %s (Account: %u) won item in auction (Entry: %u Count: %u) and pay money: %u. Original owner %s (Account: %u)", bidder_name.c_str(), bidder_accId, auction->itemTemplate, auction->itemCount, auction->bid, owner_name.c_str(), owner_accid); } } @@ -292,7 +292,7 @@ void AuctionHouseMgr::LoadAuctionItems() if (!proto) { - sLog.outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid,item_template); + sLog.outError("AuctionHouseMgr::LoadAuctionItems: Unknown item (GUID: %u id: #%u) in auction, skipped.", item_guid, item_template); continue; } @@ -327,7 +327,7 @@ void AuctionHouseMgr::LoadAuctions() } Field* fields = result->Fetch(); - uint32 AuctionCount=fields[0].GetUInt32(); + uint32 AuctionCount = fields[0].GetUInt32(); delete result; if (!AuctionCount) @@ -433,7 +433,7 @@ void AuctionHouseMgr::LoadAuctions() // Attempt send item back to owner std::ostringstream msgAuctionCanceledOwner; - msgAuctionCanceledOwner << auction->itemTemplate << ":"<< auction->itemRandomPropertyId << ":" << AUCTION_CANCELED << ":" << auction->Id << ":" << auction->itemCount; + msgAuctionCanceledOwner << auction->itemTemplate << ":" << auction->itemRandomPropertyId << ":" << AUCTION_CANCELED << ":" << auction->Id << ":" << auction->itemCount; if (auction->itemGuidLow) { @@ -949,7 +949,7 @@ bool AuctionEntry::BuildAuctionInfo(WorldPacket& data) const data << uint32(startbid); // Auction->startbid (not sure if useful) data << uint32(bid ? GetAuctionOutBid() : 0); // minimal outbid data << uint32(buyout); // auction->buyout - data << uint32((expireTime-time(NULL))*IN_MILLISECONDS);// time left + data << uint32((expireTime - time(NULL))*IN_MILLISECONDS); // time left data << ObjectGuid(HIGHGUID_PLAYER, bidder); // auction->bidder current data << uint32(bid); // current bid return true; diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 6b36bff7e..74a6ea58d 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -44,22 +44,22 @@ namespace MaNGOS : i_msgtype(msgtype), i_textId(textId), i_source(source), i_args(args) {} void operator()(WorldPacket& data, int32 loc_idx) { - char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); + char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); if (i_args) { // we need copy va_list before use or original va_list will corrupted va_list ap; - va_copy(ap,*i_args); + va_copy(ap, *i_args); char str [2048]; - vsnprintf(str,2048,text, ap); + vsnprintf(str, 2048, text, ap); va_end(ap); - do_helper(data,&str[0]); + do_helper(data, &str[0]); } else - do_helper(data,text); + do_helper(data, text); } private: void do_helper(WorldPacket& data, char const* text) @@ -71,7 +71,7 @@ namespace MaNGOS data << ObjectGuid(targetGuid); // there 0 for BG messages data << uint32(0); // can be chat msg group or something data << ObjectGuid(targetGuid); - data << uint32(strlen(text)+1); + data << uint32(strlen(text) + 1); data << text; data << uint8(i_source ? i_source->GetChatTag() : CHAT_TAG_NONE); } @@ -89,22 +89,22 @@ namespace MaNGOS : i_language(language), i_textId(textId), i_source(source), i_args(args) {} void operator()(WorldPacket& data, int32 loc_idx) { - char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); + char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); if (i_args) { // we need copy va_list before use or original va_list will corrupted va_list ap; - va_copy(ap,*i_args); + va_copy(ap, *i_args); char str [2048]; - vsnprintf(str,2048,text, ap); + vsnprintf(str, 2048, text, ap); va_end(ap); - do_helper(data,&str[0]); + do_helper(data, &str[0]); } else - do_helper(data,text); + do_helper(data, text); } private: void do_helper(WorldPacket& data, char const* text) @@ -114,10 +114,10 @@ namespace MaNGOS data << uint32(i_language); data << ObjectGuid(i_source->GetObjectGuid()); data << uint32(0); // 2.1.0 - data << uint32(strlen(i_source->GetName())+1); + data << uint32(strlen(i_source->GetName()) + 1); data << i_source->GetName(); data << ObjectGuid(); // Unit Target - isn't important for bgs - data << uint32(strlen(text)+1); + data << uint32(strlen(text) + 1); data << text; data << uint8(0); // ChatTag - for bgs allways 0? } @@ -136,12 +136,12 @@ namespace MaNGOS : i_msgtype(msgtype), i_textId(textId), i_source(source), i_arg1(arg1), i_arg2(arg2) {} void operator()(WorldPacket& data, int32 loc_idx) { - char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); - char const* arg1str = i_arg1 ? sObjectMgr.GetMangosString(i_arg1,loc_idx) : ""; - char const* arg2str = i_arg2 ? sObjectMgr.GetMangosString(i_arg2,loc_idx) : ""; + char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); + char const* arg1str = i_arg1 ? sObjectMgr.GetMangosString(i_arg1, loc_idx) : ""; + char const* arg2str = i_arg2 ? sObjectMgr.GetMangosString(i_arg2, loc_idx) : ""; char str [2048]; - snprintf(str,2048,text, arg1str, arg2str); + snprintf(str, 2048, text, arg1str, arg2str); ObjectGuid targetGuid = i_source ? i_source ->GetObjectGuid() : ObjectGuid(); @@ -150,7 +150,7 @@ namespace MaNGOS data << ObjectGuid(targetGuid); // there 0 for BG messages data << uint32(0); // can be chat msg group or something data << ObjectGuid(targetGuid); - data << uint32(strlen(str)+1); + data << uint32(strlen(str) + 1); data << str; data << uint8(i_source ? i_source->GetChatTag() : CHAT_TAG_NONE); } @@ -170,9 +170,9 @@ namespace MaNGOS : i_language(language), i_textId(textId), i_source(source), i_arg1(arg1), i_arg2(arg2) {} void operator()(WorldPacket& data, int32 loc_idx) { - char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); - char const* arg1str = i_arg1 ? sObjectMgr.GetMangosString(i_arg1,loc_idx) : ""; - char const* arg2str = i_arg2 ? sObjectMgr.GetMangosString(i_arg2,loc_idx) : ""; + char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); + char const* arg1str = i_arg1 ? sObjectMgr.GetMangosString(i_arg1, loc_idx) : ""; + char const* arg2str = i_arg2 ? sObjectMgr.GetMangosString(i_arg2, loc_idx) : ""; char str [2048]; snprintf(str, 2048, text, arg1str, arg2str); @@ -181,10 +181,10 @@ namespace MaNGOS data << uint32(i_language); data << ObjectGuid(i_source->GetObjectGuid()); data << uint32(0); // 2.1.0 - data << uint32(strlen(i_source->GetName())+1); + data << uint32(strlen(i_source->GetName()) + 1); data << i_source->GetName(); data << ObjectGuid(); // Unit Target - isn't important for bgs - data << uint32(strlen(str)+1); + data << uint32(strlen(str) + 1); data << str; data << uint8(0); // ChatTag - for bgs allways 0? } @@ -776,7 +776,7 @@ void BattleGround::EndBattleGround(Team winner) if (member) plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->personal_rating); - winner_arena_team->MemberWon(plr,loser_rating); + winner_arena_team->MemberWon(plr, loser_rating); if (member) { @@ -786,7 +786,7 @@ void BattleGround::EndBattleGround(Team winner) } else { - loser_arena_team->MemberLost(plr,winner_rating); + loser_arena_team->MemberLost(plr, winner_rating); // Arena lost => reset the win_rated_arena having the "no_loose" condition plr->GetAchievementMgr().ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE); @@ -795,12 +795,12 @@ void BattleGround::EndBattleGround(Team winner) if (team == winner) { - RewardMark(plr,ITEM_WINNER_COUNT); + RewardMark(plr, ITEM_WINNER_COUNT); RewardQuestComplete(plr); plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, 1); } else - RewardMark(plr,ITEM_LOSER_COUNT); + RewardMark(plr, ITEM_LOSER_COUNT); plr->CombatStopWithPets(true); @@ -852,27 +852,27 @@ uint32 BattleGround::GetBattlemasterEntry() const } } -void BattleGround::RewardMark(Player* plr,uint32 count) +void BattleGround::RewardMark(Player* plr, uint32 count) { switch (GetTypeID()) { 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); + 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); + 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); + RewardSpellCast(plr, SPELL_AB_MARK_LOSER); break; case BATTLEGROUND_EY: // no rewards default: @@ -889,7 +889,7 @@ void BattleGround::RewardSpellCast(Player* plr, uint32 spell_id) SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) { - sLog.outError("Battleground reward casting spell %u not exist.",spell_id); + sLog.outError("Battleground reward casting spell %u not exist.", spell_id); return; } @@ -908,7 +908,7 @@ void BattleGround::RewardItem(Player* plr, uint32 item_id, uint32 count) if (msg == EQUIP_ERR_ITEM_NOT_FOUND) { - sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.",item_id); + sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.", item_id); return; } @@ -917,13 +917,13 @@ void BattleGround::RewardItem(Player* plr, uint32 item_id, uint32 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); } -void BattleGround::SendRewardMarkByMail(Player* plr,uint32 mark, uint32 count) +void BattleGround::SendRewardMarkByMail(Player* plr, uint32 mark, uint32 count) { uint32 bmEntry = GetBattlemasterEntry(); if (!bmEntry) @@ -933,7 +933,7 @@ void BattleGround::SendRewardMarkByMail(Player* plr,uint32 mark, uint32 count) if (!markProto) return; - if (Item* markItem = Item::CreateItem(mark,count,plr)) + if (Item* markItem = Item::CreateItem(mark, count, plr)) { // save new item before send markItem->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted @@ -1038,7 +1038,7 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen if (isArena()) { plr->RemoveArenaAuras(true); // removes debuffs / dots etc., we don't want the player to die after porting out - bgTypeId=BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing) + bgTypeId = BATTLEGROUND_AA; // set the bg type to all arenas (it will be used for queue refreshing) // unsummon current and summon old pet if there was one and there isn't a current pet plr->RemovePet(PET_SAVE_NOT_IN_SLOT); @@ -1050,7 +1050,7 @@ void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool Sen ArenaTeam* winner_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team))); ArenaTeam* loser_arena_team = sObjectMgr.GetArenaTeamById(GetArenaTeamIdForTeam(team)); if (winner_arena_team && loser_arena_team) - loser_arena_team->MemberLost(plr,winner_arena_team->GetRating()); + loser_arena_team->MemberLost(plr, winner_arena_team->GetRating()); } } if (SendPacket) @@ -1203,16 +1203,16 @@ void BattleGround::AddPlayer(Player* plr) if (team == ALLIANCE) // gold { if (plr->GetTeam() == HORDE) - plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG,true); + plr->CastSpell(plr, SPELL_HORDE_GOLD_FLAG, true); else - plr->CastSpell(plr, SPELL_ALLIANCE_GOLD_FLAG,true); + plr->CastSpell(plr, SPELL_ALLIANCE_GOLD_FLAG, true); } else // green { if (plr->GetTeam() == HORDE) - plr->CastSpell(plr, SPELL_HORDE_GREEN_FLAG,true); + plr->CastSpell(plr, SPELL_HORDE_GREEN_FLAG, true); else - plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG,true); + plr->CastSpell(plr, SPELL_ALLIANCE_GREEN_FLAG, true); } plr->DestroyConjuredItems(true); @@ -1393,8 +1393,8 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created // so we must create it specific for this instance GameObject* go = new GameObject; - if (!go->Create(GetBgMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT),entry, GetBgMap(), - PHASEMASK_NORMAL, x,y,z,o, QuaternionData(rotation0,rotation1,rotation2,rotation3))) + if (!go->Create(GetBgMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), entry, GetBgMap(), + PHASEMASK_NORMAL, x, y, z, o, QuaternionData(rotation0, rotation1, rotation2, rotation3))) { sLog.outErrorDb("Gameobject template %u not found in database! BattleGround not created!", entry); sLog.outError("Cannot create gameobject template %u! BattleGround not created!", entry); @@ -1834,5 +1834,5 @@ bool BattleGround::IsTeamScoreInRange(Team team, uint32 minScore, uint32 maxScor void BattleGround::SetBracket(PvPDifficultyEntry const* bracketEntry) { m_BracketId = bracketEntry->GetBracketId(); - SetLevelRange(bracketEntry->minLevel,bracketEntry->maxLevel); + SetLevelRange(bracketEntry->minLevel, bracketEntry->maxLevel); } diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index c2593e905..f33746ec9 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -300,7 +300,7 @@ class BattleGround BattleGroundBracketId GetBracketId() const { return m_BracketId; } // the instanceId check is also used to determine a bg-template // that's why the m_map hack is here.. - uint32 GetInstanceID() { return m_Map?GetBgMap()->GetInstanceId():0; } + uint32 GetInstanceID() { return m_Map ? GetBgMap()->GetInstanceId() : 0; } BattleGroundStatus GetStatus() const { return m_Status; } uint32 GetClientInstanceID() const { return m_ClientInstanceID; } uint32 GetStartTime() const { return m_StartTime; } @@ -411,8 +411,8 @@ class BattleGround void CastSpellOnTeam(uint32 SpellID, Team team); void RewardHonorToTeam(uint32 Honor, Team team); void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, Team team); - void RewardMark(Player* plr,uint32 count); - void SendRewardMarkByMail(Player* plr,uint32 mark, uint32 count); + void RewardMark(Player* plr, uint32 count); + void SendRewardMarkByMail(Player* plr, uint32 mark, uint32 count); void RewardItem(Player* plr, uint32 item_id, uint32 count); void RewardQuestComplete(Player* plr); void RewardSpellCast(Player* plr, uint32 spell_id); @@ -633,7 +633,7 @@ inline void FillInitialWorldState(ByteBuffer& data, uint32& count, uint32 state, inline void FillInitialWorldState(ByteBuffer& data, uint32& count, uint32 state, bool value) { data << uint32(state); - data << uint32(value?1:0); + data << uint32(value ? 1 : 0); ++count; } diff --git a/src/game/BattleGroundAB.cpp b/src/game/BattleGroundAB.cpp index 774afd5fc..a2021b880 100644 --- a/src/game/BattleGroundAB.cpp +++ b/src/game/BattleGroundAB.cpp @@ -75,23 +75,23 @@ void BattleGroundAB::Update(uint32 diff) { m_NodeTimers[node] = 0; // Change from contested to occupied ! - uint8 teamIndex = m_Nodes[node]-1; + uint8 teamIndex = m_Nodes[node] - 1; m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] += 2; // create new occupied banner _CreateBanner(node, BG_AB_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); - _NodeOccupied(node,(teamIndex == 0) ? ALLIANCE:HORDE); + _NodeOccupied(node, (teamIndex == 0) ? ALLIANCE : HORDE); // Message to chatlog if (teamIndex == 0) { - 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)); PlaySoundToAll(BG_AB_SOUND_NODE_CAPTURED_ALLIANCE); } else { - SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN,CHAT_MSG_BG_SYSTEM_HORDE,NULL,LANG_BG_HORDE,_GetNodeNameId(node)); + SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node)); PlaySoundToAll(BG_AB_SOUND_NODE_CAPTURED_HORDE); } } @@ -253,7 +253,7 @@ int32 BattleGroundAB::_GetNodeNameId(uint8 node) case BG_AB_NODE_STABLES: return LANG_BG_AB_NODE_STABLES; case BG_AB_NODE_BLACKSMITH: return LANG_BG_AB_NODE_BLACKSMITH; case BG_AB_NODE_FARM: return LANG_BG_AB_NODE_FARM; - case BG_AB_NODE_LUMBER_MILL:return LANG_BG_AB_NODE_LUMBER_MILL; + case BG_AB_NODE_LUMBER_MILL: return LANG_BG_AB_NODE_LUMBER_MILL; case BG_AB_NODE_GOLD_MINE: return LANG_BG_AB_NODE_GOLD_MINE; default: MANGOS_ASSERT(0); @@ -267,12 +267,12 @@ void BattleGroundAB::FillInitialWorldStates(WorldPacket& data, uint32& count) // Node icons for (uint8 node = 0; node < BG_AB_NODES_MAX; ++node) - FillInitialWorldState(data, count, BG_AB_OP_NODEICONS[node], m_Nodes[node]==0); + FillInitialWorldState(data, count, BG_AB_OP_NODEICONS[node], m_Nodes[node] == 0); // Node occupied states for (uint8 node = 0; node < BG_AB_NODES_MAX; ++node) for (uint8 i = 1; i < BG_AB_NODES_MAX; ++i) - FillInitialWorldState(data, count, BG_AB_OP_NODESTATES[node] + plusArray[i], m_Nodes[node]==i); + FillInitialWorldState(data, count, BG_AB_OP_NODESTATES[node] + plusArray[i], m_Nodes[node] == i); // How many bases each team owns uint8 ally = 0, horde = 0; @@ -319,7 +319,7 @@ void BattleGroundAB::_SendNodeUpdate(uint8 node) UpdateWorldState(BG_AB_OP_OCCUPIED_BASES_HORDE, horde); } -void BattleGroundAB::_NodeOccupied(uint8 node,Team team) +void BattleGroundAB::_NodeOccupied(uint8 node, Team team) { uint8 capturedNodes = 0; for (uint8 i = 0; i < BG_AB_NODES_MAX; ++i) @@ -367,9 +367,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); + SendMessage2ToAll(LANG_BG_AB_NODE_CLAIMED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node), LANG_BG_HORDE); sound = BG_AB_SOUND_NODE_CLAIMED; } @@ -388,9 +388,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == BG_TEAM_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)); + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } // If contested, change back to occupied else @@ -402,12 +402,12 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target _CreateBanner(node, BG_AB_NODE_TYPE_OCCUPIED, teamIndex, true); _SendNodeUpdate(node); m_NodeTimers[node] = 0; - _NodeOccupied(node,(teamIndex == BG_TEAM_ALLIANCE) ? ALLIANCE:HORDE); + _NodeOccupied(node, (teamIndex == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE); if (teamIndex == BG_TEAM_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)); + SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); } sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } @@ -423,9 +423,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME; if (teamIndex == BG_TEAM_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)); + SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node)); sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE; } @@ -434,9 +434,9 @@ void BattleGroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* target if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED) { if (teamIndex == BG_TEAM_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)); + SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_HORDE, _GetNodeNameId(node)); } PlaySoundToAll(sound); } @@ -446,9 +446,9 @@ bool BattleGroundAB::SetupBattleGround() //buffs for (int i = 0; i < BG_AB_NODES_MAX; ++i) { - if (!AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i, Buff_Entries[0], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) - || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 1, Buff_Entries[1], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) - || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 2, Buff_Entries[2], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3]/2), cos(BG_AB_BuffPositions[i][3]/2), RESPAWN_ONE_DAY) + if (!AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i, Buff_Entries[0], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3] / 2), cos(BG_AB_BuffPositions[i][3] / 2), RESPAWN_ONE_DAY) + || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 1, Buff_Entries[1], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3] / 2), cos(BG_AB_BuffPositions[i][3] / 2), RESPAWN_ONE_DAY) + || !AddObject(BG_AB_OBJECT_SPEEDBUFF_STABLES + 3 * i + 2, Buff_Entries[2], BG_AB_BuffPositions[i][0], BG_AB_BuffPositions[i][1], BG_AB_BuffPositions[i][2], BG_AB_BuffPositions[i][3], 0, 0, sin(BG_AB_BuffPositions[i][3] / 2), cos(BG_AB_BuffPositions[i][3] / 2), RESPAWN_ONE_DAY) ) sLog.outErrorDb("BatteGroundAB: Failed to spawn buff object!"); } @@ -525,7 +525,7 @@ WorldSafeLocsEntry const* BattleGroundAB::GetClosestGraveYard(Player* player) WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[nodes[i]]); if (!entry) continue; - float dist = (entry->x - plr_x)*(entry->x - plr_x)+(entry->y - plr_y)*(entry->y - plr_y); + float dist = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y); if (mindist > dist) { mindist = dist; @@ -536,7 +536,7 @@ 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; } @@ -556,7 +556,7 @@ void BattleGroundAB::UpdatePlayerScore(Player* Source, uint32 type, uint32 value ((BattleGroundABScore*)itr->second)->BasesDefended += value; break; default: - BattleGround::UpdatePlayerScore(Source,type,value); + BattleGround::UpdatePlayerScore(Source, type, value); break; } } diff --git a/src/game/BattleGroundAB.h b/src/game/BattleGroundAB.h index 9a6191d60..12209943f 100644 --- a/src/game/BattleGroundAB.h +++ b/src/game/BattleGroundAB.h @@ -212,7 +212,7 @@ class BattleGroundAB : public BattleGround /* Creature spawning/despawning */ // TODO: working, scripted peons spawning - void _NodeOccupied(uint8 node,Team team); + void _NodeOccupied(uint8 node, Team team); int32 _GetNodeNameId(uint8 node); diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index 687a6d91f..a288d58e7 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -221,7 +221,7 @@ void BattleGroundAV::UpdateScore(BattleGroundTeamIndex teamIdx, int32 points) { m_TeamScores[teamIdx] = 0; // other team will win: - EndBattleGround((teamIdx == BG_TEAM_ALLIANCE)? HORDE : ALLIANCE); + EndBattleGround((teamIdx == BG_TEAM_ALLIANCE) ? HORDE : ALLIANCE); } else if (!m_IsInformedNearLose[teamIdx] && m_TeamScores[teamIdx] < BG_AV_SCORE_NEAR_LOSE) { @@ -246,7 +246,7 @@ void BattleGroundAV::Update(uint32 diff) { if (m_Mine_Owner[mine] != BG_AV_TEAM_NEUTRAL) { - m_Mine_Timer[mine] -=diff; + m_Mine_Timer[mine] -= diff; if (m_Mine_Timer[mine] <= 0) { UpdateScore(BattleGroundTeamIndex(m_Mine_Owner[mine]), 1); @@ -568,7 +568,7 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node) { SendYell2ToAll(LANG_BG_AV_TOWER_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), - (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_TOWERS_DEFENDED, 1); PlaySoundToAll(BG_AV_SOUND_BOTH_TOWER_DEFEND); } @@ -576,10 +576,10 @@ void BattleGroundAV::EventPlayerDefendsPoint(Player* player, BG_AV_Nodes node) { SendYell2ToAll(LANG_BG_AV_GRAVE_DEFENDED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), - (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_GRAVEYARDS_DEFENDED, 1); // update the statistic for the defending player - PlaySoundToAll((teamIdx == BG_TEAM_ALLIANCE)?BG_AV_SOUND_ALLIANCE_GOOD:BG_AV_SOUND_HORDE_GOOD); + PlaySoundToAll((teamIdx == BG_TEAM_ALLIANCE) ? BG_AV_SOUND_ALLIANCE_GOOD : BG_AV_SOUND_HORDE_GOOD); } } @@ -599,14 +599,14 @@ void BattleGroundAV::EventPlayerAssaultsPoint(Player* player, BG_AV_Nodes node) { SendYell2ToAll(LANG_BG_AV_TOWER_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), - (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); UpdatePlayerScore(player, SCORE_TOWERS_ASSAULTED, 1); } else { SendYell2ToAll(LANG_BG_AV_GRAVE_ASSAULTED, LANG_UNIVERSAL, GetSingleCreatureGuid(BG_AV_HERALD, 0), GetNodeName(node), - (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY:LANG_BG_HORDE); + (teamIdx == BG_TEAM_ALLIANCE) ? LANG_BG_ALLY : LANG_BG_HORDE); // update the statistic for the assaulting player UpdatePlayerScore(player, SCORE_GRAVEYARDS_ASSAULTED, 1); } @@ -656,11 +656,11 @@ void BattleGroundAV::FillInitialWorldStates(WorldPacket& data, uint32& count) void BattleGroundAV::UpdateNodeWorldState(BG_AV_Nodes node) { - UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].State,m_Nodes[node].Owner)], 1); + UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].State, m_Nodes[node].Owner)], 1); if (m_Nodes[node].PrevOwner == BG_AV_TEAM_NEUTRAL) // currently only snowfall is supported as neutral node UpdateWorldState(AV_SNOWFALL_N, 0); else - UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState,m_Nodes[node].PrevOwner)], 0); + UpdateWorldState(BG_AV_NodeWorldStates[node][GetWorldStateType(m_Nodes[node].PrevState, m_Nodes[node].PrevOwner)], 0); } void BattleGroundAV::SendMineWorldStates(uint32 mine) @@ -807,7 +807,7 @@ void BattleGroundAV::Reset() { m_Mine_Owner[i] = BG_AV_TEAM_NEUTRAL; m_Mine_PrevOwner[i] = m_Mine_Owner[i]; - m_ActiveEvents[BG_AV_MINE_BOSSES+ i] = BG_AV_TEAM_NEUTRAL; + m_ActiveEvents[BG_AV_MINE_BOSSES + i] = BG_AV_TEAM_NEUTRAL; m_ActiveEvents[BG_AV_MINE_EVENT + i] = BG_AV_TEAM_NEUTRAL; m_Mine_Timer[i] = BG_AV_MINE_TICK_TIMER; } diff --git a/src/game/BattleGroundAV.h b/src/game/BattleGroundAV.h index a87df41da..4bba3691c 100644 --- a/src/game/BattleGroundAV.h +++ b/src/game/BattleGroundAV.h @@ -175,7 +175,7 @@ enum BG_AV_Graveyards BG_AV_GRAVE_MAIN_HORDE = 610 }; -const uint32 BG_AV_GraveyardIds[9]= +const uint32 BG_AV_GraveyardIds[9] = { BG_AV_GRAVE_STORM_AID, BG_AV_GRAVE_STORM_GRAVE, @@ -227,35 +227,35 @@ const uint32 BG_AV_MineWorldStates[2][BG_AV_TEAMS_COUNT] = const uint32 BG_AV_NodeWorldStates[BG_AV_NODES_MAX][4] = { // Stormpike first aid station - {1326,1325,1328,1327}, + {1326, 1325, 1328, 1327}, // Stormpike Graveyard - {1335,1333,1336,1334}, + {1335, 1333, 1336, 1334}, // Stoneheart Grave - {1304,1302,1303,1301}, + {1304, 1302, 1303, 1301}, // Snowfall Grave - {1343,1341,1344,1342}, + {1343, 1341, 1344, 1342}, // Iceblood grave - {1348,1346,1349,1347}, + {1348, 1346, 1349, 1347}, // Frostwolf Grave - {1339,1337,1340,1338}, + {1339, 1337, 1340, 1338}, // Frostwolf Hut - {1331,1329,1332,1330}, + {1331, 1329, 1332, 1330}, // Dunbaldar South Bunker - {1375,1361,1378,1370}, + {1375, 1361, 1378, 1370}, // Dunbaldar North Bunker - {1374,1362,1379,1371}, + {1374, 1362, 1379, 1371}, // Icewing Bunker - {1376,1363,1380,1372}, + {1376, 1363, 1380, 1372}, // Stoneheart Bunker - {1377,1364,1381,1373}, + {1377, 1364, 1381, 1373}, // Iceblood Tower - {1390,1368,1395,1385}, + {1390, 1368, 1395, 1385}, // Tower Point - {1389,1367,1394,1384}, + {1389, 1367, 1394, 1384}, // Frostwolf East - {1388,1366,1393,1383}, + {1388, 1366, 1393, 1383}, // Frostwolf West - {1387,1365,1392,1382}, + {1387, 1365, 1392, 1382}, }; // through the armorscap-quest 4 different gravedefender exist @@ -365,8 +365,8 @@ class BattleGroundAV : public BattleGround void PopulateNode(BG_AV_Nodes node); uint32 GetNodeName(BG_AV_Nodes node); - const bool IsTower(BG_AV_Nodes node) { return (node == BG_AV_NODES_ERROR)? false : m_Nodes[node].Tower; } - const bool IsGrave(BG_AV_Nodes node) { return (node == BG_AV_NODES_ERROR)? false : !m_Nodes[node].Tower; } + const bool IsTower(BG_AV_Nodes node) { return (node == BG_AV_NODES_ERROR) ? false : m_Nodes[node].Tower; } + const bool IsGrave(BG_AV_Nodes node) { return (node == BG_AV_NODES_ERROR) ? false : !m_Nodes[node].Tower; } /*mine*/ void ChangeMineOwner(uint8 mine, BattleGroundAVTeamIndex teamIdx); diff --git a/src/game/BattleGroundBE.cpp b/src/game/BattleGroundBE.cpp index 7461949b9..85302d1fb 100644 --- a/src/game/BattleGroundBE.cpp +++ b/src/game/BattleGroundBE.cpp @@ -94,7 +94,7 @@ void BattleGroundBE::HandleKillPlayer(Player* player, Player* killer) return; } - BattleGround::HandleKillPlayer(player,killer); + BattleGround::HandleKillPlayer(player, killer); UpdateWorldState(0x9f1, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0x9f0, GetAlivePlayersCountByTeam(HORDE)); @@ -104,7 +104,7 @@ void BattleGroundBE::HandleKillPlayer(Player* player, Player* killer) bool BattleGroundBE::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(),6238.930176f,262.963470f,0.889519f,player->GetOrientation(),false); + player->TeleportTo(GetMapId(), 6238.930176f, 262.963470f, 0.889519f, player->GetOrientation(), false); return true; } diff --git a/src/game/BattleGroundEY.cpp b/src/game/BattleGroundEY.cpp index e72aecb61..435492291 100644 --- a/src/game/BattleGroundEY.cpp +++ b/src/game/BattleGroundEY.cpp @@ -163,7 +163,7 @@ void BattleGroundEY::CheckSomeoneJoinedPoint() void BattleGroundEY::CheckSomeoneLeftPoint() { //reset current point counts - for (uint8 i = 0; i < 2*BG_EY_NODES_MAX; ++i) + for (uint8 i = 0; i < 2 * BG_EY_NODES_MAX; ++i) m_CurrentPointPlayersCount[i] = 0; for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) { @@ -576,9 +576,9 @@ void BattleGroundEY::EventTeamLostPoint(Player* Source, uint32 Point) //buff isn't despawned if (team == ALLIANCE) - SendMessageToAll(LoosingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); + SendMessageToAll(LoosingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); else - SendMessageToAll(LoosingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source); + SendMessageToAll(LoosingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source); UpdatePointsIcons(team, Point); UpdatePointsCount(team); @@ -600,9 +600,9 @@ void BattleGroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point) m_PointState[Point] = EY_POINT_UNDER_CONTROL; if (team == ALLIANCE) - SendMessageToAll(CapturingPointTypes[Point].MessageIdAlliance,CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); + SendMessageToAll(CapturingPointTypes[Point].MessageIdAlliance, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source); else - SendMessageToAll(CapturingPointTypes[Point].MessageIdHorde,CHAT_MSG_BG_SYSTEM_HORDE, Source); + SendMessageToAll(CapturingPointTypes[Point].MessageIdHorde, CHAT_MSG_BG_SYSTEM_HORDE, Source); UpdatePointsIcons(team, Point); UpdatePointsCount(team); @@ -729,19 +729,19 @@ WorldSafeLocsEntry const* BattleGroundEY::GetClosestGraveYard(Player* player) float plr_z = player->GetPositionZ(); - distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z); + distance = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y) + (entry->z - plr_z) * (entry->z - plr_z); nearestDistance = distance; for (uint8 i = 0; i < BG_EY_NODES_MAX; ++i) { - if (m_PointOwnedByTeam[i]==player->GetTeam() && m_PointState[i]==EY_POINT_UNDER_CONTROL) + if (m_PointOwnedByTeam[i] == player->GetTeam() && m_PointState[i] == EY_POINT_UNDER_CONTROL) { entry = sWorldSafeLocsStore.LookupEntry(CapturingPointTypes[i].GraveYardId); if (!entry) - sLog.outError("BattleGroundEY: Not found graveyard: %u",CapturingPointTypes[i].GraveYardId); + sLog.outError("BattleGroundEY: Not found graveyard: %u", CapturingPointTypes[i].GraveYardId); else { - distance = (entry->x - plr_x)*(entry->x - plr_x) + (entry->y - plr_y)*(entry->y - plr_y) + (entry->z - plr_z)*(entry->z - plr_z); + distance = (entry->x - plr_x) * (entry->x - plr_x) + (entry->y - plr_y) * (entry->y - plr_y) + (entry->z - plr_z) * (entry->z - plr_z); if (distance < nearestDistance) { nearestDistance = distance; diff --git a/src/game/BattleGroundEY.h b/src/game/BattleGroundEY.h index 5d8d708b7..d63eb4741 100644 --- a/src/game/BattleGroundEY.h +++ b/src/game/BattleGroundEY.h @@ -319,7 +319,7 @@ class BattleGroundEY : public BattleGround uint8 m_PointState[BG_EY_NODES_MAX]; int32 m_PointBarStatus[BG_EY_NODES_MAX]; GuidVector m_PlayersNearPoint[BG_EY_NODES_MAX_WITH_SPEIAL]; - uint8 m_CurrentPointPlayersCount[2*BG_EY_NODES_MAX]; + uint8 m_CurrentPointPlayersCount[2 * BG_EY_NODES_MAX]; int32 m_PointAddingTimer; uint32 m_HonorTics; diff --git a/src/game/BattleGroundHandler.cpp b/src/game/BattleGroundHandler.cpp index 23b21716d..6e4ff8c86 100644 --- a/src/game/BattleGroundHandler.cpp +++ b/src/game/BattleGroundHandler.cpp @@ -91,7 +91,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) if (!sBattlemasterListStore.LookupEntry(bgTypeId_)) { - sLog.outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u",bgTypeId_,_player->GetGUIDLow()); + sLog.outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u", bgTypeId_, _player->GetGUIDLow()); return; } @@ -118,7 +118,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) } // expected bracket entry - PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel()); + PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) return; @@ -194,7 +194,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) member->GetSession()->SendPacket(&data); sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, err); member->GetSession()->SendPacket(&data); - DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,member->GetGUIDLow(), member->GetName()); + DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName()); } DEBUG_LOG("Battleground: group end"); } @@ -209,7 +209,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data) // send status packet (in queue) sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, ginfo->arenaType); SendPacket(&data); - DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName()); + DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName()); } sBattleGroundMgr.ScheduleQueueUpdate(0, ARENA_TYPE_NONE, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } @@ -238,7 +238,7 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket& /*recv_d if (horde_plr) ++count2; - WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4+16*count1+16*count2)); + WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4 + 4 + 16 * count1 + 16 * count2)); data << count1; // alliance flag holders count - obsolete, now always 0 /*for(uint8 i = 0; i < count1; ++i) { @@ -270,7 +270,7 @@ void WorldSession::HandleBattleGroundPlayerPositionsOpcode(WorldPacket& /*recv_d case BATTLEGROUND_AV: { //for other BG types - send default - WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4+4)); + WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, (4 + 4)); data << uint32(0); data << uint32(0); SendPacket(&data); @@ -386,7 +386,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data) } // expected bracket entry - PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel()); + PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) return; @@ -555,7 +555,7 @@ void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket& /*recv_data*/) continue; // expected bracket entry - PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel()); + PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) continue; @@ -661,7 +661,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data) BattleGroundTypeId bgTypeId = bg->GetTypeID(); BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, arenatype); - PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),_player->getLevel()); + PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel()); if (!bracketEntry) return; @@ -740,7 +740,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data) { DEBUG_LOG("Battleground: arena join as group start"); if (isRated) - DEBUG_LOG("Battleground: arena team id %u, leader %s queued with rating %u for type %u",_player->GetArenaTeamId(arenaslot),_player->GetName(),arenaRating,arenatype); + DEBUG_LOG("Battleground: arena team id %u, leader %s queued with rating %u for type %u", _player->GetArenaTeamId(arenaslot), _player->GetName(), arenaRating, arenatype); GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, isRated, false, arenaRating, ateamId); avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId()); @@ -783,7 +783,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recv_data) // send status packet (in queue) sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0, arenatype); SendPacket(&data); - DEBUG_LOG("Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s",bgQueueTypeId,bgTypeId,_player->GetGUIDLow(), _player->GetName()); + DEBUG_LOG("Battleground: player joined queue for arena, skirmish, bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName()); } sBattleGroundMgr.ScheduleQueueUpdate(arenaRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } diff --git a/src/game/BattleGroundIC.cpp b/src/game/BattleGroundIC.cpp index 8cc2873c9..7450ff28a 100644 --- a/src/game/BattleGroundIC.cpp +++ b/src/game/BattleGroundIC.cpp @@ -77,5 +77,5 @@ void BattleGroundIC::UpdatePlayerScore(Player* Source, uint32 type, uint32 value if (itr == m_PlayerScores.end()) // player not found... return; - BattleGround::UpdatePlayerScore(Source,type,value); + BattleGround::UpdatePlayerScore(Source, type, value); } diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 9108cc386..83f34f58c 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -72,7 +72,7 @@ BattleGroundQueue::~BattleGroundQueue() { for (uint32 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j) { - for (GroupsQueueType::iterator itr = m_QueuedGroups[i][j].begin(); itr!= m_QueuedGroups[i][j].end(); ++itr) + for (GroupsQueueType::iterator itr = m_QueuedGroups[i][j].begin(); itr != m_QueuedGroups[i][j].end(); ++itr) delete(*itr); m_QueuedGroups[i][j].clear(); } @@ -232,7 +232,7 @@ GroupQueueInfo* BattleGroundQueue::AddGroup(Player* leader, Group* grp, BattleGr qHorde += (*itr)->Players.size(); // Show queue status to player only (when joining queue) - if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_QUEUE_ANNOUNCER_JOIN)==1) + if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_QUEUE_ANNOUNCER_JOIN) == 1) { ChatHandler(leader).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level, qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0); @@ -805,7 +805,7 @@ void BattleGroundQueue::Update(BattleGroundTypeId bgTypeId, BattleGroundBracketI return; } - PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketById(bg_template->GetMapId(),bracket_id); + PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketById(bg_template->GetMapId(), bracket_id); if (!bracketEntry) { sLog.outError("Battleground: Update: bg bracket entry not found for map %u bracket id %u", bg_template->GetMapId(), bracket_id); @@ -1098,7 +1098,7 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[m_BgQueueTypeId]; if (bgQueue.IsPlayerInvited(m_PlayerGuid, m_BgInstanceGUID, m_RemoveTime)) { - DEBUG_LOG("Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.",plr->GetGUIDLow(),m_BgInstanceGUID); + DEBUG_LOG("Battleground: removing player %u from bg queue for instance %u because of not pressing enter battle in time.", plr->GetGUIDLow(), m_BgInstanceGUID); plr->RemoveBattleGroundQueueId(m_BgQueueTypeId); bgQueue.RemovePlayer(m_PlayerGuid, true); @@ -1130,7 +1130,7 @@ BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTe for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; i++) m_BattleGrounds[i].clear(); m_NextRatingDiscardUpdate = sWorld.getConfig(CONFIG_UINT32_ARENA_RATING_DISCARD_TIMER); - m_Testing=false; + m_Testing = false; } BattleGroundMgr::~BattleGroundMgr() @@ -1221,13 +1221,13 @@ void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket* data, BattleGro if (StatusID == 0 || !bg) { - data->Initialize(SMSG_BATTLEFIELD_STATUS, 4+8); + data->Initialize(SMSG_BATTLEFIELD_STATUS, 4 + 8); *data << uint32(QueueSlot); // queue id (0...1) *data << uint64(0); return; } - data->Initialize(SMSG_BATTLEFIELD_STATUS, (4+8+1+1+4+1+4+4+4)); + data->Initialize(SMSG_BATTLEFIELD_STATUS, (4 + 8 + 1 + 1 + 4 + 1 + 4 + 4 + 4)); *data << uint32(QueueSlot); // queue id (0...1) - player can be in 2 queues in time // uint64 in client *data << uint64(uint64(arenatype) | (uint64(0x0D) << 8) | (uint64(bg->GetTypeID()) << 16) | (uint64(0x1F90) << 48)); @@ -1266,7 +1266,7 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket* data, BattleGround* bg) { uint8 type = (bg->isArena() ? 1 : 0); // last check on 3.0.3 - data->Initialize(MSG_PVP_LOG_DATA, (1+1+4+40*bg->GetPlayerScoresSize())); + data->Initialize(MSG_PVP_LOG_DATA, (1 + 1 + 4 + 40 * bg->GetPlayerScoresSize())); *data << uint8(type); // type (battleground=0/arena=1) if (type) // arena @@ -1382,7 +1382,7 @@ void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket* data, Grou void BattleGroundMgr::BuildUpdateWorldStatePacket(WorldPacket* data, uint32 field, uint32 value) { - data->Initialize(SMSG_UPDATE_WORLD_STATE, 4+4); + data->Initialize(SMSG_UPDATE_WORLD_STATE, 4 + 4); *data << uint32(field); *data << uint32(value); } @@ -1486,7 +1486,7 @@ BattleGround* BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId if (bg_template->isArena()) { BattleGroundTypeId arenas[] = { BATTLEGROUND_NA, BATTLEGROUND_BE, BATTLEGROUND_RL/*, BATTLEGROUND_DS, BATTLEGROUND_RV*/ }; - bgTypeId = arenas[urand(0, countof(arenas)-1)]; + bgTypeId = arenas[urand(0, countof(arenas) - 1)]; bg_template = GetBattleGroundTemplate(bgTypeId); if (!bg_template) { @@ -1830,7 +1830,7 @@ void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket* data, ObjectGuid if (BattleGround* bgTemplate = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId)) { // expected bracket entry - if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel())) + if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), plr->getLevel())) { BattleGroundBracketId bracketId = bracketEntry->GetBracketId(); ClientBattleGroundIdSet const& ids = m_ClientBattleGroundIds[bgTypeId][bracketId]; @@ -1853,7 +1853,7 @@ void BattleGroundMgr::SendToBattleGround(Player* pl, uint32 instanceId, BattleGr uint32 mapid = bg->GetMapId(); float x, y, z, O; Team team = pl->GetBGTeam(); - if (team==0) + if (team == 0) team = pl->GetTeam(); bg->GetTeamStartLoc(team, x, y, z, O); @@ -1862,7 +1862,7 @@ void BattleGroundMgr::SendToBattleGround(Player* pl, uint32 instanceId, BattleGr } else { - sLog.outError("player %u trying to port to nonexistent bg instance %u",pl->GetGUIDLow(), instanceId); + sLog.outError("player %u trying to port to nonexistent bg instance %u", pl->GetGUIDLow(), instanceId); } } diff --git a/src/game/BattleGroundNA.cpp b/src/game/BattleGroundNA.cpp index 7258ef959..a54cc10e5 100644 --- a/src/game/BattleGroundNA.cpp +++ b/src/game/BattleGroundNA.cpp @@ -95,7 +95,7 @@ void BattleGroundNA::HandleKillPlayer(Player* player, Player* killer) return; } - BattleGround::HandleKillPlayer(player,killer); + BattleGround::HandleKillPlayer(player, killer); UpdateWorldState(0xa0f, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0xa10, GetAlivePlayersCountByTeam(HORDE)); @@ -105,7 +105,7 @@ void BattleGroundNA::HandleKillPlayer(Player* player, Player* killer) bool BattleGroundNA::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(),4055.504395f,2919.660645f,13.611241f,player->GetOrientation(),false); + player->TeleportTo(GetMapId(), 4055.504395f, 2919.660645f, 13.611241f, player->GetOrientation(), false); return true; } diff --git a/src/game/BattleGroundRB.cpp b/src/game/BattleGroundRB.cpp index c4c256b5f..93115698a 100644 --- a/src/game/BattleGroundRB.cpp +++ b/src/game/BattleGroundRB.cpp @@ -77,5 +77,5 @@ void BattleGroundRB::UpdatePlayerScore(Player* Source, uint32 type, uint32 value if (itr == m_PlayerScores.end()) // player not found... return; - BattleGround::UpdatePlayerScore(Source,type,value); + BattleGround::UpdatePlayerScore(Source, type, value); } diff --git a/src/game/BattleGroundRL.cpp b/src/game/BattleGroundRL.cpp index 6fc689780..fd0f96c95 100644 --- a/src/game/BattleGroundRL.cpp +++ b/src/game/BattleGroundRL.cpp @@ -94,7 +94,7 @@ void BattleGroundRL::HandleKillPlayer(Player* player, Player* killer) return; } - BattleGround::HandleKillPlayer(player,killer); + BattleGround::HandleKillPlayer(player, killer); UpdateWorldState(0xbb8, GetAlivePlayersCountByTeam(ALLIANCE)); UpdateWorldState(0xbb9, GetAlivePlayersCountByTeam(HORDE)); @@ -104,7 +104,7 @@ void BattleGroundRL::HandleKillPlayer(Player* player, Player* killer) bool BattleGroundRL::HandlePlayerUnderMap(Player* player) { - player->TeleportTo(GetMapId(),1285.810547f,1667.896851f,39.957642f,player->GetOrientation(),false); + player->TeleportTo(GetMapId(), 1285.810547f, 1667.896851f, 39.957642f, player->GetOrientation(), false); return true; } diff --git a/src/game/BattleGroundSA.cpp b/src/game/BattleGroundSA.cpp index 6a9ad9dec..00b17e94e 100644 --- a/src/game/BattleGroundSA.cpp +++ b/src/game/BattleGroundSA.cpp @@ -76,5 +76,5 @@ void BattleGroundSA::UpdatePlayerScore(Player* Source, uint32 type, uint32 value if (itr == m_PlayerScores.end()) // player not found... return; - BattleGround::UpdatePlayerScore(Source,type,value); + BattleGround::UpdatePlayerScore(Source, type, value); } diff --git a/src/game/BattleGroundWS.h b/src/game/BattleGroundWS.h index 8637339c1..8ff8a7104 100644 --- a/src/game/BattleGroundWS.h +++ b/src/game/BattleGroundWS.h @@ -134,7 +134,7 @@ class BattleGroundWS : public BattleGround virtual void Reset(); void EndBattleGround(Team winner); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); - uint32 GetRemainingTimeInMinutes() { return m_EndTimer ? (m_EndTimer-1) / (MINUTE * IN_MILLISECONDS) + 1 : 0; } + uint32 GetRemainingTimeInMinutes() { return m_EndTimer ? (m_EndTimer - 1) / (MINUTE * IN_MILLISECONDS) + 1 : 0; } void UpdateFlagState(Team team, uint32 value); void UpdateTeamScore(Team team); diff --git a/src/game/CalendarHandler.cpp b/src/game/CalendarHandler.cpp index 4a5bb4cd1..49232286c 100644 --- a/src/game/CalendarHandler.cpp +++ b/src/game/CalendarHandler.cpp @@ -30,7 +30,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/) time_t cur_time = time(NULL); - WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 4+4*0+4+4*0+4+4); + WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 4 + 4 * 0 + 4 + 4 * 0 + 4 + 4); // TODO: calendar invite event output data << (uint32) 0; // invite node count @@ -59,7 +59,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recv_data*/) } } } - data.put(p_counter,counter); + data.put(p_counter, counter); data << (uint32) 1135753200; // base date (28.12.2005 12:00) data << (uint32) 0; // raid reset count diff --git a/src/game/Camera.cpp b/src/game/Camera.cpp index e75d95eaa..d5360c023 100644 --- a/src/game/Camera.cpp +++ b/src/game/Camera.cpp @@ -134,7 +134,7 @@ void Camera::UpdateVisibilityOf(WorldObject* target) template void Camera::UpdateVisibilityOf(T* target, UpdateData& data, std::set& vis) { - m_owner.template UpdateVisibilityOf(m_source, target,data,vis); + m_owner.template UpdateVisibilityOf(m_source, target, data, vis); } template void Camera::UpdateVisibilityOf(Player* , UpdateData& , std::set&); diff --git a/src/game/Cell.h b/src/game/Cell.h index e56e52845..04c357a8a 100644 --- a/src/game/Cell.h +++ b/src/game/Cell.h @@ -52,8 +52,8 @@ struct MANGOS_DLL_DECL Cell void Compute(uint32& x, uint32& y) const { - x = data.Part.grid_x*MAX_NUMBER_OF_CELLS + data.Part.cell_x; - y = data.Part.grid_y*MAX_NUMBER_OF_CELLS + data.Part.cell_y; + x = data.Part.grid_x * MAX_NUMBER_OF_CELLS + data.Part.cell_x; + y = data.Part.grid_y * MAX_NUMBER_OF_CELLS + data.Part.cell_y; } bool DiffCell(const Cell& cell) const @@ -75,13 +75,13 @@ struct MANGOS_DLL_DECL Cell bool NoCreate() const { return data.Part.nocreate; } void SetNoCreate() { data.Part.nocreate = 1; } - GridPair gridPair() const { return GridPair(GridX(),GridY()); } + GridPair gridPair() const { return GridPair(GridX(), GridY()); } CellPair cellPair() const { return CellPair( - data.Part.grid_x*MAX_NUMBER_OF_CELLS+data.Part.cell_x, - data.Part.grid_y*MAX_NUMBER_OF_CELLS+data.Part.cell_y); + data.Part.grid_x * MAX_NUMBER_OF_CELLS + data.Part.cell_x, + data.Part.grid_y * MAX_NUMBER_OF_CELLS + data.Part.cell_y); } Cell& operator=(const Cell& cell) diff --git a/src/game/CellImpl.h b/src/game/CellImpl.h index 9c9c72260..936252de5 100644 --- a/src/game/CellImpl.h +++ b/src/game/CellImpl.h @@ -106,7 +106,7 @@ Cell::Visit(const CellPair& standing_cell, TypeContainerVisitor& v { for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; y++) { - CellPair cell_pair(x,y); + CellPair cell_pair(x, y); //lets skip standing cell since we already visited it if (cell_pair != standing_cell) { @@ -133,7 +133,7 @@ Cell::VisitCircle(TypeContainerVisitor& visitor, Map& m, const Cel { for (uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y) { - CellPair cell_pair(x,y); + CellPair cell_pair(x, y); Cell r_zone(cell_pair); r_zone.data.Part.nocreate = data.Part.nocreate; m.Visit(r_zone, visitor); @@ -225,7 +225,7 @@ inline void Cell::VisitWorldObjects(float x, float y, Map* map, T& visitor, floa if (dont_load) cell.SetNoCreate(); TypeContainerVisitor gnotifier(visitor); - cell.Visit(p ,gnotifier, *map, x, y, radius); + cell.Visit(p , gnotifier, *map, x, y, radius); } template diff --git a/src/game/Channel.cpp b/src/game/Channel.cpp index 764f94458..d9e923602 100644 --- a/src/game/Channel.cpp +++ b/src/game/Channel.cpp @@ -435,7 +435,7 @@ void Channel::List(Player* player) } else { - WorldPacket data(SMSG_CHANNEL_LIST, 1+(GetName().size()+1)+1+4+m_players.size()*(8+1)); + WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + m_players.size() * (8 + 1)); data << uint8(1); // channel type? data << GetName(); // channel name data << uint8(GetFlags()); // channel flags? @@ -461,7 +461,7 @@ void Channel::List(Player* player) } } - data.put(pos,count); + data.put(pos, count); SendToOne(&data, p); } @@ -565,7 +565,7 @@ void Channel::Say(ObjectGuid p, const char* what, uint32 lang) { uint32 messageLength = strlen(what) + 1; - WorldPacket data(SMSG_MESSAGECHAT, 1+4+8+4+m_name.size()+1+8+4+messageLength+1); + WorldPacket data(SMSG_MESSAGECHAT, 1 + 4 + 8 + 4 + m_name.size() + 1 + 8 + 4 + messageLength + 1); data << uint8(CHAT_MSG_CHANNEL); data << uint32(lang); data << ObjectGuid(p); // 2.1.0 @@ -686,7 +686,7 @@ void Channel::DeVoice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/) // done void Channel::MakeNotifyPacket(WorldPacket* data, uint8 notify_type) { - data->Initialize(SMSG_CHANNEL_NOTIFY, 1+m_name.size()+1); + data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + m_name.size() + 1); *data << uint8(notify_type); *data << m_name; } @@ -948,9 +948,9 @@ void Channel::JoinNotify(ObjectGuid guid) WorldPacket data; if (IsConstant()) - data.Initialize(SMSG_USERLIST_ADD, 8+1+1+4+GetName().size()+1); + data.Initialize(SMSG_USERLIST_ADD, 8 + 1 + 1 + 4 + GetName().size() + 1); else - data.Initialize(SMSG_USERLIST_UPDATE, 8+1+1+4+GetName().size()+1); + data.Initialize(SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size() + 1); data << ObjectGuid(guid); data << uint8(GetPlayerFlags(guid)); @@ -962,7 +962,7 @@ void Channel::JoinNotify(ObjectGuid guid) void Channel::LeaveNotify(ObjectGuid guid) { - WorldPacket data(SMSG_USERLIST_REMOVE, 8+1+4+GetName().size()+1); + WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size() + 1); data << ObjectGuid(guid); data << uint8(GetFlags()); data << uint32(GetNumPlayers()); diff --git a/src/game/ChannelHandler.cpp b/src/game/ChannelHandler.cpp index 9014728fd..1179c7ffc 100644 --- a/src/game/ChannelHandler.cpp +++ b/src/game/ChannelHandler.cpp @@ -295,7 +295,7 @@ void WorldSession::HandleGetChannelMemberCountOpcode(WorldPacket& recvPacket) { if (Channel* chn = cMgr->GetChannel(channelname, _player)) { - WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size()+1+1+4); + WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size() + 1 + 1 + 4); data << chn->GetName(); data << uint8(chn->GetFlags()); data << uint32(chn->GetNumPlayers()); diff --git a/src/game/ChannelMgr.cpp b/src/game/ChannelMgr.cpp index 8d7d50065..b71c4140c 100644 --- a/src/game/ChannelMgr.cpp +++ b/src/game/ChannelMgr.cpp @@ -38,7 +38,7 @@ ChannelMgr* channelMgr(Team team) ChannelMgr::~ChannelMgr() { - for (ChannelMap::iterator itr = channels.begin(); itr!=channels.end(); ++itr) + for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr) delete itr->second; channels.clear(); @@ -47,12 +47,12 @@ ChannelMgr::~ChannelMgr() Channel* ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id) { std::wstring wname; - Utf8toWStr(name,wname); + Utf8toWStr(name, wname); wstrToLower(wname); if (channels.find(wname) == channels.end()) { - Channel* nchan = new Channel(name,channel_id); + Channel* nchan = new Channel(name, channel_id); channels[wname] = nchan; return nchan; } @@ -63,7 +63,7 @@ Channel* ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id) Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) { std::wstring wname; - Utf8toWStr(name,wname); + Utf8toWStr(name, wname); wstrToLower(wname); ChannelMap::const_iterator i = channels.find(wname); @@ -73,7 +73,7 @@ Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) if (pkt) { WorldPacket data; - MakeNotOnPacket(&data,name); + MakeNotOnPacket(&data, name); p->GetSession()->SendPacket(&data); } @@ -86,7 +86,7 @@ Channel* ChannelMgr::GetChannel(std::string name, Player* p, bool pkt) void ChannelMgr::LeftChannel(std::string name) { std::wstring wname; - Utf8toWStr(name,wname); + Utf8toWStr(name, wname); wstrToLower(wname); ChannelMap::const_iterator i = channels.find(wname); @@ -105,6 +105,6 @@ void ChannelMgr::LeftChannel(std::string name) void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string name) { - data->Initialize(SMSG_CHANNEL_NOTIFY, (1+10)); // we guess size + data->Initialize(SMSG_CHANNEL_NOTIFY, (1 + 10)); // we guess size (*data) << (uint8)CHAT_NOT_MEMBER_NOTICE << name; } diff --git a/src/game/ChannelMgr.h b/src/game/ChannelMgr.h index c92eb695c..abdf0a0db 100644 --- a/src/game/ChannelMgr.h +++ b/src/game/ChannelMgr.h @@ -28,7 +28,7 @@ class ChannelMgr { public: - typedef std::map ChannelMap; + typedef std::map ChannelMap; ChannelMgr() {} ~ChannelMgr(); diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 727ee36db..eea40b9d0 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -79,9 +79,9 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,item_guid,spell,stackcount,remaincharges,basepoints0,basepoints1,basepoints2,periodictime0,periodictime1,periodictime2,maxduration,remaintime,effIndexMask FROM character_aura WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS, "SELECT quest,status,rewarded,explored,timer,mobcount1,mobcount2,mobcount3,mobcount4,itemcount1,itemcount2,itemcount3,itemcount4,itemcount5,itemcount6 FROM character_queststatus WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS,"SELECT quest FROM character_queststatus_daily WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADWEEKLYQUESTSTATUS,"SELECT quest FROM character_queststatus_weekly WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMONTHLYQUESTSTATUS,"SELECT quest FROM character_queststatus_monthly WHERE guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS, "SELECT quest FROM character_queststatus_daily WHERE guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADWEEKLYQUESTSTATUS, "SELECT quest FROM character_queststatus_weekly WHERE guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMONTHLYQUESTSTATUS, "SELECT quest FROM character_queststatus_monthly WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADREPUTATION, "SELECT faction,standing,flags FROM character_reputation WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADINVENTORY, "SELECT data,text,bag,slot,item,item_template FROM character_inventory JOIN item_instance ON character_inventory.item = item_instance.guid WHERE character_inventory.guid = '%u' ORDER BY bag,slot", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADITEMLOOT, "SELECT guid,itemid,amount,suffix,property FROM item_loot WHERE owner_guid = '%u'", m_guid.GetCounter()); @@ -95,7 +95,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGUILD, "SELECT guildid,rank FROM guild_member WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADARENAINFO, "SELECT arenateamid, played_week, played_season, wons_season, personal_rating FROM arena_team_member WHERE guid='%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACHIEVEMENTS, "SELECT achievement, date FROM character_achievement WHERE guid = '%u'", m_guid.GetCounter()); - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS,"SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADCRITERIAPROGRESS, "SELECT criteria, counter, date FROM character_achievement_progress WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADEQUIPMENTSETS, "SELECT setguid, setindex, name, iconname, ignore_mask, item0, item1, item2, item3, item4, item5, item6, item7, item8, item9, item10, item11, item12, item13, item14, item15, item16, item17, item18 FROM character_equipmentsets WHERE guid = '%u' ORDER BY setindex", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBGDATA, "SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map, taxi_start, taxi_end, mount_spell FROM character_battleground_data WHERE guid = '%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA, "SELECT type, time, data FROM character_account_data WHERE guid='%u'", m_guid.GetCounter()); @@ -297,7 +297,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data) QueryResult* resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%u'", GetAccountId()); if (resultacct) { - Field* fields=resultacct->Fetch(); + Field* fields = resultacct->Fetch(); uint32 acctcharcount = fields[0].GetUInt32(); delete resultacct; @@ -349,7 +349,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data) bool have_same_race = false; // if 0 then allowed creating without any characters - bool have_req_level_for_heroic = (req_level_for_heroic==0); + bool have_req_level_for_heroic = (req_level_for_heroic == 0); if (!AllowTwoSideAccounts || skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT) { @@ -357,7 +357,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recv_data) GetAccountId(), (skipCinematics == CINEMATICS_SKIP_SAME_RACE || class_ == CLASS_DEATH_KNIGHT) ? "" : "LIMIT 1"); if (result2) { - Team team_= Player::TeamForRace(race_); + Team team_ = Player::TeamForRace(race_); Field* field = result2->Fetch(); uint8 acc_race = field[1].GetUInt32(); @@ -601,7 +601,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) SendPacket(&data); // load player specific part before send times - LoadAccountData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA),PER_CHARACTER_CACHE_MASK); + LoadAccountData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA), PER_CHARACTER_CACHE_MASK); SendAccountDataTimes(PER_CHARACTER_CACHE_MASK); data.Initialize(SMSG_FEATURE_SYSTEM_STATUS, 2); // added in 2.2.0 @@ -614,16 +614,16 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) data.Initialize(SMSG_MOTD, 50); // new in 2.0.1 data << (uint32)0; - uint32 linecount=0; + uint32 linecount = 0; std::string str_motd = sWorld.GetMotd(); std::string::size_type pos, nextpos; pos = 0; - while ((nextpos= str_motd.find('@',pos)) != std::string::npos) + while ((nextpos = str_motd.find('@', pos)) != std::string::npos) { if (nextpos != pos) { - data << str_motd.substr(pos, nextpos-pos); + data << str_motd.substr(pos, nextpos - pos); ++linecount; } pos = nextpos + 1; @@ -662,7 +662,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId()); if (guild) { - data.Initialize(SMSG_GUILD_EVENT, (1+1+guild->GetMOTD().size()+1)); + data.Initialize(SMSG_GUILD_EVENT, (1 + 1 + guild->GetMOTD().size() + 1)); data << uint8(GE_MOTD); data << uint8(1); data << guild->GetMOTD(); @@ -676,12 +676,12 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) else { // remove wrong guild data - sLog.outError("Player %s (GUID: %u) marked as member of nonexistent guild (id: %u), removing guild membership for player.",pCurrChar->GetName(),pCurrChar->GetGUIDLow(),pCurrChar->GetGuildId()); + sLog.outError("Player %s (GUID: %u) marked as member of nonexistent guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId()); pCurrChar->SetInGuild(0); } } - data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4+4); + data.Initialize(SMSG_LEARNED_DANCE_MOVES, 4 + 4); data << uint32(0); data << uint32(0); SendPacket(&data); @@ -759,7 +759,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) pCurrChar->LoadPet(); // Set FFA PvP for non GM in non-rest mode - if (sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_RESTING)) + if (sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) pCurrChar->SetFFAPvP(true); if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) @@ -774,7 +774,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) { - pCurrChar->resetTalents(true,true); + pCurrChar->resetTalents(true, true); pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state SendNotification(LANG_RESET_TALENTS); // we can use SMSG_TALENTS_INVOLUNTARILY_RESET here } @@ -784,7 +784,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) // show time before shutdown if shutdown planned. if (sWorld.IsShutdowning()) - sWorld.ShutdownMsg(true,pCurrChar); + sWorld.ShutdownMsg(true, pCurrChar); if (sWorld.getConfig(CONFIG_BOOL_ALL_TAXI_PATHS)) pCurrChar->SetTaxiCheater(true); @@ -907,7 +907,7 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recv_data) return; } - uint8 res = ObjectMgr::CheckPlayerName(newname,true); + uint8 res = ObjectMgr::CheckPlayerName(newname, true); if (res != CHAR_NAME_SUCCESS) { WorldPacket data(SMSG_CHAR_RENAME, 1); @@ -967,7 +967,7 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult* result, uin sLog.outChar("Account: %d (IP: %s) Character:[%s] (guid:%u) Changed name to: %s", session->GetAccountId(), session->GetRemoteAddress().c_str(), oldname.c_str(), guidLow, newname.c_str()); - WorldPacket data(SMSG_CHAR_RENAME, 1+8+(newname.size()+1)); + WorldPacket data(SMSG_CHAR_RENAME, 1 + 8 + (newname.size() + 1)); data << uint8(RESPONSE_SUCCESS); data << guid; data << newname; @@ -984,7 +984,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) std::string name; if (!sObjectMgr.GetPlayerNameByGUID(guid, name)) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); data << ObjectGuid(guid); SendPacket(&data); @@ -994,7 +994,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) std::wstring wname; if (!Utf8toWStr(name, wname)) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); data << ObjectGuid(guid); SendPacket(&data); @@ -1003,7 +1003,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) if (!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); data << ObjectGuid(guid); SendPacket(&data); @@ -1017,7 +1017,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) if (name2 != name) // character have different name { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); data << ObjectGuid(guid); SendPacket(&data); @@ -1029,7 +1029,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) recv_data >> declinedname.name[i]; if (!normalizePlayerName(declinedname.name[i])) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); data << ObjectGuid(guid); SendPacket(&data); @@ -1039,7 +1039,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) if (!ObjectMgr::CheckDeclinedNames(GetMainPartOfName(wname, 0), declinedname)) { - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(1); data << ObjectGuid(guid); SendPacket(&data); @@ -1055,7 +1055,7 @@ void WorldSession::HandleSetPlayerDeclinedNamesOpcode(WorldPacket& recv_data) guid.GetCounter(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str()); CharacterDatabase.CommitTransaction(); - WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8); + WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4 + 8); data << uint32(0); // OK data << ObjectGuid(guid); SendPacket(&data); @@ -1180,7 +1180,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data) return; } - uint8 res = ObjectMgr::CheckPlayerName(newname,true); + uint8 res = ObjectMgr::CheckPlayerName(newname, true); if (res != CHAR_NAME_SUCCESS) { WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1); @@ -1216,7 +1216,7 @@ void WorldSession::HandleCharCustomizeOpcode(WorldPacket& recv_data) std::string IP_str = GetRemoteAddress(); sLog.outChar("Account: %d (IP: %s), Character %s customized to: %s", GetAccountId(), IP_str.c_str(), guid.GetString().c_str(), newname.c_str()); - WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1+8+(newname.size()+1)+6); + WorldPacket data(SMSG_CHAR_CUSTOMIZE, 1 + 8 + (newname.size() + 1) + 6); data << uint8(RESPONSE_SUCCESS); data << ObjectGuid(guid); data << newname; diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 4caa4ce16..4d544dc00 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -92,7 +92,7 @@ ChatCommand* ChatHandler::getCommandTable() static ChatCommand achievementCriteriaCommandTable[] = { { "add", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAchievementCriteriaAddCommand, "", NULL }, - { "remove", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAchievementCriteriaRemoveCommand,"", NULL }, + { "remove", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAchievementCriteriaRemoveCommand, "", NULL }, { NULL, 0, true, NULL, "", NULL } }; @@ -111,9 +111,9 @@ ChatCommand* ChatHandler::getCommandTable() { "white", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand, "", NULL }, { "green", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand, "", NULL }, { "blue", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand, "", NULL }, - { "purple", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand,"", NULL }, - { "orange", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand,"", NULL }, - { "yellow", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand,"", NULL }, + { "purple", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand, "", NULL }, + { "orange", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand, "", NULL }, + { "yellow", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountQualityCommand, "", NULL }, { "", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAHBotItemsAmountCommand, "", NULL }, { NULL, 0, true, NULL, "", NULL } }; @@ -190,15 +190,15 @@ ChatCommand* ChatHandler::getCommandTable() static ChatCommand characterDeletedCommandTable[] = { { "delete", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeletedDeleteCommand, "", NULL }, - { "list", SEC_ADMINISTRATOR, true, &ChatHandler::HandleCharacterDeletedListCommand,"", NULL }, - { "restore", SEC_ADMINISTRATOR, true, &ChatHandler::HandleCharacterDeletedRestoreCommand,"", NULL }, + { "list", SEC_ADMINISTRATOR, true, &ChatHandler::HandleCharacterDeletedListCommand, "", NULL }, + { "restore", SEC_ADMINISTRATOR, true, &ChatHandler::HandleCharacterDeletedRestoreCommand, "", NULL }, { "old", SEC_CONSOLE, true, &ChatHandler::HandleCharacterDeletedOldCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand characterCommandTable[] = { - { "achievements", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterAchievementsCommand,"",NULL }, + { "achievements", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterAchievementsCommand, "", NULL }, { "customize", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterCustomizeCommand, "", NULL }, { "deleted", SEC_GAMEMASTER, true, NULL, "", characterDeletedCommandTable}, { "erase", SEC_CONSOLE, true, &ChatHandler::HandleCharacterEraseCommand, "", NULL }, @@ -340,7 +340,7 @@ ChatCommand* ChatHandler::getCommandTable() { "all_default", SEC_MODERATOR, false, &ChatHandler::HandleLearnAllDefaultCommand, "", NULL }, { "all_lang", SEC_MODERATOR, false, &ChatHandler::HandleLearnAllLangCommand, "", NULL }, { "all_myclass", SEC_ADMINISTRATOR, false, &ChatHandler::HandleLearnAllMyClassCommand, "", NULL }, - { "all_mypettalents",SEC_ADMINISTRATOR, false, &ChatHandler::HandleLearnAllMyPetTalentsCommand,"", NULL }, + { "all_mypettalents", SEC_ADMINISTRATOR, false, &ChatHandler::HandleLearnAllMyPetTalentsCommand, "", NULL }, { "all_myspells", SEC_ADMINISTRATOR, false, &ChatHandler::HandleLearnAllMySpellsCommand, "", NULL }, { "all_mytalents", SEC_ADMINISTRATOR, false, &ChatHandler::HandleLearnAllMyTalentsCommand, "", NULL }, { "all_recipes", SEC_GAMEMASTER, false, &ChatHandler::HandleLearnAllRecipesCommand, "", NULL }, @@ -500,7 +500,7 @@ ChatCommand* ChatHandler::getCommandTable() static ChatCommand reloadCommandTable[] = { { "all", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllCommand, "", NULL }, - { "all_achievement",SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllAchievementCommand,"", NULL }, + { "all_achievement", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllAchievementCommand, "", NULL }, { "all_area", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllAreaCommand, "", NULL }, { "all_eventai", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllEventAICommand, "", NULL }, { "all_gossips", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAllGossipsCommand, "", NULL }, @@ -514,9 +514,9 @@ ChatCommand* ChatHandler::getCommandTable() { "config", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadConfigCommand, "", NULL }, - { "achievement_criteria_requirement",SEC_ADMINISTRATOR,true,&ChatHandler::HandleReloadAchievementCriteriaRequirementCommand,"",NULL }, + { "achievement_criteria_requirement", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAchievementCriteriaRequirementCommand, "", NULL }, { "achievement_reward", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAchievementRewardCommand, "", NULL }, - { "areatrigger_involvedrelation",SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, + { "areatrigger_involvedrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, { "areatrigger_tavern", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAreaTriggerTavernCommand, "", NULL }, { "areatrigger_teleport", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAreaTriggerTeleportCommand, "", NULL }, { "command", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCommandCommand, "", NULL }, @@ -525,7 +525,7 @@ ChatCommand* ChatHandler::getCommandTable() { "creature_ai_summons", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventAISummonsCommand, "", NULL }, { "creature_ai_texts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadEventAITextsCommand, "", NULL }, { "creature_battleground", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadBattleEventCommand, "", NULL }, - { "creature_involvedrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand,"",NULL }, + { "creature_involvedrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestInvRelationsCommand, "", NULL }, { "creature_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesCreatureCommand, "", NULL }, { "creature_questrelation", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureQuestRelationsCommand, "", NULL }, { "db_script_string", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadDbScriptStringCommand, "", NULL }, @@ -546,7 +546,7 @@ ChatCommand* ChatHandler::getCommandTable() { "item_enchantment_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadItemEnchantementsCommand, "", NULL }, { "item_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesItemCommand, "", NULL }, { "item_required_target", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadItemRequiredTragetCommand, "", NULL }, - { "locales_achievement_reward", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesAchievementRewardCommand,"", NULL }, + { "locales_achievement_reward", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesAchievementRewardCommand, "", NULL }, { "locales_creature", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesCreatureCommand, "", NULL }, { "locales_gameobject", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesGameobjectCommand, "", NULL }, { "locales_gossip_menu_option", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLocalesGossipMenuOptionCommand, "", NULL }, @@ -565,9 +565,9 @@ ChatCommand* ChatHandler::getCommandTable() { "npc_trainer", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadNpcTrainerCommand, "", NULL }, { "npc_vendor", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadNpcVendorCommand, "", NULL }, { "page_text", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPageTextsCommand, "", NULL }, - { "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesPickpocketingCommand,"",NULL}, + { "pickpocketing_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesPickpocketingCommand, "", NULL}, { "points_of_interest", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPointsOfInterestCommand, "", NULL }, - { "prospecting_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesProspectingCommand,"", NULL }, + { "prospecting_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesProspectingCommand, "", NULL }, { "quest_end_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestEndScriptsCommand, "", NULL }, { "quest_poi", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestPOICommand, "", NULL }, { "quest_start_scripts", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestStartScriptsCommand, "", NULL }, @@ -575,7 +575,7 @@ ChatCommand* ChatHandler::getCommandTable() { "reference_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadLootTemplatesReferenceCommand, "", NULL }, { "reserved_name", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadReservedNameCommand, "", NULL }, { "reputation_reward_rate", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadReputationRewardRateCommand, "", NULL }, - { "reputation_spillover_template",SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadReputationSpilloverTemplateCommand,"", NULL }, + { "reputation_spillover_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadReputationSpilloverTemplateCommand, "", NULL }, { "skill_discovery_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSkillDiscoveryTemplateCommand, "", NULL }, { "skill_extra_item_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSkillExtraItemTemplateCommand, "", NULL }, { "skill_fishing_base_level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSkillFishingBaseLevelCommand, "", NULL }, @@ -631,28 +631,28 @@ ChatCommand* ChatHandler::getCommandTable() static ChatCommand serverIdleRestartCommandTable[] = { - { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand, "", NULL }, { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleRestartCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand serverIdleShutdownCommandTable[] = { - { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand, "", NULL }, { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerIdleShutDownCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand serverRestartCommandTable[] = { - { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand, "", NULL }, { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerRestartCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; static ChatCommand serverShutdownCommandTable[] = { - { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand,"", NULL }, + { "cancel", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCancelCommand, "", NULL }, { "" , SEC_ADMINISTRATOR, true, &ChatHandler::HandleServerShutDownCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -818,7 +818,7 @@ ChatCommand* ChatHandler::getCommandTable() { "cometome", SEC_ADMINISTRATOR, false, &ChatHandler::HandleComeToMeCommand, "", NULL }, { "damage", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDamageCommand, "", NULL }, { "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL }, - { "flusharenapoints",SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, + { "flusharenapoints", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, { "repairitems", SEC_GAMEMASTER, true, &ChatHandler::HandleRepairitemsCommand, "", NULL }, { "stable", SEC_ADMINISTRATOR, false, &ChatHandler::HandleStableCommand, "", NULL }, { "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL }, @@ -909,7 +909,7 @@ bool ChatHandler::HasLowerSecurity(Player* target, ObjectGuid guid, bool strong) return true; } - return HasLowerSecurityAccount(target_session,target_account,strong); + return HasLowerSecurityAccount(target_session, target_account, strong); } bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_account, bool strong) @@ -1033,7 +1033,7 @@ void ChatHandler::CheckIntegrity(ChatCommand* table, ChatCommand* parentCommand) sLog.outError("Subcommand '%s' of command '%s' have less access level (%u) that parent (%u)", command->Name, parentCommand->Name, command->SecurityLevel, parentCommand->SecurityLevel); - if (!parentCommand && strlen(command->Name)==0) + if (!parentCommand && strlen(command->Name) == 0) sLog.outError("Subcommand '' at top level"); if (command->ChildCommands) @@ -1048,7 +1048,7 @@ void ChatHandler::CheckIntegrity(ChatCommand* table, ChatCommand* parentCommand) command->Name); } - if (parentCommand && strlen(command->Name)==0) + if (parentCommand && strlen(command->Name) == 0) sLog.outError("Subcommand '' of command '%s' have subcommands", parentCommand->Name); CheckIntegrity(command->ChildCommands, command); @@ -1129,7 +1129,7 @@ ChatCommandSearchResult ChatHandler::FindCommand(ChatCommand* table, char const* if (exactlyName) { size_t len = strlen(table[i].Name); - if (strncmp(table[i].Name, cmd.c_str(), len+1) != 0) + if (strncmp(table[i].Name, cmd.c_str(), len + 1) != 0) continue; } else @@ -1153,7 +1153,7 @@ ChatCommandSearchResult ChatHandler::FindCommand(ChatCommand* table, char const* *parentCommand = parentSubcommand ? parentSubcommand : &table[i]; // Name == "" is special case: restore original command text for next level "" (where parentSubcommand==NULL) - if (strlen(command->Name)==0 && !parentSubcommand) + if (strlen(command->Name) == 0 && !parentSubcommand) text = oldchildtext; return CHAT_COMMAND_OK; @@ -1247,7 +1247,7 @@ void ChatHandler::ExecuteCommand(const char* text) else SendSysMessage(LANG_CMD_SYNTAX); - if (ChatCommand* showCommand = (strlen(command->Name)==0 && parentCommand ? parentCommand : command)) + if (ChatCommand* showCommand = (strlen(command->Name) == 0 && parentCommand ? parentCommand : command)) if (ChatCommand* childs = showCommand->ChildCommands) ShowHelpForSubCommands(childs, showCommand->Name); @@ -1258,7 +1258,7 @@ void ChatHandler::ExecuteCommand(const char* text) case CHAT_COMMAND_UNKNOWN_SUBCOMMAND: { SendSysMessage(LANG_NO_SUBCMD); - ShowHelpForCommand(command->ChildCommands,text); + ShowHelpForCommand(command->ChildCommands, text); SetSentErrorMessage(true); break; } @@ -1298,7 +1298,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand* commandTable, const char { if (command->SecurityLevel != security) DETAIL_LOG("Table `command` overwrite for command '%s' default security (%u) by %u", - fullcommand.c_str(),command->SecurityLevel,security); + fullcommand.c_str(), command->SecurityLevel, security); command->SecurityLevel = security; command->Help = help; @@ -1489,7 +1489,7 @@ bool ChatHandler::isValidChatMessage(const char* message) { if (commandChar == *validSequenceIterator) { - if (validSequenceIterator == validSequence+4) + if (validSequenceIterator == validSequence + 4) validSequenceIterator = validSequence; else ++validSequenceIterator; @@ -1508,7 +1508,7 @@ bool ChatHandler::isValidChatMessage(const char* message) ItemPrototype const* linkedItem = NULL; Quest const* linkedQuest = NULL; - SpellEntry const* linkedSpell= NULL; + SpellEntry const* linkedSpell = NULL; AchievementEntry const* linkedAchievement = NULL; ItemRandomPropertiesEntry const* itemProperty = NULL; ItemRandomSuffixEntry const* itemSuffix = NULL; @@ -1551,7 +1551,7 @@ bool ChatHandler::isValidChatMessage(const char* message) { if (commandChar == *validSequenceIterator) { - if (validSequenceIterator == validSequence+4) + if (validSequenceIterator == validSequence + 4) validSequenceIterator = validSequence; else ++validSequenceIterator; @@ -1574,7 +1574,7 @@ bool ChatHandler::isValidChatMessage(const char* message) case 'c': color = 0; // validate color, expect 8 hex chars - for (int i=0; i<8; i++) + for (int i = 0; i < 8; i++) { char c; reader >> c; @@ -1586,14 +1586,14 @@ bool ChatHandler::isValidChatMessage(const char* message) color <<= 4; // check for hex char - if (c >= '0' && c <='9') + if (c >= '0' && c <= '9') { - color |= c-'0'; + color |= c - '0'; continue; } - if (c >= 'a' && c <='f') + if (c >= 'a' && c <= 'f') { - color |= 10+c-'a'; + color |= 10 + c - 'a'; continue; } DEBUG_LOG("ChatHandler::isValidChatMessage got non hex char '%c' while reading color", c); @@ -1635,16 +1635,16 @@ bool ChatHandler::isValidChatMessage(const char* message) int32 propertyId = 0; bool negativeNumber = false; char c; - for (uint8 i=0; i < randomPropertyPosition; ++i) + for (uint8 i = 0; i < randomPropertyPosition; ++i) { propertyId = 0; negativeNumber = false; while ((c = reader.get()) != ':') { - if (c >='0' && c<='9') + if (c >= '0' && c <= '9') { - propertyId*=10; - propertyId += c-'0'; + propertyId *= 10; + propertyId += c - '0'; } else if (c == '-') negativeNumber = true; @@ -1669,7 +1669,7 @@ bool ChatHandler::isValidChatMessage(const char* message) } // ignore other integers - while ((c >= '0' && c <= '9') || c== ':') + while ((c >= '0' && c <= '9') || c == ':') { reader.ignore(1); c = reader.peek(); @@ -1678,14 +1678,14 @@ bool ChatHandler::isValidChatMessage(const char* message) else if (strcmp(buffer, "quest") == 0) { // no color check for questlinks, each client will adapt it anyway - uint32 questid= 0; + uint32 questid = 0; // read questid char c = reader.peek(); - while (c >='0' && c<='9') + while (c >= '0' && c <= '9') { reader.ignore(1); questid *= 10; - questid += c-'0'; + questid += c - '0'; c = reader.peek(); } @@ -1697,7 +1697,7 @@ bool ChatHandler::isValidChatMessage(const char* message) return false; } - if (c !=':') + if (c != ':') { DEBUG_LOG("ChatHandler::isValidChatMessage Invalid quest link structure"); return false; @@ -1707,11 +1707,11 @@ bool ChatHandler::isValidChatMessage(const char* message) c = reader.peek(); // level uint32 questlevel = 0; - while (c >='0' && c<='9') + while (c >= '0' && c <= '9') { reader.ignore(1); questlevel *= 10; - questlevel += c-'0'; + questlevel += c - '0'; c = reader.peek(); } @@ -1721,7 +1721,7 @@ bool ChatHandler::isValidChatMessage(const char* message) return false; } - if (c !='|') + if (c != '|') { DEBUG_LOG("ChatHandler::isValidChatMessage Invalid quest link structure"); return false; @@ -1743,7 +1743,7 @@ bool ChatHandler::isValidChatMessage(const char* message) char c = reader.peek(); // base64 encoded stuff - while (c !='|' && c!='\0') + while (c != '|' && c != '\0') { reader.ignore(1); c = reader.peek(); @@ -1770,7 +1770,7 @@ bool ChatHandler::isValidChatMessage(const char* message) char c = reader.peek(); // skillpoints? whatever, drop it - while (c !='|' && c!='\0') + while (c != '|' && c != '\0') { reader.ignore(1); c = reader.peek(); @@ -1784,11 +1784,11 @@ bool ChatHandler::isValidChatMessage(const char* message) uint32 spellid = 0; // read spell entry char c = reader.peek(); - while (c >='0' && c<='9') + while (c >= '0' && c <= '9') { reader.ignore(1); spellid *= 10; - spellid += c-'0'; + spellid += c - '0'; c = reader.peek(); } linkedSpell = sSpellStore.LookupEntry(spellid); @@ -1803,11 +1803,11 @@ bool ChatHandler::isValidChatMessage(const char* message) uint32 spellid = 0; // read spell entry char c = reader.peek(); - while (c >='0' && c<='9') + while (c >= '0' && c <= '9') { reader.ignore(1); spellid *= 10; - spellid += c-'0'; + spellid += c - '0'; c = reader.peek(); } linkedSpell = sSpellStore.LookupEntry(spellid); @@ -1831,7 +1831,7 @@ bool ChatHandler::isValidChatMessage(const char* message) char c = reader.peek(); // skip progress - while (c !='|' && c != '\0') + while (c != '|' && c != '\0') { reader.ignore(1); c = reader.peek(); @@ -1849,10 +1849,10 @@ bool ChatHandler::isValidChatMessage(const char* message) uint32 glyphId = 0; char c = reader.peek(); - while (c>='0' && c <='9') + while (c >= '0' && c <= '9') { glyphId *= 10; - glyphId += c-'0'; + glyphId += c - '0'; reader.ignore(1); c = reader.peek(); } @@ -1911,20 +1911,20 @@ bool ChatHandler::isValidChatMessage(const char* message) return false; } - for (uint8 i=0; i < MAX_LOCALE; ++i) + for (uint8 i = 0; i < MAX_LOCALE; ++i) { uint32 skillLineNameLength = strlen(skillLine->name[i]); if (skillLineNameLength > 0 && strncmp(skillLine->name[i], buffer, skillLineNameLength) == 0) { // found the prefix, remove it to perform spellname validation below // -2 = strlen(": ") - uint32 spellNameLength = strlen(buffer)-skillLineNameLength-2; - memmove(buffer, buffer+skillLineNameLength+2, spellNameLength+1); + uint32 spellNameLength = strlen(buffer) - skillLineNameLength - 2; + memmove(buffer, buffer + skillLineNameLength + 2, spellNameLength + 1); } } } bool foundName = false; - for (uint8 i=0; iSpellName[i] && strcmp(linkedSpell->SpellName[i], buffer) == 0) { @@ -1948,7 +1948,7 @@ bool ChatHandler::isValidChatMessage(const char* message) } bool foundName = false; - for (uint8 i=0; i < ql->Title.size(); ++i) + for (uint8 i = 0; i < ql->Title.size(); ++i) { if (ql->Title[i] == buffer) { @@ -1965,7 +1965,7 @@ bool ChatHandler::isValidChatMessage(const char* message) } else if (linkedItem) { - char* const* suffix = itemSuffix?itemSuffix->nameSuffix:(itemProperty?itemProperty->nameSuffix:NULL); + char* const* suffix = itemSuffix ? itemSuffix->nameSuffix : (itemProperty ? itemProperty->nameSuffix : NULL); std::string expectedName = std::string(linkedItem->Name1); if (suffix) @@ -1979,7 +1979,7 @@ bool ChatHandler::isValidChatMessage(const char* message) ItemLocale const* il = sObjectMgr.GetItemLocale(linkedItem->ItemId); bool foundName = false; - for (uint8 i=LOCALE_koKR; i= il->Name.size()) @@ -2008,7 +2008,7 @@ bool ChatHandler::isValidChatMessage(const char* message) else if (linkedAchievement) { bool foundName = false; - for (uint8 i=0; iname[i] && strcmp(linkedAchievement->name[i], buffer) == 0) { @@ -2420,7 +2420,7 @@ char* ChatHandler::ExtractQuotedArg(char** args, bool asis /*= false*/) if (guard == '[') guard = ']'; - char* tail = (*args)+1; // start scan after first quote symbol + char* tail = (*args) + 1; // start scan after first quote symbol char* head = asis ? *args : tail; // start arg while (*tail && *tail != guard) @@ -2442,7 +2442,7 @@ char* ChatHandler::ExtractQuotedArg(char** args, bool asis /*= false*/) *tail = '\0'; } - *args = tail+1; + *args = tail + 1; SkipWhiteSpaces(args); @@ -2525,7 +2525,7 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= // |color|Hlinktype:key:data...|h[name]|h|r - char* tail = (*args)+1; // skip | + char* tail = (*args) + 1; // skip | if (*tail != 'H') // skip color part, some links can not have color part { @@ -2595,8 +2595,8 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= // |h[name]|h|r or :something...|h[name]|h|r - char* somethingStart = tail+1; - char* somethingEnd = tail+1; // will updated later if need + char* somethingStart = tail + 1; + char* somethingEnd = tail + 1; // will updated later if need if (*tail == ':' && somethingPair) // optional data extraction { @@ -2618,7 +2618,7 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= // |h[name]|h|r or :something2...|h[name]|h|r - while (*tail && (*tail != '|' || *(tail+1) != 'h')) // skip ... part if exist + while (*tail && (*tail != '|' || *(tail + 1) != 'h')) // skip ... part if exist ++tail; if (!*tail) @@ -2632,19 +2632,19 @@ char* ChatHandler::ExtractLinkArg(char** args, char const* const* linkTypes /*= if (!*tail || *tail != '[') return NULL; - while (*tail && (*tail != ']' || *(tail+1) != '|')) // skip name part + while (*tail && (*tail != ']' || *(tail + 1) != '|')) // skip name part ++tail; tail += 2; // skip ]| // h|r - if (!*tail || *tail != 'h' || *(tail+1) != '|') + if (!*tail || *tail != 'h' || *(tail + 1) != '|') return NULL; tail += 2; // skip h| // r - if (!*tail || *tail != 'r' || (*(tail+1) && !isWhiteSpace(*(tail+1)))) + if (!*tail || *tail != 'r' || (*(tail + 1) && !isWhiteSpace(*(tail + 1)))) return NULL; ++tail; // skip r @@ -2814,7 +2814,7 @@ bool ChatHandler::ExtractUint32KeyFromLink(char** text, char const* linkType, ui return ExtractUInt32(&arg, value); } -GameObject* ChatHandler::GetGameObjectWithGuid(uint32 lowguid,uint32 entry) +GameObject* ChatHandler::GetGameObjectWithGuid(uint32 lowguid, uint32 entry) { if (!m_session) return NULL; @@ -2826,7 +2826,7 @@ GameObject* ChatHandler::GetGameObjectWithGuid(uint32 lowguid,uint32 entry) enum SpellLinkType { - SPELL_LINK_RAW =-1, // non-link case + SPELL_LINK_RAW = -1, // non-link case SPELL_LINK_SPELL = 0, SPELL_LINK_TALENT = 1, SPELL_LINK_ENCHANT = 2, @@ -2903,7 +2903,7 @@ uint32 ChatHandler::ExtractSpellIdFromLink(char** text) GameTele const* ChatHandler::ExtractGameTeleFromLink(char** text) { // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r - char* cId = ExtractKeyFromLink(text,"Htele"); + char* cId = ExtractKeyFromLink(text, "Htele"); if (!cId) return NULL; @@ -2917,7 +2917,7 @@ GameTele const* ChatHandler::ExtractGameTeleFromLink(char** text) enum GuidLinkType { - GUID_LINK_RAW =-1, // non-link case + GUID_LINK_RAW = -1, // non-link case GUID_LINK_PLAYER = 0, GUID_LINK_CREATURE = 1, GUID_LINK_GAMEOBJECT = 2, @@ -2986,7 +2986,7 @@ ObjectGuid ChatHandler::ExtractGuidFromLink(char** text) enum LocationLinkType { - LOCATION_LINK_RAW =-1, // non-link case + LOCATION_LINK_RAW = -1, // non-link case LOCATION_LINK_PLAYER = 0, LOCATION_LINK_TELE = 1, LOCATION_LINK_TAXINODE = 2, @@ -2995,7 +2995,7 @@ enum LocationLinkType LOCATION_LINK_CREATURE_ENTRY = 5, LOCATION_LINK_GAMEOBJECT_ENTRY = 6, LOCATION_LINK_AREATRIGGER = 7, - LOCATION_LINK_AREATRIGGER_TARGET= 8, + LOCATION_LINK_AREATRIGGER_TARGET = 8, }; static char const* const locationKeys[] = @@ -3253,7 +3253,7 @@ std::string ChatHandler::ExtractPlayerNameFromLink(char** text) * * @return true if extraction successful */ -bool ChatHandler::ExtractPlayerTarget(char** args, Player** player /*= NULL*/, ObjectGuid* player_guid /*= NULL*/,std::string* player_name /*= NULL*/) +bool ChatHandler::ExtractPlayerTarget(char** args, Player** player /*= NULL*/, ObjectGuid* player_guid /*= NULL*/, std::string* player_name /*= NULL*/) { if (*args &&** args) { @@ -3340,7 +3340,7 @@ uint32 ChatHandler::ExtractAccountId(char** args, std::string* accountName /*= N { if (!sAccountMgr.GetName(account_id, account_name)) { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_str); + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_str); SetSentErrorMessage(true); return 0; } @@ -3350,7 +3350,7 @@ uint32 ChatHandler::ExtractAccountId(char** args, std::string* accountName /*= N account_name = account_str; if (!AccountMgr::normalizeString(account_name)) { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); SetSentErrorMessage(true); return 0; } @@ -3358,7 +3358,7 @@ uint32 ChatHandler::ExtractAccountId(char** args, std::string* accountName /*= N account_id = sAccountMgr.GetId(account_name); if (!account_id) { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); SetSentErrorMessage(true); return 0; } @@ -3382,16 +3382,16 @@ struct RaceMaskName static RaceMaskName const raceMaskNames[] = { // races - { "human", (1<<(RACE_HUMAN-1)) }, - { "orc", (1<<(RACE_ORC-1)) }, - { "dwarf", (1<<(RACE_DWARF-1)) }, - { "nightelf", (1<<(RACE_NIGHTELF-1))}, - { "undead", (1<<(RACE_UNDEAD-1)) }, - { "tauren", (1<<(RACE_TAUREN-1)) }, - { "gnome", (1<<(RACE_GNOME-1)) }, - { "troll", (1<<(RACE_TROLL-1)) }, - { "bloodelf", (1<<(RACE_BLOODELF-1))}, - { "draenei", (1<<(RACE_DRAENEI-1)) }, + { "human", (1 << (RACE_HUMAN - 1)) }, + { "orc", (1 << (RACE_ORC - 1)) }, + { "dwarf", (1 << (RACE_DWARF - 1)) }, + { "nightelf", (1 << (RACE_NIGHTELF - 1))}, + { "undead", (1 << (RACE_UNDEAD - 1)) }, + { "tauren", (1 << (RACE_TAUREN - 1)) }, + { "gnome", (1 << (RACE_GNOME - 1)) }, + { "troll", (1 << (RACE_TROLL - 1)) }, + { "bloodelf", (1 << (RACE_BLOODELF - 1))}, + { "draenei", (1 << (RACE_DRAENEI - 1)) }, // masks { "alliance", RACEMASK_ALLIANCE }, @@ -3578,13 +3578,13 @@ void ChatHandler::LogCommand(char const* fullcmd) { Player* p = m_session->GetPlayer(); ObjectGuid sel_guid = p->GetSelectionGuid(); - sLog.outCommand(GetAccountId(),"Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s]", + sLog.outCommand(GetAccountId(), "Command: %s [Player: %s (Account: %u) X: %f Y: %f Z: %f Map: %u Selected: %s]", fullcmd, p->GetName(), GetAccountId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), p->GetMapId(), sel_guid.GetString().c_str()); } else // 0 account -> console { - sLog.outCommand(GetAccountId(),"Command: %s [Account: %u from %s]", + sLog.outCommand(GetAccountId(), "Command: %s [Account: %u from %s]", fullcmd, GetAccountId(), GetAccountId() ? "RA-connection" : "Console"); } } diff --git a/src/game/Chat.h b/src/game/Chat.h index f1822fc44..b616300fc 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -86,7 +86,7 @@ class MANGOS_DLL_SPEC ChatHandler FillMessageData(data, m_session, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, ObjectGuid(), message); } - static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; } + static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = NULL; return start; } // function with different implementation for chat/console virtual const char* GetMangosString(int32 entry) const; @@ -95,7 +95,7 @@ class MANGOS_DLL_SPEC ChatHandler virtual void SendSysMessage(const char* str); void SendSysMessage(int32 entry); - void PSendSysMessage(const char* format, ...) ATTR_PRINTF(2,3); + void PSendSysMessage(const char* format, ...) ATTR_PRINTF(2, 3); void PSendSysMessage(int32 entry, ...); bool ParseCommands(const char* text); @@ -617,7 +617,7 @@ class MANGOS_DLL_SPEC ChatHandler bool ExtractInt32(char** args, int32& val); bool ExtractOptInt32(char** args, int32& val, int32 defVal); bool ExtractUInt32Base(char** args, uint32& val, uint32 base); - bool ExtractUInt32(char** args, uint32& val) { return ExtractUInt32Base(args,val, 10); } + bool ExtractUInt32(char** args, uint32& val) { return ExtractUInt32Base(args, val, 10); } bool ExtractOptUInt32(char** args, uint32& val, uint32 defVal); bool ExtractFloat(char** args, float& val); bool ExtractOptFloat(char** args, float& val, float defVal); @@ -646,10 +646,10 @@ class MANGOS_DLL_SPEC ChatHandler bool ExtractPlayerTarget(char** args, Player** player, ObjectGuid* player_guid = NULL, std::string* player_name = NULL); // select by arg (name/link) or in-game selection online/offline player - std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; } + std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:" + name + "|h[" + name + "]|h|r" : name; } std::string GetNameLink(Player* chr) const; - GameObject* GetGameObjectWithGuid(uint32 lowguid,uint32 entry); + GameObject* GetGameObjectWithGuid(uint32 lowguid, uint32 entry); // Utility methods for commands bool ShowAccountListHelper(QueryResult* result, uint32* limit = NULL, bool title = true, bool error = true); @@ -670,7 +670,7 @@ class MANGOS_DLL_SPEC ChatHandler bool HandleBanInfoHelper(uint32 accountid, char const* accountname); bool HandleUnBanHelper(BanMode mode, char* args); void HandleCharacterLevel(Player* player, ObjectGuid player_guid, uint32 oldlevel, uint32 newlevel); - void HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id); + void HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id); bool HandleGoHelper(Player* _player, uint32 mapid, float x, float y, float const* zPtr = NULL, float const* ortPtr = NULL); bool HandleGetValueHelper(Object* target, uint32 field, char* typeStr); bool HandlerDebugModValueHelper(Object* target, uint32 field, char* typeStr, char* valStr); diff --git a/src/game/ChatHandler.cpp b/src/game/ChatHandler.cpp index 4aee9b0ad..3e5366e41 100644 --- a/src/game/ChatHandler.cpp +++ b/src/game/ChatHandler.cpp @@ -529,7 +529,7 @@ namespace MaNGOS char const* nam = i_target ? i_target->GetNameForLocaleIdx(loc_idx) : NULL; uint32 namlen = (nam ? strlen(nam) : 0) + 1; - data.Initialize(SMSG_TEXT_EMOTE, (20+namlen)); + data.Initialize(SMSG_TEXT_EMOTE, (20 + namlen)); data << ObjectGuid(i_player.GetObjectGuid()); data << uint32(i_text_emote); data << uint32(i_emote_num); @@ -625,14 +625,14 @@ void WorldSession::HandleChatIgnoredOpcode(WorldPacket& recv_data) void WorldSession::SendPlayerNotFoundNotice(std::string name) { - WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, name.size()+1); + WorldPacket data(SMSG_CHAT_PLAYER_NOT_FOUND, name.size() + 1); data << name; SendPacket(&data); } void WorldSession::SendPlayerAmbiguousNotice(std::string name) { - WorldPacket data(SMSG_CHAT_PLAYER_AMBIGUOUS, name.size()+1); + WorldPacket data(SMSG_CHAT_PLAYER_AMBIGUOUS, name.size() + 1); data << name; SendPacket(&data); } diff --git a/src/game/CombatHandler.cpp b/src/game/CombatHandler.cpp index 87856a1ae..1c958cdf3 100644 --- a/src/game/CombatHandler.cpp +++ b/src/game/CombatHandler.cpp @@ -50,7 +50,7 @@ void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data) if (_player->IsFriendlyTo(pEnemy) || pEnemy->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) { - sLog.outError("WORLD: Enemy %s is friendly",guid.GetString().c_str()); + sLog.outError("WORLD: Enemy %s is friendly", guid.GetString().c_str()); // stop attack state at client SendAttackStop(pEnemy); @@ -65,7 +65,7 @@ void WorldSession::HandleAttackSwingOpcode(WorldPacket& recv_data) return; } - _player->Attack(pEnemy,true); + _player->Attack(pEnemy, true); } void WorldSession::HandleAttackStopOpcode(WorldPacket& /*recv_data*/) @@ -82,7 +82,7 @@ void WorldSession::HandleSetSheathedOpcode(WorldPacket& recv_data) if (sheathed >= MAX_SHEATH_STATE) { - sLog.outError("Unknown sheath state %u ??",sheathed); + sLog.outError("Unknown sheath state %u ??", sheathed); return; } @@ -91,7 +91,7 @@ void WorldSession::HandleSetSheathedOpcode(WorldPacket& recv_data) void WorldSession::SendAttackStop(Unit const* enemy) { - WorldPacket data(SMSG_ATTACKSTOP, (4+20)); // we guess size + WorldPacket data(SMSG_ATTACKSTOP, (4 + 20)); // we guess size data << GetPlayer()->GetPackGUID(); data << (enemy ? enemy->GetPackGUID() : PackedGuid()); // must be packed guid data << uint32(0); // unk, can be 1 also diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp index 4817cbf07..c268cf989 100644 --- a/src/game/ConfusedMovementGenerator.cpp +++ b/src/game/ConfusedMovementGenerator.cpp @@ -31,7 +31,7 @@ void ConfusedMovementGenerator::Initialize(T& unit) unit.GetPosition(i_x, i_y, i_z); unit.StopMoving(); - unit.addUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); + unit.addUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE); } template @@ -46,7 +46,7 @@ void ConfusedMovementGenerator::Reset(T& unit) { i_nextMoveTime.Reset(0); unit.StopMoving(); - unit.addUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); + unit.addUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE); } template @@ -73,8 +73,8 @@ bool ConfusedMovementGenerator::Update(T& unit, const uint32& diff) // start moving unit.addUnitState(UNIT_STAT_CONFUSED_MOVE); - float x = i_x + 10.0f*(rand_norm_f() - 0.5f); - float y = i_y + 10.0f*(rand_norm_f() - 0.5f); + float x = i_x + 10.0f * (rand_norm_f() - 0.5f); + float y = i_y + 10.0f * (rand_norm_f() - 0.5f); float z = i_z; unit.UpdateAllowedPositionZ(x, y, z); @@ -101,14 +101,14 @@ bool ConfusedMovementGenerator::Update(T& unit, const uint32& diff) template<> void ConfusedMovementGenerator::Finalize(Player& unit) { - unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); + unit.clearUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE); unit.StopMoving(); } template<> void ConfusedMovementGenerator::Finalize(Creature& unit) { - unit.clearUnitState(UNIT_STAT_CONFUSED|UNIT_STAT_CONFUSED_MOVE); + unit.clearUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_CONFUSED_MOVE); } template void ConfusedMovementGenerator::Initialize(Player& player); diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index fe7ef10ca..3317a7b73 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -115,7 +115,7 @@ void Corpse::SaveToDB() << GetPositionZ() << ", " << GetOrientation() << ", " << GetMapId() << ", " - << uint64(m_time) <<", " + << uint64(m_time) << ", " << uint32(GetType()) << ", " << int(GetInstanceId()) << ", " << uint16(GetPhaseMask()) << ")"; // prevent out of range error @@ -155,7 +155,7 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields) //QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map," //// 7 8 9 10 11 12 13 14 15 16 17 18 // "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse" - uint32 playerLowGuid= fields[1].GetUInt32(); + uint32 playerLowGuid = fields[1].GetUInt32(); float positionX = fields[2].GetFloat(); float positionY = fields[3].GetFloat(); float positionZ = fields[4].GetFloat(); @@ -277,7 +277,7 @@ 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; + return m_time < t - 3 * DAY; } diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 14b27d93e..39cae819b 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -349,13 +349,13 @@ bool Creature::UpdateEntry(uint32 Entry, Team team, const CreatureData* data /*= else setFaction(GetCreatureInfo()->faction_A); - SetUInt32Value(UNIT_NPC_FLAGS,GetCreatureInfo()->npcflag); + SetUInt32Value(UNIT_NPC_FLAGS, GetCreatureInfo()->npcflag); uint32 attackTimer = GetCreatureInfo()->baseattacktime; SetAttackTime(BASE_ATTACK, attackTimer); - SetAttackTime(OFF_ATTACK, attackTimer - attackTimer/4); - SetAttackTime(RANGED_ATTACK,GetCreatureInfo()->rangeattacktime); + SetAttackTime(OFF_ATTACK, attackTimer - attackTimer / 4); + SetAttackTime(RANGED_ATTACK, GetCreatureInfo()->rangeattacktime); uint32 unitFlags = GetCreatureInfo()->unit_flags; @@ -424,12 +424,12 @@ uint32 Creature::ChooseDisplayId(const CreatureInfo* cinfo, const CreatureData* if (cinfo->ModelId[3] && cinfo->ModelId[2] && cinfo->ModelId[1] && cinfo->ModelId[0]) { - display_id = cinfo->ModelId[urand(0,3)]; + display_id = cinfo->ModelId[urand(0, 3)]; } else if (cinfo->ModelId[2] && cinfo->ModelId[1] && cinfo->ModelId[0]) { uint32 modelid_tmp = sObjectMgr.GetCreatureModelAlternativeModel(cinfo->ModelId[1]); - display_id = modelid_tmp ? cinfo->ModelId[urand(0,2)] : cinfo->ModelId[2]; + display_id = modelid_tmp ? cinfo->ModelId[urand(0, 2)] : cinfo->ModelId[2]; } else if (cinfo->ModelId[1]) { @@ -462,11 +462,11 @@ void Creature::Update(uint32 update_diff, uint32 diff) { case JUST_ALIVED: // Don't must be called, see Creature::SetDeathState JUST_ALIVED -> ALIVE promoting. - sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_ALIVED (4)",GetGUIDLow(),GetEntry()); + sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_ALIVED (4)", GetGUIDLow(), GetEntry()); break; case JUST_DIED: // Don't must be called, see Creature::SetDeathState JUST_DIED -> CORPSE promoting. - sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1)",GetGUIDLow(),GetEntry()); + sLog.outError("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1)", GetGUIDLow(), GetEntry()); break; case DEAD: { @@ -691,7 +691,7 @@ void Creature::RegenerateHealth() addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); } else - addvalue = maxValue/3; + addvalue = maxValue / 3; ModifyHealth(addvalue); } @@ -702,7 +702,7 @@ void Creature::DoFleeToGetAssistance() return; float radius = sWorld.getConfig(CONFIG_FLOAT_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS); - if (radius >0) + if (radius > 0) { Creature* pCreature = NULL; @@ -714,7 +714,7 @@ 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()); } @@ -804,7 +804,7 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const if ((!cSpells || cSpells->spellList.empty()) && (!tSpells || tSpells->spellList.empty())) { sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.", - GetGUIDLow(),GetEntry()); + GetGUIDLow(), GetEntry()); return false; } } @@ -822,12 +822,12 @@ bool Creature::IsTrainerOf(Player* pPlayer, bool msg) const case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu(4913, GetObjectGuid()); break; case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090, GetObjectGuid()); break; case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu(328, GetObjectGuid()); break; - case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu(1635, GetObjectGuid()); break; + case CLASS_PALADIN: pPlayer->PlayerTalkClass->SendGossipMenu(1635, GetObjectGuid()); break; case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu(4436, GetObjectGuid()); break; case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu(4797, GetObjectGuid()); break; case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5003, GetObjectGuid()); break; - case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu(5836, GetObjectGuid()); break; - case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu(4985, GetObjectGuid()); break; + case CLASS_WARLOCK: pPlayer->PlayerTalkClass->SendGossipMenu(5836, GetObjectGuid()); break; + case CLASS_WARRIOR: pPlayer->PlayerTalkClass->SendGossipMenu(4985, GetObjectGuid()); break; } } return false; @@ -1062,7 +1062,7 @@ void Creature::SaveToDB() return; } - SaveToDB(GetMapId(), data->spawnMask,GetPhaseMask()); + SaveToDB(GetMapId(), data->spawnMask, GetPhaseMask()); } void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) @@ -1102,13 +1102,13 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) data.orientation = GetOrientation(); data.spawntimesecs = m_respawnDelay; // prevent add data integrity problems - data.spawndist = GetDefaultMovementType()==IDLE_MOTION_TYPE ? 0 : m_respawnradius; + data.spawndist = GetDefaultMovementType() == IDLE_MOTION_TYPE ? 0 : m_respawnradius; data.currentwaypoint = 0; data.curhealth = GetHealth(); data.curmana = GetPower(POWER_MANA); data.is_dead = m_isDeadByDefault; // prevent add data integrity problems - data.movementType = !m_respawnradius && GetDefaultMovementType()==RANDOM_MOTION_TYPE + data.movementType = !m_respawnradius && GetDefaultMovementType() == RANDOM_MOTION_TYPE ? IDLE_MOTION_TYPE : GetDefaultMovementType(); // updated in DB @@ -1120,11 +1120,11 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) ss << "INSERT INTO creature VALUES (" << GetGUIDLow() << "," << data.id << "," - << data.mapid <<"," + << data.mapid << "," << uint32(data.spawnMask) << "," // cast to prevent save as symbol << uint16(data.phaseMask) << "," // prevent out of range error - << data.modelid_override <<"," - << data.equipmentId <<"," + << data.modelid_override << "," + << data.equipmentId << "," << data.posX << "," << data.posY << "," << data.posZ << "," @@ -1144,7 +1144,7 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) void Creature::SelectLevel(const CreatureInfo* cinfo, float percentHealth, float percentMana) { - uint32 rank = IsPet()? 0 : cinfo->rank; + uint32 rank = IsPet() ? 0 : cinfo->rank; // level uint32 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel); @@ -1152,14 +1152,14 @@ void Creature::SelectLevel(const CreatureInfo* cinfo, float percentHealth, float uint32 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel); SetLevel(level); - float rellevel = maxlevel == minlevel ? 0 : (float(level - minlevel))/(maxlevel - minlevel); + float rellevel = maxlevel == minlevel ? 0 : (float(level - minlevel)) / (maxlevel - minlevel); // health float healthmod = _GetHealthMod(rank); uint32 minhealth = std::min(cinfo->maxhealth, cinfo->minhealth); uint32 maxhealth = std::max(cinfo->maxhealth, cinfo->minhealth); - uint32 health = uint32(healthmod * (minhealth + uint32(rellevel*(maxhealth - minhealth)))); + uint32 health = uint32(healthmod * (minhealth + uint32(rellevel * (maxhealth - minhealth)))); SetCreateHealth(health); SetMaxHealth(health); @@ -1323,7 +1323,7 @@ bool Creature::LoadFromDB(uint32 guidlow, Map* map) uint32 curhealth = data->curhealth; if (curhealth) { - curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank)); + curhealth = uint32(curhealth * _GetHealthMod(GetCreatureInfo()->rank)); if (curhealth < 1) curhealth = 1; } @@ -1470,7 +1470,7 @@ float Creature::GetAttackDistance(Unit const* pl) const // radius grow if playlevel < creaturelevel RetDistance -= (float)leveldif; - if (creaturelevel+5 <= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (creaturelevel + 5 <= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { // detect range auras RetDistance += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE); @@ -1483,14 +1483,14 @@ float Creature::GetAttackDistance(Unit const* pl) const if (RetDistance < 5) RetDistance = 5; - return (RetDistance*aggroRate); + return (RetDistance * aggroRate); } void Creature::SetDeathState(DeathState s) { if ((s == JUST_DIED && !m_isDeadByDefault) || (s == JUST_ALIVED && m_isDeadByDefault)) { - m_corpseDecayTimer = m_corpseDelay*IN_MILLISECONDS; // the max/default time for corpse decay (before creature is looted/AllLootRemovedFromCorpse() is called) + m_corpseDecayTimer = m_corpseDelay * IN_MILLISECONDS; // the max/default time for corpse decay (before creature is looted/AllLootRemovedFromCorpse() is called) m_respawnTime = time(NULL) + m_respawnDelay; // respawn delay (spawntimesecs) // always save boss respawn time at death to prevent crash cheating @@ -1739,7 +1739,7 @@ bool Creature::IsVisibleInGridForPlayer(Player* pl) const if (corpse) { // 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))) + if (corpse->IsWithinDistInMap(this, (20 + 25)*sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO))) return true; } } @@ -1779,7 +1779,7 @@ void Creature::CallAssistance() { MaNGOS::AnyAssistCreatureInRangeCheck u_check(this, getVictim(), radius); MaNGOS::CreatureListSearcher searcher(assistList, u_check); - Cell::VisitGridObjects(this,searcher, radius); + Cell::VisitGridObjects(this, searcher, radius); } if (!assistList.empty()) @@ -1798,7 +1798,7 @@ void Creature::CallForHelp(float fRadius) MaNGOS::CallOfHelpCreatureInRangeDo u_do(this, getVictim(), fRadius); MaNGOS::CreatureWorker worker(this, u_do); - Cell::VisitGridObjects(this,worker, fRadius); + Cell::VisitGridObjects(this, worker, fRadius); } bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const @@ -1880,7 +1880,7 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const if (!pVictim->isInAccessablePlaceFor(this)) return true; - if (!pVictim->isVisibleForOrDetect(this,this,false)) + if (!pVictim->isVisibleForOrDetect(this, this, false)) return true; if (sMapStore.LookupEntry(GetMapId())->IsDungeon()) @@ -2099,7 +2099,7 @@ Unit* Creature::SelectAttackingTarget(AttackingTarget target, uint32 position, S suitableUnits.push_back(pTarget); if (!suitableUnits.empty()) - return suitableUnits[urand(0, suitableUnits.size()-1)]; + return suitableUnits[urand(0, suitableUnits.size() - 1)]; break; } @@ -2146,7 +2146,7 @@ void Creature::AddCreatureSpellCooldown(uint32 spellid) uint32 cooldown = GetSpellRecoveryTime(spellInfo); if (cooldown) - _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown/IN_MILLISECONDS); + _AddCreatureSpellCooldown(spellid, time(NULL) + cooldown / IN_MILLISECONDS); if (spellInfo->Category) _AddCreatureCategoryCooldown(spellInfo->Category, time(NULL)); @@ -2241,7 +2241,7 @@ void Creature::AllLootRemovedFromCorpse() if (sWorld.getConfig(CONFIG_FLOAT_RATE_CORPSE_DECAY_LOOTED) > 0.0f) corpseLootedDelay = (uint32)((m_corpseDelay * IN_MILLISECONDS) * sWorld.getConfig(CONFIG_FLOAT_RATE_CORPSE_DECAY_LOOTED)); else - corpseLootedDelay = (m_respawnDelay*IN_MILLISECONDS) /3; + corpseLootedDelay = (m_respawnDelay * IN_MILLISECONDS) / 3; } else // corpse was skinned, corpse will despawn next update corpseLootedDelay = 0; @@ -2281,7 +2281,7 @@ uint32 Creature::GetLevelForTarget(Unit const* target) const if (!IsWorldBoss()) return Unit::GetLevelForTarget(target); - uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF); + uint32 level = target->getLevel() + sWorld.getConfig(CONFIG_UINT32_WORLD_BOSS_LEVEL_DIFF); if (level < 1) return 1; if (level > 255) @@ -2322,7 +2322,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); for (; itr != m_vendorItemCounts.end(); ++itr) - if (itr->itemId==vItem->item) + if (itr->itemId == vItem->item) break; if (itr == m_vendorItemCounts.end()) @@ -2336,7 +2336,7 @@ uint32 Creature::GetVendorItemCurrentCount(VendorItem const* vItem) { ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); - uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); + uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime); if ((vCount->count + diff * pProto->BuyCount) >= vItem->maxcount) { m_vendorItemCounts.erase(itr); @@ -2357,13 +2357,13 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us VendorItemCounts::iterator itr = m_vendorItemCounts.begin(); for (; itr != m_vendorItemCounts.end(); ++itr) - if (itr->itemId==vItem->item) + if (itr->itemId == vItem->item) break; if (itr == m_vendorItemCounts.end()) { - uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0; - m_vendorItemCounts.push_back(VendorItemCount(vItem->item,new_count)); + uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount - used_count : 0; + m_vendorItemCounts.push_back(VendorItemCount(vItem->item, new_count)); return new_count; } @@ -2375,14 +2375,14 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us { ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(vItem->item); - uint32 diff = uint32((ptime - vCount->lastIncrementTime)/vItem->incrtime); + uint32 diff = uint32((ptime - vCount->lastIncrementTime) / vItem->incrtime); if ((vCount->count + diff * pProto->BuyCount) < vItem->maxcount) vCount->count += diff * pProto->BuyCount; else vCount->count = vItem->maxcount; } - vCount->count = vCount->count > used_count ? vCount->count-used_count : 0; + vCount->count = vCount->count > used_count ? vCount->count - used_count : 0; vCount->lastIncrementTime = ptime; return vCount->count; } @@ -2456,7 +2456,7 @@ void Creature::FillGuidsListFromThreatList(GuidVector& guids, uint32 maxamount / ThreatList const& threats = getThreatManager().getThreatList(); - maxamount = maxamount > 0 ? std::min(maxamount,uint32(threats.size())) : threats.size(); + maxamount = maxamount > 0 ? std::min(maxamount, uint32(threats.size())) : threats.size(); guids.reserve(guids.size() + maxamount); diff --git a/src/game/Creature.h b/src/game/Creature.h index c195fecbe..6c824929a 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -54,7 +54,7 @@ enum CreatureFlagsExtra CREATURE_FLAG_EXTRA_NOT_TAUNTABLE = 0x00000100, // creature is immune to taunt auras and effect attack me CREATURE_FLAG_EXTRA_AGGRO_ZONE = 0x00000200, // creature sets itself in combat with zone on aggro CREATURE_FLAG_EXTRA_GUARD = 0x00000400, // creature is a guard - CREATURE_FLAG_EXTRA_NO_TALKTO_CREDIT= 0x00000800, // creature doesn't give quest-credits when talked to (temporarily flag) + CREATURE_FLAG_EXTRA_NO_TALKTO_CREDIT = 0x00000800, // creature doesn't give quest-credits when talked to (temporarily flag) }; // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform @@ -328,7 +328,7 @@ struct VendorItemData VendorItem* GetItem(uint32 slot) const { - if (slot>=m_items.size()) return NULL; + if (slot >= m_items.size()) return NULL; return m_items[slot]; } bool Empty() const { return m_items.empty(); } @@ -380,7 +380,7 @@ struct TrainerSpell bool IsCastable() const { return learnedSpell != spell; } }; -typedef UNORDERED_MAP TrainerSpellMap; +typedef UNORDERED_MAP < uint32 /*spellid*/, TrainerSpell > TrainerSpellMap; struct TrainerSpellData { @@ -393,7 +393,7 @@ struct TrainerSpellData void Clear() { spellList.clear(); } }; -typedef std::map CreatureSpellCooldowns; +typedef std::map CreatureSpellCooldowns; // max different by z coordinate for creature aggro reaction #define CREATURE_Z_ATTACK_RANGE 3 @@ -467,7 +467,7 @@ class MANGOS_DLL_SPEC Creature : public Unit bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, Team team = TEAM_NONE, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL); bool LoadCreatureAddon(bool reload); void SelectLevel(const CreatureInfo* cinfo, float percentHealth = 100.0f, float percentMana = 100.0f); - void LoadEquipment(uint32 equip_entry, bool force=false); + void LoadEquipment(uint32 equip_entry, bool force = false); bool HasStaticDBSpawnData() const; // listed in `creature` table and have fixed in DB guid @@ -476,7 +476,7 @@ class MANGOS_DLL_SPEC Creature : public Unit void Update(uint32 update_diff, uint32 time) override; // overwrite Unit::Update virtual void RegenerateAll(uint32 update_diff); - void GetRespawnCoord(float& x, float& y, float& z, float* ori = NULL, float* dist =NULL) const; + void GetRespawnCoord(float& x, float& y, float& z, float* ori = NULL, float* dist = NULL) const; uint32 GetEquipmentId() const { return m_equipmentId; } CreatureSubtype GetSubtype() const { return m_subtype; } @@ -703,7 +703,7 @@ class MANGOS_DLL_SPEC Creature : public Unit protected: bool MeetsSelectAttackingRequirement(Unit* pTarget, SpellEntry const* pSpellInfo, uint32 selectFlags) const; - bool CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team team, const CreatureData* data = NULL, GameEventCreatureData const* eventData =NULL); + bool CreateFromProto(uint32 guidlow, CreatureInfo const* cinfo, Team team, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL); bool InitEntry(uint32 entry, const CreatureData* data = NULL, GameEventCreatureData const* eventData = NULL); uint32 m_groupLootTimer; // (msecs)timer used for group loot diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index fe2248612..912f7e955 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -41,13 +41,13 @@ namespace FactorySelector const CreatureAICreator* ai_factory = NULL; - std::string ainame=creature->GetAIName(); + std::string ainame = creature->GetAIName(); // select by NPC flags _first_ - otherwise EventAI might be choosen for pets/totems // excplicit check for isControlled() and owner type to allow guardian, mini-pets and pets controlled by NPCs to be scripted by EventAI - Unit* owner=NULL; + Unit* owner = NULL; if ((creature->IsPet() && ((Pet*)creature)->isControlled() && - ((owner=creature->GetOwner()) && owner->GetTypeId()==TYPEID_PLAYER)) || creature->isCharmed()) + ((owner = creature->GetOwner()) && owner->GetTypeId() == TYPEID_PLAYER)) || creature->isCharmed()) ai_factory = ai_registry.GetRegistryItem("PetAI"); else if (creature->IsTotem()) ai_factory = ai_registry.GetRegistryItem("TotemAI"); diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 174f6bb0b..6c0ebc809 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -77,7 +77,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c) #endif if (m_creature->GetMap()->IsDungeon()) { - if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) + if ((1 << (m_creature->GetMap()->GetSpawnMode() + 1)) & (*i).event_flags) { ++events_count; } @@ -101,7 +101,7 @@ CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c) #endif if (m_creature->GetMap()->IsDungeon()) { - if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) + if ((1 << (m_creature->GetMap()->GetSpawnMode() + 1)) & (*i).event_flags) { //event flagged for instance mode m_CreatureEventAIList.push_back(CreatureEventAIHolder(*i)); @@ -153,27 +153,27 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.timer.repeatMin,event.timer.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.timer.repeatMin, event.timer.repeatMax); break; case EVENT_T_TIMER_OOC: if (m_creature->isInCombat() || m_creature->IsInEvadeMode()) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.timer.repeatMin,event.timer.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.timer.repeatMin, event.timer.repeatMax); break; case EVENT_T_HP: { if (!m_creature->isInCombat() || !m_creature->GetMaxHealth()) return false; - uint32 perc = (m_creature->GetHealth()*100) / m_creature->GetMaxHealth(); + uint32 perc = (m_creature->GetHealth() * 100) / m_creature->GetMaxHealth(); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_MANA: @@ -181,20 +181,20 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (!m_creature->isInCombat() || !m_creature->GetMaxPower(POWER_MANA)) return false; - uint32 perc = (m_creature->GetPower(POWER_MANA)*100) / m_creature->GetMaxPower(POWER_MANA); + 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; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_AGGRO: break; case EVENT_T_KILL: //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.kill.repeatMin,event.kill.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.kill.repeatMin, event.kill.repeatMax); break; case EVENT_T_DEATH: case EVENT_T_EVADE: @@ -203,15 +203,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction //Spell hit is special case, param1 and param2 handled within CreatureEventAI::SpellHit //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.spell_hit.repeatMin,event.spell_hit.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.spell_hit.repeatMin, event.spell_hit.repeatMax); break; case EVENT_T_RANGE: //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.range.repeatMin,event.range.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.range.repeatMin, event.range.repeatMax); break; case EVENT_T_OOC_LOS: //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.ooc_los.repeatMin,event.ooc_los.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.ooc_los.repeatMin, event.ooc_los.repeatMax); break; case EVENT_T_SPAWNED: break; @@ -220,13 +220,13 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxHealth()) return false; - uint32 perc = (m_creature->getVictim()->GetHealth()*100) / m_creature->getVictim()->GetMaxHealth(); + uint32 perc = (m_creature->getVictim()->GetHealth() * 100) / m_creature->getVictim()->GetMaxHealth(); if (perc > event.percent_range.percentMax || perc < event.percent_range.percentMin) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_TARGET_CASTING: @@ -234,7 +234,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.target_casting.repeatMin,event.target_casting.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.target_casting.repeatMin, event.target_casting.repeatMax); break; case EVENT_T_FRIENDLY_HP: { @@ -248,7 +248,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction pActionInvoker = pUnit; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.friendly_hp.repeatMin,event.friendly_hp.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax); break; } case EVENT_T_FRIENDLY_IS_CC: @@ -267,7 +267,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction pActionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.friendly_is_cc.repeatMin,event.friendly_is_cc.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax); break; } case EVENT_T_FRIENDLY_MISSING_BUFF: @@ -283,7 +283,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction pActionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.friendly_buff.repeatMin,event.friendly_buff.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax); break; } case EVENT_T_SUMMONED_UNIT: @@ -291,7 +291,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction case EVENT_T_SUMMONED_JUST_DESPAWN: { //Prevent event from occuring on no unit or non creatures - if (!pActionInvoker || pActionInvoker->GetTypeId()!=TYPEID_UNIT) + if (!pActionInvoker || pActionInvoker->GetTypeId() != TYPEID_UNIT) return false; //Creature id doesn't match up @@ -299,7 +299,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.summoned.repeatMin,event.summoned.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.summoned.repeatMin, event.summoned.repeatMax); break; } case EVENT_T_TARGET_MANA: @@ -307,13 +307,13 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (!m_creature->isInCombat() || !m_creature->getVictim() || !m_creature->getVictim()->GetMaxPower(POWER_MANA)) return false; - uint32 perc = (m_creature->getVictim()->GetPower(POWER_MANA)*100) / m_creature->getVictim()->GetMaxPower(POWER_MANA); + 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; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.percent_range.repeatMin,event.percent_range.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_REACHED_HOME: @@ -326,7 +326,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.buffed.repeatMin, event.buffed.repeatMax); break; } case EVENT_T_TARGET_AURA: @@ -339,7 +339,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.buffed.repeatMin, event.buffed.repeatMax); break; } case EVENT_T_MISSING_AURA: @@ -349,7 +349,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.buffed.repeatMin, event.buffed.repeatMax); break; } case EVENT_T_TARGET_MISSING_AURA: @@ -362,7 +362,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(m_creature,event.buffed.repeatMin,event.buffed.repeatMax); + pHolder.UpdateRepeatTimer(m_creature, event.buffed.repeatMin, event.buffed.repeatMax); break; } default: @@ -399,7 +399,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction if (count) { // select action number from found amount - uint32 idx = urand(0,count-1); + uint32 idx = urand(0, count - 1); // find selected action, skipping not used uint32 j = 0; @@ -431,8 +431,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 int32 temp = 0; if (action.text.TextId[1] && action.text.TextId[2]) - temp = action.text.TextId[rand()%3]; - else if (action.text.TextId[1] && urand(0,1)) + temp = action.text.TextId[rand() % 3]; + else if (action.text.TextId[1] && urand(0, 1)) temp = action.text.TextId[1]; else temp = action.text.TextId[0]; @@ -620,7 +620,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_COMBAT_MOVEMENT: // ignore no affect case - if (m_CombatMovementEnabled==(action.combat_movement.state!=0)) + if (m_CombatMovementEnabled == (action.combat_movement.state != 0)) return; m_CombatMovementEnabled = action.combat_movement.state != 0; @@ -657,7 +657,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_INC_PHASE: { - int32 new_phase = int32(m_Phase)+action.set_inc_phase.step; + int32 new_phase = int32(m_Phase) + action.set_inc_phase.step; if (new_phase < 0) { sLog.outErrorDb("CreatureEventAI: Event %d decrease Phase under 0. CreatureEntry = %d", EventId, m_creature->GetEntry()); @@ -665,8 +665,8 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } else if (new_phase >= MAX_PHASE) { - sLog.outErrorDb("CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, m_creature->GetEntry()); - m_Phase = MAX_PHASE-1; + sLog.outErrorDb("CreatureEventAI: Event %d incremented Phase above %u. Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE - 1, MAX_PHASE - 1, m_creature->GetEntry()); + m_Phase = MAX_PHASE - 1; } else m_Phase = new_phase; @@ -681,7 +681,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_QUEST_EVENT_ALL: if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER) - ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId,m_creature); + ((Player*)pActionInvoker)->GroupEventHappens(action.quest_event_all.questId, m_creature); break; case ACTION_T_CAST_EVENT_ALL: { @@ -697,7 +697,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_RANGED_MOVEMENT: m_AttackDistance = (float)action.ranged_movement.distance; - m_AttackAngle = action.ranged_movement.angle/180.0f*M_PI_F; + m_AttackAngle = action.ranged_movement.angle / 180.0f * M_PI_F; if (m_CombatMovementEnabled) { @@ -802,7 +802,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 sLog.outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, m_creature->GetEntry()); return; } - m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(),NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); + m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); break; case ACTION_T_ZONE_COMBAT_PULSE: { @@ -827,7 +827,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: { 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; @@ -887,7 +887,7 @@ void CreatureEventAI::Reset() //Reset all out of combat timers case EVENT_T_TIMER_OOC: { - if ((*i).UpdateRepeatTimer(m_creature,event.timer.initialMin,event.timer.initialMax)) + if ((*i).UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax)) (*i).Enabled = true; break; } @@ -1025,7 +1025,7 @@ void CreatureEventAI::EnterCombat(Unit* enemy) break; //Reset all in combat timers case EVENT_T_TIMER: - if ((*i).UpdateRepeatTimer(m_creature,event.timer.initialMin,event.timer.initialMax)) + if ((*i).UpdateRepeatTimer(m_creature, event.timer.initialMin, event.timer.initialMax)) (*i).Enabled = true; break; //All normal events need to be re-enabled and their time set to 0 @@ -1208,8 +1208,8 @@ void CreatureEventAI::UpdateAI(const uint32 diff) bool CreatureEventAI::IsVisible(Unit* pl) const { - return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER)) - && pl->isVisibleForOrDetect(m_creature,m_creature,true); + return m_creature->IsWithinDist(pl, sWorld.getConfig(CONFIG_FLOAT_SIGHT_MONSTER)) + && pl->isVisibleForOrDetect(m_creature, m_creature, true); } inline uint32 CreatureEventAI::GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3) @@ -1283,7 +1283,7 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list& _list, flo { MaNGOS::FriendlyMissingBuffInRangeCheck u_check(m_creature, range, spellid); MaNGOS::CreatureListSearcher searcher(_list, u_check); - Cell::VisitGridObjects(m_creature,searcher, range); + Cell::VisitGridObjects(m_creature, searcher, range); } //********************************* @@ -1293,13 +1293,13 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* { if (!pSource) { - sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i, invalid Source pointer.",textEntry); + sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i, invalid Source pointer.", textEntry); return; } if (textEntry >= 0) { - sLog.outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.",pSource->GetEntry(),pSource->GetTypeId(),pSource->GetGUIDLow(),textEntry); + sLog.outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry); return; } @@ -1307,18 +1307,18 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* if (i == sEventAIMgr.GetCreatureEventAITextMap().end()) { - sLog.outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.",pSource->GetEntry(),pSource->GetTypeId(),pSource->GetGUIDLow(),textEntry); + sLog.outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry); return; } - DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",textEntry,(*i).second.SoundId,(*i).second.Type,(*i).second.Language,(*i).second.Emote); + DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "CreatureEventAI: DoScriptText: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u", textEntry, (*i).second.SoundId, (*i).second.Type, (*i).second.Language, (*i).second.Emote); if ((*i).second.SoundId) { if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId)) pSource->PlayDirectSound((*i).second.SoundId); else - sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.",textEntry,(*i).second.SoundId); + sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.", textEntry, (*i).second.SoundId); } if ((*i).second.Emote) @@ -1328,7 +1328,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* ((Unit*)pSource)->HandleEmote((*i).second.Emote); } else - sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).",textEntry,pSource->GetTypeId()); + sLog.outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, pSource->GetTypeId()); } switch ((*i).second.Type) @@ -1387,7 +1387,7 @@ bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const* Spell, bool Trigge return false; //Unit is out of range of this spell - if (!m_creature->IsInRange(Target,TempRange->minRange,TempRange->maxRange)) + if (!m_creature->IsInRange(Target, TempRange->minRange, TempRange->maxRange)) return false; return true; @@ -1405,7 +1405,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) if ((*itr).Event.receive_emote.emoteId != text_emote) return; - PlayerCondition pcon(0, (*itr).Event.receive_emote.condition,(*itr).Event.receive_emote.conditionValue1,(*itr).Event.receive_emote.conditionValue2); + PlayerCondition pcon(0, (*itr).Event.receive_emote.condition, (*itr).Event.receive_emote.conditionValue1, (*itr).Event.receive_emote.conditionValue2); if (pcon.Meets(pPlayer)) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "CreatureEventAI: ReceiveEmote CreatureEventAI: Condition ok, processing"); @@ -1417,7 +1417,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) void CreatureEventAI::DamageTaken(Unit* /*done_by*/, uint32& damage) { - if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel+damage) + if (m_InvinceabilityHpLevel > 0 && m_creature->GetHealth() < m_InvinceabilityHpLevel + damage) { if (m_creature->GetHealth() <= m_InvinceabilityHpLevel) damage = 0; @@ -1443,7 +1443,7 @@ bool CreatureEventAI::SpawnedEventConditionsCheck(CreatureEventAI_Event const& e { // zone ID check uint32 zone, area; - m_creature->GetZoneAndAreaId(zone,area); + m_creature->GetZoneAndAreaId(zone, area); return zone == event.spawned.conditionValue1 || area == event.spawned.conditionValue1; } default: diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 9241aa617..d62bd2fa8 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -153,7 +153,7 @@ enum EventFlags EFLAG_RESERVED_6 = 0x40, EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build // no free bits, uint8 field - EFLAG_DIFFICULTY_ALL = (EFLAG_DIFFICULTY_0|EFLAG_DIFFICULTY_1|EFLAG_DIFFICULTY_2|EFLAG_DIFFICULTY_3) + EFLAG_DIFFICULTY_ALL = (EFLAG_DIFFICULTY_0 | EFLAG_DIFFICULTY_1 | EFLAG_DIFFICULTY_2 | EFLAG_DIFFICULTY_3) }; enum SpawnedEventMode diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index c4741a35b..d3dc3e700 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -36,7 +36,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use) m_CreatureEventAI_TextMap.clear(); // Load EventAI Text - sObjectMgr.LoadMangosStrings(WorldDatabase,"creature_ai_texts",MIN_CREATURE_AI_TEXT_STRING_ID,MAX_CREATURE_AI_TEXT_STRING_ID); + sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID); // Gather Additional data from EventAI Texts QueryResult* result = WorldDatabase.Query("SELECT entry, sound, type, language, emote FROM creature_ai_texts"); @@ -62,33 +62,33 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use) // range negative if (i > MIN_CREATURE_AI_TEXT_STRING_ID || i <= MAX_CREATURE_AI_TEXT_STRING_ID) { - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` is not in valid range(%d-%d)",i,MIN_CREATURE_AI_TEXT_STRING_ID,MAX_CREATURE_AI_TEXT_STRING_ID); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` is not in valid range(%d-%d)", i, MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID); continue; } // range negative (don't must be happen, loaded from same table) if (!sObjectMgr.GetMangosStringLocale(i)) { - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` not found",i); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` not found", i); continue; } if (temp.SoundId) { if (!sSoundEntriesStore.LookupEntry(temp.SoundId)) - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` has Sound %u but sound does not exist.",i,temp.SoundId); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` has Sound %u but sound does not exist.", i, temp.SoundId); } if (!GetLanguageDescByID(temp.Language)) - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` using Language %u but Language does not exist.",i,temp.Language); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` using Language %u but Language does not exist.", i, temp.Language); if (temp.Type > CHAT_TYPE_ZONE_YELL) - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` has Type %u but this Chat Type does not exist.",i,temp.Type); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` has Type %u but this Chat Type does not exist.", i, temp.Type); if (temp.Emote) { if (!sEmotesStore.LookupEntry(temp.Emote)) - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` has Emote %u but emote does not exist.",i,temp.Emote); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` has Emote %u but emote does not exist.", i, temp.Emote); } m_CreatureEventAI_TextMap[i] = temp; @@ -146,7 +146,7 @@ void CreatureEventAIMgr::CheckUnusedAITexts() } for (std::set::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr) - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` but not used in EventAI scripts.",*itr); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_texts` but not used in EventAI scripts.", *itr); } // ------------------- @@ -238,7 +238,7 @@ void CreatureEventAIMgr::CheckUnusedAISummons() } for (std::set::const_iterator itr = idx_set.begin(); itr != idx_set.end(); ++itr) - sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_summons` but not used in EventAI scripts.",*itr); + sLog.outErrorDb("CreatureEventAI: Entry %i in table `creature_ai_summons` but not used in EventAI scripts.", *itr); } // ------------------- @@ -275,7 +275,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() //Report any errors in event if (e_type >= EVENT_T_END) { - sLog.outErrorDb("CreatureEventAI: Event %u have wrong type (%u), skipping.", i,e_type); + sLog.outErrorDb("CreatureEventAI: Event %u have wrong type (%u), skipping.", i, e_type); continue; } temp.event_type = EventAI_Type(e_type); @@ -444,13 +444,13 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { if (!sEmotesTextStore.LookupEntry(temp.receive_emote.emoteId)) { - sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param1 (EmoteTextId: %u) are not valid.",temp.creature_id, i, temp.receive_emote.emoteId); + sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param1 (EmoteTextId: %u) are not valid.", temp.creature_id, i, temp.receive_emote.emoteId); continue; } if (!PlayerCondition::IsValid(0, ConditionType(temp.receive_emote.condition), temp.receive_emote.conditionValue1, temp.receive_emote.conditionValue2)) { - sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param2 (Condition: %u) are not valid.",temp.creature_id, i, temp.receive_emote.condition); + sLog.outErrorDb("CreatureEventAI: Creature %u using event %u: param2 (Condition: %u) are not valid.", temp.creature_id, i, temp.receive_emote.condition); continue; } @@ -491,10 +491,10 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() for (uint32 j = 0; j < MAX_ACTIONS; j++) { - uint16 action_type = fields[10+(j*4)].GetUInt16(); + uint16 action_type = fields[10 + (j * 4)].GetUInt16(); if (action_type >= ACTION_T_END) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u has incorrect action type (%u), replace by ACTION_T_NONE.", i, j+1, action_type); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u has incorrect action type (%u), replace by ACTION_T_NONE.", i, j + 1, action_type); temp.action[j].type = ACTION_T_NONE; continue; } @@ -502,9 +502,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() CreatureEventAI_Action& action = temp.action[j]; action.type = EventAI_ActionType(action_type); - action.raw.param1 = fields[11+(j*4)].GetUInt32(); - action.raw.param2 = fields[12+(j*4)].GetUInt32(); - action.raw.param3 = fields[13+(j*4)].GetUInt32(); + action.raw.param1 = fields[11 + (j * 4)].GetUInt32(); + action.raw.param2 = fields[12 + (j * 4)].GetUInt32(); + action.raw.param3 = fields[13 + (j * 4)].GetUInt32(); //Report any errors in actions switch (action.type) @@ -519,19 +519,19 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() if (action.text.TextId[k]) { if (k > 0 && not_set) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j+1, k+1); + sLog.outErrorDb("CreatureEventAI: 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; // range negative else if (action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u param%d references out-of-range entry (%i) in texts table.", i, j+1, k+1, action.text.TextId[k]); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u param%d references out-of-range entry (%i) in texts table.", i, j + 1, k + 1, action.text.TextId[k]); action.text.TextId[k] = 0; } else if (m_CreatureEventAI_TextMap.find(action.text.TextId[k]) == m_CreatureEventAI_TextMap.end()) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u param%d references non-existing entry (%i) in texts table.", i, j+1, k+1, action.text.TextId[k]); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u param%d references non-existing entry (%i) in texts table.", i, j + 1, k + 1, action.text.TextId[k]); action.text.TextId[k] = 0; } } @@ -539,18 +539,18 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; } case ACTION_T_SET_FACTION: - if (action.set_faction.factionId !=0 && !sFactionTemplateStore.LookupEntry(action.set_faction.factionId)) + if (action.set_faction.factionId != 0 && !sFactionTemplateStore.LookupEntry(action.set_faction.factionId)) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent FactionId %u.", i, j+1, action.set_faction.factionId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent FactionId %u.", i, j + 1, action.set_faction.factionId); action.set_faction.factionId = 0; } break; case ACTION_T_MORPH_TO_ENTRY_OR_MODEL: - if (action.morph.creatureId !=0 || action.morph.modelId !=0) + if (action.morph.creatureId != 0 || action.morph.modelId != 0) { if (action.morph.creatureId && !sCreatureStorage.LookupEntry(action.morph.creatureId)) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Creature entry %u.", i, j+1, action.morph.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Creature entry %u.", i, j + 1, action.morph.creatureId); action.morph.creatureId = 0; } @@ -558,12 +558,12 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { if (action.morph.creatureId) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j+1, action.morph.modelId,action.morph.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j + 1, action.morph.modelId, action.morph.creatureId); action.morph.modelId = 0; } else if (!sCreatureDisplayInfoStore.LookupEntry(action.morph.modelId)) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent ModelId %u.", i, j+1, action.morph.modelId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent ModelId %u.", i, j + 1, action.morph.modelId); action.morph.modelId = 0; } } @@ -571,33 +571,33 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_SOUND: if (!sSoundEntriesStore.LookupEntry(action.sound.soundId)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SoundID %u.", i, j+1, action.sound.soundId); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, action.emote.emoteId); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u param1 uses nonexistent SoundID %u.", i, j+1, action.random_sound.soundId1); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u param2 uses nonexistent SoundID %u.", i, j+1, action.random_sound.soundId2); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u param3 uses nonexistent SoundID %u.", i, j+1, action.random_sound.soundId3); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j+1, action.random_emote.emoteId1); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j+1, action.random_emote.emoteId2); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j+1, action.random_emote.emoteId3); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j+1, action.cast.spellId); + sLog.outErrorDb("CreatureEventAI: 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 { @@ -615,143 +615,143 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() action.cast.castFlags |= CAST_TRIGGERED; if (action.cast.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; } case ACTION_T_SUMMON: if (!sCreatureStorage.LookupEntry(action.summon.creatureId)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j+1, action.summon.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId); if (action.summon.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_THREAT_SINGLE_PCT: if (std::abs(action.threat_single_pct.percent) > 100) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses invalid percent value %u.", i, j+1, action.threat_single_pct.percent); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent); if (action.threat_single_pct.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_THREAT_ALL_PCT: if (std::abs(action.threat_all_pct.percent) > 100) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses invalid percent value %u.", i, j+1, action.threat_all_pct.percent); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Quest entry %u.", i, j+1, action.quest_event.questId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId); if (action.quest_event.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_CAST_EVENT: if (!sCreatureStorage.LookupEntry(action.cast_event.creatureId)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j+1, action.cast_event.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId); if (!sSpellStore.LookupEntry(action.cast_event.spellId)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j+1, action.cast_event.spellId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId); if (action.cast_event.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", 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.outErrorDb("CreatureEventAI: Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1); if (action.set_unit_field.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_SET_UNIT_FLAG: case ACTION_T_REMOVE_UNIT_FLAG: if (action.unit_flag.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_SET_PHASE: if (action.set_phase.phase >= MAX_PHASE) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase >= %u. Phase mask cannot 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.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u is change phase by too large for any use %i.", i, j+1, action.set_inc_phase.step); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u is change phase by too large for any use %i.", i, j + 1, action.set_inc_phase.step); break; case ACTION_T_QUEST_EVENT_ALL: if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event_all.questId)) { if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT)) - sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Quest entry %u.", i, j+1, action.quest_event_all.questId); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j+1, action.cast_event_all.creatureId); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j+1, action.cast_event_all.spellId); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j+1, action.remove_aura.spellId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId); if (action.remove_aura.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_RANDOM_PHASE: //PhaseId1, PhaseId2, PhaseId3 if (action.random_phase.phase1 >= MAX_PHASE) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase1 >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase1 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); if (action.random_phase.phase2 >= MAX_PHASE) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase2 >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase2 >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); if (action.random_phase.phase3 >= MAX_PHASE) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase3 >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phase3 >= %u. Phase mask cannot 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.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phaseMin >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phaseMin >= %u. Phase mask cannot be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); if (action.random_phase_range.phaseMin >= MAX_PHASE) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phaseMax >= %u. Phase mask cannot be used past phase %u.", i, j+1, MAX_PHASE, MAX_PHASE-1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phaseMax >= %u. Phase mask cannot 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.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j+1); - std::swap(action.random_phase_range.phaseMin,action.random_phase_range.phaseMax); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j + 1); + std::swap(action.random_phase_range.phaseMin, action.random_phase_range.phaseMax); // equal case processed at call } break; case ACTION_T_SUMMON_ID: if (!sCreatureStorage.LookupEntry(action.summon_id.creatureId)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j+1, action.summon_id.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId); if (action.summon_id.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end()) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j+1, action.summon_id.spawnId); + sLog.outErrorDb("CreatureEventAI: 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.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j+1, action.killed_monster.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId); if (action.killed_monster.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_SET_INST_DATA: if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1); if (action.set_inst_data.value > 4/*SPECIAL*/) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j+1); + sLog.outErrorDb("CreatureEventAI: 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)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1); if (action.set_inst_data64.target >= TARGET_T_END) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j + 1); break; case ACTION_T_UPDATE_TEMPLATE: if (!sCreatureStorage.LookupEntry(action.update_template.creatureId)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent creature entry %u.", i, j+1, action.update_template.creatureId); + sLog.outErrorDb("CreatureEventAI: 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) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong sheath state %u.", i, j+1, action.set_sheath.sheath); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong sheath state %u.", i, j + 1, action.set_sheath.sheath); action.set_sheath.sheath = SHEATH_STATE_UNARMED; } break; @@ -760,7 +760,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { if (action.invincibility_hp_level.hp_level > 100) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong percent value %u.", i, j+1, action.invincibility_hp_level.hp_level); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses wrong percent value %u.", i, j + 1, action.invincibility_hp_level.hp_level); action.invincibility_hp_level.hp_level = 100; } } @@ -770,7 +770,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { if (action.mount.creatureId && !sCreatureStorage.LookupEntry(action.mount.creatureId)) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Creature entry %u.", i, j+1, action.mount.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Creature entry %u.", i, j + 1, action.mount.creatureId); action.morph.creatureId = 0; } @@ -778,12 +778,12 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() { if (action.mount.creatureId) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j+1, action.mount.modelId, action.mount.creatureId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j + 1, action.mount.modelId, action.mount.creatureId); action.mount.modelId = 0; } else if (!sCreatureDisplayInfoStore.LookupEntry(action.mount.modelId)) { - sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent ModelId %u.", i, j+1, action.mount.modelId); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent ModelId %u.", i, j + 1, action.mount.modelId); action.mount.modelId = 0; } } @@ -803,10 +803,10 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case ACTION_T_RANDOM_SAY: case ACTION_T_RANDOM_YELL: case ACTION_T_RANDOM_TEXTEMOTE: - sLog.outErrorDb("CreatureEventAI: Event %u Action %u currently unused ACTION type. Did you forget to update database?", i, j+1); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u currently unused ACTION type. Did you forget to update database?", i, j + 1); break; default: - sLog.outErrorDb("CreatureEventAI: Event %u Action %u have currently not checked at load action type (%u). Need check code update?", i, j+1, temp.action[j].type); + sLog.outErrorDb("CreatureEventAI: Event %u Action %u have currently not checked at load action type (%u). Need check code update?", i, j + 1, temp.action[j].type); break; } } diff --git a/src/game/CreatureLinkingMgr.cpp b/src/game/CreatureLinkingMgr.cpp index 63922b13a..7b69b8bc9 100644 --- a/src/game/CreatureLinkingMgr.cpp +++ b/src/game/CreatureLinkingMgr.cpp @@ -566,7 +566,7 @@ void CreatureLinkingHolder::SetFollowing(Creature* pWho, Creature* pWhom) dy = sY - mY; dz = sZ - mZ; - float dist = sqrt(dx*dx + dy*dy + dz*dz); + float dist = sqrt(dx * dx + dy * dy + dz * dz); // REMARK: This code needs the same distance calculation that is used for following // Atm this means we have to subtract the bounding radiuses dist = dist - pWho->GetObjectBoundingRadius() - pWhom->GetObjectBoundingRadius(); @@ -595,7 +595,7 @@ bool CreatureLinkingHolder::IsSlaveInRangeOfBoss(Creature* pSlave, Creature* pBo dx = sX - mX; dy = sY - mY; - return dx*dx + dy*dy < searchRange*searchRange; + return dx * dx + dy * dy < searchRange * searchRange; } // Function to check if a passive spawning condition is met diff --git a/src/game/CreatureLinkingMgr.h b/src/game/CreatureLinkingMgr.h index 1a80cc7f4..184a89fd3 100644 --- a/src/game/CreatureLinkingMgr.h +++ b/src/game/CreatureLinkingMgr.h @@ -85,8 +85,8 @@ struct CreatureLinkingInfo uint32 mapId; uint32 masterId; uint32 masterDBGuid; - uint16 linkingFlag:16; - uint16 searchRange:16; + uint16 linkingFlag: 16; + uint16 searchRange: 16; }; /** @@ -116,7 +116,7 @@ class CreatureLinkingMgr CreatureLinkingInfo const* GetLinkedTriggerInformation(Creature* pCreature); private: - typedef std::multimap CreatureLinkingMap; + typedef std::multimap < uint32 /*slaveEntry*/, CreatureLinkingInfo > CreatureLinkingMap; typedef std::pair CreatureLinkingMapBounds; // Storage of Data: npc_entry_slave, (map, npc_entry_master, flag, master_db_guid[If Unique], search_range) @@ -163,8 +163,8 @@ class CreatureLinkingHolder // Structure associated to a master (entry case) struct InfoAndGuids { - uint16 linkingFlag:16; - uint16 searchRange:16; + uint16 linkingFlag: 16; + uint16 searchRange: 16; GuidList linkedGuids; }; // Structure associated to a master (guid case) @@ -174,9 +174,9 @@ class CreatureLinkingHolder ObjectGuid linkedGuid; }; - typedef std::multimap HolderMap; + typedef std::multimap < uint32 /*masterEntryOrGuid*/, InfoAndGuids > HolderMap; typedef std::pair HolderMapBounds; - typedef std::multimap BossGuidMap; + typedef std::multimap < uint32 /*Entry*/, ObjectGuid > BossGuidMap; typedef std::pair BossGuidMapBounds; // Helper function, to process a slave list diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index b193b378c..642c0b2e8 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -106,9 +106,9 @@ enum AchievementCriteriaTypes ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUESTS_IN_ZONE = 11, ACHIEVEMENT_CRITERIA_TYPE_DAMAGE_DONE = 13, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_DAILY_QUEST = 14, - ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND= 15, - ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP= 16, - ACHIEVEMENT_CRITERIA_TYPE_DEATH= 17, + ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND = 15, + ACHIEVEMENT_CRITERIA_TYPE_DEATH_AT_MAP = 16, + ACHIEVEMENT_CRITERIA_TYPE_DEATH = 17, ACHIEVEMENT_CRITERIA_TYPE_DEATH_IN_DUNGEON = 18, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_RAID = 19, ACHIEVEMENT_CRITERIA_TYPE_KILLED_BY_CREATURE = 20, @@ -117,7 +117,7 @@ enum AchievementCriteriaTypes ACHIEVEMENT_CRITERIA_TYPE_DEATHS_FROM = 26, ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_QUEST = 27, ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET = 28, - ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL= 29, + ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL = 29, ACHIEVEMENT_CRITERIA_TYPE_BG_OBJECTIVE_CAPTURE = 30, ACHIEVEMENT_CRITERIA_TYPE_HONORABLE_KILL_AT_AREA = 31, ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA = 32, @@ -132,18 +132,18 @@ enum AchievementCriteriaTypes ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING = 39, ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL = 40, ACHIEVEMENT_CRITERIA_TYPE_USE_ITEM = 41, - ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM= 42, + ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM = 42, ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA = 43, - ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK= 44, - ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT= 45, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION= 46, - ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION= 47, + ACHIEVEMENT_CRITERIA_TYPE_OWN_RANK = 44, + ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT = 45, + ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION = 46, + ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION = 47, // noted: rewarded as soon as the player payed, not at taking place at the seat - ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP= 48, + ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP = 48, ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM = 49, // TODO: itemlevel is mentioned in text but not present in dbc ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED_ON_LOOT = 50, - ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT= 51, + ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED_ON_LOOT = 51, ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS = 52, ACHIEVEMENT_CRITERIA_TYPE_HK_RACE = 53, ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE = 54, @@ -160,20 +160,20 @@ enum AchievementCriteriaTypes ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL = 66, ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY = 67, ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT = 68, - ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2= 69, - ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL= 70, + ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET2 = 69, + ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL = 70, ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT = 72, // TODO: title id is not mentioned in dbc ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN = 74, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS= 75, + ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS = 75, ACHIEVEMENT_CRITERIA_TYPE_WIN_DUEL = 76, ACHIEVEMENT_CRITERIA_TYPE_LOSE_DUEL = 77, // TODO: creature type (demon, undead etc.) is not stored in dbc ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE_TYPE = 78, - ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS= 80, - ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION= 82, - ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID= 83, - ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS= 84, + ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS = 80, + ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION = 82, + ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID = 83, + ACHIEVEMENT_CRITERIA_TYPE_WON_AUCTIONS = 84, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD = 85, ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED = 86, ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION = 87, @@ -200,7 +200,7 @@ enum AchievementCriteriaTypes ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE = 109, // TODO: target entry is missing ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2 = 110, - ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE= 112, + ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE = 112, ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL = 113, ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS = 114, ACHIEVEMENT_CRITERIA_TYPE_EARN_ACHIEVEMENT_POINTS = 115, diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index 4da64467a..68ec0bc62 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -27,8 +27,8 @@ #include -typedef std::map AreaFlagByAreaID; -typedef std::map AreaFlagByMapID; +typedef std::map AreaFlagByAreaID; +typedef std::map AreaFlagByMapID; struct WMOAreaTableTripple { @@ -38,7 +38,7 @@ struct WMOAreaTableTripple bool operator <(const WMOAreaTableTripple& b) const { - return memcmp(this, &b, sizeof(WMOAreaTableTripple))<0; + return memcmp(this, &b, sizeof(WMOAreaTableTripple)) < 0; } // ordered by entropy; that way memcmp will have a minimal medium runtime @@ -83,7 +83,7 @@ DBCStorage sDurabilityCostsStore(DurabilityCostsfmt); DBCStorage sEmotesStore(EmotesEntryfmt); DBCStorage sEmotesTextStore(EmotesTextEntryfmt); -typedef std::map FactionTeamMap; +typedef std::map FactionTeamMap; static FactionTeamMap sFactionTeamMap; DBCStorage sFactionStore(FactionEntryfmt); DBCStorage sFactionTemplateStore(FactionTemplateEntryfmt); @@ -215,10 +215,10 @@ static bool ReadDBCBuildFileText(const std::string& dbc_path, char const* locale { std::string filename = dbc_path + "component.wow-" + localeName + ".txt"; - if (FILE* file = fopen(filename.c_str(),"rb")) + if (FILE* file = fopen(filename.c_str(), "rb")) { char buf[100]; - fread(buf,1,100-1,file); + fread(buf, 1, 100 - 1, file); fclose(file); text = &buf[0]; @@ -236,7 +236,7 @@ static uint32 ReadDBCBuild(const std::string& dbc_path, LocaleNameStr const* loc { for (LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr) { - if (ReadDBCBuildFileText(dbc_path,itr->name,text)) + if (ReadDBCBuildFileText(dbc_path, itr->name, text)) { localeNameStr = itr; break; @@ -244,18 +244,18 @@ static uint32 ReadDBCBuild(const std::string& dbc_path, LocaleNameStr const* loc } } else - ReadDBCBuildFileText(dbc_path,localeNameStr->name,text); + ReadDBCBuildFileText(dbc_path, localeNameStr->name, text); if (text.empty()) return 0; size_t pos = text.find("version=\""); size_t pos1 = pos + strlen("version=\""); - size_t pos2 = text.find("\"",pos1); + size_t pos2 = text.find("\"", pos1); if (pos == text.npos || pos2 == text.npos || pos1 >= pos2) return 0; - std::string build_str = text.substr(pos1,pos2-pos1); + std::string build_str = text.substr(pos1, pos2 - pos1); int build = atoi(build_str.c_str()); if (build <= 0) @@ -264,9 +264,9 @@ static uint32 ReadDBCBuild(const std::string& dbc_path, LocaleNameStr const* loc return build; } -static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename) +static bool LoadDBC_assert_print(uint32 fsize, uint32 rsize, const std::string& filename) { - sLog.outError("Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize); + sLog.outError("Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).", filename.c_str(), fsize, rsize); // ASSERT must fail after function call return false; @@ -275,7 +275,7 @@ static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& f struct LocalData { LocalData(uint32 build) - : main_build(build), availableDbcLocales(0xFFFFFFFF),checkedDbcLocaleBuilds(0) {} + : main_build(build), availableDbcLocales(0xFFFFFFFF), checkedDbcLocaleBuilds(0) {} uint32 main_build; @@ -288,7 +288,7 @@ template inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& errlist, DBCStorage& storage, const std::string& dbc_path, const std::string& filename) { // compatibility format and C++ structure sizes - MANGOS_ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename)); + MANGOS_ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename)); std::string dbc_filename = dbc_path + filename; if (storage.Load(dbc_filename.c_str())) @@ -305,20 +305,20 @@ inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& err if (!(localeData.checkedDbcLocaleBuilds & (1 << i))) { - localeData.checkedDbcLocaleBuilds |= (1<name + "/" + filename; char buf[200]; - snprintf(buf,200," (exist, but DBC locale subdir %s have DBCs for build %u instead expected build %u, it and other DBC from subdir skipped)",localStr->name,build_loc,localeData.main_build); + snprintf(buf, 200, " (exist, but DBC locale subdir %s have DBCs for build %u instead expected build %u, it and other DBC from subdir skipped)", localStr->name, build_loc, localeData.main_build); errlist.push_back(dbc_filename_loc + buf); } @@ -328,13 +328,13 @@ inline void LoadDBC(LocalData& localeData, BarGoLink& bar, StoreProblemList& err std::string dbc_filename_loc = dbc_path + localStr->name + "/" + filename; if (!storage.LoadStringsFrom(dbc_filename_loc.c_str())) - localeData.availableDbcLocales &= ~(1<DBC records - sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID),area->exploreFlag)); + sAreaFlagByAreaID.insert(AreaFlagByAreaID::value_type(uint16(area->ID), area->exploreFlag)); // fill MapId->DBC records ( skip sub zones and continents ) - if (area->zone==0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530 && area->mapid != 571) - sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid,area->exploreFlag)); + if (area->zone == 0 && area->mapid != 0 && area->mapid != 1 && area->mapid != 530 && area->mapid != 571) + sAreaFlagByMapID.insert(AreaFlagByMapID::value_type(area->mapid, area->exploreFlag)); } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementStore, dbcPath,"Achievement.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAchievementCriteriaStore, dbcPath,"Achievement_Criteria.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaTriggerStore, dbcPath,"AreaTrigger.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAreaGroupStore, dbcPath,"AreaGroup.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sAuctionHouseStore, dbcPath,"AuctionHouse.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBankBagSlotPricesStore, dbcPath,"BankBagSlotPrices.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBattlemasterListStore, dbcPath,"BattlemasterList.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sBarberShopStyleStore, dbcPath,"BarberShopStyle.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharStartOutfitStore, dbcPath,"CharStartOutfit.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCharTitlesStore, dbcPath,"CharTitles.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChatChannelsStore, dbcPath,"ChatChannels.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrClassesStore, dbcPath,"ChrClasses.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sChrRacesStore, dbcPath,"ChrRaces.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCinematicSequencesStore, dbcPath,"CinematicSequences.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureDisplayInfoStore, dbcPath,"CreatureDisplayInfo.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureDisplayInfoExtraStore,dbcPath,"CreatureDisplayInfoExtra.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureFamilyStore, dbcPath,"CreatureFamily.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureSpellDataStore, dbcPath,"CreatureSpellData.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCreatureTypeStore, dbcPath,"CreatureType.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sCurrencyTypesStore, dbcPath,"CurrencyTypes.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sDungeonEncounterStore, dbcPath,"DungeonEncounter.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sDurabilityCostsStore, dbcPath,"DurabilityCosts.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sDurabilityQualityStore, dbcPath,"DurabilityQuality.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesStore, dbcPath,"Emotes.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sEmotesTextStore, dbcPath,"EmotesText.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionStore, dbcPath,"Faction.dbc"); - for (uint32 i=0; iteam) @@ -424,67 +424,67 @@ void LoadDBCStores(const std::string& dataPath) } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore, dbcPath,"FactionTemplate.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGameObjectDisplayInfoStore,dbcPath,"GameObjectDisplayInfo.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore, dbcPath,"GemProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphPropertiesStore, dbcPath,"GlyphProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGlyphSlotStore, dbcPath,"GlyphSlot.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sFactionTemplateStore, dbcPath, "FactionTemplate.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGameObjectDisplayInfoStore, dbcPath, "GameObjectDisplayInfo.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGemPropertiesStore, dbcPath, "GemProperties.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGlyphPropertiesStore, dbcPath, "GlyphProperties.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGlyphSlotStore, dbcPath, "GlyphSlot.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtBarberShopCostBaseStore,dbcPath,"gtBarberShopCostBase.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtCombatRatingsStore, dbcPath,"gtCombatRatings.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtBarberShopCostBaseStore, dbcPath, "gtBarberShopCostBase.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtCombatRatingsStore, dbcPath, "gtCombatRatings.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritBaseStore, dbcPath,"gtChanceToMeleeCritBase.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToMeleeCritStore, dbcPath,"gtChanceToMeleeCrit.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtChanceToMeleeCritBaseStore, dbcPath, "gtChanceToMeleeCritBase.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtChanceToMeleeCritStore, dbcPath, "gtChanceToMeleeCrit.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritBaseStore, dbcPath,"gtChanceToSpellCritBase.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtChanceToSpellCritStore, dbcPath,"gtChanceToSpellCrit.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtChanceToSpellCritBaseStore, dbcPath, "gtChanceToSpellCritBase.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtChanceToSpellCritStore, dbcPath, "gtChanceToSpellCrit.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTClassCombatRatingScalarStore,dbcPath,"gtOCTClassCombatRatingScalar.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenHPStore, dbcPath,"gtOCTRegenHP.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtOCTClassCombatRatingScalarStore, dbcPath, "gtOCTClassCombatRatingScalar.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtOCTRegenHPStore, dbcPath, "gtOCTRegenHP.dbc"); //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenHPPerSptStore, dbcPath,"gtRegenHPPerSpt.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenMPPerSptStore, dbcPath,"gtRegenMPPerSpt.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sHolidaysStore, dbcPath,"Holidays.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemStore, dbcPath,"Item.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemBagFamilyStore, dbcPath,"ItemBagFamily.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemClassStore, dbcPath,"ItemClass.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtRegenHPPerSptStore, dbcPath, "gtRegenHPPerSpt.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sGtRegenMPPerSptStore, dbcPath, "gtRegenMPPerSpt.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sHolidaysStore, dbcPath, "Holidays.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemStore, dbcPath, "Item.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemBagFamilyStore, dbcPath, "ItemBagFamily.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemClassStore, dbcPath, "ItemClass.dbc"); //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemDisplayInfoStore, dbcPath,"ItemDisplayInfo.dbc"); -- not used currently //LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemCondExtCostsStore, dbcPath,"ItemCondExtCosts.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemExtendedCostStore, dbcPath,"ItemExtendedCost.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemLimitCategoryStore, dbcPath,"ItemLimitCategory.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemRandomPropertiesStore,dbcPath,"ItemRandomProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemRandomSuffixStore, dbcPath,"ItemRandomSuffix.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemSetStore, dbcPath,"ItemSet.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sLockStore, dbcPath,"Lock.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMailTemplateStore, dbcPath,"MailTemplate.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMapStore, dbcPath,"Map.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemExtendedCostStore, dbcPath, "ItemExtendedCost.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemLimitCategoryStore, dbcPath, "ItemLimitCategory.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemRandomPropertiesStore, dbcPath, "ItemRandomProperties.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemRandomSuffixStore, dbcPath, "ItemRandomSuffix.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sItemSetStore, dbcPath, "ItemSet.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sLockStore, dbcPath, "Lock.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sMailTemplateStore, dbcPath, "MailTemplate.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sMapStore, dbcPath, "Map.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMapDifficultyStore, dbcPath,"MapDifficulty.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sMapDifficultyStore, dbcPath, "MapDifficulty.dbc"); // fill data for (uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i) if (MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i)) - sMapDifficultyMap[MAKE_PAIR32(entry->MapId,entry->Difficulty)] = MapDifficulty(entry->resetTime,entry->maxPlayers); + sMapDifficultyMap[MAKE_PAIR32(entry->MapId, entry->Difficulty)] = MapDifficulty(entry->resetTime, entry->maxPlayers); sMapDifficultyStore.Clear(); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sMovieStore, dbcPath,"Movie.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sOverrideSpellDataStore, dbcPath,"OverrideSpellData.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestFactionRewardStore, dbcPath,"QuestFactionReward.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestSortStore, dbcPath,"QuestSort.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sQuestXPLevelStore, dbcPath,"QuestXP.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sPvPDifficultyStore, dbcPath,"PvpDifficulty.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sOverrideSpellDataStore, dbcPath, "OverrideSpellData.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sQuestFactionRewardStore, dbcPath, "QuestFactionReward.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sQuestSortStore, dbcPath, "QuestSort.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sQuestXPLevelStore, dbcPath, "QuestXP.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sPvPDifficultyStore, dbcPath, "PvpDifficulty.dbc"); for (uint32 i = 0; i < sPvPDifficultyStore.GetNumRows(); ++i) if (PvPDifficultyEntry const* entry = sPvPDifficultyStore.LookupEntry(i)) if (entry->bracketId > MAX_BATTLEGROUND_BRACKETS) MANGOS_ASSERT(false && "Need update MAX_BATTLEGROUND_BRACKETS by DBC data"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sRandomPropertiesPointsStore, dbcPath,"RandPropPoints.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sScalingStatDistributionStore, dbcPath,"ScalingStatDistribution.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sScalingStatValuesStore, dbcPath,"ScalingStatValues.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillLineStore, dbcPath,"SkillLine.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillLineAbilityStore, dbcPath,"SkillLineAbility.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillRaceClassInfoStore, dbcPath,"SkillRaceClassInfo.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSoundEntriesStore, dbcPath,"SoundEntries.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellStore, dbcPath,"Spell.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sRandomPropertiesPointsStore, dbcPath, "RandPropPoints.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sScalingStatDistributionStore, dbcPath, "ScalingStatDistribution.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sScalingStatValuesStore, dbcPath, "ScalingStatValues.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSkillLineStore, dbcPath, "SkillLine.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSkillLineAbilityStore, dbcPath, "SkillLineAbility.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSkillRaceClassInfoStore, dbcPath, "SkillRaceClassInfo.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSoundEntriesStore, dbcPath, "SoundEntries.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellStore, dbcPath, "Spell.dbc"); for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) { SpellEntry const* spell = sSpellStore.LookupEntry(i); @@ -494,7 +494,7 @@ void LoadDBCStores(const std::string& dataPath) // DBC not support uint64 fields but SpellEntry have SpellFamilyFlags mapped at 2 uint32 fields // uint32 field already converted to bigendian if need, but must be swapped for correct uint64 bigendian view #if MANGOS_ENDIAN == MANGOS_BIGENDIAN - std::swap(*((uint32*)(&spell->SpellFamilyFlags)),*(((uint32*)(&spell->SpellFamilyFlags))+1)); + std::swap(*((uint32*)(&spell->SpellFamilyFlags)), *(((uint32*)(&spell->SpellFamilyFlags)) + 1)); #endif } @@ -522,19 +522,19 @@ void LoadDBCStores(const std::string& dataPath) } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellCastTimesStore, dbcPath,"SpellCastTimes.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDurationStore, dbcPath,"SpellDuration.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellDifficultyStore, dbcPath,"SpellDifficulty.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore, dbcPath,"SpellFocusObject.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRadiusStore, dbcPath,"SpellRadius.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRangeStore, dbcPath,"SpellRange.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRuneCostStore, dbcPath,"SpellRuneCost.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellShapeshiftFormStore, dbcPath,"SpellShapeshiftForm.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sStableSlotPricesStore, dbcPath,"StableSlotPrices.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSummonPropertiesStore, dbcPath,"SummonProperties.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentStore, dbcPath,"Talent.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellCastTimesStore, dbcPath, "SpellCastTimes.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellDurationStore, dbcPath, "SpellDuration.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellDifficultyStore, dbcPath, "SpellDifficulty.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellFocusObjectStore, dbcPath, "SpellFocusObject.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellItemEnchantmentStore, dbcPath, "SpellItemEnchantment.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellItemEnchantmentConditionStore, dbcPath, "SpellItemEnchantmentCondition.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellRadiusStore, dbcPath, "SpellRadius.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellRangeStore, dbcPath, "SpellRange.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellRuneCostStore, dbcPath, "SpellRuneCost.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSpellShapeshiftFormStore, dbcPath, "SpellShapeshiftForm.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sStableSlotPricesStore, dbcPath, "StableSlotPrices.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sSummonPropertiesStore, dbcPath, "SummonProperties.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sTalentStore, dbcPath, "Talent.dbc"); // create talent spells set for (unsigned int i = 0; i < sTalentStore.GetNumRows(); ++i) @@ -543,10 +543,10 @@ void LoadDBCStores(const std::string& dataPath) if (!talentInfo) continue; for (int j = 0; j < MAX_TALENT_RANK; j++) if (talentInfo->RankID[j]) - sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i,j); + sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(i, j); } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTalentTabStore, dbcPath,"TalentTab.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sTalentTabStore, dbcPath, "TalentTab.dbc"); // prepare fast data access to bit pos of talent ranks for use at inspecting { @@ -558,27 +558,27 @@ void LoadDBCStores(const std::string& dataPath) continue; // prevent memory corruption; otherwise cls will become 12 below - if ((talentTabInfo->ClassMask & CLASSMASK_ALL_PLAYABLE)==0) + if ((talentTabInfo->ClassMask & CLASSMASK_ALL_PLAYABLE) == 0) continue; // store class talent tab pages uint32 cls = 1; - for (uint32 m=1; !(m & talentTabInfo->ClassMask) && cls < MAX_CLASSES; m <<=1, ++cls) {} + for (uint32 m = 1; !(m & talentTabInfo->ClassMask) && cls < MAX_CLASSES; m <<= 1, ++cls) {} - sTalentTabPages[cls][talentTabInfo->tabpage]=talentTabId; + sTalentTabPages[cls][talentTabInfo->tabpage] = talentTabId; } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiNodesStore, dbcPath,"TaxiNodes.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sTaxiNodesStore, dbcPath, "TaxiNodes.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathStore, dbcPath,"TaxiPath.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sTaxiPathStore, dbcPath, "TaxiPath.dbc"); for (uint32 i = 1; i < sTaxiPathStore.GetNumRows(); ++i) if (TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(i)) - sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID,entry->price); + sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID, entry->price); uint32 pathCount = sTaxiPathStore.GetNumRows(); //## TaxiPathNode.dbc ## Loaded only for initialization different structures - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTaxiPathNodeStore, dbcPath,"TaxiPathNode.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sTaxiPathNodeStore, dbcPath, "TaxiPathNode.dbc"); // Calculate path nodes count std::vector pathLength; pathLength.resize(pathCount); // 0 and some other indexes not used @@ -603,12 +603,12 @@ void LoadDBCStores(const std::string& dataPath) std::set spellPaths; for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) if (SpellEntry const* sInfo = sSpellStore.LookupEntry(i)) - for (int j=0; j < MAX_EFFECT_INDEX; ++j) - if (sInfo->Effect[j]==123 /*SPELL_EFFECT_SEND_TAXI*/) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) + if (sInfo->Effect[j] == 123 /*SPELL_EFFECT_SEND_TAXI*/) spellPaths.insert(sInfo->EffectMiscValue[j]); - memset(sTaxiNodesMask,0,sizeof(sTaxiNodesMask)); - memset(sOldContinentsNodesMask,0,sizeof(sTaxiNodesMask)); + memset(sTaxiNodesMask, 0, sizeof(sTaxiNodesMask)); + memset(sOldContinentsNodesMask, 0, sizeof(sTaxiNodesMask)); for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) { TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); @@ -616,13 +616,13 @@ void LoadDBCStores(const std::string& dataPath) continue; TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(i); - if (src_i!=sTaxiPathSetBySource.end() && !src_i->second.empty()) + if (src_i != sTaxiPathSetBySource.end() && !src_i->second.empty()) { bool ok = false; for (TaxiPathSetForSource::const_iterator dest_i = src_i->second.begin(); dest_i != src_i->second.end(); ++dest_i) { // not spell path - if (spellPaths.find(dest_i->second.ID)==spellPaths.end()) + if (spellPaths.find(dest_i->second.ID) == spellPaths.end()) { ok = true; break; @@ -635,7 +635,7 @@ void LoadDBCStores(const std::string& dataPath) // valid taxi network node uint8 field = (uint8)((i - 1) / 32); - uint32 submask = 1<<((i-1)%32); + uint32 submask = 1 << ((i - 1) % 32); sTaxiNodesMask[field] |= submask; // old continent node (+ nodes virtually at old continents, check explicitly to avoid loading map files for zone info) @@ -644,12 +644,12 @@ void LoadDBCStores(const std::string& dataPath) } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTeamContributionPoints, dbcPath,"TeamContributionPoints.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sTotemCategoryStore, dbcPath,"TotemCategory.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleStore, dbcPath,"Vehicle.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sVehicleSeatStore, dbcPath,"VehicleSeat.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapAreaStore, dbcPath,"WorldMapArea.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWMOAreaTableStore, dbcPath,"WMOAreaTable.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sTeamContributionPoints, dbcPath, "TeamContributionPoints.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sTotemCategoryStore, dbcPath, "TotemCategory.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sVehicleStore, dbcPath, "Vehicle.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sVehicleSeatStore, dbcPath, "VehicleSeat.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sWorldMapAreaStore, dbcPath, "WorldMapArea.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sWMOAreaTableStore, dbcPath, "WMOAreaTable.dbc"); for (uint32 i = 0; i < sWMOAreaTableStore.GetNumRows(); ++i) { if (WMOAreaTableEntry const* entry = sWMOAreaTableStore.LookupEntry(i)) @@ -657,13 +657,13 @@ void LoadDBCStores(const std::string& dataPath) sWMOAreaInfoByTripple.insert(WMOAreaInfoByTripple::value_type(WMOAreaTableTripple(entry->rootId, entry->adtId, entry->groupId), entry)); } } - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldMapOverlayStore, dbcPath,"WorldMapOverlay.dbc"); - LoadDBC(availableDbcLocales,bar,bad_dbc_files,sWorldSafeLocsStore, dbcPath,"WorldSafeLocs.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sWorldMapOverlayStore, dbcPath, "WorldMapOverlay.dbc"); + LoadDBC(availableDbcLocales, bar, bad_dbc_files, sWorldSafeLocsStore, dbcPath, "WorldSafeLocs.dbc"); // error checks if (bad_dbc_files.size() >= DBCFilesCount) { - sLog.outError("\nIncorrect DataDir value in mangosd.conf or ALL required *.dbc files (%d) not found by path: %sdbc",DBCFilesCount,dataPath.c_str()); + sLog.outError("\nIncorrect DataDir value in mangosd.conf or ALL required *.dbc files (%d) not found by path: %sdbc", DBCFilesCount, dataPath.c_str()); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -673,7 +673,7 @@ void LoadDBCStores(const std::string& dataPath) for (std::list::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i) str += *i + "\n"; - sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s",(uint32)bad_dbc_files.size(),DBCFilesCount,str.c_str()); + sLog.outError("\nSome required *.dbc files (%u from %d) not found or not compatible:\n%s", (uint32)bad_dbc_files.size(), DBCFilesCount, str.c_str()); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -687,7 +687,7 @@ void LoadDBCStores(const std::string& dataPath) !sMapStore.LookupEntry(724) || // last map added in 3.3.5a !sSpellStore.LookupEntry(80864)) // last added spell in 3.3.5a { - sLog.outError("\nYou have mixed version DBC files. Please re-extract DBC files for one from client build: %s",AcceptableClientBuildsListStr().c_str()); + sLog.outError("\nYou have mixed version DBC files. Please re-extract DBC files for one from client build: %s", AcceptableClientBuildsListStr().c_str()); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -699,7 +699,7 @@ void LoadDBCStores(const std::string& dataPath) SimpleFactionsList const* GetFactionTeamList(uint32 faction) { FactionTeamMap::const_iterator itr = sFactionTeamMap.find(faction); - if (itr==sFactionTeamMap.end()) + if (itr == sFactionTeamMap.end()) return NULL; return &itr->second; } @@ -711,13 +711,13 @@ char const* GetPetName(uint32 petfamily, uint32 dbclang) CreatureFamilyEntry const* pet_family = sCreatureFamilyStore.LookupEntry(petfamily); if (!pet_family) return NULL; - return pet_family->Name[dbclang]?pet_family->Name[dbclang]:NULL; + return pet_family->Name[dbclang] ? pet_family->Name[dbclang] : NULL; } TalentSpellPos const* GetTalentSpellPos(uint32 spellId) { TalentSpellPosMap::const_iterator itr = sTalentSpellPosMap.find(spellId); - if (itr==sTalentSpellPosMap.end()) + if (itr == sTalentSpellPosMap.end()) return NULL; return &itr->second; @@ -726,7 +726,7 @@ TalentSpellPos const* GetTalentSpellPos(uint32 spellId) uint32 GetTalentSpellCost(TalentSpellPos const* pos) { if (pos) - return pos->rank+1; + return pos->rank + 1; return 0; } @@ -763,7 +763,7 @@ AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id) return sAreaStore.LookupEntry(areaflag); } -AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id) +AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id) { if (area_flag) return sAreaStore.LookupEntry(area_flag); @@ -796,7 +796,7 @@ uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId) ContentLevels GetContentLevelsForMapAndZone(uint32 mapid, uint32 zoneId) { - mapid = GetVirtualMapForMapAndZone(mapid,zoneId); + mapid = GetVirtualMapForMapAndZone(mapid, zoneId); if (mapid < 2) return CONTENT_1_60; @@ -826,9 +826,9 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id) bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId) { - if (requiredTotemCategoryId==0) + if (requiredTotemCategoryId == 0) return true; - if (itemTotemCategoryId==0) + if (itemTotemCategoryId == 0) return false; TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId); @@ -838,13 +838,13 @@ bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredT if (!reqEntry) return false; - if (itemEntry->categoryType!=reqEntry->categoryType) + if (itemEntry->categoryType != reqEntry->categoryType) return false; - return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask; + return (itemEntry->categoryMask & reqEntry->categoryMask) == reqEntry->categoryMask; } -bool Zone2MapCoordinates(float& x,float& y,uint32 zone) +bool Zone2MapCoordinates(float& x, float& y, uint32 zone) { WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone); @@ -852,14 +852,14 @@ bool Zone2MapCoordinates(float& x,float& y,uint32 zone) if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1) return false; - std::swap(x,y); // at client map coords swapped - x = x*((maEntry->x2-maEntry->x1)/100)+maEntry->x1; - y = y*((maEntry->y2-maEntry->y1)/100)+maEntry->y1; // client y coord from top to down + std::swap(x, y); // at client map coords swapped + x = x * ((maEntry->x2 - maEntry->x1) / 100) + maEntry->x1; + y = y * ((maEntry->y2 - maEntry->y1) / 100) + maEntry->y1; // client y coord from top to down return true; } -bool Map2ZoneCoordinates(float& x,float& y,uint32 zone) +bool Map2ZoneCoordinates(float& x, float& y, uint32 zone) { WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone); @@ -867,16 +867,16 @@ bool Map2ZoneCoordinates(float& x,float& y,uint32 zone) if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1) return false; - x = (x-maEntry->x1)/((maEntry->x2-maEntry->x1)/100); - y = (y-maEntry->y1)/((maEntry->y2-maEntry->y1)/100); // client y coord from top to down - std::swap(x,y); // client have map coords swapped + x = (x - maEntry->x1) / ((maEntry->x2 - maEntry->x1) / 100); + y = (y - maEntry->y1) / ((maEntry->y2 - maEntry->y1) / 100); // client y coord from top to down + std::swap(x, y); // client have map coords swapped return true; } MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty) { - MapDifficultyMap::const_iterator itr = sMapDifficultyMap.find(MAKE_PAIR32(mapId,difficulty)); + MapDifficultyMap::const_iterator itr = sMapDifficultyMap.find(MAKE_PAIR32(mapId, difficulty)); return itr != sMapDifficultyMap.end() ? &itr->second : NULL; } @@ -927,8 +927,8 @@ bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, flo if (atEntry->radius > 0) { // if we have radius check it - float dist2 = (x-atEntry->x)*(x-atEntry->x) + (y-atEntry->y)*(y-atEntry->y) + (z-atEntry->z)*(z-atEntry->z); - if (dist2 > (atEntry->radius + delta)*(atEntry->radius + delta)) + float dist2 = (x - atEntry->x) * (x - atEntry->x) + (y - atEntry->y) * (y - atEntry->y) + (z - atEntry->z) * (z - atEntry->z); + if (dist2 > (atEntry->radius + delta) * (atEntry->radius + delta)) return false; } else @@ -939,23 +939,23 @@ bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, flo // is-in-cube check and we have to calculate only one point instead of 4 // 2PI = 360, keep in mind that ingame orientation is counter-clockwise - double rotation = 2*M_PI-atEntry->box_orientation; + double rotation = 2 * M_PI - atEntry->box_orientation; double sinVal = sin(rotation); double cosVal = cos(rotation); float playerBoxDistX = x - atEntry->x; float playerBoxDistY = y - atEntry->y; - float rotPlayerX = float(atEntry->x + playerBoxDistX * cosVal - playerBoxDistY*sinVal); - float rotPlayerY = float(atEntry->y + playerBoxDistY * cosVal + playerBoxDistX*sinVal); + float rotPlayerX = float(atEntry->x + playerBoxDistX * cosVal - playerBoxDistY * sinVal); + float rotPlayerY = float(atEntry->y + playerBoxDistY * cosVal + playerBoxDistX * sinVal); // box edges are parallel to coordiante axis, so we can treat every dimension independently :D float dz = z - atEntry->z; float dx = rotPlayerX - atEntry->x; float dy = rotPlayerY - atEntry->y; - if ((fabs(dx) > atEntry->box_x/2 + delta) || - (fabs(dy) > atEntry->box_y/2 + delta) || - (fabs(dz) > atEntry->box_z/2 + delta)) + if ((fabs(dx) > atEntry->box_x / 2 + delta) || + (fabs(dy) > atEntry->box_y / 2 + delta) || + (fabs(dz) > atEntry->box_z / 2 + delta)) { return false; } diff --git a/src/game/DBCStores.h b/src/game/DBCStores.h index 25f982c44..1a59553da 100644 --- a/src/game/DBCStores.h +++ b/src/game/DBCStores.h @@ -42,7 +42,7 @@ uint32 GetAreaFlagByMapId(uint32 mapid); WMOAreaTableEntry const* GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid); MANGOS_DLL_SPEC AreaTableEntry const* GetAreaEntryByAreaID(uint32 area_id); -MANGOS_DLL_SPEC AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag,uint32 map_id); +MANGOS_DLL_SPEC AreaTableEntry const* GetAreaEntryByAreaFlagAndMap(uint32 area_flag, uint32 map_id); uint32 GetVirtualMapForMapAndZone(uint32 mapid, uint32 zoneId); @@ -58,10 +58,10 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id); bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId); -bool Zone2MapCoordinates(float& x,float& y,uint32 zone); -bool Map2ZoneCoordinates(float& x,float& y,uint32 zone); +bool Zone2MapCoordinates(float& x, float& y, uint32 zone); +bool Map2ZoneCoordinates(float& x, float& y, uint32 zone); -typedef std::map MapDifficultyMap; +typedef std::map < uint32/*pair32(map,diff)*/, MapDifficulty > MapDifficultyMap; MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty); // natural order for difficulties up-down iteration diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index 3061186cc..9475fe667 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -913,7 +913,7 @@ struct FactionTemplateEntry } return (hostileMask & entry.ourMask) != 0; } - bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) !=0; } + bool IsHostileToPlayers() const { return (hostileMask & FACTION_MASK_PLAYER) != 0; } bool IsNeutralToAll() const { for (int i = 0; i < 4; ++i) @@ -921,7 +921,7 @@ struct FactionTemplateEntry return false; return hostileMask == 0 && friendlyMask == 0; } - bool IsContestedGuardFaction() const { return (factionFlags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD)!=0; } + bool IsContestedGuardFaction() const { return (factionFlags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) != 0; } }; struct GameObjectDisplayInfoEntry @@ -1259,10 +1259,10 @@ struct MapEntry bool IsMountAllowed() const { return !IsDungeon() || - MapID==209 || MapID==269 || MapID==309 || // TanarisInstance, CavernsOfTime, Zul'gurub - MapID==509 || MapID==534 || MapID==560 || // AhnQiraj, HyjalPast, HillsbradPast - MapID==568 || MapID==580 || MapID==595 || // ZulAman, Sunwell Plateau, Culling of Stratholme - MapID==603 || MapID==615 || MapID==616; // Ulduar, The Obsidian Sanctum, The Eye Of Eternity + MapID == 209 || MapID == 269 || MapID == 309 || // TanarisInstance, CavernsOfTime, Zul'gurub + MapID == 509 || MapID == 534 || MapID == 560 || // AhnQiraj, HyjalPast, HillsbradPast + MapID == 568 || MapID == 580 || MapID == 595 || // ZulAman, Sunwell Plateau, Culling of Stratholme + MapID == 603 || MapID == 615 || MapID == 616; // Ulduar, The Obsidian Sanctum, The Eye Of Eternity } bool IsContinent() const @@ -2100,9 +2100,9 @@ struct WorldSafeLocsEntry #endif typedef std::set SpellCategorySet; -typedef std::map SpellCategoryStore; +typedef std::map SpellCategoryStore; typedef std::set PetFamilySpellsSet; -typedef std::map PetFamilySpellsStore; +typedef std::map PetFamilySpellsStore; // Structures not used for casting to loaded DBC data and not required then packing struct MapDifficulty @@ -2123,18 +2123,18 @@ struct TalentSpellPos uint8 rank; }; -typedef std::map TalentSpellPosMap; +typedef std::map TalentSpellPosMap; struct TaxiPathBySourceAndDestination { - TaxiPathBySourceAndDestination() : ID(0),price(0) {} - TaxiPathBySourceAndDestination(uint32 _id,uint32 _price) : ID(_id),price(_price) {} + TaxiPathBySourceAndDestination() : ID(0), price(0) {} + TaxiPathBySourceAndDestination(uint32 _id, uint32 _price) : ID(_id), price(_price) {} uint32 ID; uint32 price; }; -typedef std::map TaxiPathSetForSource; -typedef std::map TaxiPathSetBySource; +typedef std::map TaxiPathSetForSource; +typedef std::map TaxiPathSetBySource; struct TaxiPathNodePtr { @@ -2146,7 +2146,7 @@ struct TaxiPathNodePtr operator TaxiPathNodeEntry const& () const { return *i_ptr; } }; -typedef Path TaxiPathNodeList; +typedef Path TaxiPathNodeList; typedef std::vector TaxiPathNodesByPath; #define TaxiMaskSize 14 diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index 11f591d5a..5729c8f4f 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -19,103 +19,103 @@ #ifndef MANGOS_DBCSFRM_H #define MANGOS_DBCSFRM_H -const char Achievementfmt[]="niixssssssssssssssssxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxxxxxxxxii"; -const char AchievementCriteriafmt[]="niiiiiiiissssssssssssssssxixiii"; -const char AreaTableEntryfmt[]="iiinixxxxxissssssssssssssssxixxxxxxx"; -const char AreaGroupEntryfmt[]="niiiiiii"; -const char AreaTriggerEntryfmt[]="niffffffff"; -const char AuctionHouseEntryfmt[]="niiixxxxxxxxxxxxxxxxx"; -const char BankBagSlotPricesEntryfmt[]="ni"; -const char BarberShopStyleEntryfmt[]="nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii"; -const char BattlemasterListEntryfmt[]="niiiiiiiiixssssssssssssssssxiiii"; -const char CharStartOutfitEntryfmt[]="diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -const char CharTitlesEntryfmt[]="nxssssssssssssssssxxxxxxxxxxxxxxxxxxi"; -const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx"; +const char Achievementfmt[] = "niixssssssssssssssssxxxxxxxxxxxxxxxxxxiixixxxxxxxxxxxxxxxxxxii"; +const char AchievementCriteriafmt[] = "niiiiiiiissssssssssssssssxixiii"; +const char AreaTableEntryfmt[] = "iiinixxxxxissssssssssssssssxixxxxxxx"; +const char AreaGroupEntryfmt[] = "niiiiiii"; +const char AreaTriggerEntryfmt[] = "niffffffff"; +const char AuctionHouseEntryfmt[] = "niiixxxxxxxxxxxxxxxxx"; +const char BankBagSlotPricesEntryfmt[] = "ni"; +const char BarberShopStyleEntryfmt[] = "nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii"; +const char BattlemasterListEntryfmt[] = "niiiiiiiiixssssssssssssssssxiiii"; +const char CharStartOutfitEntryfmt[] = "diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; +const char CharTitlesEntryfmt[] = "nxssssssssssssssssxxxxxxxxxxxxxxxxxxi"; +const char ChatChannelsEntryfmt[] = "iixssssssssssssssssxxxxxxxxxxxxxxxxxx"; // ChatChannelsEntryfmt, index not used (more compact store) -const char ChrClassesEntryfmt[]="nxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; -const char ChrRacesEntryfmt[]="nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi"; -const char CinematicSequencesEntryfmt[]="nxxxxxxxxx"; -const char CreatureDisplayInfofmt[]="nxxifxxxxxxxxxxx"; -const char CreatureDisplayInfoExtrafmt[]="nixxxxxxxxxxxxxxxxxxx"; -const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx"; -const char CreatureSpellDatafmt[]="niiiixxxx"; -const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx"; -const char CurrencyTypesfmt[]="xnxi"; -const char DungeonEncounterfmt[]="niiiissssssssssssssssxx"; -const char DurabilityCostsfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiii"; -const char DurabilityQualityfmt[]="nf"; -const char EmotesEntryfmt[]="nxxiiix"; -const char EmotesTextEntryfmt[]="nxixxxxxxxxxxxxxxxx"; -const char FactionEntryfmt[]="niiiiiiiiiiiiiiiiiiffixssssssssssssssssxxxxxxxxxxxxxxxxxx"; -const char FactionTemplateEntryfmt[]="niiiiiiiiiiiii"; -const char GameObjectDisplayInfofmt[]="nxxxxxxxxxxxfxxxxxx"; -const char GemPropertiesEntryfmt[]="nixxi"; -const char GlyphPropertiesfmt[]="niii"; -const char GlyphSlotfmt[]="nii"; -const char GtBarberShopCostBasefmt[]="f"; -const char GtCombatRatingsfmt[]="f"; -const char GtChanceToMeleeCritBasefmt[]="f"; -const char GtChanceToMeleeCritfmt[]="f"; -const char GtChanceToSpellCritBasefmt[]="f"; -const char GtChanceToSpellCritfmt[]="f"; -const char GtOCTClassCombatRatingScalarfmt[]="df"; -const char GtOCTRegenHPfmt[]="f"; +const char ChrClassesEntryfmt[] = "nxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; +const char ChrRacesEntryfmt[] = "nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi"; +const char CinematicSequencesEntryfmt[] = "nxxxxxxxxx"; +const char CreatureDisplayInfofmt[] = "nxxifxxxxxxxxxxx"; +const char CreatureDisplayInfoExtrafmt[] = "nixxxxxxxxxxxxxxxxxxx"; +const char CreatureFamilyfmt[] = "nfifiiiiixssssssssssssssssxx"; +const char CreatureSpellDatafmt[] = "niiiixxxx"; +const char CreatureTypefmt[] = "nxxxxxxxxxxxxxxxxxx"; +const char CurrencyTypesfmt[] = "xnxi"; +const char DungeonEncounterfmt[] = "niiiissssssssssssssssxx"; +const char DurabilityCostsfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiiiiiii"; +const char DurabilityQualityfmt[] = "nf"; +const char EmotesEntryfmt[] = "nxxiiix"; +const char EmotesTextEntryfmt[] = "nxixxxxxxxxxxxxxxxx"; +const char FactionEntryfmt[] = "niiiiiiiiiiiiiiiiiiffixssssssssssssssssxxxxxxxxxxxxxxxxxx"; +const char FactionTemplateEntryfmt[] = "niiiiiiiiiiiii"; +const char GameObjectDisplayInfofmt[] = "nxxxxxxxxxxxfxxxxxx"; +const char GemPropertiesEntryfmt[] = "nixxi"; +const char GlyphPropertiesfmt[] = "niii"; +const char GlyphSlotfmt[] = "nii"; +const char GtBarberShopCostBasefmt[] = "f"; +const char GtCombatRatingsfmt[] = "f"; +const char GtChanceToMeleeCritBasefmt[] = "f"; +const char GtChanceToMeleeCritfmt[] = "f"; +const char GtChanceToSpellCritBasefmt[] = "f"; +const char GtChanceToSpellCritfmt[] = "f"; +const char GtOCTClassCombatRatingScalarfmt[] = "df"; +const char GtOCTRegenHPfmt[] = "f"; //const char GtOCTRegenMPfmt[]="f"; -const char GtRegenHPPerSptfmt[]="f"; -const char GtRegenMPPerSptfmt[]="f"; -const char Holidaysfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -const char Itemfmt[]="niiiiiii"; -const char ItemBagFamilyfmt[]="nxxxxxxxxxxxxxxxxx"; -const char ItemClassfmt[]="nxxssssssssssssssssx"; +const char GtRegenHPPerSptfmt[] = "f"; +const char GtRegenMPPerSptfmt[] = "f"; +const char Holidaysfmt[] = "nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; +const char Itemfmt[] = "niiiiiii"; +const char ItemBagFamilyfmt[] = "nxxxxxxxxxxxxxxxxx"; +const char ItemClassfmt[] = "nxxssssssssssssssssx"; //const char ItemDisplayTemplateEntryfmt[]="nxxxxxxxxxxixxxxxxxxxxx"; //const char ItemCondExtCostsEntryfmt[]="xiii"; -const char ItemExtendedCostEntryfmt[]="niiiiiiiiiiiiiix"; -const char ItemLimitCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii"; -const char ItemRandomPropertiesfmt[]="nxiiiiissssssssssssssssx"; -const char ItemRandomSuffixfmt[]="nssssssssssssssssxxiiiiiiiiii"; -const char ItemSetEntryfmt[]="dssssssssssssssssxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiii"; -const char LockEntryfmt[]="niiiiiiiiiiiiiiiiiiiiiiiixxxxxxxx"; -const char MailTemplateEntryfmt[]="nxxxxxxxxxxxxxxxxxssssssssssssssssx"; -const char MapEntryfmt[]="nxixxssssssssssssssssxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixiffxixx"; -const char MapDifficultyEntryfmt[]="diixxxxxxxxxxxxxxxxxiix"; -const char MovieEntryfmt[]="nxx"; -const char OverrideSpellDatafmt[]="niiiiiiiiiix"; -const char QuestFactionRewardfmt[]="niiiiiiiiii"; -const char QuestSortEntryfmt[]="nxxxxxxxxxxxxxxxxx"; -const char QuestXPLevelfmt[]="niiiiiiiiii"; -const char PvPDifficultyfmt[]="diiiii"; -const char RandomPropertiesPointsfmt[]="niiiiiiiiiiiiiii"; -const char ScalingStatDistributionfmt[]="niiiiiiiiiiiiiiiiiiiii"; -const char ScalingStatValuesfmt[]="iniiiiiiiiiiiiiiiiixiiii"; -const char SkillLinefmt[]="nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxi"; -const char SkillLineAbilityfmt[]="niiiixxiiiiixx"; -const char SkillRaceClassInfofmt[]="diiiiixx"; -const char SoundEntriesfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -const char SpellCastTimefmt[]="nixx"; -const char SpellDurationfmt[]="niii"; -const char SpellDifficultyfmt[]="niiii"; -const char SpellEntryfmt[]="niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxi"; -const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx"; -const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiixxx"; -const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX"; -const char SpellRadiusfmt[]="nfxx"; -const char SpellRangefmt[]="nffffxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -const char SpellRuneCostfmt[]="niiii"; -const char SpellShapeshiftFormfmt[]="nxxxxxxxxxxxxxxxxxxiixiiixxiiiiiiii"; +const char ItemExtendedCostEntryfmt[] = "niiiiiiiiiiiiiix"; +const char ItemLimitCategoryEntryfmt[] = "nxxxxxxxxxxxxxxxxxii"; +const char ItemRandomPropertiesfmt[] = "nxiiiiissssssssssssssssx"; +const char ItemRandomSuffixfmt[] = "nssssssssssssssssxxiiiiiiiiii"; +const char ItemSetEntryfmt[] = "dssssssssssssssssxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiii"; +const char LockEntryfmt[] = "niiiiiiiiiiiiiiiiiiiiiiiixxxxxxxx"; +const char MailTemplateEntryfmt[] = "nxxxxxxxxxxxxxxxxxssssssssssssssssx"; +const char MapEntryfmt[] = "nxixxssssssssssssssssxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixiffxixx"; +const char MapDifficultyEntryfmt[] = "diixxxxxxxxxxxxxxxxxiix"; +const char MovieEntryfmt[] = "nxx"; +const char OverrideSpellDatafmt[] = "niiiiiiiiiix"; +const char QuestFactionRewardfmt[] = "niiiiiiiiii"; +const char QuestSortEntryfmt[] = "nxxxxxxxxxxxxxxxxx"; +const char QuestXPLevelfmt[] = "niiiiiiiiii"; +const char PvPDifficultyfmt[] = "diiiii"; +const char RandomPropertiesPointsfmt[] = "niiiiiiiiiiiiiii"; +const char ScalingStatDistributionfmt[] = "niiiiiiiiiiiiiiiiiiiii"; +const char ScalingStatValuesfmt[] = "iniiiiiiiiiiiiiiiiixiiii"; +const char SkillLinefmt[] = "nixssssssssssssssssxxxxxxxxxxxxxxxxxxixxxxxxxxxxxxxxxxxi"; +const char SkillLineAbilityfmt[] = "niiiixxiiiiixx"; +const char SkillRaceClassInfofmt[] = "diiiiixx"; +const char SoundEntriesfmt[] = "nxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; +const char SpellCastTimefmt[] = "nixx"; +const char SpellDurationfmt[] = "niii"; +const char SpellDifficultyfmt[] = "niiii"; +const char SpellEntryfmt[] = "niiiiiiiiiiiixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxi"; +const char SpellFocusObjectfmt[] = "nxxxxxxxxxxxxxxxxx"; +const char SpellItemEnchantmentfmt[] = "nxiiiiiixxxiiissssssssssssssssxiiiixxx"; +const char SpellItemEnchantmentConditionfmt[] = "nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX"; +const char SpellRadiusfmt[] = "nfxx"; +const char SpellRangefmt[] = "nffffxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; +const char SpellRuneCostfmt[] = "niiii"; +const char SpellShapeshiftFormfmt[] = "nxxxxxxxxxxxxxxxxxxiixiiixxiiiiiiii"; const char StableSlotPricesfmt[] = "ni"; const char SummonPropertiesfmt[] = "niiiii"; -const char TalentEntryfmt[]="niiiiiiiixxxxixxixxxxxx"; -const char TalentTabEntryfmt[]="nxxxxxxxxxxxxxxxxxxxiiix"; -const char TaxiNodesEntryfmt[]="nifffssssssssssssssssxii"; -const char TaxiPathEntryfmt[]="niii"; -const char TaxiPathNodeEntryfmt[]="diiifffiiii"; -const char TeamContributionPointsfmt[]="df"; -const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii"; -const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx"; -const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx"; -const char WMOAreaTableEntryfmt[]="niiixxxxxiixxxxxxxxxxxxxxxxx"; -const char WorldMapAreaEntryfmt[]="xinxffffixx"; -const char WorldMapOverlayEntryfmt[]="nxiiiixxxxxxxxxxx"; -const char WorldSafeLocsEntryfmt[]="nifffxxxxxxxxxxxxxxxxx"; +const char TalentEntryfmt[] = "niiiiiiiixxxxixxixxxxxx"; +const char TalentTabEntryfmt[] = "nxxxxxxxxxxxxxxxxxxxiiix"; +const char TaxiNodesEntryfmt[] = "nifffssssssssssssssssxii"; +const char TaxiPathEntryfmt[] = "niii"; +const char TaxiPathNodeEntryfmt[] = "diiifffiiii"; +const char TeamContributionPointsfmt[] = "df"; +const char TotemCategoryEntryfmt[] = "nxxxxxxxxxxxxxxxxxii"; +const char VehicleEntryfmt[] = "niffffiiiiiiiifffffffffffffffssssfifixxx"; +const char VehicleSeatEntryfmt[] = "niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx"; +const char WMOAreaTableEntryfmt[] = "niiixxxxxiixxxxxxxxxxxxxxxxx"; +const char WorldMapAreaEntryfmt[] = "xinxffffixx"; +const char WorldMapOverlayEntryfmt[] = "nxiiiixxxxxxxxxxx"; +const char WorldSafeLocsEntryfmt[] = "nifffxxxxxxxxxxxxxxxxx"; #endif diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index f83c2514e..2b206a310 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -67,7 +67,7 @@ bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, SpellEf if (!IsPositionValid()) { - sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY()); + sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, effIndex, GetPositionX(), GetPositionY()); return false; } diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h index 1dce0fdfb..f0ae2fc30 100644 --- a/src/game/DynamicObject.h +++ b/src/game/DynamicObject.h @@ -49,7 +49,7 @@ class DynamicObject : public WorldObject ObjectGuid const& GetCasterGuid() const { return GetGuidValue(DYNAMICOBJECT_CASTER); } Unit* GetCaster() const; float GetRadius() const { return m_radius; } - DynamicObjectType GetType() const { return (DynamicObjectType)GetByteValue(DYNAMICOBJECT_BYTES,0); } + DynamicObjectType GetType() const { return (DynamicObjectType)GetByteValue(DYNAMICOBJECT_BYTES, 0); } bool IsAffecting(Unit* unit) const { return m_affected.find(unit->GetObjectGuid()) != m_affected.end(); } void AddAffected(Unit* unit) { m_affected.insert(unit->GetObjectGuid()); } void RemoveAffected(Unit* unit) { m_affected.erase(unit->GetObjectGuid()); } diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 93e26e4fa..23d08f2e6 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -73,36 +73,36 @@ bool FleeingMovementGenerator::_getPoint(T& owner, float& x, float& y, float& if (dist_from_caster > 0.2f) angle_to_caster = fright->GetAngle(&owner); else - angle_to_caster = frand(0, 2*M_PI_F); + angle_to_caster = frand(0, 2 * M_PI_F); } else { dist_from_caster = 0.0f; - angle_to_caster = frand(0, 2*M_PI_F); + angle_to_caster = frand(0, 2 * M_PI_F); } float dist, angle; if (dist_from_caster < MIN_QUIET_DISTANCE) { - dist = frand(0.4f, 1.3f)*(MIN_QUIET_DISTANCE - dist_from_caster); - angle = angle_to_caster + frand(-M_PI_F/8, M_PI_F/8); + dist = frand(0.4f, 1.3f) * (MIN_QUIET_DISTANCE - dist_from_caster); + angle = angle_to_caster + frand(-M_PI_F / 8, M_PI_F / 8); } else if (dist_from_caster > MAX_QUIET_DISTANCE) { - dist = frand(0.4f, 1.0f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); - angle = -angle_to_caster + frand(-M_PI_F/4, M_PI_F/4); + dist = frand(0.4f, 1.0f) * (MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); + angle = -angle_to_caster + frand(-M_PI_F / 4, M_PI_F / 4); } else // we are inside quiet range { - dist = frand(0.6f, 1.2f)*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); - angle = frand(0, 2*M_PI_F); + dist = frand(0.6f, 1.2f) * (MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE); + angle = frand(0, 2 * M_PI_F); } float curr_x, curr_y, curr_z; owner.GetPosition(curr_x, curr_y, curr_z); - x = curr_x + dist*cos(angle); - y = curr_y + dist*sin(angle); + x = curr_x + dist * cos(angle); + y = curr_y + dist * sin(angle); z = curr_z; owner.UpdateAllowedPositionZ(x, y, z); @@ -113,7 +113,7 @@ bool FleeingMovementGenerator::_getPoint(T& owner, float& x, float& y, float& template void FleeingMovementGenerator::Initialize(T& owner) { - owner.addUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); + owner.addUnitState(UNIT_STAT_FLEEING | UNIT_STAT_FLEEING_MOVE); owner.StopMoving(); if (owner.GetTypeId() == TYPEID_UNIT) @@ -125,14 +125,14 @@ void FleeingMovementGenerator::Initialize(T& owner) template<> void FleeingMovementGenerator::Finalize(Player& owner) { - owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); + owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_FLEEING_MOVE); owner.StopMoving(); } template<> void FleeingMovementGenerator::Finalize(Creature& owner) { - owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); + owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_FLEEING_MOVE); } template @@ -183,7 +183,7 @@ template bool FleeingMovementGenerator::Update(Creature&, const uint32 void TimedFleeingMovementGenerator::Finalize(Unit& owner) { - owner.clearUnitState(UNIT_STAT_FLEEING|UNIT_STAT_FLEEING_MOVE); + owner.clearUnitState(UNIT_STAT_FLEEING | UNIT_STAT_FLEEING_MOVE); if (Unit* victim = owner.getVictim()) { if (owner.isAlive()) diff --git a/src/game/Formulas.h b/src/game/Formulas.h index 36886883e..fbd182d75 100644 --- a/src/game/Formulas.h +++ b/src/game/Formulas.h @@ -25,9 +25,9 @@ namespace MaNGOS { namespace Honor { - inline float hk_honor_at_level(uint32 level, uint32 count=1) + inline float hk_honor_at_level(uint32 level, uint32 count = 1) { - return (float)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f))); + return (float)ceil(count * (-0.53177f + 0.59357f * exp((level + 23.54042f) / 26.07859f))); } } namespace XP @@ -39,9 +39,9 @@ namespace MaNGOS if (pl_level <= 5) return 0; else if (pl_level <= 39) - return pl_level - 5 - pl_level/10; + return pl_level - 5 - pl_level / 10; else if (pl_level <= 59) - return pl_level - 1 - pl_level/5; + return pl_level - 1 - pl_level / 5; else return pl_level - 9; } @@ -85,7 +85,7 @@ namespace MaNGOS case CONTENT_61_70: nBaseExp = 235; break; case CONTENT_71_80: nBaseExp = 580; break; default: - sLog.outError("BaseGain: Unsupported content level %u",content); + sLog.outError("BaseGain: Unsupported content level %u", content); nBaseExp = 45; break; } @@ -94,7 +94,7 @@ namespace MaNGOS uint32 nLevelDiff = mob_level - pl_level; if (nLevelDiff > 4) nLevelDiff = 4; - return ((pl_level*5 + nBaseExp) * (20 + nLevelDiff)/10 + 1)/2; + return ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2; } else { @@ -102,7 +102,7 @@ namespace MaNGOS if (mob_level > gray_level) { uint32 ZD = GetZeroDifference(pl_level); - return (pl_level*5 + nBaseExp) * (ZD + mob_level - pl_level)/ZD; + return (pl_level * 5 + nBaseExp) * (ZD + mob_level - pl_level) / ZD; } return 0; } @@ -110,19 +110,19 @@ namespace MaNGOS inline uint32 Gain(Player* pl, Unit* u) { - if (u->GetTypeId()==TYPEID_UNIT && ( + if (u->GetTypeId() == TYPEID_UNIT && ( ((Creature*)u)->IsTotem() || ((Creature*)u)->IsPet() || (((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL))) return 0; - uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(),pl->GetZoneId())); + uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(), pl->GetZoneId())); if (xp_gain == 0) return 0; - if (u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsElite()) + if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsElite()) xp_gain *= 2; - return (uint32)(xp_gain*sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL)); + return (uint32)(xp_gain * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL)); } inline float xp_in_group_rate(uint32 count, bool isRaid) diff --git a/src/game/GMTicketHandler.cpp b/src/game/GMTicketHandler.cpp index fe4c4269b..c86f444e2 100644 --- a/src/game/GMTicketHandler.cpp +++ b/src/game/GMTicketHandler.cpp @@ -28,7 +28,7 @@ void WorldSession::SendGMTicketGetTicket(uint32 status, GMTicket* ticket /*= NULL*/) { int len = ticket ? strlen(ticket->GetText()) : 0; - WorldPacket data(SMSG_GMTICKET_GETTICKET, (4+len+1+4+2+4+4)); + WorldPacket data(SMSG_GMTICKET_GETTICKET, (4 + len + 1 + 4 + 2 + 4 + 4)); data << uint32(status); // standard 0x0A, 0x06 if text present if (status == 6) { @@ -46,8 +46,8 @@ void WorldSession::SendGMTicketGetTicket(uint32 status, GMTicket* ticket /*= NUL void WorldSession::SendGMResponse(GMTicket* ticket) { - int len = strlen(ticket->GetText())+1+strlen(ticket->GetResponse())+1; - WorldPacket data(SMSG_GMTICKET_GET_RESPONSE, 4+4+len+1+1+1); + int len = strlen(ticket->GetText()) + 1 + strlen(ticket->GetResponse()) + 1; + WorldPacket data(SMSG_GMTICKET_GET_RESPONSE, 4 + 4 + len + 1 + 1 + 1); data << uint32(123); data << uint32(456); data << ticket->GetText(); // issue text @@ -137,7 +137,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recv_data) for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) { if (itr->second->GetSession()->GetSecurity() >= SEC_GAMEMASTER && itr->second->isAcceptTickets()) - ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW,GetPlayer()->GetName()); + ChatHandler(itr->second).PSendSysMessage(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName()); } } diff --git a/src/game/GMTicketMgr.h b/src/game/GMTicketMgr.h index 8a72d7803..a06d47c58 100644 --- a/src/game/GMTicketMgr.h +++ b/src/game/GMTicketMgr.h @@ -37,7 +37,7 @@ class GMTicket m_guid = guid; m_text = text; m_responseText = responsetext; - m_lastUpdate =update; + m_lastUpdate = update; } ObjectGuid const& GetPlayerGuid() const diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index f915ffdf2..92c12d31a 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -75,7 +75,7 @@ void GameEventMgr::StartEvent(uint16 event_id, bool overwrite /*=false*/, bool r { mGameEvent[event_id].start = time(NULL); if (mGameEvent[event_id].end <= mGameEvent[event_id].start) - mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length; + mGameEvent[event_id].end = mGameEvent[event_id].start + mGameEvent[event_id].length; } } @@ -86,7 +86,7 @@ void GameEventMgr::StopEvent(uint16 event_id, bool overwrite) { mGameEvent[event_id].start = time(NULL) - mGameEvent[event_id].length * MINUTE; if (mGameEvent[event_id].end <= mGameEvent[event_id].start) - mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length; + mGameEvent[event_id].end = mGameEvent[event_id].start + mGameEvent[event_id].length; } } @@ -106,7 +106,7 @@ void GameEventMgr::LoadFromDB() uint32 max_event_id = fields[0].GetUInt16(); delete result; - mGameEvent.resize(max_event_id+1); + mGameEvent.resize(max_event_id + 1); } QueryResult* result = WorldDatabase.Query("SELECT entry,UNIX_TIMESTAMP(start_time),UNIX_TIMESTAMP(end_time),occurence,length,holiday,description FROM game_event"); @@ -176,14 +176,14 @@ void GameEventMgr::LoadFromDB() sLog.outString(">> Loaded %u game events", count); } - std::map pool2event; // for check unique spawn event associated with pool - std::map creature2event; // for check unique spawn event associated with creature - std::map go2event; // for check unique spawn event associated with gameobject + std::map pool2event; // for check unique spawn event associated with pool + std::map creature2event; // for check unique spawn event associated with creature + std::map go2event; // for check unique spawn event associated with gameobject // list only positive event top pools, filled at creature/gameobject loading mGameEventSpawnPoolIds.resize(mGameEvent.size()); - mGameEventCreatureGuids.resize(mGameEvent.size()*2-1); + mGameEventCreatureGuids.resize(mGameEvent.size() * 2 - 1); // 1 2 result = WorldDatabase.Query("SELECT creature.guid, game_event_creature.event " "FROM creature JOIN game_event_creature ON creature.guid = game_event_creature.guid"); @@ -262,7 +262,7 @@ void GameEventMgr::LoadFromDB() sLog.outString(">> Loaded %u creatures in game events", count); } - mGameEventGameobjectGuids.resize(mGameEvent.size()*2-1); + mGameEventGameobjectGuids.resize(mGameEvent.size() * 2 - 1); // 1 2 result = WorldDatabase.Query("SELECT gameobject.guid, game_event_gameobject.event " "FROM gameobject JOIN game_event_gameobject ON gameobject.guid=game_event_gameobject.guid"); @@ -342,7 +342,7 @@ void GameEventMgr::LoadFromDB() } // now recheck that all eventPools linked with events after our skip pools with parents - for (std::map::const_iterator itr = pool2event.begin(); itr != pool2event.end(); ++itr) + for (std::map::const_iterator itr = pool2event.begin(); itr != pool2event.end(); ++itr) { uint16 pool_id = itr->first; int16 event_id = itr->second; @@ -382,7 +382,7 @@ void GameEventMgr::LoadFromDB() if (event_id == 0) { - sLog.outErrorDb("`game_event_creature_data` game event id (%i) is reserved and can't be used." ,event_id); + sLog.outErrorDb("`game_event_creature_data` game event id (%i) is reserved and can't be used." , event_id); continue; } @@ -497,7 +497,7 @@ void GameEventMgr::LoadFromDB() sLog.outString(">> Loaded %u quest additions in game events", count); } - mGameEventMails.resize(mGameEvent.size()*2-1); + mGameEventMails.resize(mGameEvent.size() * 2 - 1); result = WorldDatabase.Query("SELECT event, raceMask, quest, mailTemplateId, senderEntry FROM game_event_mail"); @@ -707,7 +707,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) if (internal_event_id < 0 || (size_t)internal_event_id >= mGameEventCreatureGuids.size()) { - sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventCreatureGuids.size()); + sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")", internal_event_id, mGameEventCreatureGuids.size()); return; } @@ -737,7 +737,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) if (internal_event_id < 0 || (size_t)internal_event_id >= mGameEventGameobjectGuids.size()) { - sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventGameobjectGuids.size()); + sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")", internal_event_id, mGameEventGameobjectGuids.size()); return; } @@ -784,7 +784,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) if (internal_event_id < 0 || (size_t)internal_event_id >= mGameEventCreatureGuids.size()) { - sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventCreatureGuids.size()); + sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")", internal_event_id, mGameEventCreatureGuids.size()); return; } @@ -814,7 +814,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id) if (internal_event_id < 0 || (size_t)internal_event_id >= mGameEventGameobjectGuids.size()) { - sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventGameobjectGuids.size()); + sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")", internal_event_id, mGameEventGameobjectGuids.size()); return; } diff --git a/src/game/GameEventMgr.h b/src/game/GameEventMgr.h index 2a068891c..4c617c686 100644 --- a/src/game/GameEventMgr.h +++ b/src/game/GameEventMgr.h @@ -32,7 +32,7 @@ class MapPersistentState; struct GameEventData { - GameEventData() : start(1),end(0),occurence(0),length(0), holiday_id(HOLIDAY_NONE) {} + GameEventData() : start(1), end(0), occurence(0), length(0), holiday_id(HOLIDAY_NONE) {} time_t start; time_t end; uint32 occurence; // Delay in minutes between occurences of the event @@ -81,7 +81,7 @@ class GameEventMgr void Initialize(MapPersistentState* state); // called at new MapPersistentState object create uint32 Update(ActiveEvents const* activeAtShutdown = NULL); bool IsValidEvent(uint16 event_id) const { return event_id < mGameEvent.size() && mGameEvent[event_id].isValid(); } - bool IsActiveEvent(uint16 event_id) const { return (m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); } + bool IsActiveEvent(uint16 event_id) const { return (m_ActiveEvents.find(event_id) != m_ActiveEvents.end()); } bool IsActiveHoliday(HolidayIds id); uint32 Initialize(); void StartEvent(uint16 event_id, bool overwrite = false, bool resume = false); @@ -107,7 +107,7 @@ class GameEventMgr typedef std::list GameEventCreatureDataList; typedef std::vector GameEventCreatureDataMap; typedef std::multimap GameEventCreatureDataPerGuidMap; - typedef std::pair GameEventCreatureDataPerGuidBounds; + typedef std::pair GameEventCreatureDataPerGuidBounds; typedef std::list QuestList; typedef std::vector GameEventQuestMap; diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 0cdec50ce..d0d26e1be 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -88,8 +88,8 @@ void GameObject::RemoveFromWorld() // Remove GO from owner if (ObjectGuid owner_guid = GetOwnerGuid()) { - if (Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid)) - owner->RemoveGameObject(this,false); + if (Unit* owner = ObjectAccessor::GetUnit(*this, owner_guid)) + 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.", @@ -106,20 +106,20 @@ void GameObject::RemoveFromWorld() bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, QuaternionData rotation, uint8 animprogress, GOState go_state) { MANGOS_ASSERT(map); - Relocate(x,y,z,ang); + Relocate(x, y, z, ang); SetMap(map); - SetPhaseMask(phaseMask,false); + SetPhaseMask(phaseMask, false); if (!IsPositionValid()) { - sLog.outError("Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates are invalid (X: %f Y: %f)",guidlow,name_id,x,y); + sLog.outError("Gameobject (GUID: %u Entry: %u ) not created. Suggested coordinates are invalid (X: %f Y: %f)", guidlow, name_id, x, y); return false; } GameObjectInfo const* goinfo = ObjectMgr::GetGameObjectInfo(name_id); if (!goinfo) { - sLog.outErrorDb("Gameobject (GUID: %u) not created: Entry %u does not exist in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f) ang: %f",guidlow, name_id, map->GetId(), x, y, z, ang); + sLog.outErrorDb("Gameobject (GUID: %u) not created: Entry %u does not exist in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f) ang: %f", guidlow, name_id, map->GetId(), x, y, z, ang); return false; } @@ -129,18 +129,18 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa if (goinfo->type >= MAX_GAMEOBJECT_TYPE) { - sLog.outErrorDb("Gameobject (GUID: %u) not created: Entry %u has invalid type %u in `gameobject_template`. It may crash client if created.",guidlow,name_id,goinfo->type); + sLog.outErrorDb("Gameobject (GUID: %u) not created: Entry %u has invalid type %u in `gameobject_template`. It may crash client if created.", guidlow, name_id, goinfo->type); return false; } SetObjectScale(goinfo->size); - SetWorldRotation(rotation.x,rotation.y,rotation.z,rotation.w); + SetWorldRotation(rotation.x, rotation.y, rotation.z, rotation.w); // For most of gameobjects is (0, 0, 0, 1) quaternion, only some transports has not standart rotation if (const GameObjectDataAddon* addon = sGameObjectDataAddonStorage.LookupEntry(guidlow)) SetTransportPathRotation(addon->path_rotation); else - SetTransportPathRotation(QuaternionData(0,0,0,1)); + SetTransportPathRotation(QuaternionData(0, 0, 0, 1)); SetUInt32Value(GAMEOBJECT_FACTION, goinfo->faction); SetUInt32Value(GAMEOBJECT_FLAGS, goinfo->flags); @@ -238,7 +238,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) { caster->FinishSpell(CURRENT_CHANNELED_SPELL); - WorldPacket data(SMSG_FISH_NOT_HOOKED,0); + WorldPacket data(SMSG_FISH_NOT_HOOKED, 0); ((Player*)caster)->GetSession()->SendPacket(&data); } // can be deleted @@ -304,9 +304,9 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) { MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius); MaNGOS::UnitSearcher checker(ok, u_check); - Cell::VisitGridObjects(this,checker, radius); + Cell::VisitGridObjects(this, checker, radius); if (!ok) - Cell::VisitWorldObjects(this,checker, radius); + Cell::VisitWorldObjects(this, checker, radius); } else // environmental trap { @@ -316,7 +316,7 @@ void GameObject::Update(uint32 update_diff, uint32 p_time) Player* p_ok = NULL; MaNGOS::AnyPlayerInObjectRangeCheck p_check(this, radius); MaNGOS::PlayerSearcher checker(p_ok, p_check); - Cell::VisitWorldObjects(this,checker, radius); + Cell::VisitWorldObjects(this, checker, radius); ok = p_ok; } @@ -519,7 +519,7 @@ void GameObject::getFishLoot(Loot* fishloot, Player* loot_owner) fishloot->clear(); uint32 zone, subzone; - GetZoneAndAreaId(zone,subzone); + GetZoneAndAreaId(zone, subzone); // if subzone loot exist use it if (!fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, (subzone != zone)) && subzone != zone) @@ -600,7 +600,7 @@ bool GameObject::LoadFromDB(uint32 guid, Map* map) if (!data) { - sLog.outErrorDb("Gameobject (GUID: %u) not found in table `gameobject`, can't load. ",guid); + sLog.outErrorDb("Gameobject (GUID: %u) not found in table `gameobject`, can't load. ", guid); return false; } @@ -615,7 +615,7 @@ bool GameObject::LoadFromDB(uint32 guid, Map* map) uint8 animprogress = data->animprogress; GOState go_state = data->go_state; - if (!Create(guid,entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state)) + if (!Create(guid, entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state)) return false; if (!GetGOInfo()->GetDespawnPossibility() && !GetGOInfo()->IsDespawnAtAction() && data->spawntimesecs >= 0) @@ -825,7 +825,7 @@ bool GameObject::ActivateToQuest(Player* pTarget) const //look for battlegroundAV for some objects which are only activated after mine gots captured by own team 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()))) + if (bg->GetTypeID() == BATTLEGROUND_AV && !(((BattleGroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(), pTarget->GetTeam()))) return false; return true; } @@ -925,7 +925,7 @@ GameObject* GameObject::LookupFishingHoleAround(float range) MaNGOS::NearestGameObjectFishingHoleCheck u_check(*this, range); MaNGOS::GameObjectSearcher checker(ok, u_check); - Cell::VisitGridObjects(this,checker, range); + Cell::VisitGridObjects(this, checker, range); return ok; } @@ -948,7 +948,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f if (!time_to_restore) time_to_restore = GetGOInfo()->GetAutoCloseTime(); - SwitchDoorOrButton(true,alternative); + SwitchDoorOrButton(true, alternative); SetLootState(GO_ACTIVATED); m_cooldownTime = time(NULL) + time_to_restore; @@ -1103,10 +1103,10 @@ void GameObject::Use(Unit* user) // every slot will be on that straight line float orthogonalOrientation = GetOrientation() + M_PI_F * 0.5f; // find nearest slot - for (uint32 i=0; ichair.slots; ++i) + for (uint32 i = 0; i < info->chair.slots; ++i) { // the distance between this slot and the center of the go - imagine a 1D space - float relativeDistance = (info->size*i)-(info->size*(info->chair.slots-1)/2.0f); + float relativeDistance = (info->size * i) - (info->size * (info->chair.slots - 1) / 2.0f); float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation); float y_i = GetPositionY() + relativeDistance * sin(orthogonalOrientation); @@ -1567,7 +1567,7 @@ void GameObject::Use(Unit* user) Player* player = (Player*)user; // fallback, will always work - player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); + player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET); WorldPacket data(SMSG_ENABLE_BARBER_SHOP, 0); player->GetSession()->SendPacket(&data); @@ -1646,7 +1646,7 @@ struct QuaternionCompressed MANGOS_ASSERT(w >= 0); w = sqrt(w); - return Quat(x,y,z,w); + return Quat(x, y, z, w); } int64 m_raw; @@ -1669,10 +1669,10 @@ void GameObject::SetWorldRotation(float qx, float qy, float qz, float qw) void GameObject::SetTransportPathRotation(QuaternionData rotation) { - SetFloatValue(GAMEOBJECT_PARENTROTATION+0, rotation.x); - SetFloatValue(GAMEOBJECT_PARENTROTATION+1, rotation.y); - SetFloatValue(GAMEOBJECT_PARENTROTATION+2, rotation.z); - SetFloatValue(GAMEOBJECT_PARENTROTATION+3, rotation.w); + SetFloatValue(GAMEOBJECT_PARENTROTATION + 0, rotation.x); + SetFloatValue(GAMEOBJECT_PARENTROTATION + 1, rotation.y); + SetFloatValue(GAMEOBJECT_PARENTROTATION + 2, rotation.z); + SetFloatValue(GAMEOBJECT_PARENTROTATION + 3, rotation.w); } void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot) @@ -1684,7 +1684,7 @@ void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot) bool GameObject::IsHostileTo(Unit const* unit) const { // always non-hostile to GM in GM mode - if (unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) + if (unit->GetTypeId() == TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) return false; // test owner instead if have @@ -1727,7 +1727,7 @@ bool GameObject::IsHostileTo(Unit const* unit) const bool GameObject::IsFriendlyTo(Unit const* unit) const { // always friendly to GM in GM mode - if (unit->GetTypeId()==TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) + if (unit->GetTypeId() == TYPEID_PLAYER && ((Player const*)unit)->isGameMaster()) return true; // test owner instead if have @@ -1753,7 +1753,7 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const if (tester_faction->faction) { // forced reaction - if (ReputationRank const* force =((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) + if (ReputationRank const* force = ((Player*)unit)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) return *force >= REP_FRIENDLY; // apply reputation state diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 7b7f52995..b1d0914cb 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -425,7 +425,7 @@ struct GameObjectInfo case GAMEOBJECT_TYPE_AREADAMAGE: return areadamage.lockId; case GAMEOBJECT_TYPE_CAMERA: return camera.lockId; case GAMEOBJECT_TYPE_FLAGSTAND: return flagstand.lockId; - case GAMEOBJECT_TYPE_FISHINGHOLE:return fishinghole.lockId; + case GAMEOBJECT_TYPE_FISHINGHOLE: return fishinghole.lockId; case GAMEOBJECT_TYPE_FLAGDROP: return flagdrop.lockId; default: return 0; } @@ -556,7 +556,7 @@ struct QuaternionData QuaternionData() : x(0.f), y(0.f), z(0.f), w(0.f) {} QuaternionData(float X, float Y, float Z, float W) : x(X), y(Y), z(Z), w(W) {} - bool isUnit() const { return fabs(x*x + y*y + z*z + w*w - 1.f) < 1e-5;} + bool isUnit() const { return fabs(x * x + y * y + z * z + w * w - 1.f) < 1e-5;} }; // from `gameobject` diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 7caa24fe0..a9d50b80a 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -204,7 +204,7 @@ void PlayerMenu::CloseGossip() // Outdated void PlayerMenu::SendPointOfInterest(float X, float Y, uint32 Icon, uint32 Flags, uint32 Data, char const* locName) { - WorldPacket data(SMSG_GOSSIP_POI, (4+4+4+4+4+10)); // guess size + WorldPacket data(SMSG_GOSSIP_POI, (4 + 4 + 4 + 4 + 4 + 10)); // guess size data << uint32(Flags); data << float(X); data << float(Y); @@ -221,7 +221,7 @@ void PlayerMenu::SendPointOfInterest(uint32 poi_id) PointOfInterest const* poi = sObjectMgr.GetPointOfInterest(poi_id); if (!poi) { - sLog.outErrorDb("Requested send nonexistent POI (Id: %u), ignore.",poi_id); + sLog.outErrorDb("Requested send nonexistent POI (Id: %u), ignore.", poi_id); return; } @@ -233,7 +233,7 @@ void PlayerMenu::SendPointOfInterest(uint32 poi_id) if (pl->IconName.size() > size_t(loc_idx) && !pl->IconName[loc_idx].empty()) icon_name = pl->IconName[loc_idx]; - WorldPacket data(SMSG_GOSSIP_POI, (4+4+4+4+4+10)); // guess size + WorldPacket data(SMSG_GOSSIP_POI, (4 + 4 + 4 + 4 + 4 + 10)); // guess size data << uint32(poi->flags); data << float(poi->x); data << float(poi->y); @@ -669,7 +669,7 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* pQuest) if (pQuest->ReqCreatureOrGOId[iI] < 0) { // client expected gameobject template id in form (id|0x80000000) - data << uint32((pQuest->ReqCreatureOrGOId[iI]*(-1))|0x80000000); + data << uint32((pQuest->ReqCreatureOrGOId[iI] * (-1)) | 0x80000000); } else { @@ -776,7 +776,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* pQuest, ObjectGuid npcGU data << uint32(pQuest->XPValue(GetMenuSession()->GetPlayer())); // TODO: fixme. rewarded honor points. Multiply with 10 to satisfy client - data << uint32(10*MaNGOS::Honor::hk_honor_at_level(GetMenuSession()->GetPlayer()->getLevel(), pQuest->GetRewHonorAddition())); + data << uint32(10 * MaNGOS::Honor::hk_honor_at_level(GetMenuSession()->GetPlayer()->getLevel(), pQuest->GetRewHonorAddition())); data << float(pQuest->GetRewHonorMultiplier()); data << uint32(0x08); // unused by client? diff --git a/src/game/GridDefines.h b/src/game/GridDefines.h index 2b11c48f1..807d316eb 100644 --- a/src/game/GridDefines.h +++ b/src/game/GridDefines.h @@ -68,7 +68,7 @@ typedef GridRefManager DynamicObjectMapType; typedef GridRefManager GameObjectMapType; typedef GridRefManager PlayerMapType; -typedef Grid GridType; +typedef Grid GridType; typedef NGrid NGridType; typedef TypeMapContainer GridTypeMapContainer; @@ -77,7 +77,7 @@ typedef TypeMapContainer WorldTypeMapContainer; template struct MANGOS_DLL_DECL CoordPair { - CoordPair(uint32 x=0, uint32 y=0) : x_coord(x), y_coord(y) {} + CoordPair(uint32 x = 0, uint32 y = 0) : x_coord(x), y_coord(y) {} CoordPair(const CoordPair& obj) : x_coord(obj.x_coord), y_coord(obj.y_coord) {} bool operator==(const CoordPair& obj) const { return (obj.x_coord == x_coord && obj.y_coord == y_coord); } bool operator!=(const CoordPair& obj) const { return !operator==(obj); } @@ -98,7 +98,7 @@ struct MANGOS_DLL_DECL CoordPair void operator>>(const uint32 val) { - if (x_coord+val < LIMIT) + if (x_coord + val < LIMIT) x_coord += val; else x_coord = LIMIT - 1; @@ -114,7 +114,7 @@ struct MANGOS_DLL_DECL CoordPair void operator+=(const uint32 val) { - if (y_coord+val < LIMIT) + if (y_coord + val < LIMIT) y_coord += val; else y_coord = LIMIT - 1; @@ -122,8 +122,8 @@ struct MANGOS_DLL_DECL CoordPair CoordPair& normalize() { - x_coord = std::min(x_coord, LIMIT-1); - y_coord = std::min(y_coord, LIMIT-1); + x_coord = std::min(x_coord, LIMIT - 1); + y_coord = std::min(y_coord, LIMIT - 1); return *this; } @@ -140,11 +140,11 @@ namespace MaNGOS inline RET_TYPE Compute(float x, float y, float center_offset, float size) { // calculate and store temporary values in double format for having same result as same mySQL calculations - double x_offset = (double(x) - center_offset)/size; - double y_offset = (double(y) - center_offset)/size; + double x_offset = (double(x) - center_offset) / size; + double y_offset = (double(y) - center_offset) / size; - int x_val = int(x_offset+CENTER_VAL + 0.5); - int y_val = int(y_offset+CENTER_VAL + 0.5); + int x_val = int(x_offset + CENTER_VAL + 0.5); + int y_val = int(y_offset + CENTER_VAL + 0.5); return RET_TYPE(x_val, y_val); } @@ -178,12 +178,12 @@ namespace MaNGOS inline bool IsValidMapCoord(float x, float y, float z) { - return IsValidMapCoord(x,y) && finite(z); + return IsValidMapCoord(x, y) && finite(z); } inline bool IsValidMapCoord(float x, float y, float z, float o) { - return IsValidMapCoord(x,y,z) && finite(o); + return IsValidMapCoord(x, y, z) && finite(o); } } #endif diff --git a/src/game/GridMap.cpp b/src/game/GridMap.cpp index 4eb444661..548bb46bf 100644 --- a/src/game/GridMap.cpp +++ b/src/game/GridMap.cpp @@ -77,7 +77,7 @@ bool GridMap::loadData(char* filename) if (!in) return true; - fread(&header, sizeof(header),1,in); + fread(&header, sizeof(header), 1, in); if (header.mapMagic == *((uint32 const*)(MAP_MAGIC)) && header.versionMagic == *((uint32 const*)(MAP_VERSION_MAGIC)) && IsAcceptableClientBuild(header.buildMagic)) @@ -151,8 +151,8 @@ bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/) m_gridArea = header.gridArea; if (!(header.flags & MAP_AREA_NO_AREA)) { - m_area_map = new uint16 [16*16]; - fread(m_area_map, sizeof(uint16), 16*16, in); + m_area_map = new uint16 [16 * 16]; + fread(m_area_map, sizeof(uint16), 16 * 16, in); } return true; @@ -171,28 +171,28 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/) { if ((header.flags & MAP_HEIGHT_AS_INT16)) { - m_uint16_V9 = new uint16 [129*129]; - m_uint16_V8 = new uint16 [128*128]; - fread(m_uint16_V9, sizeof(uint16), 129*129, in); - fread(m_uint16_V8, sizeof(uint16), 128*128, in); + m_uint16_V9 = new uint16 [129 * 129]; + m_uint16_V8 = new uint16 [128 * 128]; + fread(m_uint16_V9, sizeof(uint16), 129 * 129, in); + fread(m_uint16_V8, sizeof(uint16), 128 * 128, in); m_gridIntHeightMultiplier = (header.gridMaxHeight - header.gridHeight) / 65535; m_gridGetHeight = &GridMap::getHeightFromUint16; } else if ((header.flags & MAP_HEIGHT_AS_INT8)) { - m_uint8_V9 = new uint8 [129*129]; - m_uint8_V8 = new uint8 [128*128]; - fread(m_uint8_V9, sizeof(uint8), 129*129, in); - fread(m_uint8_V8, sizeof(uint8), 128*128, in); + m_uint8_V9 = new uint8 [129 * 129]; + m_uint8_V8 = new uint8 [128 * 128]; + fread(m_uint8_V9, sizeof(uint8), 129 * 129, in); + fread(m_uint8_V8, sizeof(uint8), 128 * 128, in); m_gridIntHeightMultiplier = (header.gridMaxHeight - header.gridHeight) / 255; m_gridGetHeight = &GridMap::getHeightFromUint8; } else { - m_V9 = new float [129*129]; - m_V8 = new float [128*128]; - fread(m_V9, sizeof(float), 129*129, in); - fread(m_V8, sizeof(float), 128*128, in); + m_V9 = new float [129 * 129]; + m_V8 = new float [128 * 128]; + fread(m_V9, sizeof(float), 129 * 129, in); + fread(m_V8, sizeof(float), 128 * 128, in); m_gridGetHeight = &GridMap::getHeightFromFloat; } } @@ -219,14 +219,14 @@ bool GridMap::loadGridMapLiquidData(FILE* in, uint32 offset, uint32 /*size*/) if (!(header.flags & MAP_LIQUID_NO_TYPE)) { - m_liquid_type = new uint8 [16*16]; - fread(m_liquid_type, sizeof(uint8), 16*16, in); + m_liquid_type = new uint8 [16 * 16]; + fread(m_liquid_type, sizeof(uint8), 16 * 16, in); } if (!(header.flags & MAP_LIQUID_NO_HEIGHT)) { - m_liquid_map = new float [m_liquid_width*m_liquid_height]; - fread(m_liquid_map, sizeof(float), m_liquid_width*m_liquid_height, in); + m_liquid_map = new float [m_liquid_width * m_liquid_height]; + fread(m_liquid_map, sizeof(float), m_liquid_width * m_liquid_height, in); } return true; @@ -237,11 +237,11 @@ uint16 GridMap::getArea(float x, float y) if (!m_area_map) return m_gridArea; - x = 16 * (32 - x/SIZE_OF_GRIDS); - y = 16 * (32 - y/SIZE_OF_GRIDS); + x = 16 * (32 - x / SIZE_OF_GRIDS); + y = 16 * (32 - y / SIZE_OF_GRIDS); int lx = (int)x & 15; int ly = (int)y & 15; - return m_area_map[lx*16 + ly]; + return m_area_map[lx * 16 + ly]; } float GridMap::getHeightFromFlat(float /*x*/, float /*y*/) const @@ -254,8 +254,8 @@ float GridMap::getHeightFromFloat(float x, float y) const if (!m_V8 || !m_V9) return m_gridHeight; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); int x_int = (int)x; int y_int = (int)y; @@ -279,26 +279,26 @@ float GridMap::getHeightFromFloat(float x, float y) const // 2 - solve linear equation from triangle points // Calculate coefficients for solve h = a*x + b*y + c - float a,b,c; + float a, b, c; // Select triangle: - if (x+y < 1) + if (x + y < 1) { if (x > y) { // 1 triangle (h1, h2, h5 points) - float h1 = m_V9[(x_int)*129 + y_int]; - float h2 = m_V9[(x_int+1)*129 + y_int]; - float h5 = 2 * m_V8[x_int*128 + y_int]; - a = h2-h1; - b = h5-h1-h2; + float h1 = m_V9[(x_int) * 129 + y_int]; + float h2 = m_V9[(x_int + 1) * 129 + y_int]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; + a = h2 - h1; + b = h5 - h1 - h2; c = h1; } else { // 2 triangle (h1, h3, h5 points) - float h1 = m_V9[x_int*129 + y_int ]; - float h3 = m_V9[x_int*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h1 = m_V9[x_int * 129 + y_int ]; + float h3 = m_V9[x_int * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h5 - h1 - h3; b = h3 - h1; c = h1; @@ -309,9 +309,9 @@ float GridMap::getHeightFromFloat(float x, float y) const if (x > y) { // 3 triangle (h2, h4, h5 points) - float h2 = m_V9[(x_int+1)*129 + y_int ]; - float h4 = m_V9[(x_int+1)*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h2 = m_V9[(x_int + 1) * 129 + y_int ]; + float h4 = m_V9[(x_int + 1) * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h2 + h4 - h5; b = h4 - h2; c = h5 - h4; @@ -319,9 +319,9 @@ float GridMap::getHeightFromFloat(float x, float y) const else { // 4 triangle (h3, h4, h5 points) - float h3 = m_V9[(x_int)*129 + y_int+1]; - float h4 = m_V9[(x_int+1)*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h3 = m_V9[(x_int) * 129 + y_int + 1]; + float h4 = m_V9[(x_int + 1) * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h4 - h3; b = h3 + h4 - h5; c = h5 - h4; @@ -336,8 +336,8 @@ float GridMap::getHeightFromUint8(float x, float y) const if (!m_uint8_V8 || !m_uint8_V9) return m_gridHeight; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); int x_int = (int)x; int y_int = (int)y; @@ -347,17 +347,17 @@ float GridMap::getHeightFromUint8(float x, float y) const y_int &= (MAP_RESOLUTION - 1); int32 a, b, c; - uint8* V9_h1_ptr = &m_uint8_V9[x_int*128 + x_int + y_int]; - if (x+y < 1) + uint8* V9_h1_ptr = &m_uint8_V9[x_int * 128 + x_int + y_int]; + if (x + y < 1) { if (x > y) { // 1 triangle (h1, h2, h5 points) int32 h1 = V9_h1_ptr[ 0]; int32 h2 = V9_h1_ptr[129]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; - a = h2-h1; - b = h5-h1-h2; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; + a = h2 - h1; + b = h5 - h1 - h2; c = h1; } else @@ -365,7 +365,7 @@ float GridMap::getHeightFromUint8(float x, float y) const // 2 triangle (h1, h3, h5 points) int32 h1 = V9_h1_ptr[0]; int32 h3 = V9_h1_ptr[1]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; a = h5 - h1 - h3; b = h3 - h1; c = h1; @@ -378,7 +378,7 @@ float GridMap::getHeightFromUint8(float x, float y) const // 3 triangle (h2, h4, h5 points) int32 h2 = V9_h1_ptr[129]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; a = h2 + h4 - h5; b = h4 - h2; c = h5 - h4; @@ -388,7 +388,7 @@ float GridMap::getHeightFromUint8(float x, float y) const // 4 triangle (h3, h4, h5 points) int32 h3 = V9_h1_ptr[ 1]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; a = h4 - h3; b = h3 + h4 - h5; c = h5 - h4; @@ -396,7 +396,7 @@ float GridMap::getHeightFromUint8(float x, float y) const } // Calculate height - return (float)((a * x) + (b * y) + c)*m_gridIntHeightMultiplier + m_gridHeight; + return (float)((a * x) + (b * y) + c) * m_gridIntHeightMultiplier + m_gridHeight; } float GridMap::getHeightFromUint16(float x, float y) const @@ -404,8 +404,8 @@ float GridMap::getHeightFromUint16(float x, float y) const if (!m_uint16_V8 || !m_uint16_V9) return m_gridHeight; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); int x_int = (int)x; int y_int = (int)y; @@ -415,17 +415,17 @@ float GridMap::getHeightFromUint16(float x, float y) const y_int &= (MAP_RESOLUTION - 1); int32 a, b, c; - uint16* V9_h1_ptr = &m_uint16_V9[x_int*128 + x_int + y_int]; - if (x+y < 1) + uint16* V9_h1_ptr = &m_uint16_V9[x_int * 128 + x_int + y_int]; + if (x + y < 1) { if (x > y) { // 1 triangle (h1, h2, h5 points) int32 h1 = V9_h1_ptr[ 0]; int32 h2 = V9_h1_ptr[129]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; - a = h2-h1; - b = h5-h1-h2; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; + a = h2 - h1; + b = h5 - h1 - h2; c = h1; } else @@ -433,7 +433,7 @@ float GridMap::getHeightFromUint16(float x, float y) const // 2 triangle (h1, h3, h5 points) int32 h1 = V9_h1_ptr[0]; int32 h3 = V9_h1_ptr[1]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; a = h5 - h1 - h3; b = h3 - h1; c = h1; @@ -446,7 +446,7 @@ float GridMap::getHeightFromUint16(float x, float y) const // 3 triangle (h2, h4, h5 points) int32 h2 = V9_h1_ptr[129]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; a = h2 + h4 - h5; b = h4 - h2; c = h5 - h4; @@ -456,7 +456,7 @@ float GridMap::getHeightFromUint16(float x, float y) const // 4 triangle (h3, h4, h5 points) int32 h3 = V9_h1_ptr[ 1]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; a = h4 - h3; b = h3 + h4 - h5; c = h5 - h4; @@ -464,7 +464,7 @@ float GridMap::getHeightFromUint16(float x, float y) const } // Calculate height - return (float)((a * x) + (b * y) + c)*m_gridIntHeightMultiplier + m_gridHeight; + return (float)((a * x) + (b * y) + c) * m_gridIntHeightMultiplier + m_gridHeight; } float GridMap::getLiquidLevel(float x, float y) @@ -472,19 +472,19 @@ float GridMap::getLiquidLevel(float x, float y) if (!m_liquid_map) return m_liquidLevel; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); - int cx_int = ((int)x & (MAP_RESOLUTION-1)) - m_liquid_offY; - int cy_int = ((int)y & (MAP_RESOLUTION-1)) - m_liquid_offX; + int cx_int = ((int)x & (MAP_RESOLUTION - 1)) - m_liquid_offY; + int cy_int = ((int)y & (MAP_RESOLUTION - 1)) - m_liquid_offX; - if (cx_int < 0 || cx_int >=m_liquid_height) + if (cx_int < 0 || cx_int >= m_liquid_height) return INVALID_HEIGHT_VALUE; - if (cy_int < 0 || cy_int >=m_liquid_width) + if (cy_int < 0 || cy_int >= m_liquid_width) return INVALID_HEIGHT_VALUE; - return m_liquid_map[cx_int*m_liquid_width + cy_int]; + return m_liquid_map[cx_int * m_liquid_width + cy_int]; } uint8 GridMap::getTerrainType(float x, float y) @@ -492,11 +492,11 @@ uint8 GridMap::getTerrainType(float x, float y) if (!m_liquid_type) return (uint8)m_liquidType; - x = 16 * (32 - x/SIZE_OF_GRIDS); - y = 16 * (32 - y/SIZE_OF_GRIDS); + x = 16 * (32 - x / SIZE_OF_GRIDS); + y = 16 * (32 - y / SIZE_OF_GRIDS); int lx = (int)x & 15; int ly = (int)y & 15; - return m_liquid_type[lx*16 + ly]; + return m_liquid_type[lx * 16 + ly]; } // Get water state on map @@ -507,33 +507,33 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re return LIQUID_MAP_NO_WATER; // Get cell - float cx = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - float cy = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + float cx = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + float cy = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); - int x_int = (int)cx & (MAP_RESOLUTION-1); - int y_int = (int)cy & (MAP_RESOLUTION-1); + int x_int = (int)cx & (MAP_RESOLUTION - 1); + int y_int = (int)cy & (MAP_RESOLUTION - 1); // Check water type in cell - uint8 type = m_liquid_type ? m_liquid_type[(x_int>>3)*16 + (y_int>>3)] : m_liquidType; + uint8 type = m_liquid_type ? m_liquid_type[(x_int >> 3) * 16 + (y_int >> 3)] : m_liquidType; if (type == 0) return LIQUID_MAP_NO_WATER; // Check req liquid type mask - if (ReqLiquidType && !(ReqLiquidType&type)) + if (ReqLiquidType && !(ReqLiquidType & type)) return LIQUID_MAP_NO_WATER; // Check water level: // Check water height map int lx_int = x_int - m_liquid_offY; - if (lx_int < 0 || lx_int >=m_liquid_height) + if (lx_int < 0 || lx_int >= m_liquid_height) return LIQUID_MAP_NO_WATER; int ly_int = y_int - m_liquid_offX; - if (ly_int < 0 || ly_int >=m_liquid_width) + if (ly_int < 0 || ly_int >= m_liquid_width) return LIQUID_MAP_NO_WATER; // Get water level - float liquid_level = m_liquid_map ? m_liquid_map[lx_int*m_liquid_width + ly_int] : m_liquidLevel; + float liquid_level = m_liquid_map ? m_liquid_map[lx_int * m_liquid_width + ly_int] : m_liquidLevel; // Get ground level (sub 0.2 for fix some errors) float ground_level = getHeight(x, y); @@ -566,17 +566,17 @@ GridMapLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 Re return LIQUID_MAP_ABOVE_WATER; } -bool GridMap::ExistMap(uint32 mapid,int gx,int gy) +bool GridMap::ExistMap(uint32 mapid, int gx, int gy) { - int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1; + int len = sWorld.GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1; char* tmp = new char[len]; - snprintf(tmp, len, (char*)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),mapid,gx,gy); + snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%03u%02u%02u.map").c_str(), mapid, gx, gy); - FILE* pf=fopen(tmp,"rb"); + FILE* pf = fopen(tmp, "rb"); if (!pf) { - sLog.outError("Check existing of map file '%s': not exist!",tmp); + sLog.outError("Check existing of map file '%s': not exist!", tmp); delete[] tmp; return false; } @@ -587,7 +587,7 @@ bool GridMap::ExistMap(uint32 mapid,int gx,int gy) header.versionMagic != *((uint32 const*)(MAP_VERSION_MAGIC)) || !IsAcceptableClientBuild(header.buildMagic)) { - sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.",tmp); + sLog.outError("Map file '%s' is non-compatible version (outdated?). Please, create new using ad.exe program.", tmp); delete [] tmp; fclose(pf); //close file before return return false; @@ -598,18 +598,18 @@ bool GridMap::ExistMap(uint32 mapid,int gx,int gy) return true; } -bool GridMap::ExistVMap(uint32 mapid,int gx,int gy) +bool GridMap::ExistVMap(uint32 mapid, int gx, int gy) { if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager()) { if (vmgr->isMapLoadingEnabled()) { // x and y are swapped !! => fixed now - bool exists = vmgr->existsMap((sWorld.GetDataPath()+ "vmaps").c_str(), mapid, gx,gy); + bool exists = vmgr->existsMap((sWorld.GetDataPath() + "vmaps").c_str(), mapid, gx, gy); if (!exists) { - std::string name = vmgr->getDirFileName(mapid,gx,gy); - sLog.outError("VMap file '%s' is missing or point to wrong version vmap file, redo vmaps with latest vmap_assembler.exe program", (sWorld.GetDataPath()+"vmaps/"+name).c_str()); + std::string name = vmgr->getDirFileName(mapid, gx, gy); + sLog.outError("VMap file '%s' is missing or point to wrong version vmap file, redo vmaps with latest vmap_assembler.exe program", (sWorld.GetDataPath() + "vmaps/" + name).c_str()); return false; } } @@ -747,7 +747,7 @@ float TerrainInfo::GetHeight(float x, float y, float z, bool pUseVmaps, float ma float z2 = z + 2.f; if (GridMap* gmap = const_cast(this)->GetGrid(x, y)) { - float _mapheight = gmap->getHeight(x,y); + float _mapheight = gmap->getHeight(x, y); // look from a bit higher pos to find the floor, ignore under surface case if (z2 > _mapheight) @@ -790,7 +790,7 @@ float TerrainInfo::GetHeight(float x, float y, float z, bool pUseVmaps, float ma // we are already under the surface or vmap height above map heigt // or if the distance of the vmap height is less the land height distance - if (z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z)) + if (z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight - z) > fabs(vmapHeight - z)) return vmapHeight; else return mapHeight; // better use .map surface height @@ -816,14 +816,14 @@ inline bool IsOutdoorWMO(uint32 mogpFlags, int32 adtId, int32 rootId, int32 grou return false; } - outdoor = mogpFlags&0x8; + outdoor = mogpFlags & 0x8; if (wmoEntry) { if (wmoEntry->Flags & 4) return true; - if ((wmoEntry->Flags & 2)!=0) + if ((wmoEntry->Flags & 2) != 0) outdoor = false; } return outdoor; @@ -839,7 +839,7 @@ bool TerrainInfo::IsOutdoors(float x, float y, float z) const return true; AreaTableEntry const* atEntry = 0; - WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); + WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); if (wmoEntry) { DEBUG_LOG("Got WMOAreaTableEntry! flag %u, areaid %u", wmoEntry->Flags, wmoEntry->areaId); @@ -859,7 +859,7 @@ bool TerrainInfo::GetAreaInfo(float x, float y, float z, uint32& flags, int32& a // check if there's terrain between player height and object height if (GridMap* gmap = const_cast(this)->GetGrid(x, y)) { - float _mapheight = gmap->getHeight(x,y); + float _mapheight = gmap->getHeight(x, y); // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice... if (z + 2.0f > _mapheight && _mapheight > vmap_z) return false; @@ -917,17 +917,17 @@ uint8 TerrainInfo::GetTerrainType(float x, float y) const uint32 TerrainInfo::GetAreaId(float x, float y, float z) const { - return TerrainManager::GetAreaIdByAreaFlag(GetAreaFlag(x,y,z),m_mapId); + return TerrainManager::GetAreaIdByAreaFlag(GetAreaFlag(x, y, z), m_mapId); } uint32 TerrainInfo::GetZoneId(float x, float y, float z) const { - return TerrainManager::GetZoneIdByAreaFlag(GetAreaFlag(x,y,z),m_mapId); + return TerrainManager::GetZoneIdByAreaFlag(GetAreaFlag(x, y, z), m_mapId); } void TerrainInfo::GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, float y, float z) const { - TerrainManager::GetZoneAndAreaIdByAreaFlag(zoneid,areaid,GetAreaFlag(x,y,z),m_mapId); + TerrainManager::GetZoneAndAreaIdByAreaFlag(zoneid, areaid, GetAreaFlag(x, y, z), m_mapId); } @@ -999,7 +999,7 @@ bool TerrainInfo::IsUnderWater(float x, float y, float z) const { if (const_cast(this)->GetGrid(x, y)) { - if (getLiquidStatus(x, y, z, MAP_LIQUID_TYPE_WATER|MAP_LIQUID_TYPE_OCEAN)&LIQUID_MAP_UNDER_WATER) + if (getLiquidStatus(x, y, z, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN)&LIQUID_MAP_UNDER_WATER) return true; } return false; @@ -1038,8 +1038,8 @@ float TerrainInfo::GetWaterOrGroundLevel(float x, float y, float z, float* pGrou GridMap* TerrainInfo::GetGrid(const float x, const float y) { // half opt method - int gx=(int)(32-x/SIZE_OF_GRIDS); //grid x - int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y + int gx = (int)(32 - x / SIZE_OF_GRIDS); //grid x + int gy = (int)(32 - y / SIZE_OF_GRIDS); //grid y //quick check if GridMap already loaded GridMap* pMap = m_GridMaps[gx][gy]; @@ -1061,11 +1061,11 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y) GridMap* map = new GridMap(); // map file name - char* tmp=NULL; - int len = sWorld.GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1; + char* tmp = NULL; + int len = sWorld.GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1; tmp = new char[len]; - snprintf(tmp, len, (char*)(sWorld.GetDataPath()+"maps/%03u%02u%02u.map").c_str(),m_mapId, x, y); - sLog.outDetail("Loading map %s",tmp); + snprintf(tmp, len, (char*)(sWorld.GetDataPath() + "maps/%03u%02u%02u.map").c_str(), m_mapId, x, y); + sLog.outDetail("Loading map %s", tmp); if (!map->loadData(tmp)) { @@ -1080,17 +1080,17 @@ GridMap* TerrainInfo::LoadMapAndVMap(const uint32 x, const uint32 y) const MapEntry* i_mapEntry = sMapStore.LookupEntry(m_mapId); const char* mapName = i_mapEntry ? i_mapEntry->name[sWorld.GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; - int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath()+ "vmaps").c_str(), m_mapId, x, y); + int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld.GetDataPath() + "vmaps").c_str(), m_mapId, x, y); switch (vmapLoadResult) { case VMAP::VMAP_LOAD_RESULT_OK: - sLog.outDetail("VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y); + sLog.outDetail("VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x, y, x, y); break; case VMAP::VMAP_LOAD_RESULT_ERROR: - sLog.outDetail("Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y); + sLog.outDetail("Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x, y, x, y); break; case VMAP::VMAP_LOAD_RESULT_IGNORED: - DEBUG_LOG("Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x,y,x,y); + DEBUG_LOG("Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", mapName, m_mapId, x, y, x, y); break; } @@ -1191,9 +1191,9 @@ void TerrainManager::UnloadAll() i_TerrainMap.clear(); } -uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id) +uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag, uint32 map_id) { - AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id); + AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id); if (entry) return entry->ID; @@ -1201,9 +1201,9 @@ uint32 TerrainManager::GetAreaIdByAreaFlag(uint16 areaflag,uint32 map_id) return 0; } -uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id) +uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag, uint32 map_id) { - AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id); + AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id); if (entry) return (entry->zone != 0) ? entry->zone : entry->ID; @@ -1211,9 +1211,9 @@ uint32 TerrainManager::GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id) return 0; } -void TerrainManager::GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag,uint32 map_id) +void TerrainManager::GetZoneAndAreaIdByAreaFlag(uint32& zoneid, uint32& areaid, uint16 areaflag, uint32 map_id) { - AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id); + AreaTableEntry const* entry = GetAreaEntryByAreaFlagAndMap(areaflag, map_id); areaid = entry ? entry->ID : 0; zoneid = entry ? ((entry->zone != 0) ? entry->zone : entry->ID) : 0; diff --git a/src/game/GridMap.h b/src/game/GridMap.h index 56f0d4e8b..8fb51d856 100644 --- a/src/game/GridMap.h +++ b/src/game/GridMap.h @@ -218,7 +218,7 @@ class MANGOS_DLL_SPEC TerrainInfo : public Referencable //TODO: move all terrain/vmaps data info query functions //from 'Map' class into this class - float GetHeight(float x, float y, float z, bool pCheckVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const; + float GetHeight(float x, float y, float z, bool pCheckVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const; float GetWaterLevel(float x, float y, float z, float* pGround = NULL) const; float GetWaterOrGroundLevel(float x, float y, float z, float* pGround = NULL, bool swim = false) const; bool IsInWater(float x, float y, float z, GridMapLiquidData* data = 0) const; @@ -226,7 +226,7 @@ class MANGOS_DLL_SPEC TerrainInfo : public Referencable GridMapLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, GridMapLiquidData* data = 0) const; - uint16 GetAreaFlag(float x, float y, float z, bool* isOutdoors=0) const; + uint16 GetAreaFlag(float x, float y, float z, bool* isOutdoors = 0) const; uint8 GetTerrainType(float x, float y) const; uint32 GetAreaId(float x, float y, float z) const; @@ -293,20 +293,20 @@ class MANGOS_DLL_DECL TerrainManager : public MaNGOS::SingletongetSource()->UpdateVisibilityOf(&i_object); } @@ -44,7 +44,7 @@ void VisibleNotifier::Notify() // but exist one case when this possible and object not out of range: transports if (Transport* transport = player.GetTransport()) { - for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr!=transport->GetPassengers().end(); ++itr) + for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr) { if (i_clientGUIDs.find((*itr)->GetObjectGuid()) != i_clientGUIDs.end()) { @@ -58,7 +58,7 @@ void VisibleNotifier::Notify() // generate outOfRange for not iterate objects i_data.AddOutOfRangeGUID(i_clientGUIDs); - for (GuidSet::iterator itr = i_clientGUIDs.begin(); itr!=i_clientGUIDs.end(); ++itr) + for (GuidSet::iterator itr = i_clientGUIDs.begin(); itr != i_clientGUIDs.end(); ++itr) { player.m_clientGUIDs.erase(*itr); @@ -141,13 +141,13 @@ void ObjectMessageDeliverer::Visit(CameraMapType& m) void MessageDistDeliverer::Visit(CameraMapType& m) { - for (CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Player* owner = iter->getSource()->GetOwner(); if ((i_toSelf || owner != &i_player) && (!i_ownTeamOnly || owner->GetTeam() == i_player.GetTeam()) && - (!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_player,i_dist))) + (!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_player, i_dist))) { if (!i_player.InSamePhase(iter->getSource()->GetBody())) continue; @@ -160,9 +160,9 @@ void MessageDistDeliverer::Visit(CameraMapType& m) void ObjectMessageDistDeliverer::Visit(CameraMapType& m) { - for (CameraMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { - if (!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_object,i_dist)) + if (!i_dist || iter->getSource()->GetBody()->IsWithinDist(&i_object, i_dist)) { if (!i_object.InSamePhase(iter->getSource()->GetBody())) continue; @@ -186,7 +186,7 @@ void ObjectUpdater::Visit(GridRefManager& m) bool CannibalizeObjectCheck::operator()(Corpse* u) { // ignore bones - if (u->GetType()==CORPSE_BONES) + if (u->GetType() == CORPSE_BONES) return false; Player* owner = ObjectAccessor::FindPlayer(u->GetOwnerGuid()); diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 2435021fd..03dc1487e 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -204,7 +204,7 @@ namespace MaNGOS Check& i_check; WorldObjectSearcher(WorldObject*& result, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} void Visit(GameObjectMapType& m); void Visit(PlayerMapType& m); @@ -223,7 +223,7 @@ namespace MaNGOS Check& i_check; WorldObjectListSearcher(std::list& objects, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {} void Visit(PlayerMapType& m); void Visit(CreatureMapType& m); @@ -245,34 +245,34 @@ namespace MaNGOS void Visit(GameObjectMapType& m) { - for (GameObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (GameObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->getSource()->InSamePhase(i_phaseMask)) i_do(itr->getSource()); } void Visit(PlayerMapType& m) { - for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->getSource()->InSamePhase(i_phaseMask)) i_do(itr->getSource()); } void Visit(CreatureMapType& m) { - for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->getSource()->InSamePhase(i_phaseMask)) i_do(itr->getSource()); } void Visit(CorpseMapType& m) { - for (CorpseMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (CorpseMapType::iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->getSource()->InSamePhase(i_phaseMask)) i_do(itr->getSource()); } void Visit(DynamicObjectMapType& m) { - for (DynamicObjectMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (DynamicObjectMapType::iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->getSource()->InSamePhase(i_phaseMask)) i_do(itr->getSource()); } @@ -290,7 +290,7 @@ namespace MaNGOS Check& i_check; GameObjectSearcher(GameObject*& result, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} void Visit(GameObjectMapType& m); @@ -339,7 +339,7 @@ namespace MaNGOS Check& i_check; UnitSearcher(Unit*& result, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} void Visit(CreatureMapType& m); void Visit(PlayerMapType& m); @@ -356,7 +356,7 @@ namespace MaNGOS Check& i_check; UnitLastSearcher(Unit*& result, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} void Visit(CreatureMapType& m); void Visit(PlayerMapType& m); @@ -373,7 +373,7 @@ namespace MaNGOS Check& i_check; UnitListSearcher(std::list& objects, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {} void Visit(PlayerMapType& m); void Visit(CreatureMapType& m); @@ -391,7 +391,7 @@ namespace MaNGOS Check& i_check; CreatureSearcher(Creature*& result, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} void Visit(CreatureMapType& m); @@ -407,7 +407,7 @@ namespace MaNGOS Check& i_check; CreatureLastSearcher(Creature*& result, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} void Visit(CreatureMapType& m); @@ -422,7 +422,7 @@ namespace MaNGOS Check& i_check; CreatureListSearcher(std::list& objects, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {} void Visit(CreatureMapType& m); @@ -440,7 +440,7 @@ namespace MaNGOS void Visit(CreatureMapType& m) { - for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->getSource()->InSamePhase(i_phaseMask)) i_do(itr->getSource()); } @@ -458,7 +458,7 @@ namespace MaNGOS Check& i_check; PlayerSearcher(Player*& result, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_object(result), i_check(check) {} void Visit(PlayerMapType& m); @@ -473,7 +473,7 @@ namespace MaNGOS Check& i_check; PlayerListSearcher(std::list& objects, Check& check) - : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects),i_check(check) {} + : i_phaseMask(check.GetFocusObject().GetPhaseMask()), i_objects(objects), i_check(check) {} void Visit(PlayerMapType& m); @@ -491,7 +491,7 @@ namespace MaNGOS void Visit(PlayerMapType& m) { - for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->getSource()->InSamePhase(i_phaseMask)) i_do(itr->getSource()); } @@ -511,8 +511,8 @@ namespace MaNGOS void Visit(CameraMapType& m) { - for (CameraMapType::iterator itr=m.begin(); itr != m.end(); ++itr) - if (itr->getSource()->GetBody()->InSamePhase(i_searcher) && itr->getSource()->GetBody()->IsWithinDist(i_searcher,i_dist)) + for (CameraMapType::iterator itr = m.begin(); itr != m.end(); ++itr) + if (itr->getSource()->GetBody()->InSamePhase(i_searcher) && itr->getSource()->GetBody()->IsWithinDist(i_searcher, i_dist)) i_do(itr->getSource()->GetOwner()); } template void Visit(GridRefManager&) {} @@ -547,7 +547,7 @@ namespace MaNGOS { if (i_fobj->isHonorOrXPTarget(u) || u->getDeathState() != CORPSE || u->IsDeadByDefault() || u->IsTaxiFlying() || - (u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID-1)))==0 || + (u->GetCreatureTypeMask() & (1 << (CREATURE_TYPE_HUMANOID - 1))) == 0 || (u->GetDisplayId() != u->GetNativeDisplayId())) return false; @@ -566,7 +566,7 @@ namespace MaNGOS WorldObject const& GetFocusObject() const { return *i_fobj; } bool operator()(Player* u) { - if (u->getDeathState()!=CORPSE || u->IsTaxiFlying() || + if (u->getDeathState() != CORPSE || u->IsTaxiFlying() || u->HasAuraType(SPELL_AURA_GHOST) || (u->GetDisplayId() != u->GetNativeDisplayId())) return false; @@ -574,9 +574,9 @@ namespace MaNGOS } bool operator()(Creature* u) { - if (u->getDeathState()!=CORPSE || u->IsTaxiFlying() || u->IsDeadByDefault() || + if (u->getDeathState() != CORPSE || u->IsTaxiFlying() || u->IsDeadByDefault() || (u->GetDisplayId() != u->GetNativeDisplayId()) || - (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL)!=0) + (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL) != 0) return false; return i_fobj->IsWithinDistInMap(u, i_range); @@ -603,7 +603,7 @@ namespace MaNGOS bool operator()(Creature* u) { if (i_fobj->IsFriendlyTo(u) || u->isAlive() || u->IsTaxiFlying() || - (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD)==0) + (u->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) == 0) return false; return i_fobj->IsWithinDistInMap(u, i_range); @@ -631,7 +631,7 @@ namespace MaNGOS class GameObjectFocusCheck { public: - GameObjectFocusCheck(Unit const* unit,uint32 focusId) : i_unit(unit), i_focusId(focusId) {} + GameObjectFocusCheck(Unit const* unit, uint32 focusId) : i_unit(unit), i_focusId(focusId) {} WorldObject const& GetFocusObject() const { return *i_unit; } bool operator()(GameObject* go) const { @@ -678,7 +678,7 @@ namespace MaNGOS class NearestGameObjectEntryInObjectRangeCheck { public: - NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj,uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) {} + NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) {} WorldObject const& GetFocusObject() const { return i_obj; } bool operator()(GameObject* go) { @@ -713,7 +713,7 @@ namespace MaNGOS if (go->GetEntry() == i_entry && go->IsWithinDist3d(i_x, i_y, i_z, i_range)) { // use found GO range as new range limit for next check - i_range = go->GetDistance(i_x,i_y,i_z); + i_range = go->GetDistance(i_x, i_y, i_z); return true; } @@ -851,7 +851,7 @@ namespace MaNGOS return u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u) - && u->isVisibleForOrDetect(i_funit,i_funit,false); + && u->isVisibleForOrDetect(i_funit, i_funit, false); } private: WorldObject const* i_obj; @@ -902,7 +902,7 @@ namespace MaNGOS bool operator()(Unit* u) { if (u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) && - !i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit,i_funit,false)) + !i_funit->IsFriendlyTo(u) && u->isVisibleForOrDetect(i_funit, i_funit, false)) { i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check return true; @@ -936,7 +936,7 @@ namespace MaNGOS return false; // ignore totems as AoE targets - if (u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsTotem()) + if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsTotem()) return false; // check visibility only for unit-like original casters @@ -971,10 +971,10 @@ namespace MaNGOS if (!u->isTargetableForAttack()) return false; - if (u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->IsTotem()) + if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsTotem()) return false; - if ((i_targetForPlayer ? !i_obj->IsFriendlyTo(u) : i_obj->IsHostileTo(u))&& i_obj->IsWithinDistInMap(u, i_range)) + if ((i_targetForPlayer ? !i_obj->IsFriendlyTo(u) : i_obj->IsHostileTo(u)) && i_obj->IsWithinDistInMap(u, i_range)) return true; return false; @@ -1016,7 +1016,7 @@ namespace MaNGOS public: explicit AnyStealthedCheck(WorldObject const* fobj) : i_fobj(fobj) {} WorldObject const& GetFocusObject() const { return *i_fobj; } - bool operator()(Unit* u) { return u->GetVisibility()==VISIBILITY_GROUP_STEALTH; } + bool operator()(Unit* u) { return u->GetVisibility() == VISIBILITY_GROUP_STEALTH; } private: WorldObject const* i_fobj; }; @@ -1065,7 +1065,7 @@ namespace MaNGOS { if (u == i_obj) return false; - if (!u->CanAssistTo(i_obj,i_enemy)) + if (!u->CanAssistTo(i_obj, i_enemy)) return false; if (!i_obj->IsWithinDistInMap(u, i_range)) @@ -1091,7 +1091,7 @@ namespace MaNGOS class NearestCreatureEntryWithLiveStateInObjectRangeCheck { public: - NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj,uint32 entry, bool onlyAlive, bool onlyDead, float range) + NearestCreatureEntryWithLiveStateInObjectRangeCheck(WorldObject const& obj, uint32 entry, bool onlyAlive, bool onlyDead, float range) : i_obj(obj), i_entry(entry), i_onlyAlive(onlyAlive), i_onlyDead(onlyDead), i_range(range) {} WorldObject const& GetFocusObject() const { return i_obj; } bool operator()(Creature* u) @@ -1122,7 +1122,7 @@ namespace MaNGOS WorldObject const& GetFocusObject() const { return *m_pObject; } bool operator()(Unit* pUnit) { - if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit,m_fRange,false)) + if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit, m_fRange, false)) return true; return false; diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h index bf1fa385a..7cdfa05b5 100644 --- a/src/game/GridNotifiersImpl.h +++ b/src/game/GridNotifiersImpl.h @@ -92,7 +92,7 @@ inline void MaNGOS::CreatureRelocationNotifier::Visit(PlayerMapType& m) if (!i_creature.isAlive()) return; - for (PlayerMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { Player* player = iter->getSource(); if (player->isAlive() && !player->IsTaxiFlying()) @@ -130,7 +130,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) return; // Evade target - if (target->GetTypeId()==TYPEID_UNIT && ((Creature*)target)->IsInEvadeMode()) + if (target->GetTypeId() == TYPEID_UNIT && ((Creature*)target)->IsInEvadeMode()) return; //Check player targets and remove if in GM mode or GM invisibility (for not self casting case) @@ -171,7 +171,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) holder->AddAura(Aur, eff_index); target->AddAuraToModList(Aur); holder->SetInUse(true); - Aur->ApplyModifier(true,true); + Aur->ApplyModifier(true, true); holder->SetInUse(false); } else if (holder->GetAuraDuration() >= 0 && uint32(holder->GetAuraDuration()) < i_dynobject.GetDuration()) @@ -194,7 +194,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) template<> inline void MaNGOS::DynamicObjectUpdater::Visit(CreatureMapType& m) { - for (CreatureMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (CreatureMapType::iterator itr = m.begin(); itr != m.end(); ++itr) VisitHelper(itr->getSource()); } @@ -561,14 +561,14 @@ template void MaNGOS::LocalizedPacketDo::operator()(Player* p) { int32 loc_idx = p->GetSession()->GetSessionDbLocaleIndex(); - uint32 cache_idx = loc_idx+1; + uint32 cache_idx = loc_idx + 1; WorldPacket* data; // create if not cached yet - if (i_data_cache.size() < cache_idx+1 || !i_data_cache[cache_idx]) + if (i_data_cache.size() < cache_idx + 1 || !i_data_cache[cache_idx]) { - if (i_data_cache.size() < cache_idx+1) - i_data_cache.resize(cache_idx+1); + if (i_data_cache.size() < cache_idx + 1) + i_data_cache.resize(cache_idx + 1); data = new WorldPacket(SMSG_MESSAGECHAT, 200); @@ -586,14 +586,14 @@ template void MaNGOS::LocalizedPacketListDo::operator()(Player* p) { int32 loc_idx = p->GetSession()->GetSessionDbLocaleIndex(); - uint32 cache_idx = loc_idx+1; + uint32 cache_idx = loc_idx + 1; WorldPacketList* data_list; // create if not cached yet - if (i_data_cache.size() < cache_idx+1 || i_data_cache[cache_idx].empty()) + if (i_data_cache.size() < cache_idx + 1 || i_data_cache[cache_idx].empty()) { - if (i_data_cache.size() < cache_idx+1) - i_data_cache.resize(cache_idx+1); + if (i_data_cache.size() < cache_idx + 1) + i_data_cache.resize(cache_idx + 1); data_list = &i_data_cache[cache_idx]; diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 1c262ad78..f09d36f93 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -201,7 +201,7 @@ bool Group::LoadGroupFromDB(Field* fields) m_lootThreshold = ItemQualities(fields[4].GetUInt16()); for (int i = 0; i < TARGET_ICON_COUNT; ++i) - m_targetIcons[i] = ObjectGuid(fields[5+i].GetUInt64()); + m_targetIcons[i] = ObjectGuid(fields[5 + i].GetUInt64()); return true; } @@ -279,7 +279,7 @@ uint32 Group::RemoveInvite(Player* player) void Group::RemoveAllInvites() { - for (InvitesList::iterator itr = m_invitees.begin(); itr!=m_invitees.end(); ++itr) + for (InvitesList::iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) (*itr)->SetGroupInvite(NULL); m_invitees.clear(); @@ -317,8 +317,8 @@ bool Group::AddMember(ObjectGuid guid, const char* name) { // reset the new member's instances, unless he is currently in one of them // including raid/heroic instances that they are not permanently bound to! - player->ResetInstances(INSTANCE_RESET_GROUP_JOIN,false); - player->ResetInstances(INSTANCE_RESET_GROUP_JOIN,true); + player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, false); + player->ResetInstances(INSTANCE_RESET_GROUP_JOIN, true); if (player->getLevel() >= LEVELREQUIREMENT_HEROIC) { @@ -373,7 +373,7 @@ uint32 Group::RemoveMember(ObjectGuid guid, uint8 method) } else { - data.Initialize(SMSG_GROUP_LIST, 1+1+1+1+8+4+4+8); + data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8); data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0); data << uint64(0) << uint32(0) << uint32(0) << uint64(0); player->GetSession()->SendPacket(&data); @@ -384,7 +384,7 @@ uint32 Group::RemoveMember(ObjectGuid guid, uint8 method) if (leaderChanged) { - WorldPacket data(SMSG_GROUP_SET_LEADER, (m_memberSlots.front().name.size()+1)); + WorldPacket data(SMSG_GROUP_SET_LEADER, (m_memberSlots.front().name.size() + 1)); data << m_memberSlots.front().name; BroadcastPacket(&data, true); } @@ -406,7 +406,7 @@ void Group::ChangeLeader(ObjectGuid guid) _setLeader(guid); - WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size()+1); + WorldPacket data(SMSG_GROUP_SET_LEADER, slot->name.size() + 1); data << slot->name; BroadcastPacket(&data, true); SendUpdate(); @@ -456,7 +456,7 @@ void Group::Disband(bool hideDestroy) } else { - data.Initialize(SMSG_GROUP_LIST, 1+1+1+1+8+4+4+8); + data.Initialize(SMSG_GROUP_LIST, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 8); data << uint8(0x10) << uint8(0) << uint8(0) << uint8(0); data << uint64(0) << uint32(0) << uint32(0) << uint64(0); player->GetSession()->SendPacket(&data); @@ -489,7 +489,7 @@ void Group::Disband(bool hideDestroy) void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll& r) { - WorldPacket data(SMSG_LOOT_START_ROLL, (8+4+4+4+4+4+4+1)); + WorldPacket data(SMSG_LOOT_START_ROLL, (8 + 4 + 4 + 4 + 4 + 4 + 4 + 1)); data << r.lootedTargetGUID; // creature guid what we're looting data << uint32(mapid); // 3.3.3 mapid data << uint32(r.itemSlot); // item slot in loot @@ -513,7 +513,7 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll& r) // dependent from player RollVoteMask mask = r.GetVoteMaskFor(p); - data.put(voteMaskPos,uint8(mask)); + data.put(voteMaskPos, uint8(mask)); p->GetSession()->SendPacket(&data); } @@ -521,7 +521,7 @@ void Group::SendLootStartRoll(uint32 CountDown, uint32 mapid, const Roll& r) void Group::SendLootRoll(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 rollType, const Roll& r) { - WorldPacket data(SMSG_LOOT_ROLL, (8+4+8+4+4+4+1+1+1)); + WorldPacket data(SMSG_LOOT_ROLL, (8 + 4 + 8 + 4 + 4 + 4 + 1 + 1 + 1)); data << r.lootedTargetGUID; // creature guid what we're looting data << uint32(r.itemSlot); // unknown, maybe amount of players, or item slot in loot data << targetGuid; @@ -545,7 +545,7 @@ void Group::SendLootRoll(ObjectGuid const& targetGuid, uint8 rollNumber, uint8 r void Group::SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, RollVote rollType, const Roll& r) { - WorldPacket data(SMSG_LOOT_ROLL_WON, (8+4+4+4+4+8+1+1)); + WorldPacket data(SMSG_LOOT_ROLL_WON, (8 + 4 + 4 + 4 + 4 + 8 + 1 + 1)); data << r.lootedTargetGUID; // creature guid what we're looting data << uint32(r.itemSlot); // item slot in loot data << uint32(r.itemid); // the itemEntryId for the item that shall be rolled for @@ -568,14 +568,14 @@ void Group::SendLootRollWon(ObjectGuid const& targetGuid, uint8 rollNumber, Roll void Group::SendLootAllPassed(Roll const& r) { - WorldPacket data(SMSG_LOOT_ALL_PASSED, (8+4+4+4+4)); + WorldPacket data(SMSG_LOOT_ALL_PASSED, (8 + 4 + 4 + 4 + 4)); data << r.lootedTargetGUID; // creature guid what we're looting data << uint32(r.itemSlot); // item slot in loot data << uint32(r.itemid); // The itemEntryId for the item that shall be rolled for data << uint32(r.itemRandomPropId); // Item random property ID data << uint32(r.itemRandomSuffix); // Item random suffix ID - for (Roll::PlayerVote::const_iterator itr=r.playerVote.begin(); itr!=r.playerVote.end(); ++itr) + for (Roll::PlayerVote::const_iterator itr = r.playerVote.begin(); itr != r.playerVote.end(); ++itr) { Player* p = sObjectMgr.GetPlayer(itr->first); if (!p || !p->GetSession()) @@ -632,7 +632,7 @@ void Group::NeedBeforeGreed(WorldObject* pSource, Loot* loot) void Group::MasterLoot(WorldObject* pSource, Loot* loot) { - for (LootItemList::iterator i=loot->items.begin(); i != loot->items.end(); ++i) + for (LootItemList::iterator i = loot->items.begin(); i != loot->items.end(); ++i) { ItemPrototype const* item = ObjectMgr::GetItemPrototype(i->itemid); if (!item) @@ -955,7 +955,7 @@ void Group::SetTargetIcon(uint8 id, ObjectGuid whoGuid, ObjectGuid targetGuid) m_targetIcons[id] = targetGuid; - WorldPacket data(MSG_RAID_TARGET_UPDATE, (1+8+1+8)); + WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + 8 + 1 + 8)); data << uint8(0); // set targets data << whoGuid; data << uint8(id); @@ -975,7 +975,7 @@ static void GetDataForXPAtKill_helper(Player* player, Unit const* victim, uint32 not_gray_member_with_max_level = player; } -void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player*& member_with_max_level, Player*& not_gray_member_with_max_level, Player* additional) +void Group::GetDataForXPAtKill(Unit const* victim, uint32& count, uint32& sum_level, Player*& member_with_max_level, Player*& not_gray_member_with_max_level, Player* additional) { for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { @@ -991,7 +991,7 @@ void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_lev continue; ++count; - GetDataForXPAtKill_helper(member,victim,sum_level,member_with_max_level,not_gray_member_with_max_level); + GetDataForXPAtKill_helper(member, victim, sum_level, member_with_max_level, not_gray_member_with_max_level); } if (additional) @@ -999,7 +999,7 @@ void Group::GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_lev if (additional->IsAtGroupRewardDistance(victim)) // at req. distance { ++count; - GetDataForXPAtKill_helper(additional,victim,sum_level,member_with_max_level,not_gray_member_with_max_level); + GetDataForXPAtKill_helper(additional, victim, sum_level, member_with_max_level, not_gray_member_with_max_level); } } } @@ -1009,7 +1009,7 @@ void Group::SendTargetIconList(WorldSession* session) if (!session) return; - WorldPacket data(MSG_RAID_TARGET_UPDATE, (1+TARGET_ICON_COUNT*9)); + WorldPacket data(MSG_RAID_TARGET_UPDATE, (1 + TARGET_ICON_COUNT * 9)); data << uint8(1); // list targets for (int i = 0; i < TARGET_ICON_COUNT; ++i) @@ -1032,7 +1032,7 @@ void Group::SendUpdate() if (!player || !player->GetSession() || player->GetGroup() != this) continue; // guess size - WorldPacket data(SMSG_GROUP_LIST, (1+1+1+1+8+4+GetMembersCount()*20)); + WorldPacket data(SMSG_GROUP_LIST, (1 + 1 + 1 + 1 + 8 + 4 + GetMembersCount() * 20)); data << uint8(m_groupType); // group type (flags in 3.3) data << uint8(citr->group); // groupid data << uint8(GetFlags(*citr)); // group flags @@ -1044,7 +1044,7 @@ void Group::SendUpdate() } data << GetObjectGuid(); // group guid data << uint32(0); // 3.3, this value increments every time SMSG_GROUP_LIST is sent - data << uint32(GetMembersCount()-1); + data << uint32(GetMembersCount() - 1); for (member_citerator citr2 = m_memberSlots.begin(); citr2 != m_memberSlots.end(); ++citr2) { if (citr->guid == citr2->guid) @@ -1062,7 +1062,7 @@ void Group::SendUpdate() } data << m_leaderGuid; // leader guid - if (GetMembersCount()-1) + if (GetMembersCount() - 1) { data << uint8(m_lootMethod); // loot method data << m_looterGuid; // looter guid @@ -1212,7 +1212,7 @@ bool Group::_addMember(ObjectGuid guid, const char* name, bool isAssistant, uint { // insert into group table CharacterDatabase.PExecute("INSERT INTO group_member(groupId,memberGuid,assistant,subgroup) VALUES('%u','%u','%u','%u')", - m_Id, member.guid.GetCounter(), ((member.assistant==1)?1:0), member.group); + m_Id, member.guid.GetCounter(), ((member.assistant == 1) ? 1 : 0), member.group); } return true; @@ -1373,7 +1373,7 @@ bool Group::_setAssistantFlag(ObjectGuid guid, const bool& state) slot->assistant = state; if (!isBGGroup()) - CharacterDatabase.PExecute("UPDATE group_member SET assistant='%u' WHERE memberGuid='%u'", (state==true)?1:0, guid.GetCounter()); + CharacterDatabase.PExecute("UPDATE group_member SET assistant='%u' WHERE memberGuid='%u'", (state == true) ? 1 : 0, guid.GetCounter()); return true; } @@ -1780,7 +1780,7 @@ InstanceGroupBind* Group::GetBoundInstance(uint32 mapid, Player* player) Difficulty difficulty = player->GetDifficulty(mapEntry->IsRaid()); // some instances only have one difficulty - MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty); + MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty); if (!mapDiff) difficulty = DUNGEON_DIFFICULTY_NORMAL; @@ -1794,7 +1794,7 @@ InstanceGroupBind* Group::GetBoundInstance(uint32 mapid, Player* player) InstanceGroupBind* Group::GetBoundInstance(Map* aMap, Difficulty difficulty) { // some instances only have one difficulty - MapDifficulty const* mapDiff = GetMapDifficultyData(aMap->GetId(),difficulty); + MapDifficulty const* mapDiff = GetMapDifficultyData(aMap->GetId(), difficulty); if (!mapDiff) return NULL; @@ -1873,7 +1873,7 @@ static void RewardGroupAtKill_helper(Player* pGroupGuy, Unit* pVictim, uint32 co { // honor can be in PvP and !PvP (racial leader) cases (for alive) if (pGroupGuy->isAlive()) - pGroupGuy->RewardHonor(pVictim,count); + pGroupGuy->RewardHonor(pVictim, count); // xp and reputation only in !PvP case if (!PvP) @@ -1882,24 +1882,24 @@ static void RewardGroupAtKill_helper(Player* pGroupGuy, Unit* pVictim, uint32 co // if is in dungeon then all receive full reputation at kill // rewarded any alive/dead/near_corpse group member - pGroupGuy->RewardReputation(pVictim,is_dungeon ? 1.0f : rate); + pGroupGuy->RewardReputation(pVictim, is_dungeon ? 1.0f : rate); // XP updated only for alive group member if (pGroupGuy->isAlive() && not_gray_member_with_max_level && pGroupGuy->getLevel() <= not_gray_member_with_max_level->getLevel()) { - uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp*rate) : uint32((xp*rate/2)+1); + uint32 itr_xp = (member_with_max_level == not_gray_member_with_max_level) ? uint32(xp * rate) : uint32((xp * rate / 2) + 1); pGroupGuy->GiveXP(itr_xp, pVictim); if (Pet* pet = pGroupGuy->GetPet()) - pet->GivePetXP(itr_xp/2); + pet->GivePetXP(itr_xp / 2); } // quest objectives updated only for alive group member or dead but with not released body - if (pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + if (pGroupGuy->isAlive() || !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) { // normal creature (not pet/etc) can be only in !PvP case - if (pVictim->GetTypeId()==TYPEID_UNIT) + if (pVictim->GetTypeId() == TYPEID_UNIT) if (CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(pVictim->GetEntry())) pGroupGuy->KilledMonster(normalInfo, pVictim->GetObjectGuid()); } @@ -1925,7 +1925,7 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap) Player* member_with_max_level = NULL; Player* not_gray_member_with_max_level = NULL; - GetDataForXPAtKill(pVictim,count,sum_level,member_with_max_level,not_gray_member_with_max_level,player_tap); + GetDataForXPAtKill(pVictim, count, sum_level, member_with_max_level, not_gray_member_with_max_level, player_tap); if (member_with_max_level) { @@ -1935,7 +1935,7 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap) /// skip in check PvP case (for speed, not used) bool is_raid = PvP ? false : sMapStore.LookupEntry(pVictim->GetMapId())->IsRaid() && isRaidGroup(); bool is_dungeon = PvP ? false : sMapStore.LookupEntry(pVictim->GetMapId())->IsDungeon(); - float group_rate = MaNGOS::XP::xp_in_group_rate(count,is_raid); + float group_rate = MaNGOS::XP::xp_in_group_rate(count, is_raid); for (GroupReference* itr = GetFirstMember(); itr != NULL; itr = itr->next()) { @@ -1944,7 +1944,7 @@ void Group::RewardGroupAtKill(Unit* pVictim, Player* player_tap) continue; // will proccessed later - if (pGroupGuy==player_tap) + if (pGroupGuy == player_tap) continue; if (!pGroupGuy->IsAtGroupRewardDistance(pVictim)) diff --git a/src/game/Group.h b/src/game/Group.h index 2f14e7470..d57120607 100644 --- a/src/game/Group.h +++ b/src/game/Group.h @@ -200,7 +200,7 @@ class MANGOS_DLL_SPEC Group typedef std::list MemberSlotList; typedef MemberSlotList::const_iterator member_citerator; - typedef UNORDERED_MAP< uint32 /*mapId*/, InstanceGroupBind> BoundInstancesMap; + typedef UNORDERED_MAP < uint32 /*mapId*/, InstanceGroupBind > BoundInstancesMap; protected: typedef MemberSlotList::iterator member_witerator; typedef std::set InvitesList; @@ -225,7 +225,7 @@ class MANGOS_DLL_SPEC Group void SetLooterGuid(ObjectGuid guid) { m_looterGuid = guid; } void UpdateLooterGuid(WorldObject* pSource, bool ifneed = false); void SetLootThreshold(ItemQualities threshold) { m_lootThreshold = threshold; } - void Disband(bool hideDestroy=false); + void Disband(bool hideDestroy = false); // properties accessories uint32 GetId() const { return m_Id; } @@ -254,7 +254,7 @@ class MANGOS_DLL_SPEC Group bool IsAssistant(ObjectGuid guid) const { member_citerator mslot = _getMemberCSlot(guid); - if (mslot==m_memberSlots.end()) + if (mslot == m_memberSlots.end()) return false; return mslot->assistant; @@ -272,7 +272,7 @@ class MANGOS_DLL_SPEC Group MemberSlotList const& GetMemberSlots() const { return m_memberSlots; } GroupReference* GetFirstMember() { return m_memberMgr.getFirst(); } uint32 GetMembersCount() const { return m_memberSlots.size(); } - void GetDataForXPAtKill(Unit const* victim, uint32& count,uint32& sum_level, Player*& member_with_max_level, Player*& not_gray_member_with_max_level, Player* additional = NULL); + void GetDataForXPAtKill(Unit const* victim, uint32& count, uint32& sum_level, Player*& member_with_max_level, Player*& not_gray_member_with_max_level, Player* additional = NULL); uint8 GetMemberGroup(ObjectGuid guid) const { member_citerator mslot = _getMemberCSlot(guid); @@ -333,7 +333,7 @@ class MANGOS_DLL_SPEC Group void SendUpdate(); void UpdatePlayerOutOfRange(Player* pPlayer); // ignore: GUID of player that will be ignored - void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore = ObjectGuid()); + void BroadcastPacket(WorldPacket* packet, bool ignorePlayersInBGRaid, int group = -1, ObjectGuid ignore = ObjectGuid()); void BroadcastReadyCheck(WorldPacket* packet); void OfflineReadyCheck(); @@ -366,7 +366,7 @@ class MANGOS_DLL_SPEC Group BoundInstancesMap& GetBoundInstances(Difficulty difficulty) { return m_boundInstances[difficulty]; } protected: - bool _addMember(ObjectGuid guid, const char* name, bool isAssistant=false); + bool _addMember(ObjectGuid guid, const char* name, bool isAssistant = false); bool _addMember(ObjectGuid guid, const char* name, bool isAssistant, uint8 group); bool _removeMember(ObjectGuid guid); // returns true if leader has changed void _setLeader(ObjectGuid guid); diff --git a/src/game/GroupHandler.cpp b/src/game/GroupHandler.cpp index 09ae533c8..37d2046c8 100644 --- a/src/game/GroupHandler.cpp +++ b/src/game/GroupHandler.cpp @@ -42,7 +42,7 @@ void WorldSession::SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res) { - WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (4+member.size()+1+4+4)); + WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (4 + member.size() + 1 + 4 + 4)); data << uint32(operation); data << member; // max len 48 data << uint32(res); @@ -432,7 +432,7 @@ void WorldSession::HandleMinimapPingOpcode(WorldPacket& recv_data) /********************/ // everything is fine, do it - WorldPacket data(MSG_MINIMAP_PING, (8+4+4)); + WorldPacket data(MSG_MINIMAP_PING, (8 + 4 + 4)); data << GetPlayer()->GetObjectGuid(); data << float(x); data << float(y); @@ -455,7 +455,7 @@ void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data) //DEBUG_LOG("ROLL: MIN: %u, MAX: %u, ROLL: %u", minimum, maximum, roll); - WorldPacket data(MSG_RANDOM_ROLL, 4+4+4+8); + WorldPacket data(MSG_RANDOM_ROLL, 4 + 4 + 4 + 8); data << uint32(minimum); data << uint32(maximum); data << uint32(roll); @@ -567,7 +567,7 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket& recv_data) /********************/ // everything is fine, do it - group->SetAssistant(guid, (flag==0?false:true)); + group->SetAssistant(guid, (flag == 0 ? false : true)); } void WorldSession::HandlePartyAssignmentOpcode(WorldPacket& recv_data) @@ -814,7 +814,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data) Player* player = ObjectAccessor::FindPlayer(guid, false); if (!player) { - WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3+4+2); + WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3 + 4 + 2); data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related data << guid.WriteAsPacked(); data << uint32(GROUP_UPDATE_FLAG_STATUS); @@ -825,7 +825,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket& recv_data) Pet* pet = player->GetPet(); - WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4+2+2+2+1+2*6+8+1+8); + WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 4 + 2 + 2 + 2 + 1 + 2 * 6 + 8 + 1 + 8); data << uint8(0); // only for SMSG_PARTY_MEMBER_STATS_FULL, probably arena/bg related data << player->GetPackGUID(); diff --git a/src/game/GuardAI.cpp b/src/game/GuardAI.cpp index 3caebc287..a817f9a5c 100644 --- a/src/game/GuardAI.cpp +++ b/src/game/GuardAI.cpp @@ -45,7 +45,7 @@ void GuardAI::MoveInLineOfSight(Unit* u) u->isInAccessablePlaceFor(m_creature)) { float attackRadius = m_creature->GetAttackDistance(u); - if (m_creature->IsWithinDistInMap(u,attackRadius)) + if (m_creature->IsWithinDistInMap(u, attackRadius)) { //Need add code to let guard support player AttackStart(u); @@ -117,8 +117,8 @@ void GuardAI::UpdateAI(const uint32 /*diff*/) bool GuardAI::IsVisible(Unit* pl) const { - return m_creature->IsWithinDist(pl,sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER)) - && pl->isVisibleForOrDetect(m_creature,m_creature,true); + return m_creature->IsWithinDist(pl, sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER)) + && pl->isVisibleForOrDetect(m_creature, m_creature, true); } void GuardAI::AttackStart(Unit* u) @@ -126,7 +126,7 @@ void GuardAI::AttackStart(Unit* u) if (!u) return; - if (m_creature->Attack(u,true)) + if (m_creature->Attack(u, true)) { i_victimGuid = u->GetObjectGuid(); m_creature->AddThreat(u); diff --git a/src/game/Guild.cpp b/src/game/Guild.cpp index 1364e037f..dd2ee6b36 100644 --- a/src/game/Guild.cpp +++ b/src/game/Guild.cpp @@ -205,7 +205,7 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank) newmember.accountId = fields[4].GetInt32(); delete result; if (newmember.Level < 1 || newmember.Level > STRONG_MAX_LEVEL || - !((1 << (newmember.Class-1)) & CLASSMASK_ALL_PLAYABLE)) + !((1 << (newmember.Class - 1)) & CLASSMASK_ALL_PLAYABLE)) { sLog.outError("%s has a broken data in field `characters` table, cannot add him to guild.", plGuid.GetString().c_str()); return false; @@ -319,7 +319,7 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult) { if (!guildRanksResult) { - sLog.outError("Guild %u has broken `guild_rank` data, creating new...",m_Id); + sLog.outError("Guild %u has broken `guild_rank` data, creating new...", m_Id); CreateDefaultGuildRanks(0); return true; } @@ -431,8 +431,8 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult) newmember.BankRemMoney = fields[6].GetUInt32(); for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i) { - newmember.BankResetTimeTab[i] = fields[7+(2*i)].GetUInt32(); - newmember.BankRemSlotsTab[i] = fields[8+(2*i)].GetUInt32(); + newmember.BankResetTimeTab[i] = fields[7 + (2 * i)].GetUInt32(); + newmember.BankRemSlotsTab[i] = fields[8 + (2 * i)].GetUInt32(); } newmember.Name = fields[19].GetCppString(); @@ -456,7 +456,7 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult) // the zone through xy coords .. this is a bit redundant, but shouldn't be called often newmember.ZoneId = Player::GetZoneIdFromDB(newmember.guid); } - if (!((1 << (newmember.Class-1)) & CLASSMASK_ALL_PLAYABLE)) // can be at broken `class` field + if (!((1 << (newmember.Class - 1)) & CLASSMASK_ALL_PLAYABLE)) // can be at broken `class` field { sLog.outError("%s has a broken data in field `characters`.`class`, deleting him from guild!", newmember.guid.GetString().c_str()); CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid); @@ -559,7 +559,7 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding) void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language) { - if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(),GR_RIGHT_GCHATSPEAK)) + if (session && session->GetPlayer() && HasRankRight(session->GetPlayer()->GetRank(), GR_RIGHT_GCHATSPEAK)) { WorldPacket data; ChatHandler::FillMessageData(&data, session, CHAT_MSG_GUILD, language, msg.c_str()); @@ -568,7 +568,7 @@ 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(session->GetPlayer()->GetObjectGuid())) + if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetObjectGuid())) pl->GetSession()->SendPacket(&data); } } @@ -585,7 +585,7 @@ void Guild::BroadcastToOfficers(WorldSession* session, const std::string& msg, u Player* pl = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); - if (pl && pl->GetSession() && HasRankRight(pl->GetRank(),GR_RIGHT_OFFCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetObjectGuid())) + if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_OFFCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetPlayer()->GetObjectGuid())) pl->GetSession()->SendPacket(&data); } } @@ -614,7 +614,7 @@ void Guild::BroadcastPacketToRank(WorldPacket* packet, uint32 rankId) } } -void Guild::CreateRank(std::string name_,uint32 rights) +void Guild::CreateRank(std::string name_, uint32 rights) { if (m_Ranks.size() >= GUILD_RANKS_MAX_COUNT) return; @@ -636,9 +636,9 @@ void Guild::CreateRank(std::string name_,uint32 rights) CharacterDatabase.PExecute("INSERT INTO guild_rank (guildid,rid,rname,rights) VALUES ('%u', '%u', '%s', '%u')", m_Id, new_rank_id, name_.c_str(), rights); } -void Guild::AddRank(const std::string& name_,uint32 rights, uint32 money) +void Guild::AddRank(const std::string& name_, uint32 rights, uint32 money) { - m_Ranks.push_back(RankInfo(name_,rights,money)); + m_Ranks.push_back(RankInfo(name_, rights, money)); } void Guild::DelRank() @@ -727,7 +727,7 @@ void Guild::Disband() void Guild::Roster(WorldSession* session /*= NULL*/) { // we can only guess size - WorldPacket data(SMSG_GUILD_ROSTER, (4+MOTD.length()+1+GINFO.length()+1+4+m_Ranks.size()*(4+4+GUILD_BANK_MAX_TABS*(4+4))+members.size()*50)); + WorldPacket data(SMSG_GUILD_ROSTER, (4 + MOTD.length() + 1 + GINFO.length() + 1 + 4 + m_Ranks.size() * (4 + 4 + GUILD_BANK_MAX_TABS * (4 + 4)) + members.size() * 50)); data << uint32(members.size()); data << MOTD; data << GINFO; @@ -768,7 +768,7 @@ void Guild::Roster(WorldSession* session /*= NULL*/) data << uint8(itr->second.Class); data << uint8(0); // new 2.4.0 data << uint32(itr->second.ZoneId); - data << float(float(time(NULL)-itr->second.LogoutTime) / DAY); + data << float(float(time(NULL) - itr->second.LogoutTime) / DAY); data << itr->second.Pnote; data << itr->second.OFFnote; } @@ -782,7 +782,7 @@ void Guild::Roster(WorldSession* session /*= NULL*/) void Guild::Query(WorldSession* session) { - WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8*32+200));// we can only guess size + WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8 * 32 + 200)); // we can only guess size data << uint32(m_Id); data << m_Name; @@ -860,7 +860,7 @@ void Guild::DisplayGuildEventLog(WorldSession* session) if (itr->EventType == GUILD_EVENT_LOG_PROMOTE_PLAYER || itr->EventType == GUILD_EVENT_LOG_DEMOTE_PLAYER) data << uint8(itr->NewRank); // Event timestamp - data << uint32(time(NULL)-itr->TimeStamp); + data << uint32(time(NULL) - itr->TimeStamp); } session->SendPacket(&data); DEBUG_LOG("WORLD: Sent (MSG_GUILD_EVENT_LOG_QUERY)"); @@ -958,7 +958,7 @@ void Guild::DisplayGuildBankContent(WorldSession* session, uint8 TabId) void Guild::DisplayGuildBankMoneyUpdate(WorldSession* session) { - WorldPacket data(SMSG_GUILD_BANK_LIST, 8+1+4+1+1); + WorldPacket data(SMSG_GUILD_BANK_LIST, 8 + 1 + 4 + 1 + 1); data << uint64(GetGuildBankMoney()); data << uint8(0); // TabId, default 0 @@ -1006,7 +1006,7 @@ void Guild::DisplayGuildBankContentUpdate(uint8 TabId, int32 slot1, int32 slot2) if (!player) continue; - if (!IsMemberHaveRights(itr->first,TabId,GUILD_BANK_RIGHT_VIEW_TAB)) + if (!IsMemberHaveRights(itr->first, TabId, GUILD_BANK_RIGHT_VIEW_TAB)) continue; data.put(rempos, uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId))); @@ -1041,10 +1041,10 @@ void Guild::DisplayGuildBankContentUpdate(uint8 TabId, GuildItemPosCountVec cons if (!player) continue; - if (!IsMemberHaveRights(itr->first,TabId,GUILD_BANK_RIGHT_VIEW_TAB)) + if (!IsMemberHaveRights(itr->first, TabId, GUILD_BANK_RIGHT_VIEW_TAB)) continue; - data.put(rempos,uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId))); + data.put(rempos, uint32(GetMemberSlotWithdrawRem(player->GetGUIDLow(), TabId))); player->GetSession()->SendPacket(&data); } @@ -1171,13 +1171,13 @@ void Guild::LoadGuildBankFromDB() if (TabId >= GetPurchasedTabs()) { - sLog.outError("Guild::LoadGuildBankFromDB: Invalid tab for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); + sLog.outError("Guild::LoadGuildBankFromDB: Invalid tab for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemEntry); continue; } if (SlotId >= GUILD_BANK_MAX_SLOTS) { - sLog.outError("Guild::LoadGuildBankFromDB: Invalid slot for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); + sLog.outError("Guild::LoadGuildBankFromDB: Invalid slot for item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemEntry); continue; } @@ -1185,7 +1185,7 @@ void Guild::LoadGuildBankFromDB() if (!proto) { - sLog.outError("Guild::LoadGuildBankFromDB: Unknown item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid,ItemEntry); + sLog.outError("Guild::LoadGuildBankFromDB: Unknown item (GUID: %u id: #%u) in guild bank, skipped.", ItemGuid, ItemEntry); continue; } @@ -1224,7 +1224,7 @@ bool Guild::MemberMoneyWithdraw(uint32 amount, uint32 LowGuid) if (MoneyWithDrawRight < amount || GetGuildBankMoney() < amount) return false; - SetBankMoney(GetGuildBankMoney()-amount); + SetBankMoney(GetGuildBankMoney() - amount); if (MoneyWithDrawRight < WITHDRAW_MONEY_UNLIMITED) { @@ -1290,11 +1290,11 @@ uint32 Guild::GetMemberSlotWithdrawRem(uint32 LowGuid, uint8 TabId) if (itr->second.RankId == GR_GUILDMASTER) return WITHDRAW_SLOT_UNLIMITED; - if ((GetBankRights(itr->second.RankId,TabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB) + if ((GetBankRights(itr->second.RankId, TabId) & GUILD_BANK_RIGHT_VIEW_TAB) != GUILD_BANK_RIGHT_VIEW_TAB) return 0; - uint32 curTime = uint32(time(NULL)/MINUTE); - if (curTime - itr->second.BankResetTimeTab[TabId] >= 24*HOUR/MINUTE) + uint32 curTime = uint32(time(NULL) / MINUTE); + if (curTime - itr->second.BankResetTimeTab[TabId] >= 24 * HOUR / MINUTE) { itr->second.BankResetTimeTab[TabId] = curTime; itr->second.BankRemSlotsTab[TabId] = GetBankSlotPerDay(itr->second.RankId, TabId); @@ -1313,9 +1313,9 @@ uint32 Guild::GetMemberMoneyWithdrawRem(uint32 LowGuid) if (itr->second.RankId == GR_GUILDMASTER) return WITHDRAW_MONEY_UNLIMITED; - uint32 curTime = uint32(time(NULL)/MINUTE); // minutes + uint32 curTime = uint32(time(NULL) / MINUTE); // minutes // 24 hours - if (curTime > itr->second.BankResetTimeMoney + 24*HOUR/MINUTE) + if (curTime > itr->second.BankResetTimeMoney + 24 * HOUR / MINUTE) { itr->second.BankResetTimeMoney = curTime; itr->second.BankRemMoney = GetBankMoneyPerDay(itr->second.RankId); @@ -1533,7 +1533,7 @@ void Guild::DisplayGuildBankLogs(WorldSession* session, uint8 TabId) if (TabId == GUILD_BANK_MAX_TABS) { // Here we display money logs - WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Money.size()*(4*4+1)+1+1); + WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Money.size() * (4 * 4 + 1) + 1 + 1); data << uint8(TabId); // Here GUILD_BANK_MAX_TABS data << uint8(m_GuildBankEventLog_Money.size()); // number of log entries for (GuildBankEventLog::const_iterator itr = m_GuildBankEventLog_Money.begin(); itr != m_GuildBankEventLog_Money.end(); ++itr) @@ -1562,7 +1562,7 @@ void Guild::DisplayGuildBankLogs(WorldSession* session, uint8 TabId) else { // here we display current tab logs - WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Item[TabId].size()*(4*4+1+1)+1+1); + WorldPacket data(MSG_GUILD_BANK_LOG_QUERY, m_GuildBankEventLog_Item[TabId].size() * (4 * 4 + 1 + 1) + 1 + 1); data << uint8(TabId); // Here a real Tab Id // number of log entries data << uint8(m_GuildBankEventLog_Item[TabId].size()); @@ -1870,7 +1870,7 @@ InventoryResult Guild::CanStoreItem(uint8 tab, uint8 slot, GuildItemPosCountVec& // in specific slot if (slot != NULL_SLOT) { - InventoryResult res = _CanStoreItem_InSpecificSlot(tab,slot,dest,count,swap,pItem); + InventoryResult res = _CanStoreItem_InSpecificSlot(tab, slot, dest, count, swap, pItem); if (res != EQUIP_ERR_OK) return res; @@ -1921,14 +1921,14 @@ void Guild::SetGuildBankTabText(uint8 TabId, std::string text) CharacterDatabase.PExecute("UPDATE guild_bank_tab SET TabText='%s' WHERE guildid='%u' AND TabId='%u'", text.c_str(), m_Id, uint32(TabId)); // announce - SendGuildBankTabText(NULL,TabId); + SendGuildBankTabText(NULL, TabId); } void Guild::SendGuildBankTabText(WorldSession* session, uint8 TabId) { GuildBankTab const* tab = m_TabListMap[TabId]; - WorldPacket data(MSG_QUERY_GUILD_BANK_TEXT, 1+tab->Text.size()+1); + WorldPacket data(MSG_QUERY_GUILD_BANK_TEXT, 1 + tab->Text.size() + 1); data << uint8(TabId); data << tab->Text; @@ -2000,7 +2000,7 @@ void Guild::SwapItems(Player* pl, uint8 BankTab, uint8 BankTabSlot, uint8 BankTa else // non split { GuildItemPosCountVec gDest; - InventoryResult msg = CanStoreItem(BankTabDst,BankTabSlotDst,gDest,pItemSrc->GetCount(), pItemSrc, false); + InventoryResult msg = CanStoreItem(BankTabDst, BankTabSlotDst, gDest, pItemSrc->GetCount(), pItemSrc, false); if (msg == EQUIP_ERR_OK) // merge to { CharacterDatabase.BeginTransaction(); @@ -2106,7 +2106,7 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin CharacterDatabase.BeginTransaction(); LogBankEvent(GUILD_BANK_LOG_WITHDRAW_ITEM, BankTab, pl->GetGUIDLow(), pItemBank->GetEntry(), SplitedAmount); - pItemBank->SetCount(pItemBank->GetCount()-SplitedAmount); + pItemBank->SetCount(pItemBank->GetCount() - SplitedAmount); pItemBank->FSetState(ITEM_CHANGED); pItemBank->SaveToDB(); // not in inventory and can be save standalone pl->MoveItemToInventory(dest, pNewItem, true); @@ -2162,7 +2162,7 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin GuildItemPosCountVec gDest; if (pItemChar) { - msg = CanStoreItem(BankTab,BankTabSlot,gDest,pItemChar->GetCount(),pItemChar,true); + msg = CanStoreItem(BankTab, BankTabSlot, gDest, pItemChar->GetCount(), pItemChar, true); if (msg != EQUIP_ERR_OK) { pl->SendEquipError(msg, pItemChar, NULL); @@ -2180,8 +2180,8 @@ void Guild::MoveFromBankToChar(Player* pl, uint8 BankTab, uint8 BankTabSlot, uin // logging item move to bank if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )", - pl->GetName(),pl->GetSession()->GetAccountId(), + sLog.outCommand(pl->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )", + pl->GetName(), pl->GetSession()->GetAccountId(), pItemChar->GetProto()->Name1, pItemChar->GetEntry(), pItemChar->GetCount(), m_Id); } @@ -2256,8 +2256,8 @@ void Guild::MoveFromCharToBank(Player* pl, uint8 PlayerBag, uint8 PlayerSlot, ui // logging item move to bank (before items merge if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )", - pl->GetName(),pl->GetSession()->GetAccountId(), + sLog.outCommand(pl->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )", + pl->GetName(), pl->GetSession()->GetAccountId(), pItemChar->GetProto()->Name1, pItemChar->GetEntry(), SplitedAmount, m_Id); } @@ -2265,7 +2265,7 @@ void Guild::MoveFromCharToBank(Player* pl, uint8 PlayerBag, uint8 PlayerSlot, ui LogBankEvent(GUILD_BANK_LOG_DEPOSIT_ITEM, BankTab, pl->GetGUIDLow(), pItemChar->GetEntry(), SplitedAmount); pl->ItemRemovedQuestCheck(pItemChar->GetEntry(), SplitedAmount); - pItemChar->SetCount(pItemChar->GetCount()-SplitedAmount); + pItemChar->SetCount(pItemChar->GetCount() - SplitedAmount); pItemChar->SetState(ITEM_CHANGED); pl->SaveInventoryAndGoldToDB(); StoreItem(BankTab, dest, pNewItem); @@ -2282,8 +2282,8 @@ void Guild::MoveFromCharToBank(Player* pl, uint8 PlayerBag, uint8 PlayerSlot, ui // logging item move to bank if (pl->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(pl->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )", - pl->GetName(),pl->GetSession()->GetAccountId(), + sLog.outCommand(pl->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit item: %s (Entry: %d Count: %u) to guild bank (Guild ID: %u )", + pl->GetName(), pl->GetSession()->GetAccountId(), pItemChar->GetProto()->Name1, pItemChar->GetEntry(), pItemChar->GetCount(), m_Id); } @@ -2365,7 +2365,7 @@ void Guild::BroadcastEvent(GuildEvents event, ObjectGuid guid, char const* str1 { uint8 strCount = !str1 ? 0 : (!str2 ? 1 : (!str3 ? 2 : 3)); - WorldPacket data(SMSG_GUILD_EVENT, 1 + 1 + 1*strCount + (!guid ? 0 : 8)); + WorldPacket data(SMSG_GUILD_EVENT, 1 + 1 + 1 * strCount + (!guid ? 0 : 8)); data << uint8(event); data << uint8(strCount); diff --git a/src/game/Guild.h b/src/game/Guild.h index 55676cbfb..7ecb1548c 100644 --- a/src/game/Guild.h +++ b/src/game/Guild.h @@ -359,7 +359,7 @@ class Guild _do(player); } - void CreateRank(std::string name,uint32 rights); + void CreateRank(std::string name, uint32 rights); void DelRank(); std::string GetRankName(uint32 rankId); uint32 GetRankRights(uint32 rankId); @@ -418,7 +418,7 @@ class Guild void SetGuildBankTabInfo(uint8 TabId, std::string name, std::string icon); uint8 GetPurchasedTabs() const { return m_TabListMap.size(); } uint32 GetBankRights(uint32 rankId, uint8 TabId) const; - bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId,uint32 rights) const; + bool IsMemberHaveRights(uint32 LowGuid, uint8 TabId, uint32 rights) const; bool CanMemberViewTab(uint32 LowGuid, uint8 TabId) const; // Load void LoadGuildBankFromDB(); @@ -440,11 +440,11 @@ class Guild // Guild Bank Event Logs void LoadGuildBankEventLogFromDB(); void DisplayGuildBankLogs(WorldSession* session, uint8 TabId); - void LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0); + void LogBankEvent(uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount = 0, uint8 DestTabId = 0); bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry); protected: - void AddRank(const std::string& name,uint32 rights,uint32 money); + void AddRank(const std::string& name, uint32 rights, uint32 money); uint32 m_Id; std::string m_Name; diff --git a/src/game/GuildHandler.cpp b/src/game/GuildHandler.cpp index 9e7e52a08..db715b6be 100644 --- a/src/game/GuildHandler.cpp +++ b/src/game/GuildHandler.cpp @@ -126,7 +126,7 @@ void WorldSession::HandleGuildInviteOpcode(WorldPacket& recvPacket) // Put record into guildlog guild->LogGuildEvent(GUILD_EVENT_LOG_INVITE_PLAYER, GetPlayer()->GetObjectGuid(), player->GetObjectGuid()); - WorldPacket data(SMSG_GUILD_INVITE, (8+10)); // guess size + WorldPacket data(SMSG_GUILD_INVITE, (8 + 10)); // guess size data << GetPlayer()->GetName(); data << guild->GetName(); player->GetSession()->SendPacket(&data); @@ -206,7 +206,7 @@ void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/) if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && player->GetTeam() != sObjectMgr.GetPlayerTeamByGUID(guild->GetLeaderGuid())) return; - if (!guild->AddMember(GetPlayer()->GetObjectGuid(),guild->GetLowestRank())) + if (!guild->AddMember(GetPlayer()->GetObjectGuid(), guild->GetLowestRank())) return; // Put record into guild log guild->LogGuildEvent(GUILD_EVENT_LOG_JOIN_GUILD, GetPlayer()->GetObjectGuid()); @@ -503,7 +503,7 @@ void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket) { DEBUG_LOG("WORLD: Received CMSG_GUILD_SET_PUBLIC_NOTE"); - std::string name,PNOTE; + std::string name, PNOTE; recvPacket >> name; if (!normalizePlayerName(name)) @@ -678,9 +678,9 @@ void WorldSession::HandleGuildDelRankOpcode(WorldPacket& /*recvPacket*/) guild->Roster(); // broadcast for tab rights update } -void WorldSession::SendGuildCommandResult(uint32 typecmd, const std::string& str,uint32 cmdresult) +void WorldSession::SendGuildCommandResult(uint32 typecmd, const std::string& str, uint32 cmdresult) { - WorldPacket data(SMSG_GUILD_COMMAND_RESULT, (8+str.size()+1)); + WorldPacket data(SMSG_GUILD_COMMAND_RESULT, (8 + str.size() + 1)); data << typecmd; data << str; data << cmdresult; @@ -750,14 +750,14 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) return; } - if (GetPlayer()->GetMoney() < 10*GOLD) + if (GetPlayer()->GetMoney() < 10 * GOLD) { //"You can't afford to do that." SendSaveGuildEmblem(ERR_GUILDEMBLEM_NOTENOUGHMONEY); return; } - GetPlayer()->ModifyMoney(-10*GOLD); + GetPlayer()->ModifyMoney(-10 * GOLD); guild->SetEmblem(EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor); //"Guild Emblem saved." @@ -797,7 +797,7 @@ void WorldSession::HandleGuildPermissions(WorldPacket& /* recv_data */) { uint32 rankId = GetPlayer()->GetRank(); - WorldPacket data(MSG_GUILD_PERMISSIONS, 4*15+1); + WorldPacket data(MSG_GUILD_PERMISSIONS, 4 * 15 + 1); data << uint32(rankId); // guild rank id data << uint32(pGuild->GetRankRights(rankId)); // rank rights // money per day left @@ -898,7 +898,7 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recv_data) CharacterDatabase.BeginTransaction(); - pGuild->SetBankMoney(pGuild->GetGuildBankMoney()+money); + pGuild->SetBankMoney(pGuild->GetGuildBankMoney() + money); GetPlayer()->ModifyMoney(-int(money)); GetPlayer()->SaveGoldToDB(); @@ -907,8 +907,8 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket& recv_data) // logging money if (_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)", - _player->GetName(),_player->GetSession()->GetAccountId(),money,GuildId); + sLog.outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) deposit money (Amount: %u) to guild bank (Guild ID %u)", + _player->GetName(), _player->GetSession()->GetAccountId(), money, GuildId); } // log @@ -944,7 +944,7 @@ void WorldSession::HandleGuildBankWithdrawMoney(WorldPacket& recv_data) if (!pGuild->GetPurchasedTabs()) return; - if (pGuild->GetGuildBankMoney()GetGuildBankMoney() < money) // not enough money in bank return; if (!pGuild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_WITHDRAW_GOLD)) diff --git a/src/game/HomeMovementGenerator.cpp b/src/game/HomeMovementGenerator.cpp index 81abd2b26..54c32478d 100644 --- a/src/game/HomeMovementGenerator.cpp +++ b/src/game/HomeMovementGenerator.cpp @@ -41,7 +41,7 @@ void HomeMovementGenerator::_setTargetLocation(Creature& owner) Movement::MoveSplineInit init(owner); float x, y, z, o; // at apply we can select more nice return points base at current movegen - if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner,x,y,z)) + if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner, x, y, z)) { owner.GetRespawnCoord(x, y, z, &o); init.SetFacing(o); diff --git a/src/game/HostileRefManager.cpp b/src/game/HostileRefManager.cpp index ef701f1c6..2f4d36a5c 100644 --- a/src/game/HostileRefManager.cpp +++ b/src/game/HostileRefManager.cpp @@ -41,7 +41,7 @@ HostileRefManager::~HostileRefManager() void HostileRefManager::threatAssist(Unit* pVictim, float pThreat, SpellEntry const* pThreatSpell, bool pSingleTarget) { uint32 size = pSingleTarget ? 1 : getSize(); // if pSingleTarget do not devide threat - float threat = pThreat/size; + float threat = pThreat / size; HostileReference* ref = getFirst(); while (ref) { @@ -149,7 +149,7 @@ void HostileRefManager::deleteReference(Unit* pCreature) //================================================= // set state for one reference, defined by Unit -void HostileRefManager::setOnlineOfflineState(Unit* pCreature,bool pIsOnline) +void HostileRefManager::setOnlineOfflineState(Unit* pCreature, bool pIsOnline) { HostileReference* ref = getFirst(); while (ref) diff --git a/src/game/HostileRefManager.h b/src/game/HostileRefManager.h index a4571c3e6..f666ac23a 100644 --- a/src/game/HostileRefManager.h +++ b/src/game/HostileRefManager.h @@ -41,7 +41,7 @@ class HostileRefManager : public RefManager // send threat to all my hateres for the pVictim // The pVictim is hated than by them as well // use for buffs and healing threat functionality - void threatAssist(Unit* pVictim, float threat, SpellEntry const* threatSpell = 0, bool pSingleTarget=false); + void threatAssist(Unit* pVictim, float threat, SpellEntry const* threatSpell = 0, bool pSingleTarget = false); void addThreatPercent(int32 pValue); @@ -59,7 +59,7 @@ class HostileRefManager : public RefManager void setOnlineOfflineState(bool pIsOnline); // set state for one reference, defined by Unit - void setOnlineOfflineState(Unit* pCreature,bool pIsOnline); + void setOnlineOfflineState(Unit* pCreature, bool pIsOnline); // delete one reference, defined by Unit void deleteReference(Unit* pCreature); @@ -68,7 +68,7 @@ class HostileRefManager : public RefManager void SetThreatRedirection(ObjectGuid guid, uint32 pct) { m_redirectionTargetGuid = guid; - m_redirectionMod = pct/100.0f; + m_redirectionMod = pct / 100.0f; } void ResetThreatRedirection() diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp index e66631624..62c96c2c6 100644 --- a/src/game/InstanceData.cpp +++ b/src/game/InstanceData.cpp @@ -42,7 +42,7 @@ void InstanceData::SaveToDB() bool InstanceData::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= NULL*/, uint32 /*miscvalue1*/ /*= 0*/) { sLog.outError("Achievement system call InstanceData::CheckAchievementCriteriaMeet but instance script for map %u not have implementation for achievement criteria %u", - instance->GetId(),criteria_id); + instance->GetId(), criteria_id); return false; } diff --git a/src/game/Item.cpp b/src/game/Item.cpp index ac2b449d3..675e80194 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -33,7 +33,7 @@ void AddItemsSetItem(Player* player, Item* item) if (!set) { - sLog.outErrorDb("Item set %u for item (id %u) not found, mods not applied.", setid,proto->ItemId); + sLog.outErrorDb("Item set %u for item (id %u) not found, mods not applied.", setid, proto->ItemId); return; } @@ -63,7 +63,7 @@ void AddItemsSetItem(Player* player, Item* item) break; if (x < player->ItemSetEff.size()) - player->ItemSetEff[x]=eff; + player->ItemSetEff[x] = eff; else player->ItemSetEff.push_back(eff); } @@ -94,7 +94,7 @@ void AddItemsSetItem(Player* player, Item* item) SpellEntry const* spellInfo = sSpellStore.LookupEntry(set->spells[x]); if (!spellInfo) { - sLog.outError("WORLD: unknown spell id %u in items set %u effects", set->spells[x],setid); + sLog.outError("WORLD: unknown spell id %u in items set %u effects", set->spells[x], setid); break; } @@ -115,7 +115,7 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto) if (!set) { - sLog.outErrorDb("Item set #%u for item #%u not found, mods not removed.", setid,proto->ItemId); + sLog.outErrorDb("Item set #%u for item #%u not found, mods not removed.", setid, proto->ItemId); return; } @@ -265,7 +265,7 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability); for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) - SetSpellCharges(i,itemProto->Spells[i].SpellCharges); + SetSpellCharges(i, itemProto->Spells[i].SpellCharges); SetUInt32Value(ITEM_FIELD_DURATION, itemProto->Duration); @@ -444,7 +444,7 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid) return false; // update max durability (and durability) if need - if (proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) + if (proto->MaxDurability != GetUInt32Value(ITEM_FIELD_MAXDURABILITY)) { SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability); if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability) @@ -633,7 +633,7 @@ uint32 Item::GetSpell() case ITEM_SUBCLASS_WEAPON_DAGGER: return 1180; case ITEM_SUBCLASS_WEAPON_THROWN: return 2567; case ITEM_SUBCLASS_WEAPON_SPEAR: return 3386; - case ITEM_SUBCLASS_WEAPON_CROSSBOW:return 5011; + case ITEM_SUBCLASS_WEAPON_CROSSBOW: return 5011; case ITEM_SUBCLASS_WEAPON_WAND: return 5009; default: return 0; } @@ -702,7 +702,7 @@ void Item::SetItemRandomProperties(int32 randomPropId) { if (GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != int32(item_rand->ID)) { - SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID,item_rand->ID); + SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, item_rand->ID); SetState(ITEM_CHANGED); } for (uint32 i = PROP_ENCHANTMENT_SLOT_2; i < PROP_ENCHANTMENT_SLOT_2 + 3; ++i) @@ -733,7 +733,7 @@ bool Item::UpdateItemSuffixFactor() uint32 suffixFactor = GenerateEnchSuffixFactor(GetEntry()); if (GetItemSuffixFactor() == suffixFactor) return false; - SetUInt32Value(ITEM_FIELD_PROPERTY_SEED,suffixFactor); + SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, suffixFactor); return true; } @@ -792,7 +792,7 @@ void Item::AddToUpdateQueueOf(Player* player) return; player->m_itemUpdateQueue.push_back(this); - uQueuePos = player->m_itemUpdateQueue.size() -1; + uQueuePos = player->m_itemUpdateQueue.size() - 1; } void Item::RemoveFromUpdateQueueOf(Player* player) @@ -980,7 +980,7 @@ bool Item::GemsFitSockets() const bool fits = true; for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot) { - uint8 SocketColor = GetProto()->Socket[enchant_slot-SOCK_ENCHANTMENT_SLOT].Color; + uint8 SocketColor = GetProto()->Socket[enchant_slot - SOCK_ENCHANTMENT_SLOT].Color; uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) diff --git a/src/game/Item.h b/src/game/Item.h index b98ae11b2..d50410634 100644 --- a/src/game/Item.h +++ b/src/game/Item.h @@ -286,7 +286,7 @@ class MANGOS_DLL_SPEC Item : public Object void SetOwnerGuid(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); } Player* GetOwner()const; - void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED,val); } + void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED, val); } bool IsSoulBound() const { return HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_BINDED); } bool IsBoundAccountWide() const { return GetProto()->Flags & ITEM_FLAG_BOA; } bool IsBindedNotWith(Player const* player) const; @@ -350,7 +350,7 @@ class MANGOS_DLL_SPEC Item : public Object // spell charges (signed but stored as unsigned) int32 GetSpellCharges(uint8 index/*0..5*/ = 0) const { return GetInt32Value(ITEM_FIELD_SPELL_CHARGES + index); } - void SetSpellCharges(uint8 index/*0..5*/, int32 value) { SetInt32Value(ITEM_FIELD_SPELL_CHARGES + index,value); } + void SetSpellCharges(uint8 index/*0..5*/, int32 value) { SetInt32Value(ITEM_FIELD_SPELL_CHARGES + index, value); } bool HasMaxCharges() const; void RestoreCharges(); diff --git a/src/game/ItemEnchantmentMgr.cpp b/src/game/ItemEnchantmentMgr.cpp index 46b2f09dc..4838043bd 100644 --- a/src/game/ItemEnchantmentMgr.cpp +++ b/src/game/ItemEnchantmentMgr.cpp @@ -95,7 +95,7 @@ uint32 GetItemEnchantMod(uint32 entry) if (tab == RandomItemEnch.end()) { - sLog.outErrorDb("Item RandomProperty / RandomSuffix id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.",entry); + sLog.outErrorDb("Item RandomProperty / RandomSuffix id #%u used in `item_template` but it doesn't have records in `item_enchantment_template` table.", entry); return 0; } diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp index cc8861a4e..b149b0830 100644 --- a/src/game/ItemHandler.cpp +++ b/src/game/ItemHandler.cpp @@ -662,7 +662,7 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recv_data) { for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - if (Bag* pBag = (Bag*)_player->GetItemByPos(INVENTORY_SLOT_BAG_0,i)) + if (Bag* pBag = (Bag*)_player->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { if (bagGuid == pBag->GetObjectGuid()) { @@ -738,7 +738,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid) if (!vItems && !tItems) { - WorldPacket data(SMSG_LIST_INVENTORY, (8+1+1)); + WorldPacket data(SMSG_LIST_INVENTORY, (8 + 1 + 1)); data << ObjectGuid(vendorguid); data << uint8(0); // count==0, next will be error code data << uint8(0); // "Vendor has no inventory" @@ -751,7 +751,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid) uint8 count = 0; - WorldPacket data(SMSG_LIST_INVENTORY, (8+1+numitems*8*4)); + WorldPacket data(SMSG_LIST_INVENTORY, (8 + 1 + numitems * 8 * 4)); data << ObjectGuid(vendorguid); size_t count_pos = data.wpos(); @@ -803,7 +803,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorguid) // reputation discount uint32 price = (crItem->ExtendedCost == 0 || pProto->Flags2 & ITEM_FLAG2_EXT_COST_REQUIRES_GOLD) ? uint32(floor(pProto->BuyPrice * discountMod)) : 0; - data << uint32(vendorslot +1); // client size expected counting from 1 + data << uint32(vendorslot + 1); // client size expected counting from 1 data << uint32(pProto->ItemId); data << uint32(pProto->DisplayInfoID); data << uint32(crItem->maxcount <= 0 ? 0xFFFFFFFF : pCreature->GetVendorItemCurrentCount(crItem)); @@ -1042,7 +1042,7 @@ void WorldSession::HandleSetAmmoOpcode(WorldPacket& recv_data) void WorldSession::SendEnchantmentLog(ObjectGuid targetGuid, ObjectGuid casterGuid, uint32 itemId, uint32 spellId) { - WorldPacket data(SMSG_ENCHANTMENTLOG, (8+8+4+4+1)); // last check 2.0.10 + WorldPacket data(SMSG_ENCHANTMENTLOG, (8 + 8 + 4 + 4 + 1)); // last check 2.0.10 data << ObjectGuid(targetGuid); data << ObjectGuid(casterGuid); data << uint32(itemId); @@ -1054,7 +1054,7 @@ void WorldSession::SendEnchantmentLog(ObjectGuid targetGuid, ObjectGuid casterGu void WorldSession::SendItemEnchantTimeUpdate(ObjectGuid playerGuid, ObjectGuid itemGuid, uint32 slot, uint32 duration) { // last check 2.0.10 - WorldPacket data(SMSG_ITEM_ENCHANT_TIME_UPDATE, (8+4+4+8)); + WorldPacket data(SMSG_ITEM_ENCHANT_TIME_UPDATE, (8 + 4 + 4 + 8)); data << ObjectGuid(itemGuid); data << uint32(slot); data << uint32(duration); @@ -1076,7 +1076,7 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket& recv_data) std::string name = pProto->Name1; sObjectMgr.GetItemLocaleStrings(pProto->ItemId, loc_idx, &name); // guess size - WorldPacket data(SMSG_ITEM_NAME_QUERY_RESPONSE, (4+10)); + WorldPacket data(SMSG_ITEM_NAME_QUERY_RESPONSE, (4 + 10)); data << uint32(pProto->ItemId); data << name; data << uint32(pProto->InventoryType); @@ -1223,7 +1223,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) if (!gemGuid.IsItem()) return; - for (int j = i+1; j < MAX_GEM_SOCKETS; ++j) + for (int j = i + 1; j < MAX_GEM_SOCKETS; ++j) if (gemGuids[j] == gemGuid) return; } @@ -1402,7 +1402,7 @@ void WorldSession::HandleSocketOpcode(WorldPacket& recv_data) bool SocketBonusToBeActivated = itemTarget->GemsFitSockets();// current socketbonus state if (SocketBonusActivated != SocketBonusToBeActivated) // if there was a change... { - _player->ApplyEnchantment(itemTarget,BONUS_ENCHANTMENT_SLOT, false); + _player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, false); itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetProto()->socketBonus : 0), 0, 0); _player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, true); //it is not displayed, client has an inbuilt system to determine if the bonus is activated @@ -1471,7 +1471,7 @@ void WorldSession::HandleItemTextQuery(WorldPacket& recv_data) DEBUG_LOG("CMSG_ITEM_TEXT_QUERY item guid: %u", itemGuid.GetCounter()); - WorldPacket data(SMSG_ITEM_TEXT_QUERY_RESPONSE, (4+10));// guess size + WorldPacket data(SMSG_ITEM_TEXT_QUERY_RESPONSE, (4 + 10)); // guess size if (Item* item = _player->GetItemByGuid(itemGuid)) { diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index 7101e5cc4..ba6734708 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -633,7 +633,7 @@ struct ItemPrototype return false; } - uint32 GetMaxStackSize() const { return Stackable > 0 ? uint32(Stackable) : uint32(0x7FFFFFFF-1); } + uint32 GetMaxStackSize() const { return Stackable > 0 ? uint32(Stackable) : uint32(0x7FFFFFFF - 1); } float getDPS() const { @@ -641,16 +641,16 @@ struct ItemPrototype return 0; float temp = 0; for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i) - temp+=Damage[i].DamageMin + Damage[i].DamageMax; - return temp*500/Delay; + temp += Damage[i].DamageMin + Damage[i].DamageMax; + return temp * 500 / Delay; } int32 getFeralBonus(int32 extraDPS = 0) const { // 0x02A5F3 - is mask for Melee weapon from ItemSubClassMask.dbc - if (Class == ITEM_CLASS_WEAPON && (1<CastSpell(chr,7355,false); + chr->CastSpell(chr, 7355, false); return true; } @@ -97,9 +97,9 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/) char const* full; if (m_session) - full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,"|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r"); + full = _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, "|cffffffff|Hurl:" REVISION_ID "|h" REVISION_ID "|h|r"); else - full = _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID); + full = _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID); SendSysMessage(full); if (sScriptMgr.IsScriptLibraryLoaded()) @@ -113,8 +113,8 @@ bool ChatHandler::HandleServerInfoCommand(char* /*args*/) else SendSysMessage(LANG_USING_SCRIPT_LIB_NONE); - PSendSysMessage(LANG_USING_WORLD_DB,sWorld.GetDBVersion()); - PSendSysMessage(LANG_USING_EVENT_AI,sWorld.GetCreatureEventAIVersion()); + PSendSysMessage(LANG_USING_WORLD_DB, sWorld.GetDBVersion()); + PSendSysMessage(LANG_USING_EVENT_AI, sWorld.GetCreatureEventAIVersion()); PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum); PSendSysMessage(LANG_UPTIME, str.c_str()); @@ -145,7 +145,7 @@ bool ChatHandler::HandleDismountCommand(char* /*args*/) bool ChatHandler::HandleSaveCommand(char* /*args*/) { - Player* player=m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); // save GM account without delay and output message (testing, etc) if (GetAccessLevel() > SEC_PLAYER) @@ -157,7 +157,7 @@ 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)) + if (save_interval == 0 || (save_interval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= save_interval - 20 * IN_MILLISECONDS)) player->SaveToDB(); return true; diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index a80aeb4e0..4098099e3 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -127,7 +127,7 @@ bool ChatHandler::HandleAnnounceCommand(char* args) if (!*args) return false; - sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args); + sWorld.SendWorldText(LANG_SYSTEMMESSAGE, args); return true; } @@ -140,7 +140,7 @@ bool ChatHandler::HandleNotifyCommand(char* args) std::string str = GetMangosString(LANG_GLOBAL_NOTIFY); str += args; - WorldPacket data(SMSG_NOTIFICATION, (str.size()+1)); + WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); data << str; sWorld.SendGlobalMessage(&data); @@ -285,7 +285,7 @@ bool ChatHandler::HandleGPSCommand(char* args) Cell cell(cell_val); uint32 zone_id, area_id; - obj->GetZoneAndAreaId(zone_id,area_id); + obj->GetZoneAndAreaId(zone_id, area_id); MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId()); AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id); @@ -306,11 +306,11 @@ bool ChatHandler::HandleGPSCommand(char* args) GridPair p = MaNGOS::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY()); - int gx=63-p.x_coord; - int gy=63-p.y_coord; + int gx = 63 - p.x_coord; + int gy = 63 - p.y_coord; - uint32 have_map = GridMap::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0; - uint32 have_vmap = GridMap::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0; + uint32 have_map = GridMap::ExistMap(obj->GetMapId(), gx, gy) ? 1 : 0; + uint32 have_vmap = GridMap::ExistVMap(obj->GetMapId(), gx, gy) ? 1 : 0; if (have_vmap) { @@ -333,7 +333,7 @@ bool ChatHandler::HandleGPSCommand(char* args) DEBUG_LOG("Player %s GPS call for %s '%s' (%s: %u):", m_session ? GetNameLink().c_str() : GetMangosString(LANG_CONSOLE_COMMAND), (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(), - (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry())); + (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow() : obj->GetEntry())); DEBUG_LOG(GetMangosString(LANG_MAP_POSITION), obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : ""), @@ -391,14 +391,14 @@ bool ChatHandler::HandleNamegoCommand(char* args) // only allow if gm mode is on if (!target->isGameMaster()) { - PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,nameLink.c_str()); + PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str()); SetSentErrorMessage(true); return false; } // if both players are in different bgs else if (target->GetBattleGroundId() && m_session->GetPlayer()->GetBattleGroundId() != target->GetBattleGroundId()) { - PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,nameLink.c_str()); + PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG, nameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -415,7 +415,7 @@ bool ChatHandler::HandleNamegoCommand(char* args) if (cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId()) { // cannot summon from instance to instance - PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str()); + PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -426,13 +426,13 @@ bool ChatHandler::HandleNamegoCommand(char* args) (m_session->GetPlayer()->GetGroup()->GetLeaderGuid() != m_session->GetPlayer()->GetObjectGuid())) // the last check is a bit excessive, but let it be, just in case { - PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,nameLink.c_str()); + PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str()); SetSentErrorMessage(true); return false; } } - PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),""); + PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), ""); if (needReportToTarget(target)) ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, playerLink(_player->GetName()).c_str()); @@ -447,9 +447,9 @@ bool ChatHandler::HandleNamegoCommand(char* args) target->SaveRecallPosition(); // before GM - float x,y,z; + float x, y, z; m_session->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectBoundingRadius()); - target->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,target->GetOrientation()); + target->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, target->GetOrientation()); } else { @@ -459,7 +459,7 @@ bool ChatHandler::HandleNamegoCommand(char* args) std::string nameLink = playerLink(target_name); - PSendSysMessage(LANG_SUMMONING, nameLink.c_str(),GetMangosString(LANG_OFFLINE)); + PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), GetMangosString(LANG_OFFLINE)); // in point where GM stay Player::SavePositionInDB(target_guid, m_session->GetPlayer()->GetMapId(), @@ -505,14 +505,14 @@ bool ChatHandler::HandleGonameCommand(char* args) // only allow if gm mode is on if (!_player->isGameMaster()) { - PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chrNameLink.c_str()); + PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } // if both players are in different bgs else if (_player->GetBattleGroundId() && _player->GetBattleGroundId() != target->GetBattleGroundId()) { - PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chrNameLink.c_str()); + PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -533,7 +533,7 @@ bool ChatHandler::HandleGonameCommand(char* args) // we are in group, we can go only if we are in the player group if (_player->GetGroup() != target->GetGroup()) { - PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chrNameLink.c_str()); + PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -543,7 +543,7 @@ bool ChatHandler::HandleGonameCommand(char* args) // we are not in group, let's verify our GM mode if (!_player->isGameMaster()) { - PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chrNameLink.c_str()); + PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -591,8 +591,8 @@ bool ChatHandler::HandleGonameCommand(char* args) _player->SaveRecallPosition(); // to point to see at target with same orientation - float x,y,z; - target->GetContactPoint(_player,x,y,z); + float x, y, z; + target->GetContactPoint(_player, x, y, z); _player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE); } @@ -607,10 +607,10 @@ bool ChatHandler::HandleGonameCommand(char* args) PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str()); // to point where player stay (if loaded) - float x,y,z,o; + float x, y, z, o; uint32 map; bool in_flight; - if (!Player::LoadPositionFromDB(target_guid, map,x,y,z,o,in_flight)) + if (!Player::LoadPositionFromDB(target_guid, map, x, y, z, o, in_flight)) return false; return HandleGoHelper(_player, map, x, y, &z); @@ -710,7 +710,7 @@ bool ChatHandler::HandleModifyManaCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetNameLink().c_str(), mana, manam); - chr->SetMaxPower(POWER_MANA,manam); + chr->SetMaxPower(POWER_MANA, manam); chr->SetPower(POWER_MANA, mana); return true; @@ -722,8 +722,8 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args) if (!*args) return false; - int32 energy = atoi(args)*10; - int32 energym = atoi(args)*10; + int32 energy = atoi(args) * 10; + int32 energym = atoi(args) * 10; if (energy <= 0 || energym <= 0 || energym < energy) { @@ -744,14 +744,14 @@ bool ChatHandler::HandleModifyEnergyCommand(char* args) if (HasLowerSecurity(chr)) return false; - PSendSysMessage(LANG_YOU_CHANGE_ENERGY, GetNameLink(chr).c_str(), energy/10, energym/10); + 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->SetMaxPower(POWER_ENERGY, energym); chr->SetPower(POWER_ENERGY, energy); - DETAIL_LOG(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY)); + DETAIL_LOG(GetMangosString(LANG_CURRENT_ENERGY), chr->GetMaxPower(POWER_ENERGY)); return true; } @@ -762,8 +762,8 @@ bool ChatHandler::HandleModifyRageCommand(char* args) if (!*args) return false; - int32 rage = atoi(args)*10; - int32 ragem = atoi(args)*10; + int32 rage = atoi(args) * 10; + int32 ragem = atoi(args) * 10; if (rage <= 0 || ragem <= 0 || ragem < rage) { @@ -784,11 +784,11 @@ bool ChatHandler::HandleModifyRageCommand(char* args) if (HasLowerSecurity(chr)) return false; - PSendSysMessage(LANG_YOU_CHANGE_RAGE, GetNameLink(chr).c_str(), rage/10, ragem/10); + 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->SetMaxPower(POWER_RAGE, ragem); chr->SetPower(POWER_RAGE, rage); return true; @@ -800,8 +800,8 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args) if (!*args) return false; - int32 rune = atoi(args)*10; - int32 runem = atoi(args)*10; + int32 rune = atoi(args) * 10; + int32 runem = atoi(args) * 10; if (rune <= 0 || runem <= 0 || runem < rune) { @@ -818,11 +818,11 @@ bool ChatHandler::HandleModifyRunicPowerCommand(char* args) return false; } - PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, GetNameLink(chr).c_str(), rune/10, runem/10); + PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, GetNameLink(chr).c_str(), rune / 10, runem / 10); if (needReportToTarget(chr)) - ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune/10, runem/10); + ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetNameLink().c_str(), rune / 10, runem / 10); - chr->SetMaxPower(POWER_RUNIC_POWER,runem); + chr->SetMaxPower(POWER_RUNIC_POWER, runem); chr->SetPower(POWER_RUNIC_POWER, rune); return true; @@ -847,7 +847,7 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS); uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS); uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS); - PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag); + PSendSysMessage(LANG_CURRENT_FACTION, chr->GetGUIDLow(), factionid, flag, npcflag, dyflag); } return true; } @@ -885,9 +885,9 @@ bool ChatHandler::HandleModifyFactionCommand(char* args) PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(), factionid, flag, npcflag, dyflag); chr->setFaction(factionid); - chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag); - chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag); - chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag); + chr->SetUInt32Value(UNIT_FIELD_FLAGS, flag); + chr->SetUInt32Value(UNIT_NPC_FLAGS, npcflag); + chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS, dyflag); return true; } @@ -910,7 +910,7 @@ bool ChatHandler::HandleModifyTalentCommand(char* args) return false; } - if (target->GetTypeId()==TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER) { // check online security if (HasLowerSecurity((Player*)target)) @@ -953,7 +953,7 @@ 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; @@ -1007,7 +1007,7 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args) if (chr->IsTaxiFlying()) { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); + PSendSysMessage(LANG_CHAR_IN_FLIGHT, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -1055,7 +1055,7 @@ bool ChatHandler::HandleModifySpeedCommand(char* args) if (chr->IsTaxiFlying()) { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); + PSendSysMessage(LANG_CHAR_IN_FLIGHT, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -1100,7 +1100,7 @@ bool ChatHandler::HandleModifySwimCommand(char* args) if (chr->IsTaxiFlying()) { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); + PSendSysMessage(LANG_CHAR_IN_FLIGHT, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -1145,7 +1145,7 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args) if (chr->IsTaxiFlying()) { - PSendSysMessage(LANG_CHAR_IN_FLIGHT,chrNameLink.c_str()); + PSendSysMessage(LANG_CHAR_IN_FLIGHT, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -1217,7 +1217,7 @@ bool ChatHandler::HandleModifyScaleCommand(char* args) return false; } - if (target->GetTypeId()==TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER) { // check online security if (HasLowerSecurity((Player*)target)) @@ -1246,211 +1246,211 @@ bool ChatHandler::HandleModifyMountCommand(char* args) switch (num) { case 1: - mId=14340; + mId = 14340; break; case 2: - mId=4806; + mId = 4806; break; case 3: - mId=6471; + mId = 6471; break; case 4: - mId=12345; + mId = 12345; break; case 5: - mId=6472; + mId = 6472; break; case 6: - mId=6473; + mId = 6473; break; case 7: - mId=10670; + mId = 10670; break; case 8: - mId=10719; + mId = 10719; break; case 9: - mId=10671; + mId = 10671; break; case 10: - mId=10672; + mId = 10672; break; case 11: - mId=10720; + mId = 10720; break; case 12: - mId=14349; + mId = 14349; break; case 13: - mId=11641; + mId = 11641; break; case 14: - mId=12244; + mId = 12244; break; case 15: - mId=12242; + mId = 12242; break; case 16: - mId=14578; + mId = 14578; break; case 17: - mId=14579; + mId = 14579; break; case 18: - mId=14349; + mId = 14349; break; case 19: - mId=12245; + mId = 12245; break; case 20: - mId=14335; + mId = 14335; break; case 21: - mId=207; + mId = 207; break; case 22: - mId=2328; + mId = 2328; break; case 23: - mId=2327; + mId = 2327; break; case 24: - mId=2326; + mId = 2326; break; case 25: - mId=14573; + mId = 14573; break; case 26: - mId=14574; + mId = 14574; break; case 27: - mId=14575; + mId = 14575; break; case 28: - mId=604; + mId = 604; break; case 29: - mId=1166; + mId = 1166; break; case 30: - mId=2402; + mId = 2402; break; case 31: - mId=2410; + mId = 2410; break; case 32: - mId=2409; + mId = 2409; break; case 33: - mId=2408; + mId = 2408; break; case 34: - mId=2405; + mId = 2405; break; case 35: - mId=14337; + mId = 14337; break; case 36: - mId=6569; + mId = 6569; break; case 37: - mId=10661; + mId = 10661; break; case 38: - mId=10666; + mId = 10666; break; case 39: - mId=9473; + mId = 9473; break; case 40: - mId=9476; + mId = 9476; break; case 41: - mId=9474; + mId = 9474; break; case 42: - mId=14374; + mId = 14374; break; case 43: - mId=14376; + mId = 14376; break; case 44: - mId=14377; + mId = 14377; break; case 45: - mId=2404; + mId = 2404; break; case 46: - mId=2784; + mId = 2784; break; case 47: - mId=2787; + mId = 2787; break; case 48: - mId=2785; + mId = 2785; break; case 49: - mId=2736; + mId = 2736; break; case 50: - mId=2786; + mId = 2786; break; case 51: - mId=14347; + mId = 14347; break; case 52: - mId=14346; + mId = 14346; break; case 53: - mId=14576; + mId = 14576; break; case 54: - mId=9695; + mId = 9695; break; case 55: - mId=9991; + mId = 9991; break; case 56: - mId=6448; + mId = 6448; break; case 57: - mId=6444; + mId = 6444; break; case 58: - mId=6080; + mId = 6080; break; case 59: - mId=6447; + mId = 6447; break; case 60: - mId=4805; + mId = 4805; break; case 61: - mId=9714; + mId = 9714; break; case 62: - mId=6448; + mId = 6448; break; case 63: - mId=6442; + mId = 6442; break; case 64: - mId=14632; + mId = 14632; break; case 65: - mId=14332; + mId = 14332; break; case 66: - mId=14331; + mId = 14331; break; case 67: - mId=8469; + mId = 8469; break; case 68: - mId=2830; + mId = 2830; break; case 69: - mId=2346; + mId = 2346; break; default: SendSysMessage(LANG_NO_MOUNT); @@ -1477,14 +1477,14 @@ bool ChatHandler::HandleModifyMountCommand(char* args) chr->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP); chr->Mount(mId); - WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4)); + WorldPacket data(SMSG_FORCE_RUN_SPEED_CHANGE, (8 + 4 + 1 + 4)); data << chr->GetPackGUID(); data << (uint32)0; data << (uint8)0; //new 2.1.0 data << float(speed); chr->SendMessageToSet(&data, true); - data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4)); + data.Initialize(SMSG_FORCE_SWIM_SPEED_CHANGE, (8 + 4 + 4)); data << chr->GetPackGUID(); data << (uint32)0; data << float(speed); @@ -1545,7 +1545,7 @@ bool ChatHandler::HandleModifyMoneyCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetNameLink().c_str(), addmoney); - if (addmoney >=MAX_MONEY_AMOUNT) + if (addmoney >= MAX_MONEY_AMOUNT) chr->SetMoney(MAX_MONEY_AMOUNT); else chr->ModifyMoney(addmoney); @@ -1610,7 +1610,7 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; uint32 counter = 0; // Counter for figure out that we found smth. @@ -1634,7 +1634,7 @@ bool ChatHandler::HandleLookupAreaCommand(char* args) loc = 0; for (; loc < MAX_LOCALE; ++loc) { - if (loc==GetSessionDbcLocale()) + if (loc == GetSessionDbcLocale()) continue; name = areaEntry->area_name[loc]; @@ -1651,7 +1651,7 @@ 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]; @@ -1681,7 +1681,7 @@ bool ChatHandler::HandleLookupTeleCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; // converting string that we try to find to lower case @@ -1706,7 +1706,7 @@ bool ChatHandler::HandleLookupTeleCommand(char* args) if (reply.str().empty()) SendSysMessage(LANG_COMMAND_TELE_NOLOCATION); else - PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str()); + PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str()); return true; } @@ -1771,7 +1771,7 @@ bool ChatHandler::HandleSendMailCommand(char* args) // from console show nonexistent sender MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM); - draft.SendMailTo(MailReceiver(target, target_guid),sender); + draft.SendMailTo(MailReceiver(target, target_guid), sender); std::string nameLink = playerLink(target_name); PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); @@ -1806,14 +1806,14 @@ bool ChatHandler::HandleTeleNameCommand(char* args) std::string chrNameLink = playerLink(target_name); - if (target->IsBeingTeleported()==true) + if (target->IsBeingTeleported() == true) { PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str()); SetSentErrorMessage(true); return false; } - PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(),"", tele->name.c_str()); + PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(), "", tele->name.c_str()); if (needReportToTarget(target)) ChatHandler(target).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetNameLink().c_str()); @@ -1830,7 +1830,7 @@ bool ChatHandler::HandleTeleNameCommand(char* args) PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str()); Player::SavePositionInDB(target_guid, tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation, - sTerrainMgr.GetZoneId(tele->mapId,tele->position_x,tele->position_y,tele->position_z)); + sTerrainMgr.GetZoneId(tele->mapId, tele->position_x, tele->position_y, tele->position_z)); } return true; @@ -1868,7 +1868,7 @@ bool ChatHandler::HandleTeleGroupCommand(char* args) Group* grp = player->GetGroup(); if (!grp) { - PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); + PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -1892,7 +1892,7 @@ bool ChatHandler::HandleTeleGroupCommand(char* args) continue; } - PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(),"", tele->name.c_str()); + PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str()); if (needReportToTarget(pl)) ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); @@ -1929,7 +1929,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args) if (!grp) { - PSendSysMessage(LANG_NOT_IN_GROUP,nameLink.c_str()); + PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); SetSentErrorMessage(true); return false; } @@ -1952,7 +1952,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args) { Player* pl = itr->getSource(); - if (!pl || pl==m_session->GetPlayer() || !pl->GetSession()) + if (!pl || pl == m_session->GetPlayer() || !pl->GetSession()) continue; // check online security @@ -1961,7 +1961,7 @@ bool ChatHandler::HandleGroupgoCommand(char* args) std::string plNameLink = GetNameLink(pl); - if (pl->IsBeingTeleported()==true) + if (pl->IsBeingTeleported() == true) { PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); SetSentErrorMessage(true); @@ -1975,13 +1975,13 @@ bool ChatHandler::HandleGroupgoCommand(char* args) if (plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId()) { // cannot summon from instance to instance - PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,plNameLink.c_str()); + PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str()); SetSentErrorMessage(true); return false; } } - PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(),""); + PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), ""); if (needReportToTarget(pl)) ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, nameLink.c_str()); @@ -1996,9 +1996,9 @@ bool ChatHandler::HandleGroupgoCommand(char* args) pl->SaveRecallPosition(); // before GM - float x,y,z; + float x, y, z; m_session->GetPlayer()->GetClosePoint(x, y, z, pl->GetObjectBoundingRadius()); - pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation()); + pl->TeleportTo(m_session->GetPlayer()->GetMapId(), x, y, z, pl->GetOrientation()); } return true; @@ -2017,9 +2017,9 @@ bool ChatHandler::HandleGoHelper(Player* player, uint32 mapid, float x, float y, ort = *ortPtr; // check full provided coordinates - if (!MapManager::IsValidMapCoord(mapid,x,y,z,ort)) + if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort)) { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); SetSentErrorMessage(true); return false; } @@ -2027,9 +2027,9 @@ bool ChatHandler::HandleGoHelper(Player* player, uint32 mapid, float x, float y, else { // we need check x,y before ask Z or can crash at invalide coordinates - if (!MapManager::IsValidMapCoord(mapid,x,y)) + if (!MapManager::IsValidMapCoord(mapid, x, y)) { - PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid); + PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid); SetSentErrorMessage(true); return false; } @@ -2071,7 +2071,7 @@ bool ChatHandler::HandleGoTaxinodeCommand(char* args) if (node->x == 0.0f && node->y == 0.0f && node->z == 0.0f) { - PSendSysMessage(LANG_INVALID_TARGET_COORD,node->x,node->y,node->map_id); + PSendSysMessage(LANG_INVALID_TARGET_COORD, node->x, node->y, node->map_id); SetSentErrorMessage(true); return false; } @@ -2198,7 +2198,7 @@ bool ChatHandler::HandleGoZoneXYCommand(char* args) return false; } - if (!Zone2MapCoordinates(x,y,zoneEntry->ID)) + if (!Zone2MapCoordinates(x, y, zoneEntry->ID)) { PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[GetSessionDbcLocale()], mapEntry->MapID, mapEntry->name[GetSessionDbcLocale()]); @@ -2227,8 +2227,8 @@ bool ChatHandler::HandleGoGridCommand(char* args) return false; // center of grid - float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; - float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS; + float x = (grid_x - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS; + float y = (grid_y - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS; return HandleGoHelper(_player, mapid, x, y); } diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 5ad345839..1f627ba7b 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -86,7 +86,7 @@ bool ChatHandler::HandleMuteCommand(char* args) if (HasLowerSecurity(target, target_guid, true)) return false; - time_t mutetime = time(NULL) + notspeaktime*60; + time_t mutetime = time(NULL) + notspeaktime * 60; if (target) target->GetSession()->m_muteTime = mutetime; @@ -222,7 +222,7 @@ bool ChatHandler::HandleTriggerCommand(char* args) if (!m_session) return false; - float dist2 = MAP_SIZE*MAP_SIZE; + float dist2 = MAP_SIZE * MAP_SIZE; Player* pl = m_session->GetPlayer(); @@ -239,7 +239,7 @@ bool ChatHandler::HandleTriggerCommand(char* args) float dx = atTestEntry->x - pl->GetPositionX(); float dy = atTestEntry->y - pl->GetPositionY(); - float test_dist2 = dx*dx + dy*dy; + float test_dist2 = dx * dx + dy * dy; if (test_dist2 >= dist2) continue; @@ -338,7 +338,7 @@ bool ChatHandler::HandleTriggerActiveCommand(char* /*args*/) bool ChatHandler::HandleTriggerNearCommand(char* args) { float distance = (!*args) ? 10.0f : (float)atof(args); - float dist2 = distance*distance; + float dist2 = distance * distance; uint32 counter = 0; // Counter for figure out that we found smth. Player* pl = m_session->GetPlayer(); @@ -356,7 +356,7 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) float dx = atEntry->x - pl->GetPositionX(); float dy = atEntry->y - pl->GetPositionY(); - if (dx*dx + dy*dy > dist2) + if (dx * dx + dy * dy > dist2) continue; ShowTriggerListHelper(atEntry); @@ -381,7 +381,7 @@ bool ChatHandler::HandleTriggerNearCommand(char* args) float dx = at->target_X - pl->GetPositionX(); float dy = at->target_Y - pl->GetPositionY(); - if (dx*dx + dy*dy > dist2) + if (dx * dx + dy * dy > dist2) continue; ShowTriggerTargetListHelper(atEntry->id, at); @@ -469,7 +469,7 @@ bool ChatHandler::HandleGoGraveyardCommand(char* args) enum CreatureLinkType { - CREATURE_LINK_RAW =-1, // non-link case + CREATURE_LINK_RAW = -1, // non-link case CREATURE_LINK_GUID = 0, CREATURE_LINK_ENTRY = 1, }; @@ -584,7 +584,7 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) { std::string name = pParam1; WorldDatabase.escape_string(name); - QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM creature, creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), name.c_str()); + QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM creature, creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), name.c_str()); if (!result) { SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); @@ -629,7 +629,7 @@ bool ChatHandler::HandleGoCreatureCommand(char* args) enum GameobjectLinkType { - GAMEOBJECT_LINK_RAW =-1, // non-link case + GAMEOBJECT_LINK_RAW = -1, // non-link case GAMEOBJECT_LINK_GUID = 0, GAMEOBJECT_LINK_ENTRY = 1, }; @@ -733,7 +733,7 @@ bool ChatHandler::HandleGoObjectCommand(char* args) { std::string name = pParam1; WorldDatabase.escape_string(name); - QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM gameobject, gameobject_template WHERE gameobject.id = gameobject_template.entry AND gameobject_template.name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), name.c_str()); + QueryResult* result = WorldDatabase.PQuery("SELECT guid FROM gameobject, gameobject_template WHERE gameobject.id = gameobject_template.entry AND gameobject_template.name "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), name.c_str()); if (!result) { SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND); @@ -792,7 +792,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) if (ExtractUInt32(&cId, id)) { result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),id); + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(), id); } else { @@ -800,8 +800,8 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) WorldDatabase.escape_string(name); result = WorldDatabase.PQuery( "SELECT guid, id, position_x, position_y, position_z, orientation, map, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " - "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" ORDER BY order_ ASC LIMIT 1", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(),name.c_str()); + "FROM gameobject,gameobject_template WHERE gameobject_template.entry = gameobject.id AND map = %i AND name "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'")" ORDER BY order_ ASC LIMIT 1", + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(), name.c_str()); } } else @@ -814,8 +814,8 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) { if (initString) { - eventFilter << "OR event IN (" <<*itr; - initString =false; + eventFilter << "OR event IN (" << *itr; + initString = false; } else eventFilter << "," << *itr; @@ -829,7 +829,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, " "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " "LEFT OUTER JOIN game_event_gameobject on gameobject.guid=game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10", - m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(),eventFilter.str().c_str()); + m_session->GetPlayer()->GetPositionX(), m_session->GetPlayer()->GetPositionY(), m_session->GetPlayer()->GetPositionZ(), m_session->GetPlayer()->GetMapId(), eventFilter.str().c_str()); } if (!result) @@ -863,7 +863,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) if (!found) { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id); return false; } @@ -871,7 +871,7 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) if (!goI) { - PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); + PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST, id); return false; } @@ -881,14 +881,14 @@ bool ChatHandler::HandleGameObjectTargetCommand(char* args) if (target) { - time_t curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); + time_t curRespawnDelay = target->GetRespawnTimeEx() - time(NULL); if (curRespawnDelay < 0) curRespawnDelay = 0; - std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); - std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); + std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay, true); + std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true); - PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); + PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str()); ShowNpcOrGoSpawnInformation(target->GetGUIDLow()); } @@ -910,7 +910,7 @@ bool ChatHandler::HandleGameObjectDeleteCommand(char* args) // 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) { @@ -929,7 +929,7 @@ bool ChatHandler::HandleGameObjectDeleteCommand(char* args) return false; } - owner->RemoveGameObject(obj,false); + owner->RemoveGameObject(obj, false); } obj->SetRespawnTime(0); // not save respawn time @@ -956,7 +956,7 @@ bool ChatHandler::HandleGameObjectTurnCommand(char* args) // 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) { @@ -990,7 +990,7 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args) // 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) { @@ -1004,7 +1004,7 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args) Player* chr = m_session->GetPlayer(); Map* map = obj->GetMap(); - map->Remove(obj,false); + map->Remove(obj, false); obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); @@ -1032,7 +1032,7 @@ bool ChatHandler::HandleGameObjectMoveCommand(char* args) } Map* map = obj->GetMap(); - map->Remove(obj,false); + map->Remove(obj, false); obj->Relocate(x, y, z, obj->GetOrientation()); @@ -1121,7 +1121,7 @@ bool ChatHandler::HandleGameObjectAddCommand(char* args) sObjectMgr.AddGameobjectToGrid(db_lowGUID, sObjectMgr.GetGOData(db_lowGUID)); - PSendSysMessage(LANG_GAMEOBJECT_ADD,id,gInfo->name,db_lowGUID,x,y,z); + PSendSysMessage(LANG_GAMEOBJECT_ADD, id, gInfo->name, db_lowGUID, x, y, z); return true; } @@ -1140,7 +1140,7 @@ bool ChatHandler::HandleGameObjectPhaseCommand(char* args) // 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) { @@ -1157,7 +1157,7 @@ bool ChatHandler::HandleGameObjectPhaseCommand(char* args) return false; } - obj->SetPhaseMask(phasemask,true); + obj->SetPhaseMask(phasemask, true); obj->SaveToDB(); return true; } @@ -1175,7 +1175,7 @@ bool ChatHandler::HandleGameObjectNearCommand(char* args) "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), - pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); + pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), distance * distance); if (result) { @@ -1203,7 +1203,7 @@ bool ChatHandler::HandleGameObjectNearCommand(char* args) delete result; } - PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE,distance,count); + PSendSysMessage(LANG_COMMAND_NEAROBJMESSAGE, distance, count); return true; } @@ -1237,7 +1237,7 @@ void ChatHandler::ShowAchievementListHelper(AchievementEntry const* achEntry, Lo { // complete date tm* aTm = localtime(date); - ss << ":1:" << aTm->tm_mon+1 << ":" << aTm->tm_mday << ":" << (aTm->tm_year+1900-2000) << ":"; + ss << ":1:" << aTm->tm_mon + 1 << ":" << aTm->tm_mday << ":" << (aTm->tm_year + 1900 - 2000) << ":"; // complete criteria mask (all bits set) ss << uint32(-1) << ":" << uint32(-1) << ":" << uint32(-1) << ":" << uint32(-1) << ":"; @@ -1507,9 +1507,9 @@ bool ChatHandler::HandleModifyRepCommand(char* args) if (wrank.substr(0, wrankStr.size()) == wrankStr) { int32 delta; - if (!ExtractOptInt32(&args, delta, 0) || (delta < 0) || (delta > ReputationMgr::PointsInRank[r] -1)) + if (!ExtractOptInt32(&args, delta, 0) || (delta < 0) || (delta > ReputationMgr::PointsInRank[r] - 1)) { - PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r]-1)); + PSendSysMessage(LANG_COMMAND_FACTION_DELTA, (ReputationMgr::PointsInRank[r] - 1)); SetSentErrorMessage(true); return false; } @@ -1542,7 +1542,7 @@ bool ChatHandler::HandleModifyRepCommand(char* args) return false; } - target->GetReputationMgr().SetReputation(factionEntry,amount); + target->GetReputationMgr().SetReputation(factionEntry, amount); PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[GetSessionDbcLocale()], factionId, GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); return true; @@ -1633,11 +1633,11 @@ bool ChatHandler::HandleNpcAddVendorItemCommand(char* args) return false; } - sObjectMgr.AddVendorItem(vendor_entry,itemId,maxcount,incrtime,extendedcost); + sObjectMgr.AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost); ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); - PSendSysMessage(LANG_ITEM_ADDED_TO_LIST,itemId,pProto->Name1,maxcount,incrtime,extendedcost); + PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, pProto->Name1, maxcount, incrtime, extendedcost); return true; } @@ -1665,14 +1665,14 @@ bool ChatHandler::HandleNpcDelVendorItemCommand(char* args) if (!sObjectMgr.RemoveVendorItem(vendor->GetEntry(), itemId)) { - PSendSysMessage(LANG_ITEM_NOT_IN_LIST,itemId); + PSendSysMessage(LANG_ITEM_NOT_IN_LIST, itemId); SetSentErrorMessage(true); return false; } ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemId); - PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST,itemId,pProto->Name1); + PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, pProto->Name1); return true; } @@ -1738,7 +1738,7 @@ bool ChatHandler::HandleNpcAddMoveCommand(char* args) sWaypointMgr.AddLastNode(lowguid, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), wait, 0); // update movement type - WorldDatabase.PExecuteLog("UPDATE creature SET MovementType=%u WHERE guid=%u", WAYPOINT_MOTION_TYPE,lowguid); + WorldDatabase.PExecuteLog("UPDATE creature SET MovementType=%u WHERE guid=%u", WAYPOINT_MOTION_TYPE, lowguid); if (pCreature) { pCreature->SetDefaultMovementType(WAYPOINT_MOTION_TYPE); @@ -1782,8 +1782,8 @@ bool ChatHandler::HandleNpcChangeLevelCommand(char* args) ((Pet*)pCreature)->GivePetLevel(lvl); else { - pCreature->SetMaxHealth(100 + 30*lvl); - pCreature->SetHealth(100 + 30*lvl); + pCreature->SetMaxHealth(100 + 30 * lvl); + pCreature->SetHealth(100 + 30 * lvl); pCreature->SetLevel(lvl); if (pCreature->HasStaticDBSpawnData()) @@ -1927,7 +1927,7 @@ bool ChatHandler::HandleNpcMoveCommand(char* args) const_cast(data)->posZ = z; const_cast(data)->orientation = o; } - pCreature->GetMap()->CreatureRelocation(pCreature,x, y, z,o); + pCreature->GetMap()->CreatureRelocation(pCreature, x, y, z, o); pCreature->GetMotionMaster()->Initialize(); if (pCreature->isAlive()) // dead creature will reset movement generator at respawn { @@ -2032,9 +2032,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); + PSendSysMessage(LANG_MOVE_TYPE_SET, type_str); return true; } @@ -2118,7 +2118,7 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args) } MovementGeneratorType mtype = IDLE_MOTION_TYPE; - if (option >0.0f) + if (option > 0.0f) mtype = RANDOM_MOTION_TYPE; Creature* pCreature = getSelectedCreature(); @@ -2138,8 +2138,8 @@ bool ChatHandler::HandleNpcSpawnDistCommand(char* args) pCreature->Respawn(); } - WorldDatabase.PExecuteLog("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u",option,mtype,u_guidlow); - PSendSysMessage(LANG_COMMAND_SPAWNDIST,option); + WorldDatabase.PExecuteLog("UPDATE creature SET spawndist=%f, MovementType=%i WHERE guid=%u", option, mtype, u_guidlow); + PSendSysMessage(LANG_COMMAND_SPAWNDIST, option); return true; } //spawn time handling @@ -2198,7 +2198,7 @@ bool ChatHandler::HandleNpcUnFollowCommand(char* /*args*/) } if (creature->GetMotionMaster()->empty() || - creature->GetMotionMaster()->GetCurrentMovementGeneratorType()!=FOLLOW_MOTION_TYPE) + creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE) { PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU); SetSentErrorMessage(true); @@ -2268,7 +2268,7 @@ bool ChatHandler::HandleNpcSetPhaseCommand(char* args) return false; } - pCreature->SetPhaseMask(phasemask,true); + pCreature->SetPhaseMask(phasemask, true); if (pCreature->HasStaticDBSpawnData()) pCreature->SaveToDB(); @@ -2521,7 +2521,7 @@ bool ChatHandler::HandleModifyPhaseCommand(char* args) else if (target->GetTypeId() == TYPEID_PLAYER && HasLowerSecurity((Player*)target)) return false; - target->SetPhaseMask(phasemask,true); + target->SetPhaseMask(phasemask, true); return true; } @@ -2579,7 +2579,7 @@ bool ChatHandler::HandlePInfoCommand(char* args) AccountTypes security = SEC_PLAYER; std::string last_login = GetMangosString(LANG_ERROR); - QueryResult* result = LoginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'",accId); + QueryResult* result = LoginDatabase.PQuery("SELECT username,gmlevel,last_ip,last_login FROM account WHERE id = '%u'", accId); if (result) { Field* fields = result->Fetch(); @@ -2602,13 +2602,13 @@ bool ChatHandler::HandlePInfoCommand(char* args) std::string nameLink = playerLink(target_name); - PSendSysMessage(LANG_PINFO_ACCOUNT, (target?"":GetMangosString(LANG_OFFLINE)), nameLink.c_str(), target_guid.GetCounter(), username.c_str(), accId, security, last_ip.c_str(), last_login.c_str(), latency); + PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : GetMangosString(LANG_OFFLINE)), nameLink.c_str(), target_guid.GetCounter(), username.c_str(), accId, security, last_ip.c_str(), last_login.c_str(), latency); - std::string timeStr = secsToTimeString(total_player_time,true,true); - uint32 gold = money /GOLD; + std::string timeStr = secsToTimeString(total_player_time, true, true); + uint32 gold = money / GOLD; uint32 silv = (money % GOLD) / SILVER; uint32 copp = (money % GOLD) % SILVER; - PSendSysMessage(LANG_PINFO_LEVEL, timeStr.c_str(), level, gold,silv,copp); + PSendSysMessage(LANG_PINFO_LEVEL, timeStr.c_str(), level, gold, silv, copp); return true; } @@ -2696,7 +2696,7 @@ bool ChatHandler::HandleTicketCommand(char* args) return false; // mgr numbering tickets start from 0 - ticket = sTicketMgr.GetGMTicketByOrderPos(num-1); + ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1); if (!ticket) { @@ -2743,7 +2743,7 @@ bool ChatHandler::HandleTicketCommand(char* args) return false; // mgr numbering tickets start from 0 - GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num-1); + GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1); if (!ticket) { PSendSysMessage(LANG_COMMAND_TICKETNOTEXIST, num); @@ -2794,11 +2794,11 @@ bool ChatHandler::HandleDelTicketCommand(char* args) // delticket #num if (ExtractUInt32(&px, num)) { - if (num ==0) + if (num == 0) return false; // mgr numbering tickets start from 0 - GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num-1); + GMTicket* ticket = sTicketMgr.GetGMTicketByOrderPos(num - 1); if (!ticket) { @@ -2838,7 +2838,7 @@ bool ChatHandler::HandleDelTicketCommand(char* args) std::string nameLink = playerLink(target_name); - PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL,nameLink.c_str()); + PSendSysMessage(LANG_COMMAND_TICKETPLAYERDEL, nameLink.c_str()); return true; } @@ -3001,7 +3001,7 @@ bool ChatHandler::HandleWpAddCommand(char* args) target->SaveToDB(); } else - WorldDatabase.PExecuteLog("UPDATE creature SET MovementType=%u WHERE guid=%u", WAYPOINT_MOTION_TYPE,lowguid); + WorldDatabase.PExecuteLog("UPDATE creature SET MovementType=%u WHERE guid=%u", WAYPOINT_MOTION_TYPE, lowguid); PSendSysMessage(LANG_WAYPOINT_ADDED, point, lowguid); @@ -3244,7 +3244,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) if (!wpGuid) return false; - PSendSysMessage(LANG_WAYPOINT_ADDED_NO, point+1); + PSendSysMessage(LANG_WAYPOINT_ADDED_NO, point + 1); return true; } // add @@ -3282,7 +3282,7 @@ bool ChatHandler::HandleWpModifyCommand(char* args) if (npcCreature) { // Any waypoints left? - QueryResult* result2 = WorldDatabase.PQuery("SELECT point FROM creature_movement WHERE id = '%u'",lowguid); + QueryResult* result2 = WorldDatabase.PQuery("SELECT point FROM creature_movement WHERE id = '%u'", lowguid); if (!result2) { npcCreature->SetDefaultMovementType(RANDOM_MOTION_TYPE); @@ -3556,7 +3556,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) uint32 spell = fields[4].GetUInt32(); uint32 textid[MAX_WAYPOINT_TEXT]; for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) - textid[i] = fields[5+i].GetUInt32(); + textid[i] = fields[5 + i].GetUInt32(); uint32 model1 = fields[10].GetUInt32(); uint32 model2 = fields[11].GetUInt32(); @@ -3570,7 +3570,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) PSendSysMessage(LANG_WAYPOINT_INFO_EMOTE, emote); PSendSysMessage(LANG_WAYPOINT_INFO_SPELL, spell); for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) - PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i+1, textid[i], (textid[i] ? GetMangosString(textid[i]) : "")); + PSendSysMessage(LANG_WAYPOINT_INFO_TEXT, i + 1, textid[i], (textid[i] ? GetMangosString(textid[i]) : "")); } while (result->NextRow()); @@ -3583,7 +3583,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) { PSendSysMessage("DEBUG: wp on, GUID: %u", lowguid); - QueryResult* result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM creature_movement WHERE id = '%u'",lowguid); + QueryResult* result = WorldDatabase.PQuery("SELECT point, position_x,position_y,position_z FROM creature_movement WHERE id = '%u'", lowguid); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); @@ -3650,7 +3650,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn()); // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); - wpCreature->LoadFromDB(wpCreature->GetGUIDLow(),map); + wpCreature->LoadFromDB(wpCreature->GetGUIDLow(), map); map->Add(wpCreature); //wpCreature->GetMap()->Add(wpCreature); } @@ -3665,7 +3665,7 @@ bool ChatHandler::HandleWpShowCommand(char* args) { PSendSysMessage("DEBUG: wp first, GUID: %u", lowguid); - QueryResult* result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM creature_movement WHERE point='1' AND id = '%u'",lowguid); + QueryResult* result = WorldDatabase.PQuery("SELECT position_x,position_y,position_z FROM creature_movement WHERE point='1' AND id = '%u'", lowguid); if (!result) { PSendSysMessage(LANG_WAYPOINT_NOTFOUND, lowguid); @@ -3930,7 +3930,7 @@ bool ChatHandler::HandleWpImportCommand(char* args) { while (! infile.eof()) { - getline(infile,line); + getline(infile, line); //cout << line << endl; QueryResult* result = WorldDatabase.Query(line.c_str()); delete result; @@ -4102,7 +4102,7 @@ bool ChatHandler::HandleLookupEventCommand(char* args) std::wstring wnamepart; // converting string that we try to find to lower case - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; wstrToLower(wnamepart); @@ -4135,7 +4135,7 @@ bool ChatHandler::HandleLookupEventCommand(char* args) } } - if (counter==0) + if (counter == 0) SendSysMessage(LANG_NOEVENTFOUND); return true; @@ -4179,7 +4179,7 @@ bool ChatHandler::HandleEventListCommand(char* args) ++counter; } - if (counter==0) + if (counter == 0) SendSysMessage(LANG_NOEVENTFOUND); return true; @@ -4212,14 +4212,14 @@ bool ChatHandler::HandleEventInfoCommand(char* args) std::string endTimeStr = TimeToTimestampStr(eventData.end); uint32 delay = sGameEventMgr.NextCheck(event_id); - time_t nextTime = time(NULL)+delay; - std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL)+delay) : "-"; + time_t nextTime = time(NULL) + delay; + std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(NULL) + delay) : "-"; std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE); std::string lengthStr = secsToTimeString(eventData.length * MINUTE); - PSendSysMessage(LANG_EVENT_INFO,event_id,eventData.description.c_str(),activeStr, - startTimeStr.c_str(),endTimeStr.c_str(),occurenceStr.c_str(),lengthStr.c_str(), + PSendSysMessage(LANG_EVENT_INFO, event_id, eventData.description.c_str(), activeStr, + startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(), nextStr.c_str()); return true; } @@ -4253,13 +4253,13 @@ bool ChatHandler::HandleEventStartCommand(char* args) if (sGameEventMgr.IsActiveEvent(event_id)) { - PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id); + PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE, event_id); SetSentErrorMessage(true); return false; } PSendSysMessage(LANG_EVENT_STARTED, event_id, eventData.description.c_str()); - sGameEventMgr.StartEvent(event_id,true); + sGameEventMgr.StartEvent(event_id, true); return true; } @@ -4292,13 +4292,13 @@ bool ChatHandler::HandleEventStopCommand(char* args) if (!sGameEventMgr.IsActiveEvent(event_id)) { - PSendSysMessage(LANG_EVENT_NOT_ACTIVE,event_id); + PSendSysMessage(LANG_EVENT_NOT_ACTIVE, event_id); SetSentErrorMessage(true); return false; } PSendSysMessage(LANG_EVENT_STOPPED, event_id, eventData.description.c_str()); - sGameEventMgr.StopEvent(event_id,true); + sGameEventMgr.StopEvent(event_id, true); return true; } @@ -4317,7 +4317,7 @@ bool ChatHandler::HandleCombatStopCommand(char* args) return true; } -void ChatHandler::HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) +void ChatHandler::HandleLearnSkillRecipesHelper(Player* player, uint32 skill_id) { uint32 classmask = player->getClassMask(); @@ -4344,7 +4344,7 @@ void ChatHandler::HandleLearnSkillRecipesHelper(Player* player,uint32 skill_id) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,player,false)) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, player, false)) continue; player->learnSpell(skillLine->spellId, false); @@ -4362,7 +4362,7 @@ bool ChatHandler::HandleLearnAllCraftsCommand(char* /*args*/) if ((skillInfo->categoryId == SKILL_CATEGORY_PROFESSION || skillInfo->categoryId == SKILL_CATEGORY_SECONDARY) && skillInfo->canLink) // only prof. with recipes have { - HandleLearnSkillRecipesHelper(m_session->GetPlayer(),skillInfo->id); + HandleLearnSkillRecipesHelper(m_session->GetPlayer(), skillInfo->id); } } @@ -4417,7 +4417,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) loc = 0; for (; loc < MAX_LOCALE; ++loc) { - if (loc==GetSessionDbcLocale()) + if (loc == GetSessionDbcLocale()) continue; name = skillInfo->name[loc]; @@ -4439,7 +4439,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(char* args) if (!targetSkillInfo) return false; - HandleLearnSkillRecipesHelper(target,targetSkillInfo->id); + HandleLearnSkillRecipesHelper(target, targetSkillInfo->id); uint16 maxLevel = target->GetPureMaxSkillValue(targetSkillInfo->id); target->SetSkill(targetSkillInfo->id, maxLevel, maxLevel); @@ -4460,7 +4460,7 @@ bool ChatHandler::HandleLookupAccountEmailCommand(char* args) std::string email = emailStr; LoginDatabase.escape_string(email); // 0 1 2 3 4 - QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), email.c_str()); return ShowAccountListHelper(result, &limit); } @@ -4479,9 +4479,9 @@ bool ChatHandler::HandleLookupAccountIpCommand(char* args) LoginDatabase.escape_string(ip); // 0 1 2 3 4 - QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), ip.c_str()); - return ShowAccountListHelper(result,&limit); + return ShowAccountListHelper(result, &limit); } bool ChatHandler::HandleLookupAccountNameCommand(char* args) @@ -4500,7 +4500,7 @@ bool ChatHandler::HandleLookupAccountNameCommand(char* args) LoginDatabase.escape_string(account); // 0 1 2 3 4 - QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT id, username, last_ip, gmlevel, expansion FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), account.c_str()); return ShowAccountListHelper(result, &limit); } @@ -4542,10 +4542,10 @@ bool ChatHandler::ShowAccountListHelper(QueryResult* result, uint32* limit, bool if (m_session) PSendSysMessage(LANG_ACCOUNT_LIST_LINE_CHAT, - account,fields[1].GetString(),char_name,fields[2].GetString(),fields[3].GetUInt32(),fields[4].GetUInt32()); + account, fields[1].GetString(), char_name, fields[2].GetString(), fields[3].GetUInt32(), fields[4].GetUInt32()); else PSendSysMessage(LANG_ACCOUNT_LIST_LINE_CONSOLE, - account,fields[1].GetString(),char_name,fields[2].GetString(),fields[3].GetUInt32(),fields[4].GetUInt32()); + account, fields[1].GetString(), char_name, fields[2].GetString(), fields[3].GetUInt32(), fields[4].GetUInt32()); } while (result->NextRow()); @@ -4571,7 +4571,7 @@ bool ChatHandler::HandleLookupPlayerIpCommand(char* args) std::string ip = ipStr; LoginDatabase.escape_string(ip); - QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), ip.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE last_ip "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), ip.c_str()); return LookupPlayerSearchCommand(result, &limit); } @@ -4592,7 +4592,7 @@ bool ChatHandler::HandleLookupPlayerAccountCommand(char* args) LoginDatabase.escape_string(account); - QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), account.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE username "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), account.c_str()); return LookupPlayerSearchCommand(result, &limit); } @@ -4610,7 +4610,7 @@ bool ChatHandler::HandleLookupPlayerEmailCommand(char* args) std::string email = emailStr; LoginDatabase.escape_string(email); - QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"), email.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT id,username FROM account WHERE email "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), email.c_str()); return LookupPlayerSearchCommand(result, &limit); } @@ -4646,8 +4646,8 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, uint32* limit) { if (chars->GetRowCount()) { - PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT,acc_name.c_str(),acc_id); - ShowPlayerListHelper(chars,limit,true,false); + PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, acc_name.c_str(), acc_id); + ShowPlayerListHelper(chars, limit, true, false); } else delete chars; @@ -4705,7 +4705,7 @@ bool ChatHandler::HandleLookupPoolCommand(char* args) ++counter; } - if (counter==0) + if (counter == 0) SendSysMessage(LANG_NO_POOL); return true; @@ -4736,7 +4736,7 @@ bool ChatHandler::HandlePoolListCommand(char* args) } } - if (counter==0) + if (counter == 0) PSendSysMessage(LANG_NO_POOL_FOR_MAP, mapState->GetMapEntry()->name[GetSessionDbcLocale()], mapState->GetMapId()); return true; @@ -5062,18 +5062,18 @@ bool ChatHandler::HandleLookupTitleCommand(char* args) { char const* knownStr = target && target->HasTitle(titleInfo) ? GetMangosString(LANG_KNOWN) : ""; - char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE)==titleInfo->bit_index + char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index ? GetMangosString(LANG_ACTIVE) : ""; char titleNameStr[80]; - snprintf(titleNameStr,80,name.c_str(),targetName); + snprintf(titleNameStr, 80, name.c_str(), targetName); // send title in "id (idx:idx) - [namedlink locale]" format if (m_session) - PSendSysMessage(LANG_TITLE_LIST_CHAT,id,titleInfo->bit_index,id,titleNameStr,localeNames[loc],knownStr,activeStr); + PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleNameStr, localeNames[loc], knownStr, activeStr); else - PSendSysMessage(LANG_TITLE_LIST_CONSOLE,id,titleInfo->bit_index,titleNameStr,localeNames[loc],knownStr,activeStr); + PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, titleNameStr, localeNames[loc], knownStr, activeStr); ++counter; } @@ -5122,7 +5122,7 @@ bool ChatHandler::HandleTitlesAddCommand(char* args) char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); + snprintf(titleNameStr, 80, titleInfo->name[GetSessionDbcLocale()], targetName); target->SetTitle(titleInfo); PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); @@ -5164,19 +5164,19 @@ bool ChatHandler::HandleTitlesRemoveCommand(char* args) return false; } - target->SetTitle(titleInfo,true); + target->SetTitle(titleInfo, true); std::string tNameLink = GetNameLink(target); char const* targetName = target->GetName(); char titleNameStr[80]; - snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); + snprintf(titleNameStr, 80, titleInfo->name[GetSessionDbcLocale()], targetName); PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) { - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + target->SetUInt32Value(PLAYER_CHOSEN_TITLE, 0); PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str()); } @@ -5250,7 +5250,7 @@ bool ChatHandler::HandleCharacterTitlesCommand(char* args) : ""; char titleNameStr[80]; - snprintf(titleNameStr,80,name.c_str(),targetName); + snprintf(titleNameStr, 80, name.c_str(), targetName); // send title in "id (idx:idx) - [namedlink locale]" format if (m_session) @@ -5299,7 +5299,7 @@ bool ChatHandler::HandleTitlesCurrentCommand(char* args) std::string tNameLink = GetNameLink(target); target->SetTitle(titleInfo); // to be sure that title now known - target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index); + target->SetUInt32Value(PLAYER_CHOSEN_TITLE, titleInfo->bit_index); PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[GetSessionDbcLocale()], tNameLink.c_str()); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index ac7f5efb2..e5e2be5be 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -274,7 +274,7 @@ bool ChatHandler::HandleReloadAllLootCommand(char* /*args*/) bool ChatHandler::HandleReloadAllNpcCommand(char* args) { - if (*args!='a') // will be reloaded from all_gossips + if (*args != 'a') // will be reloaded from all_gossips HandleReloadNpcGossipCommand((char*)"a"); HandleReloadNpcTrainerCommand((char*)"a"); HandleReloadNpcVendorCommand((char*)"a"); @@ -344,7 +344,7 @@ bool ChatHandler::HandleReloadAllSpellCommand(char* /*args*/) bool ChatHandler::HandleReloadAllGossipsCommand(char* args) { - if (*args!='a') // already reload from all_scripts + if (*args != 'a') // already reload from all_scripts HandleReloadGossipScriptsCommand((char*)"a"); HandleReloadGossipMenuCommand((char*)"a"); HandleReloadNpcGossipCommand((char*)"a"); @@ -463,12 +463,12 @@ bool ChatHandler::HandleReloadGossipScriptsCommand(char* args) return false; } - if (*args!='a') + if (*args != 'a') sLog.outString("Re-Loading Scripts from `gossip_scripts`..."); sScriptMgr.LoadGossipScripts(); - if (*args!='a') + if (*args != 'a') SendGlobalSysMessage("DB table `gossip_scripts` reloaded."); return true; @@ -876,13 +876,13 @@ bool ChatHandler::HandleReloadGameObjectScriptsCommand(char* args) return false; } - if (*args!='a') + if (*args != 'a') sLog.outString("Re-Loading Scripts from `gameobject_[template]_scripts`..."); sScriptMgr.LoadGameObjectScripts(); sScriptMgr.LoadGameObjectTemplateScripts(); - if (*args!='a') + if (*args != 'a') SendGlobalSysMessage("DB table `gameobject_[template]_scripts` reloaded."); return true; @@ -897,12 +897,12 @@ bool ChatHandler::HandleReloadEventScriptsCommand(char* args) return false; } - if (*args!='a') + if (*args != 'a') sLog.outString("Re-Loading Scripts from `event_scripts`..."); sScriptMgr.LoadEventScripts(); - if (*args!='a') + if (*args != 'a') SendGlobalSysMessage("DB table `event_scripts` reloaded."); return true; @@ -1155,7 +1155,7 @@ 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)) + if (HasLowerSecurityAccount(NULL, targetAccountId, true)) return false; /// account can't set security to same or grater level, need more power GM or console @@ -1169,7 +1169,7 @@ bool ChatHandler::HandleAccountSetGmLevelCommand(char* args) if (targetPlayer) { - ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED,GetNameLink().c_str(), gm); + ChatHandler(targetPlayer).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED, GetNameLink().c_str(), gm); targetPlayer->GetSession()->SetSecurity(AccountTypes(gm)); } @@ -1196,10 +1196,10 @@ bool ChatHandler::HandleAccountSetPasswordCommand(char* args) /// can set password only for target with less security /// This is also reject self apply in fact - if (HasLowerSecurityAccount(NULL,targetAccountId,true)) + if (HasLowerSecurityAccount(NULL, targetAccountId, true)) return false; - if (strcmp(szPassword1,szPassword2)) + if (strcmp(szPassword1, szPassword2)) { SendSysMessage(LANG_NEW_PASSWORDS_NOT_MATCH); SetSentErrorMessage(true); @@ -1214,7 +1214,7 @@ bool ChatHandler::HandleAccountSetPasswordCommand(char* args) SendSysMessage(LANG_COMMAND_PASSWORD); break; case AOR_NAME_NOT_EXIST: - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,account_name.c_str()); + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, account_name.c_str()); SetSentErrorMessage(true); return false; case AOR_PASS_TOO_LONG: @@ -1605,7 +1605,7 @@ bool ChatHandler::HandleUnLearnCommand(char* args) 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); @@ -1641,13 +1641,13 @@ bool ChatHandler::HandleCooldownCommand(char* args) if (!sSpellStore.LookupEntry(spell_id)) { - PSendSysMessage(LANG_UNKNOWN_SPELL, target==m_session->GetPlayer() ? GetMangosString(LANG_YOU) : tNameLink.c_str()); + PSendSysMessage(LANG_UNKNOWN_SPELL, target == m_session->GetPlayer() ? GetMangosString(LANG_YOU) : tNameLink.c_str()); SetSentErrorMessage(true); return false; } - target->RemoveSpellCooldown(spell_id,true); - PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target==m_session->GetPlayer() ? GetMangosString(LANG_YOU) : tNameLink.c_str()); + target->RemoveSpellCooldown(spell_id, true); + PSendSysMessage(LANG_REMOVE_COOLDOWN, spell_id, target == m_session->GetPlayer() ? GetMangosString(LANG_YOU) : tNameLink.c_str()); } return true; } @@ -2267,9 +2267,9 @@ bool ChatHandler::HandleLearnAllCommand(char* /*args*/) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); continue; } @@ -2307,9 +2307,9 @@ bool ChatHandler::HandleLearnAllGMCommand(char* /*args*/) uint32 spell = atol((char*)gmSpellList[gmSpellIter++]); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); continue; } @@ -2345,7 +2345,7 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(char* /*args*/) continue; // skip server-side/triggered spells - if (spellInfo->spellLevel==0) + if (spellInfo->spellLevel == 0) continue; // skip wrong class/race skills @@ -2362,7 +2362,7 @@ bool ChatHandler::HandleLearnAllMySpellsCommand(char* /*args*/) continue; // skip broken spells - if (!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer(), false)) continue; m_session->GetPlayer()->learnSpell(spellInfo->Id, false); @@ -2393,9 +2393,9 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(char* /*args*/) // search highest talent rank uint32 spellid = 0; - for (int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { - if (talentInfo->RankID[rank]!=0) + if (talentInfo->RankID[rank] != 0) { spellid = talentInfo->RankID[rank]; break; @@ -2406,7 +2406,7 @@ bool ChatHandler::HandleLearnAllMyTalentsCommand(char* /*args*/) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer(), false)) continue; // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) @@ -2465,15 +2465,15 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(char* /*args*/) continue; // prevent learn talent for different family (cheating) - if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)==0) + if (((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask) == 0) continue; // search highest talent rank uint32 spellid = 0; - for (int rank = MAX_TALENT_RANK-1; rank >= 0; --rank) + for (int rank = MAX_TALENT_RANK - 1; rank >= 0; --rank) { - if (talentInfo->RankID[rank]!=0) + if (talentInfo->RankID[rank] != 0) { spellid = talentInfo->RankID[rank]; break; @@ -2484,7 +2484,7 @@ bool ChatHandler::HandleLearnAllMyPetTalentsCommand(char* /*args*/) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellid); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer(),false)) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer(), false)) continue; // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree) @@ -2516,7 +2516,7 @@ bool ChatHandler::HandleLearnAllDefaultCommand(char* args) target->learnDefaultSpells(); target->learnQuestRewardedSpells(); - PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST,GetNameLink(target).c_str()); + PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST, GetNameLink(target).c_str()); return true; } @@ -2541,9 +2541,9 @@ bool ChatHandler::HandleLearnCommand(char* args) return false; SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); - if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); SetSentErrorMessage(true); return false; } @@ -2553,7 +2553,7 @@ bool ChatHandler::HandleLearnCommand(char* args) if (targetPlayer == m_session->GetPlayer()) SendSysMessage(LANG_YOU_KNOWN_SPELL); else - PSendSysMessage(LANG_TARGET_KNOWN_SPELL,GetNameLink(targetPlayer).c_str()); + PSendSysMessage(LANG_TARGET_KNOWN_SPELL, GetNameLink(targetPlayer).c_str()); SetSentErrorMessage(true); return false; } @@ -2638,16 +2638,16 @@ bool ChatHandler::HandleAddItemCommand(char* args) Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId)); // remove binding (let GM give it to another player later) - if (pl==plTarget) + if (pl == plTarget) for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) if (Item* item1 = pl->GetItemByPos(itr->pos)) item1->SetBinding(false); if (count > 0 && item) { - pl->SendNewItem(item,count,false,true); - if (pl!=plTarget) - plTarget->SendNewItem(item,count,true,false); + pl->SendNewItem(item, count, false, true); + if (pl != plTarget) + plTarget->SendNewItem(item, count, true, false); } if (noSpaceForCount > 0) @@ -2665,7 +2665,7 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) // prevent generation all items with itemset field value '0' if (itemsetId == 0) { - PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); + PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemsetId); SetSentErrorMessage(true); return false; } @@ -2694,12 +2694,12 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) Item* item = plTarget->StoreNewItem(dest, pProto->ItemId, true); // remove binding (let GM give it to another player later) - if (pl==plTarget) + if (pl == plTarget) item->SetBinding(false); - pl->SendNewItem(item,1,false,true); - if (pl!=plTarget) - plTarget->SendNewItem(item,1,true,false); + pl->SendNewItem(item, 1, false, true); + if (pl != plTarget) + plTarget->SendNewItem(item, 1, true, false); } else { @@ -2711,7 +2711,7 @@ bool ChatHandler::HandleAddItemSetCommand(char* args) if (!found) { - PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND,itemsetId); + PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemsetId); SetSentErrorMessage(true); return false; @@ -2749,19 +2749,19 @@ bool ChatHandler::HandleListItemCommand(char* args) // inventory case uint32 inv_count = 0; - result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id); + result = CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'", item_id); if (result) { inv_count = (*result)[0].GetUInt32(); delete result; } - result=CharacterDatabase.PQuery( - // 0 1 2 3 4 5 - "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " - "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " - "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", - item_id,uint32(count)); + result = CharacterDatabase.PQuery( + // 0 1 2 3 4 5 + "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name " + "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters " + "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ", + item_id, uint32(count)); if (result) { @@ -2776,17 +2776,17 @@ bool ChatHandler::HandleListItemCommand(char* args) std::string owner_name = fields[5].GetCppString(); char const* item_pos = 0; - if (Player::IsEquipmentPos(item_bag,item_slot)) + if (Player::IsEquipmentPos(item_bag, item_slot)) item_pos = "[equipped]"; - else if (Player::IsInventoryPos(item_bag,item_slot)) + else if (Player::IsInventoryPos(item_bag, item_slot)) item_pos = "[in inventory]"; - else if (Player::IsBankPos(item_bag,item_slot)) + else if (Player::IsBankPos(item_bag, item_slot)) item_pos = "[in bank]"; else item_pos = ""; PSendSysMessage(LANG_ITEMLIST_SLOT, - item_guid,owner_name.c_str(),owner_guid,owner_acc,item_pos); + item_guid, owner_name.c_str(), owner_guid, owner_acc, item_pos); } while (result->NextRow()); @@ -2795,14 +2795,14 @@ bool ChatHandler::HandleListItemCommand(char* args) delete result; if (count > res_count) - count-=res_count; + count -= res_count; else if (count) count = 0; } // mail case uint32 mail_count = 0; - result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id); + result = CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id); if (result) { mail_count = (*result)[0].GetUInt32(); @@ -2811,12 +2811,12 @@ bool ChatHandler::HandleListItemCommand(char* args) if (count > 0) { - result=CharacterDatabase.PQuery( - // 0 1 2 3 4 5 6 - "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " - "FROM mail,mail_items,characters as char_s,characters as char_r " - "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", - item_id,uint32(count)); + result = CharacterDatabase.PQuery( + // 0 1 2 3 4 5 6 + "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name " + "FROM mail,mail_items,characters as char_s,characters as char_r " + "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u", + item_id, uint32(count)); } else result = NULL; @@ -2837,7 +2837,7 @@ bool ChatHandler::HandleListItemCommand(char* args) char const* item_pos = "[in mail]"; PSendSysMessage(LANG_ITEMLIST_MAIL, - item_guid,item_s_name.c_str(),item_s,item_s_acc,item_r_name.c_str(),item_r,item_r_acc,item_pos); + item_guid, item_s_name.c_str(), item_s, item_s_acc, item_r_name.c_str(), item_r, item_r_acc, item_pos); } while (result->NextRow()); @@ -2846,14 +2846,14 @@ bool ChatHandler::HandleListItemCommand(char* args) delete result; if (count > res_count) - count-=res_count; + count -= res_count; else if (count) count = 0; } // auction case uint32 auc_count = 0; - result=CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auction WHERE item_template='%u'",item_id); + result = CharacterDatabase.PQuery("SELECT COUNT(item_template) FROM auction WHERE item_template='%u'", item_id); if (result) { auc_count = (*result)[0].GetUInt32(); @@ -2862,11 +2862,11 @@ bool ChatHandler::HandleListItemCommand(char* args) if (count > 0) { - result=CharacterDatabase.PQuery( - // 0 1 2 3 - "SELECT auction.itemguid, auction.itemowner, characters.account, characters.name " - "FROM auction,characters WHERE auction.item_template='%u' AND characters.guid = auction.itemowner LIMIT %u", - item_id,uint32(count)); + result = CharacterDatabase.PQuery( + // 0 1 2 3 + "SELECT auction.itemguid, auction.itemowner, characters.account, characters.name " + "FROM auction,characters WHERE auction.item_template='%u' AND characters.guid = auction.itemowner LIMIT %u", + item_id, uint32(count)); } else result = NULL; @@ -2883,7 +2883,7 @@ bool ChatHandler::HandleListItemCommand(char* args) char const* item_pos = "[in auction]"; - PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc,item_pos); + PSendSysMessage(LANG_ITEMLIST_AUCTION, item_guid, owner_name.c_str(), owner, owner_acc, item_pos); } while (result->NextRow()); @@ -2892,18 +2892,18 @@ bool ChatHandler::HandleListItemCommand(char* args) // guild bank case uint32 guild_count = 0; - result=CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id); + result = CharacterDatabase.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'", item_id); if (result) { guild_count = (*result)[0].GetUInt32(); delete result; } - result=CharacterDatabase.PQuery( - // 0 1 2 - "SELECT gi.item_guid, gi.guildid, guild.name " - "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", - item_id,uint32(count)); + result = CharacterDatabase.PQuery( + // 0 1 2 + "SELECT gi.item_guid, gi.guildid, guild.name " + "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ", + item_id, uint32(count)); if (result) { @@ -2916,7 +2916,7 @@ bool ChatHandler::HandleListItemCommand(char* args) char const* item_pos = "[in guild bank]"; - PSendSysMessage(LANG_ITEMLIST_GUILD,item_guid,guild_name.c_str(),guild_guid,item_pos); + PSendSysMessage(LANG_ITEMLIST_GUILD, item_guid, guild_name.c_str(), guild_guid, item_pos); } while (result->NextRow()); @@ -2925,19 +2925,19 @@ bool ChatHandler::HandleListItemCommand(char* args) delete result; if (count > res_count) - count-=res_count; + count -= res_count; else if (count) count = 0; } - if (inv_count+mail_count+auc_count+guild_count == 0) + if (inv_count + mail_count + auc_count + guild_count == 0) { SendSysMessage(LANG_COMMAND_NOITEMFOUND); SetSentErrorMessage(true); return false; } - PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE,item_id,inv_count+mail_count+auc_count+guild_count,inv_count,mail_count,auc_count,guild_count); + PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE, item_id, inv_count + mail_count + auc_count + guild_count, inv_count, mail_count, auc_count, guild_count); return true; } @@ -2982,11 +2982,11 @@ bool ChatHandler::HandleListObjectCommand(char* args) { Player* pl = m_session->GetPlayer(); result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),go_id,uint32(count)); + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), go_id, uint32(count)); } else result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u", - go_id,uint32(count)); + go_id, uint32(count)); if (result) { @@ -3042,7 +3042,7 @@ bool ChatHandler::HandleListCreatureCommand(char* args) QueryResult* result; uint32 cr_count = 0; - result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id); + result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'", cr_id); if (result) { cr_count = (*result)[0].GetUInt32(); @@ -3053,11 +3053,11 @@ bool ChatHandler::HandleListCreatureCommand(char* args) { Player* pl = m_session->GetPlayer(); result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", - pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id,uint32(count)); + pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), cr_id, uint32(count)); } else result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", - cr_id,uint32(count)); + cr_id, uint32(count)); if (result) { @@ -3117,7 +3117,7 @@ bool ChatHandler::HandleLookupItemCommand(char* args) std::wstring wnamepart; // converting string that we try to find to lower case - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; wstrToLower(wnamepart); @@ -3144,7 +3144,7 @@ bool ChatHandler::HandleLookupItemCommand(char* args) ++counter; } - if (counter==0) + if (counter == 0) SendSysMessage(LANG_COMMAND_NOITEMFOUND); return true; @@ -3158,7 +3158,7 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; // converting string that we try to find to lower case @@ -3182,7 +3182,7 @@ bool ChatHandler::HandleLookupItemSetCommand(char* args) loc = 0; for (; loc < MAX_LOCALE; ++loc) { - if (loc==GetSessionDbcLocale()) + if (loc == GetSessionDbcLocale()) continue; name = set->name[loc]; @@ -3198,9 +3198,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]); + PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), localeNames[loc]); ++counter; } } @@ -3221,7 +3221,7 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; // converting string that we try to find to lower case @@ -3245,7 +3245,7 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) loc = 0; for (; loc < MAX_LOCALE; ++loc) { - if (loc==GetSessionDbcLocale()) + if (loc == GetSessionDbcLocale()) continue; name = skillInfo->name[loc]; @@ -3270,14 +3270,14 @@ bool ChatHandler::HandleLookupSkillCommand(char* args) uint32 tempValue = target->GetSkillTempBonusValue(id); char const* valFormat = GetMangosString(LANG_SKILL_VALUES); - snprintf(valStr,50,valFormat,curValue,maxValue,permValue,tempValue); + snprintf(valStr, 50, valFormat, curValue, maxValue, permValue, tempValue); } // 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); + PSendSysMessage(LANG_SKILL_LIST_CONSOLE, id, name.c_str(), localeNames[loc], knownStr, valStr); ++counter; } @@ -3346,7 +3346,7 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; // converting string that we try to find to lower case @@ -3370,7 +3370,7 @@ bool ChatHandler::HandleLookupSpellCommand(char* args) loc = 0; for (; loc < MAX_LOCALE; ++loc) { - if (loc==GetSessionDbcLocale()) + if (loc == GetSessionDbcLocale()) continue; name = spellInfo->SpellName[loc]; @@ -3439,7 +3439,7 @@ bool ChatHandler::HandleLookupQuestCommand(char* args) std::wstring wnamepart; // converting string that we try to find to lower case - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; wstrToLower(wnamepart); @@ -3463,7 +3463,7 @@ bool ChatHandler::HandleLookupQuestCommand(char* args) ++counter; } - if (counter==0) + if (counter == 0) SendSysMessage(LANG_COMMAND_NOQUESTFOUND); return true; @@ -3478,14 +3478,14 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) std::wstring wnamepart; // converting string that we try to find to lower case - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; wstrToLower(wnamepart); uint32 counter = 0; - for (uint32 id = 0; id< sCreatureStorage.MaxEntry; ++id) + for (uint32 id = 0; id < sCreatureStorage.MaxEntry; ++id) { CreatureInfo const* cInfo = sCreatureStorage.LookupEntry (id); if (!cInfo) @@ -3510,7 +3510,7 @@ bool ChatHandler::HandleLookupCreatureCommand(char* args) ++counter; } - if (counter==0) + if (counter == 0) SendSysMessage(LANG_COMMAND_NOCREATUREFOUND); return true; @@ -3525,14 +3525,14 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) std::wstring wnamepart; // converting string that we try to find to lower case - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; wstrToLower(wnamepart); uint32 counter = 0; - for (uint32 id = 0; id< sGOStorage.MaxEntry; id++) + for (uint32 id = 0; id < sGOStorage.MaxEntry; id++) { GameObjectInfo const* gInfo = sGOStorage.LookupEntry(id); if (!gInfo) @@ -3575,7 +3575,7 @@ bool ChatHandler::HandleLookupObjectCommand(char* args) } } - if (counter==0) + if (counter == 0) SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND); return true; @@ -3589,7 +3589,7 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) std::string namepart = args; std::wstring wnamepart; - if (!Utf8toWStr(namepart,wnamepart)) + if (!Utf8toWStr(namepart, wnamepart)) return false; // converting string that we try to find to lower case @@ -3613,7 +3613,7 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) loc = 0; for (; loc < MAX_LOCALE; ++loc) { - if (loc==GetSessionDbcLocale()) + if (loc == GetSessionDbcLocale()) continue; name = nodeEntry->name[loc]; @@ -3629,11 +3629,11 @@ bool ChatHandler::HandleLookupTaxiNodeCommand(char* args) { // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format if (m_session) - PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, id, id, name.c_str(),localeNames[loc], - nodeEntry->map_id,nodeEntry->x,nodeEntry->y,nodeEntry->z); + PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, id, id, name.c_str(), localeNames[loc], + nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z); else PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, id, name.c_str(), localeNames[loc], - nodeEntry->map_id,nodeEntry->x,nodeEntry->y,nodeEntry->z); + nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z); ++counter; } } @@ -3705,7 +3705,7 @@ bool ChatHandler::HandleGuildInviteCommand(char* args) return false; // player's guild membership checked in AddMember before add - if (!targetGuild->AddMember(target_guid,targetGuild->GetLowestRank())) + if (!targetGuild->AddMember(target_guid, targetGuild->GetLowestRank())) return false; return true; @@ -3824,7 +3824,7 @@ bool ChatHandler::HandleGetDistanceCommand(char* args) dy = player->GetPositionY() - obj->GetPositionY(); dz = player->GetPositionZ() - obj->GetPositionZ(); - PSendSysMessage(LANG_DISTANCE, player->GetDistance(obj), player->GetDistance2d(obj), sqrt(dx*dx + dy*dy + dz*dz)); + PSendSysMessage(LANG_DISTANCE, player->GetDistance(obj), player->GetDistance2d(obj), sqrt(dx * dx + dy * dy + dz * dz)); return true; } @@ -3840,7 +3840,7 @@ bool ChatHandler::HandleDieCommand(char* /*args*/) return false; } - if (target->GetTypeId()==TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER) { if (HasLowerSecurity((Player*)target, ObjectGuid(), false)) return false; @@ -3875,7 +3875,7 @@ bool ChatHandler::HandleDamageCommand(char* args) if (!ExtractInt32(&args, damage_int)) return false; - if (damage_int <=0) + if (damage_int <= 0) return true; uint32 damage = damage_int; @@ -3907,14 +3907,14 @@ bool ChatHandler::HandleDamageCommand(char* args) uint32 absorb = 0; uint32 resist = 0; - target->CalculateDamageAbsorbAndResist(m_session->GetPlayer(),schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + target->CalculateDamageAbsorbAndResist(m_session->GetPlayer(), schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); if (damage <= absorb + resist) return true; damage -= absorb + resist; - m_session->GetPlayer()->DealDamageMods(target,damage,&absorb); + m_session->GetPlayer()->DealDamageMods(target, damage, &absorb); m_session->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false); m_session->GetPlayer()->SendAttackStateUpdate(HITINFO_NORMALSWING2, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_NORMAL, 0); return true; @@ -4002,7 +4002,7 @@ bool ChatHandler::HandleAuraCommand(char* args) for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) { uint8 eff = spellInfo->Effect[i]; - if (eff>=TOTAL_SPELL_EFFECTS) + if (eff >= TOTAL_SPELL_EFFECTS) continue; if (IsAreaAuraEffect(eff) || eff == SPELL_EFFECT_APPLY_AURA || @@ -4055,9 +4055,9 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) Team g_team; if (!teamStr) g_team = TEAM_BOTH_ALLOWED; - else if (strncmp(teamStr, "horde", strlen(teamStr))==0) + else if (strncmp(teamStr, "horde", strlen(teamStr)) == 0) g_team = HORDE; - else if (strncmp(teamStr, "alliance", strlen(teamStr))==0) + else if (strncmp(teamStr, "alliance", strlen(teamStr)) == 0) g_team = ALLIANCE; else return false; @@ -4075,7 +4075,7 @@ bool ChatHandler::HandleLinkGraveCommand(char* args) uint32 zoneId = player->GetZoneId(); AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(zoneId); - if (!areaEntry || areaEntry->zone !=0) + if (!areaEntry || areaEntry->zone != 0) { PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE, g_id, zoneId); SetSentErrorMessage(true); @@ -4213,17 +4213,17 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/) uint32 Entry = target->GetEntry(); CreatureInfo const* cInfo = target->GetCreatureInfo(); - time_t curRespawnDelay = target->GetRespawnTimeEx()-time(NULL); + time_t curRespawnDelay = target->GetRespawnTimeEx() - time(NULL); if (curRespawnDelay < 0) curRespawnDelay = 0; - std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay,true); - std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(),true); + std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay, true); + std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true); // Send information dependend on difficulty mode CreatureInfo const* baseInfo = ObjectMgr::GetCreatureTemplate(Entry); uint32 diff = 1; for (; diff < MAX_DIFFICULTY; ++diff) - if (baseInfo->DifficultyEntry[diff-1] == target->GetCreatureInfo()->Entry) + if (baseInfo->DifficultyEntry[diff - 1] == target->GetCreatureInfo()->Entry) break; if (diff < MAX_DIFFICULTY) @@ -4234,12 +4234,12 @@ bool ChatHandler::HandleNpcInfoCommand(char* /*args*/) PSendSysMessage(LANG_NPCINFO_CHAR, target->GetGuidStr().c_str(), faction, npcflags, Entry, displayid, nativeid); PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel()); - PSendSysMessage(LANG_NPCINFO_HEALTH,target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); + PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->getFaction()); - PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(),curRespawnDelayStr.c_str()); - PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid,cInfo->pickpocketLootId,cInfo->SkinLootId); + PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str()); + PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId); PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); - PSendSysMessage(LANG_NPCINFO_POSITION,float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); + PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); if ((npcflags & UNIT_NPC_FLAG_VENDOR)) { @@ -4362,24 +4362,24 @@ 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) + for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) { if (flag != 0) { - m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0xFFFFFFFF); + m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1 + i, 0xFFFFFFFF); } else { - m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i,0); + m_session->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1 + i, 0); } } @@ -4392,16 +4392,16 @@ void ChatHandler::HandleCharacterLevel(Player* player, ObjectGuid player_guid, u { player->GiveLevel(newlevel); player->InitTalentForLevel(); - player->SetUInt32Value(PLAYER_XP,0); + player->SetUInt32Value(PLAYER_XP, 0); 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); + ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_UP, GetNameLink().c_str(), newlevel); else // if(oldlevel > newlevel) - ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN,GetNameLink().c_str(),newlevel); + ChatHandler(player).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, GetNameLink().c_str(), newlevel); } } else @@ -4453,7 +4453,7 @@ bool ChatHandler::HandleCharacterLevelCommand(char* args) if (!m_session || m_session->GetPlayer() != target) // including player==NULL { std::string nameLink = playerLink(target_name); - PSendSysMessage(LANG_YOU_CHANGE_LVL,nameLink.c_str(),newlevel); + PSendSysMessage(LANG_YOU_CHANGE_LVL, nameLink.c_str(), newlevel); } return true; @@ -4498,7 +4498,7 @@ bool ChatHandler::HandleLevelUpCommand(char* args) if (!m_session || m_session->GetPlayer() != target) // including chr==NULL { std::string nameLink = playerLink(target_name); - PSendSysMessage(LANG_YOU_CHANGE_LVL,nameLink.c_str(),newlevel); + PSendSysMessage(LANG_YOU_CHANGE_LVL, nameLink.c_str(), newlevel); } return true; @@ -4552,7 +4552,7 @@ bool ChatHandler::HandleHideAreaCommand(char* args) int offset = area / 32; uint32 val = (uint32)(1 << (area % 32)); - if (area<0 || offset >= PLAYER_EXPLORED_ZONES_SIZE) + if (area < 0 || offset >= PLAYER_EXPLORED_ZONES_SIZE) { SendSysMessage(LANG_BAD_VALUE); SetSentErrorMessage(true); @@ -4631,15 +4631,15 @@ bool ChatHandler::HandleAuctionItemCommand(char* args) if (!ExtractOptUInt32(&args, buyout, 0)) return false; - uint32 etime = 4*MIN_AUCTION_TIME; + 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; + etime = 2 * MIN_AUCTION_TIME; else if (strncmp(timeStr, "verylong", strlen(timeStr)) == 0) - etime = 4*MIN_AUCTION_TIME; + etime = 4 * MIN_AUCTION_TIME; else return false; } @@ -4755,7 +4755,7 @@ bool ChatHandler::HandleTeleAddCommand(char* args) if (!*args) return false; - Player* player=m_session->GetPlayer(); + Player* player = m_session->GetPlayer(); if (!player) return false; @@ -4844,7 +4844,7 @@ bool ChatHandler::HandleListAurasCommand(char* /*args*/) PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, holder->GetId(), aur->GetEffIndex(), aur->GetModifier()->m_auraname, aur->GetAuraDuration(), aur->GetAuraMaxDuration(), ss_name.str().c_str(), - (holder->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + (holder->IsPassive() ? passiveStr : ""), (talent ? talentStr : ""), holder->GetCasterGuid().GetString().c_str()); } else @@ -4852,7 +4852,7 @@ bool ChatHandler::HandleListAurasCommand(char* /*args*/) PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, holder->GetId(), aur->GetEffIndex(), aur->GetModifier()->m_auraname, aur->GetAuraDuration(), aur->GetAuraMaxDuration(), name, - (holder->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + (holder->IsPassive() ? passiveStr : ""), (talent ? talentStr : ""), holder->GetCasterGuid().GetString().c_str()); } } @@ -4874,13 +4874,13 @@ bool ChatHandler::HandleListAurasCommand(char* /*args*/) ss_name << "|cffffffff|Hspell:" << (*itr)->GetId() << "|h[" << name << "]|h|r"; PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), - ss_name.str().c_str(),((*itr)->GetHolder()->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + ss_name.str().c_str(), ((*itr)->GetHolder()->IsPassive() ? passiveStr : ""), (talent ? talentStr : ""), (*itr)->GetCasterGuid().GetString().c_str()); } else { PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE, (*itr)->GetId(), (*itr)->GetEffIndex(), - name,((*itr)->GetHolder()->IsPassive() ? passiveStr : ""),(talent ? talentStr : ""), + name, ((*itr)->GetHolder()->IsPassive() ? passiveStr : ""), (talent ? talentStr : ""), (*itr)->GetCasterGuid().GetString().c_str()); } } @@ -4961,7 +4961,7 @@ static bool HandleResetStatsOrLevelHelper(Player* player) ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(player->getClass()); if (!cEntry) { - sLog.outError("Class %u not found in DBC (Wrong DBC files?)",player->getClass()); + sLog.outError("Class %u not found in DBC (Wrong DBC files?)", player->getClass()); return false; } @@ -5015,7 +5015,7 @@ bool ChatHandler::HandleResetLevelCommand(char* args) target->InitTaxiNodesForLevel(); target->InitGlyphsForLevel(); target->InitTalentForLevel(); - target->SetUInt32Value(PLAYER_XP,0); + target->SetUInt32Value(PLAYER_XP, 0); target->_ApplyAllLevelScaleItemMods(true); @@ -5057,13 +5057,13 @@ bool ChatHandler::HandleResetSpellsCommand(char* args) target->resetSpells(); ChatHandler(target).SendSysMessage(LANG_RESET_SPELLS); - if (!m_session || m_session->GetPlayer()!=target) - PSendSysMessage(LANG_RESET_SPELLS_ONLINE,GetNameLink(target).c_str()); + if (!m_session || m_session->GetPlayer() != target) + PSendSysMessage(LANG_RESET_SPELLS_ONLINE, GetNameLink(target).c_str()); } else { - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS), target_guid.GetCounter()); - PSendSysMessage(LANG_RESET_SPELLS_OFFLINE,target_name.c_str()); + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'", uint32(AT_LOGIN_RESET_SPELLS), target_guid.GetCounter()); + PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, target_name.c_str()); } return true; @@ -5079,12 +5079,12 @@ bool ChatHandler::HandleResetSpecsCommand(char* args) if (target) { - target->resetTalents(true,true); + target->resetTalents(true, true); target->SendTalentsInfoData(false); 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); @@ -5124,7 +5124,7 @@ bool ChatHandler::HandleResetTalentsCommand(char* args) ChatHandler((Player*)owner).SendSysMessage(LANG_RESET_PET_TALENTS); if (!m_session || m_session->GetPlayer() != ((Player*)owner)) - PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE,GetNameLink((Player*)owner).c_str()); + PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE, GetNameLink((Player*)owner).c_str()); } return true; } @@ -5140,7 +5140,7 @@ bool ChatHandler::HandleResetTalentsCommand(char* args) target->SendTalentsInfoData(false); 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); @@ -5164,14 +5164,14 @@ bool ChatHandler::HandleResetAllCommand(char* args) AtLoginFlags atLogin; // Command specially created as single command to prevent using short case names - if (casename=="spells") + if (casename == "spells") { atLogin = AT_LOGIN_RESET_SPELLS; sWorld.SendWorldText(LANG_RESETALL_SPELLS); if (!m_session) SendSysMessage(LANG_RESETALL_SPELLS); } - else if (casename=="talents") + else if (casename == "talents") { atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS); sWorld.SendWorldText(LANG_RESETALL_TALENTS); @@ -5255,7 +5255,7 @@ bool ChatHandler::HandleServerIdleRestartCommand(char* args) if (exitcode > 125) return false; - sWorld.ShutdownServ(delay, SHUTDOWN_MASK_RESTART|SHUTDOWN_MASK_IDLE, exitcode); + sWorld.ShutdownServ(delay, SHUTDOWN_MASK_RESTART | SHUTDOWN_MASK_IDLE, exitcode); return true; } @@ -5298,7 +5298,7 @@ bool ChatHandler::HandleQuestAddCommand(char* args) Quest const* pQuest = sObjectMgr.GetQuestTemplate(entry); if (!pQuest) { - PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND,entry); + PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry); SetSentErrorMessage(true); return false; } @@ -5359,9 +5359,9 @@ bool ChatHandler::HandleQuestRemoveCommand(char* args) for (uint8 slot = 0; slot < MAX_QUEST_LOG_SIZE; ++slot) { uint32 quest = player->GetQuestSlotQuestId(slot); - if (quest==entry) + if (quest == entry) { - player->SetQuestSlot(slot,0); + player->SetQuestSlot(slot, 0); // we ignore unequippable quest items in this case, its' still be equipped player->TakeQuestSourceItem(quest, false); @@ -5412,14 +5412,14 @@ bool ChatHandler::HandleQuestCompleteCommand(char* args) if (!id || !count) continue; - uint32 curItemCount = player->GetItemCount(id,true); + uint32 curItemCount = player->GetItemCount(id, true); ItemPosCountVec dest; uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, id, count - curItemCount); if (msg == EQUIP_ERR_OK) { Item* item = player->StoreNewItem(dest, id, true); - player->SendNewItem(item,count-curItemCount, true, false); + player->SendNewItem(item, count - curItemCount, true, false); } } @@ -5454,7 +5454,7 @@ 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 @@ -5507,7 +5507,7 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) case BAN_ACCOUNT: if (!AccountMgr::normalizeString(nameOrIP)) { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str()); + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, nameOrIP.c_str()); SetSentErrorMessage(true); return false; } @@ -5526,11 +5526,11 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) break; } - switch (sWorld.BanAccount(mode, nameOrIP, duration_secs, reason,m_session ? m_session->GetPlayerName() : "")) + switch (sWorld.BanAccount(mode, nameOrIP, duration_secs, reason, m_session ? m_session->GetPlayerName() : "")) { 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; @@ -5540,13 +5540,13 @@ bool ChatHandler::HandleBanHelper(BanMode mode, char* args) switch (mode) { default: - PSendSysMessage(LANG_BAN_NOTFOUND,"account", nameOrIP.c_str()); + PSendSysMessage(LANG_BAN_NOTFOUND, "account", nameOrIP.c_str()); break; case BAN_CHARACTER: - PSendSysMessage(LANG_BAN_NOTFOUND,"character", nameOrIP.c_str()); + PSendSysMessage(LANG_BAN_NOTFOUND, "character", nameOrIP.c_str()); break; case BAN_IP: - PSendSysMessage(LANG_BAN_NOTFOUND,"ip", nameOrIP.c_str()); + PSendSysMessage(LANG_BAN_NOTFOUND, "ip", nameOrIP.c_str()); break; } SetSentErrorMessage(true); @@ -5587,7 +5587,7 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) case BAN_ACCOUNT: if (!AccountMgr::normalizeString(nameOrIP)) { - PSendSysMessage(LANG_ACCOUNT_NOT_EXIST,nameOrIP.c_str()); + PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, nameOrIP.c_str()); SetSentErrorMessage(true); return false; } @@ -5606,10 +5606,10 @@ bool ChatHandler::HandleUnBanHelper(BanMode mode, char* args) break; } - if (sWorld.RemoveBanAccount(mode,nameOrIP)) - PSendSysMessage(LANG_UNBAN_UNBANNED,nameOrIP.c_str()); + if (sWorld.RemoveBanAccount(mode, nameOrIP)) + PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str()); else - PSendSysMessage(LANG_UNBAN_ERROR,nameOrIP.c_str()); + PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str()); return true; } @@ -5624,7 +5624,7 @@ bool ChatHandler::HandleBanInfoAccountCommand(char* args) if (!accountid) return false; - return HandleBanInfoHelper(accountid,account_name.c_str()); + return HandleBanInfoHelper(accountid, account_name.c_str()); } bool ChatHandler::HandleBanInfoCharacterCommand(char* args) @@ -5637,37 +5637,37 @@ bool ChatHandler::HandleBanInfoCharacterCommand(char* args) uint32 accountid = target ? target->GetSession()->GetAccountId() : sObjectMgr.GetPlayerAccountIdByGUID(target_guid); std::string accountname; - if (!sAccountMgr.GetName(accountid,accountname)) + if (!sAccountMgr.GetName(accountid, accountname)) { PSendSysMessage(LANG_BANINFO_NOCHARACTER); return true; } - return HandleBanInfoHelper(accountid,accountname.c_str()); + return HandleBanInfoHelper(accountid, accountname.c_str()); } bool ChatHandler::HandleBanInfoHelper(uint32 accountid, char const* accountname) { - QueryResult* result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid); + QueryResult* result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC", accountid); if (!result) { PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountname); return true; } - PSendSysMessage(LANG_BANINFO_BANHISTORY,accountname); + PSendSysMessage(LANG_BANINFO_BANHISTORY, accountname); do { Field* fields = result->Fetch(); time_t unbandate = time_t(fields[3].GetUInt64()); bool active = false; - if (fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 ||unbandate >= time(NULL))) + if (fields[2].GetBool() && (fields[1].GetUInt64() == (uint64)0 || unbandate >= time(NULL))) active = true; bool permanent = (fields[1].GetUInt64() == (uint64)0); - std::string bantime = permanent?GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[1].GetUInt64(), true); + std::string bantime = permanent ? GetMangosString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true); PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].GetString(), bantime.c_str(), active ? GetMangosString(LANG_BANINFO_YES):GetMangosString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); + fields[0].GetString(), bantime.c_str(), active ? GetMangosString(LANG_BANINFO_YES) : GetMangosString(LANG_BANINFO_NO), fields[4].GetString(), fields[5].GetString()); } while (result->NextRow()); @@ -5690,7 +5690,7 @@ bool ChatHandler::HandleBanInfoIPCommand(char* args) std::string IP = cIP; LoginDatabase.escape_string(IP); - QueryResult* result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'", IP.c_str()); if (!result) { PSendSysMessage(LANG_BANINFO_NOIP); @@ -5700,8 +5700,8 @@ bool ChatHandler::HandleBanInfoIPCommand(char* args) Field* fields = result->Fetch(); bool permanent = !fields[6].GetUInt64(); PSendSysMessage(LANG_BANINFO_IPENTRY, - fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER):fields[2].GetString(), - permanent ? GetMangosString(LANG_BANINFO_INFINITE):secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); + fields[0].GetString(), fields[1].GetString(), permanent ? GetMangosString(LANG_BANINFO_NEVER) : fields[2].GetString(), + permanent ? GetMangosString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetString(), fields[5].GetString()); delete result; return true; } @@ -5716,7 +5716,7 @@ bool ChatHandler::HandleBanListCharacterCommand(char* args) std::string filter = cFilter; LoginDatabase.escape_string(filter); - QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'"),filter.c_str()); + QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'"), filter.c_str()); if (!result) { PSendSysMessage(LANG_BANLIST_NOCHARACTER); @@ -5744,7 +5744,7 @@ bool ChatHandler::HandleBanListAccountCommand(char* args) else { result = LoginDatabase.PQuery("SELECT account.id, username FROM account, account_banned" - " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id", + " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'")" GROUP BY account.id", filter.c_str()); } @@ -5769,11 +5769,11 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) Field* fields = result->Fetch(); uint32 accountid = fields[0].GetUInt32(); - QueryResult* banresult = LoginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid); + QueryResult* banresult = LoginDatabase.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id", accountid); if (banresult) { Field* fields2 = banresult->Fetch(); - PSendSysMessage("%s",fields2[0].GetString()); + PSendSysMessage("%s", fields2[0].GetString()); delete banresult; } } @@ -5798,7 +5798,7 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) account_name = fields[1].GetCppString(); // "character" case, name need extract from another DB else - sAccountMgr.GetName(account_id,account_name); + sAccountMgr.GetName(account_id, account_name); // No SQL injection. id is uint32. QueryResult* banInfo = LoginDatabase.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id); @@ -5813,17 +5813,17 @@ bool ChatHandler::HandleBanListHelper(QueryResult* result) if (fields2[0].GetUInt64() == fields2[1].GetUInt64()) { PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, - fields2[2].GetString(),fields2[3].GetString()); + account_name.c_str(), aTm_ban->tm_year % 100, aTm_ban->tm_mon + 1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + fields2[2].GetString(), fields2[3].GetString()); } else { time_t t_unban = fields2[1].GetUInt64(); tm* aTm_unban = localtime(&t_unban); PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - account_name.c_str(),aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, - aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, - fields2[2].GetString(),fields2[3].GetString()); + account_name.c_str(), aTm_ban->tm_year % 100, aTm_ban->tm_mon + 1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + aTm_unban->tm_year % 100, aTm_unban->tm_mon + 1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, + fields2[2].GetString(), fields2[3].GetString()); } } while (banInfo->NextRow()); @@ -5857,8 +5857,8 @@ bool ChatHandler::HandleBanListIPCommand(char* args) else { result = LoginDatabase.PQuery("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned" - " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'","'%s'","'%%'") - " ORDER BY unbandate",filter.c_str()); + " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_" "_CONCAT3_("'%%'", "'%s'", "'%%'") + " ORDER BY unbandate", filter.c_str()); } if (!result) @@ -5874,7 +5874,7 @@ bool ChatHandler::HandleBanListIPCommand(char* args) do { Field* fields = result->Fetch(); - PSendSysMessage("%s",fields[0].GetString()); + PSendSysMessage("%s", fields[0].GetString()); } while (result->NextRow()); } @@ -5893,7 +5893,7 @@ bool ChatHandler::HandleBanListIPCommand(char* args) if (fields[1].GetUInt64() == fields[2].GetUInt64()) { PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + fields[0].GetString(), aTm_ban->tm_year % 100, aTm_ban->tm_mon + 1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, fields[3].GetString(), fields[4].GetString()); } else @@ -5901,8 +5901,8 @@ bool ChatHandler::HandleBanListIPCommand(char* args) time_t t_unban = fields[2].GetUInt64(); tm* aTm_unban = localtime(&t_unban); PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - fields[0].GetString(), aTm_ban->tm_year%100, aTm_ban->tm_mon+1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, - aTm_unban->tm_year%100, aTm_unban->tm_mon+1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, + fields[0].GetString(), aTm_ban->tm_year % 100, aTm_ban->tm_mon + 1, aTm_ban->tm_mday, aTm_ban->tm_hour, aTm_ban->tm_min, + aTm_unban->tm_year % 100, aTm_unban->tm_mon + 1, aTm_unban->tm_mday, aTm_unban->tm_hour, aTm_unban->tm_min, fields[3].GetString(), fields[4].GetString()); } } @@ -5935,7 +5935,7 @@ bool ChatHandler::HandleRespawnCommand(char* /*args*/) } MaNGOS::RespawnDo u_do; - MaNGOS::WorldObjectWorker worker(pl,u_do); + MaNGOS::WorldObjectWorker worker(pl, u_do); Cell::VisitGridObjects(pl, worker, pl->GetMap()->GetVisibilityDistance()); return true; } @@ -5990,7 +5990,7 @@ bool ChatHandler::HandlePDumpLoadCommand(char* args) return false; } - if (ObjectMgr::CheckPlayerName(name,true) != CHAR_NAME_SUCCESS) + if (ObjectMgr::CheckPlayerName(name, true) != CHAR_NAME_SUCCESS) { PSendSysMessage(LANG_INVALID_CHARACTER_NAME); SetSentErrorMessage(true); @@ -6026,15 +6026,15 @@ bool ChatHandler::HandlePDumpLoadCommand(char* args) PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); break; case DUMP_FILE_OPEN_ERROR: - PSendSysMessage(LANG_FILE_OPEN_FAIL,file); + PSendSysMessage(LANG_FILE_OPEN_FAIL, file); SetSentErrorMessage(true); return false; case DUMP_FILE_BROKEN: - PSendSysMessage(LANG_DUMP_BROKEN,file); + PSendSysMessage(LANG_DUMP_BROKEN, file); SetSentErrorMessage(true); return false; case DUMP_TOO_MANY_CHARS: - PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL,account_name.c_str(),account_id); + PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account_name.c_str(), account_id); SetSentErrorMessage(true); return false; default: @@ -6096,7 +6096,7 @@ bool ChatHandler::HandlePDumpWriteCommand(char* args) PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); break; case DUMP_FILE_OPEN_ERROR: - PSendSysMessage(LANG_FILE_OPEN_FAIL,file); + PSendSysMessage(LANG_FILE_OPEN_FAIL, file); SetSentErrorMessage(true); return false; default: @@ -6118,11 +6118,11 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) return false; } - PSendSysMessage(LANG_MOVEGENS_LIST,(unit->GetTypeId()==TYPEID_PLAYER ? "Player" : "Creature"),unit->GetGUIDLow()); + PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow()); MotionMaster* mm = unit->GetMotionMaster(); - float x,y,z; - mm->GetDestination(x,y,z); + float x, y, z; + mm->GetDestination(x, y, z); for (MotionMaster::const_iterator itr = mm->begin(); itr != mm->end(); ++itr) { switch ((*itr)->GetMovementGeneratorType()) @@ -6135,39 +6135,39 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) case CHASE_MOTION_TYPE: { Unit* target = NULL; - if (unit->GetTypeId()==TYPEID_PLAYER) + if (unit->GetTypeId() == TYPEID_PLAYER) target = static_cast const*>(*itr)->GetTarget(); else target = static_cast const*>(*itr)->GetTarget(); if (!target) SendSysMessage(LANG_MOVEGENS_CHASE_NULL); - else if (target->GetTypeId()==TYPEID_PLAYER) - PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER,target->GetName(),target->GetGUIDLow()); + else if (target->GetTypeId() == TYPEID_PLAYER) + PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUIDLow()); else - PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE,target->GetName(),target->GetGUIDLow()); + PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUIDLow()); break; } case FOLLOW_MOTION_TYPE: { Unit* target = NULL; - if (unit->GetTypeId()==TYPEID_PLAYER) + if (unit->GetTypeId() == TYPEID_PLAYER) target = static_cast const*>(*itr)->GetTarget(); else target = static_cast const*>(*itr)->GetTarget(); if (!target) SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL); - else if (target->GetTypeId()==TYPEID_PLAYER) - PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER,target->GetName(),target->GetGUIDLow()); + else if (target->GetTypeId() == TYPEID_PLAYER) + PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUIDLow()); else - PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE,target->GetName(),target->GetGUIDLow()); + PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUIDLow()); break; } case HOME_MOTION_TYPE: - if (unit->GetTypeId()==TYPEID_UNIT) + if (unit->GetTypeId() == TYPEID_UNIT) { - PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE,x,y,z); + PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z); } else SendSysMessage(LANG_MOVEGENS_HOME_PLAYER); @@ -6175,14 +6175,14 @@ bool ChatHandler::HandleMovegensCommand(char* /*args*/) case FLIGHT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FLIGHT); break; case POINT_MOTION_TYPE: { - PSendSysMessage(LANG_MOVEGENS_POINT,x,y,z); + PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z); break; } case FLEEING_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_FEAR); break; case DISTRACT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_DISTRACT); break; case EFFECT_MOTION_TYPE: SendSysMessage(LANG_MOVEGENS_EFFECT); break; default: - PSendSysMessage(LANG_MOVEGENS_UNKNOWN,(*itr)->GetMovementGeneratorType()); + PSendSysMessage(LANG_MOVEGENS_UNKNOWN, (*itr)->GetMovementGeneratorType()); break; } } @@ -6200,15 +6200,15 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) int l = strlen(param); int val; - if (strncmp(param,"player",l) == 0) + if (strncmp(param, "player", l) == 0) sWorld.SetPlayerLimit(-SEC_PLAYER); - else if (strncmp(param,"moderator",l) == 0) + else if (strncmp(param, "moderator", l) == 0) sWorld.SetPlayerLimit(-SEC_MODERATOR); - else if (strncmp(param,"gamemaster",l) == 0) + else if (strncmp(param, "gamemaster", l) == 0) sWorld.SetPlayerLimit(-SEC_GAMEMASTER); - else if (strncmp(param,"administrator",l) == 0) + else if (strncmp(param, "administrator", l) == 0) sWorld.SetPlayerLimit(-SEC_ADMINISTRATOR); - else if (strncmp(param,"reset",l) == 0) + else if (strncmp(param, "reset", l) == 0) sWorld.SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT)); else if (ExtractInt32(¶m, val)) { @@ -6237,7 +6237,7 @@ bool ChatHandler::HandleServerPLimitCommand(char* args) default: secName = ""; break; } - PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit,secName); + PSendSysMessage("Player limits: amount %u, min. security level %s.", pLimit, secName); return true; } @@ -6265,9 +6265,9 @@ bool ChatHandler::HandleCastCommand(char* args) if (!spellInfo) return false; - if (!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); SetSentErrorMessage(true); return false; } @@ -6276,7 +6276,7 @@ bool ChatHandler::HandleCastCommand(char* args) if (!triggered && *args) // can be fail also at syntax error return false; - m_session->GetPlayer()->CastSpell(target,spell,triggered); + m_session->GetPlayer()->CastSpell(target, spell, triggered); return true; } @@ -6304,7 +6304,7 @@ bool ChatHandler::HandleCastBackCommand(char* args) caster->SetFacingToObject(m_session->GetPlayer()); - caster->CastSpell(m_session->GetPlayer(),spell,triggered); + caster->CastSpell(m_session->GetPlayer(), spell, triggered); return true; } @@ -6323,9 +6323,9 @@ bool ChatHandler::HandleCastDistCommand(char* args) if (!spellInfo) return false; - if (!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); SetSentErrorMessage(true); return false; } @@ -6338,10 +6338,10 @@ bool ChatHandler::HandleCastDistCommand(char* args) if (!triggered && *args) // can be fail also at syntax error return false; - float x,y,z; - m_session->GetPlayer()->GetClosePoint(x,y,z,dist); + float x, y, z; + m_session->GetPlayer()->GetClosePoint(x, y, z, dist); - m_session->GetPlayer()->CastSpell(x,y,z,spell,triggered); + m_session->GetPlayer()->CastSpell(x, y, z, spell, triggered); return true; } @@ -6374,7 +6374,7 @@ bool ChatHandler::HandleCastTargetCommand(char* args) caster->SetFacingToObject(m_session->GetPlayer()); - caster->CastSpell(caster->getVictim(),spell,triggered); + caster->CastSpell(caster->getVictim(), spell, triggered); return true; } @@ -6424,9 +6424,9 @@ bool ChatHandler::HandleCastSelfCommand(char* args) if (!spellInfo) return false; - if (!SpellMgr::IsSpellValid(spellInfo,m_session->GetPlayer())) + if (!SpellMgr::IsSpellValid(spellInfo, m_session->GetPlayer())) { - PSendSysMessage(LANG_COMMAND_SPELL_BROKEN,spell); + PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell); SetSentErrorMessage(true); return false; } @@ -6595,7 +6595,7 @@ bool ChatHandler::HandleGMListFullCommand(char* /*args*/) do { Field* fields = result->Fetch(); - PSendSysMessage("|%15s|%6s|", fields[0].GetString(),fields[1].GetString()); + PSendSysMessage("|%15s|%6s|", fields[0].GetString(), fields[1].GetString()); } while (result->NextRow()); @@ -6708,7 +6708,7 @@ bool ChatHandler::HandleAccountSetAddonCommand(char* args) // Let set addon state only for lesser (strong) security level // or to self account if (GetAccountId() && GetAccountId() != account_id && - HasLowerSecurityAccount(NULL,account_id,true)) + HasLowerSecurityAccount(NULL, account_id, true)) return false; uint32 lev; @@ -6717,7 +6717,7 @@ bool ChatHandler::HandleAccountSetAddonCommand(char* args) // No SQL injection LoginDatabase.PExecute("UPDATE account SET expansion = '%u' WHERE id = '%u'", lev, account_id); - PSendSysMessage(LANG_ACCOUNT_SETADDON,account_name.c_str(), account_id, lev); + PSendSysMessage(LANG_ACCOUNT_SETADDON, account_name.c_str(), account_id, lev); return true; } @@ -6780,7 +6780,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) return false; // extract items - typedef std::pair ItemPair; + typedef std::pair ItemPair; typedef std::list< ItemPair > ItemPairs; ItemPairs items; @@ -6818,11 +6818,11 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) while (item_count > item_proto->GetMaxStackSize()) { - items.push_back(ItemPair(item_id,item_proto->GetMaxStackSize())); + items.push_back(ItemPair(item_id, item_proto->GetMaxStackSize())); item_count -= item_proto->GetMaxStackSize(); } - items.push_back(ItemPair(item_id,item_count)); + items.push_back(ItemPair(item_id, item_count)); if (items.size() > MAX_MAIL_ITEMS) { @@ -6837,7 +6837,7 @@ bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args) for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr) { - if (Item* item = Item::CreateItem(itr->first,itr->second,m_session ? m_session->GetPlayer() : 0)) + if (Item* item = Item::CreateItem(itr->first, itr->second, m_session ? m_session->GetPlayer() : 0)) { item->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted draft.AddItem(item); @@ -6946,7 +6946,7 @@ bool ChatHandler::HandleSendMoneyCommand(char* args) // from console show nonexistent sender MailSender sender(MAIL_NORMAL, m_session ? m_session->GetPlayer()->GetObjectGuid().GetCounter() : 0, MAIL_STATIONERY_GM); - draft.SendMailTo(MailReceiver(receiver, receiver_guid),sender); + draft.SendMailTo(MailReceiver(receiver, receiver_guid), sender); std::string nameLink = playerLink(receiver_name); PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); @@ -7150,8 +7150,8 @@ bool ChatHandler::HandleMmapTestArea(char* args) uint32 paths = 0; uint32 uStartTime = WorldTimer::getMSTime(); - float gx,gy,gz; - m_session->GetPlayer()->GetPosition(gx,gy,gz); + float gx, gy, gz; + m_session->GetPlayer()->GetPosition(gx, gy, gz); for (std::list::iterator itr = creatureList.begin(); itr != creatureList.end(); ++itr) { PathFinder path(*itr); diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index 90ec93c91..58c5d7611 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -50,7 +50,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data) GameObject* go = player->GetMap()->GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO - if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) + if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE))) { player->SendLootRelease(lguid); return; @@ -88,9 +88,9 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data) { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); - bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); + bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass() == CLASS_ROGUE && pCreature->lootForPickPocketed); - if (!ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) + if (!ok_loot || !pCreature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) { player->SendLootRelease(lguid); return; @@ -101,7 +101,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data) } default: { - sLog.outError("%s is unsupported for looting.",lguid.GetString().c_str()); + sLog.outError("%s is unsupported for looting.", lguid.GetString().c_str()); return; } } @@ -110,7 +110,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data) QuestItem* ffaitem = NULL; QuestItem* conditem = NULL; - LootItem* item = loot->LootItemInSlot(lootSlot,player,&qitem,&ffaitem,&conditem); + LootItem* item = loot->LootItemInSlot(lootSlot, player, &qitem, &ffaitem, &conditem); if (!item) { @@ -148,14 +148,14 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data) if (ffaitem) { //freeforall case, notify only one player of the removal - ffaitem->is_looted=true; + ffaitem->is_looted = true; player->SendNotifyLootItemRemoved(lootSlot); } else { //not freeforall, notify everyone if (conditem) - conditem->is_looted=true; + conditem->is_looted = true; loot->NotifyItemRemoved(lootSlot); } } @@ -194,7 +194,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/) GameObject* pGameObject = GetPlayer()->GetMap()->GetGameObject(guid); // not check distance for GO in case owned GO (fishing bobber case, for example) - if (pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) + if (pGameObject && (pGameObject->GetOwnerGuid() == _player->GetObjectGuid() || pGameObject->IsWithinDistInMap(_player, INTERACTION_DISTANCE))) pLoot = &pGameObject->loot; break; @@ -203,7 +203,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/) { Corpse* bones = _player->GetMap()->GetCorpse(guid); - if (bones && bones->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) + if (bones && bones->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) pLoot = &bones->loot; break; @@ -222,9 +222,9 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/) { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(guid); - bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); + bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass() == CLASS_ROGUE && pCreature->lootForPickPocketed); - if (ok_loot && pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) + if (ok_loot && pCreature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) pLoot = &pCreature->loot ; break; @@ -247,18 +247,18 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/) Player* playerGroup = itr->getSource(); if (!playerGroup) continue; - if (player->IsWithinDistInMap(playerGroup,sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE),false)) + if (player->IsWithinDistInMap(playerGroup, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE), false)) playersNear.push_back(playerGroup); } - uint32 money_per_player = uint32((pLoot->gold)/(playersNear.size())); + uint32 money_per_player = uint32((pLoot->gold) / (playersNear.size())); for (std::vector::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i) { (*i)->ModifyMoney(money_per_player); (*i)->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, money_per_player); - WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1); + WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1); data << uint32(money_per_player); data << uint8(playersNear.size() > 1 ? 0 : 1);// 0 is "you share of loot..." @@ -270,7 +270,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recv_data*/) player->ModifyMoney(pLoot->gold); player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, pLoot->gold); - WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4+1); + WorldPacket data(SMSG_LOOT_MONEY_NOTIFY, 4 + 1); data << uint32(pLoot->gold); data << uint8(1); // 1 is "you loot..." player->GetSession()->SendPacket(&data); @@ -329,7 +329,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid); // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO - if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))) + if (!go || ((go->GetOwnerGuid() != _player->GetObjectGuid() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE))) return; loot = &go->loot; @@ -351,8 +351,8 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) if (go_min != 0 && go_max > go_min) { float amount_rate = sWorld.getConfig(CONFIG_FLOAT_RATE_MINING_AMOUNT); - float min_amount = go_min*amount_rate; - float max_amount = go_max*amount_rate; + float min_amount = go_min * amount_rate; + float max_amount = go_max * amount_rate; go->AddUse(); float uses = float(go->GetUseCount()); @@ -367,9 +367,9 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) LockEntry const* lockInfo = sLockStore.LookupEntry(go->GetGOInfo()->chest.lockId); if (lockInfo) ReqValue = lockInfo->Skill[0]; - float skill = float(player->GetSkillValue(SKILL_MINING))/(ReqValue+25); - double chance = pow(0.8*chance_rate,4*(1/double(max_amount))*double(uses)); - if (roll_chance_f(float(100.0f*chance+skill))) + float skill = float(player->GetSkillValue(SKILL_MINING)) / (ReqValue + 25); + double chance = pow(0.8 * chance_rate, 4 * (1 / double(max_amount)) * double(uses)); + if (roll_chance_f(float(100.0f * chance + skill))) { go->SetLootState(GO_READY); } @@ -389,7 +389,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) { // The fishing hole used once more go->AddUse(); // if the max usage is reached, will be despawned at next tick - if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens)) + if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens, go->GetGOInfo()->fishinghole.maxSuccessOpens)) { go->SetLootState(GO_JUST_DEACTIVATED); } @@ -409,7 +409,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) case HIGHGUID_CORPSE: // ONLY remove insignia at BG { Corpse* corpse = _player->GetMap()->GetCorpse(lguid); - if (!corpse || !corpse->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) + if (!corpse || !corpse->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) return; loot = &corpse->loot; @@ -453,7 +453,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) player->AutoStoreLoot(pItem->loot); // can be lost if no space pItem->loot.clear(); pItem->SetLootState(ITEM_LOOT_REMOVED); - player->DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), true); + player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true); break; } // normal persistence loot @@ -463,7 +463,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) if (pItem->loot.isLooted()) { pItem->SetLootState(ITEM_LOOT_REMOVED); - player->DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), true); + player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true); } break; } @@ -475,8 +475,8 @@ void WorldSession::DoLootRelease(ObjectGuid lguid) { Creature* pCreature = GetPlayer()->GetMap()->GetCreature(lguid); - bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass()==CLASS_ROGUE && pCreature->lootForPickPocketed); - if (!ok_loot || !pCreature->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) + bool ok_loot = pCreature && pCreature->isAlive() == (player->getClass() == CLASS_ROGUE && pCreature->lootForPickPocketed); + if (!ok_loot || !pCreature->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) return; loot = &pCreature->loot; @@ -553,7 +553,7 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data) if (slotid > pLoot->items.size()) { - DEBUG_LOG("AutoLootItem: Player %s might be using a hack! (slot %d, size %lu)",GetPlayer()->GetName(), slotid, (unsigned long)pLoot->items.size()); + DEBUG_LOG("AutoLootItem: Player %s might be using a hack! (slot %d, size %lu)", GetPlayer()->GetName(), slotid, (unsigned long)pLoot->items.size()); return; } @@ -578,8 +578,8 @@ void WorldSession::HandleLootMasterGiveOpcode(WorldPacket& recv_data) target->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count); // mark as looted - item.count=0; - item.is_looted=true; + item.count = 0; + item.is_looted = true; pLoot->NotifyItemRemoved(slotid); --pLoot->unlootedCount; diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index fa813da35..9ed6ecf8c 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -45,11 +45,11 @@ LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject loo LootStore LootTemplates_Item("item_loot_template", "item entry with ITEM_FLAG_LOOTABLE", true); LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false); LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true); -LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true); +LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template", "creature pickpocket lootid", true); LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true); LootStore LootTemplates_Reference("reference_loot_template", "reference id", false); LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true); -LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)",false); +LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false); class LootTemplate::LootGroup // A set of loot definitions for items (refs are not allowed) { @@ -75,7 +75,7 @@ class LootTemplate::LootGroup // A set of loot def //Remove all data and free all memory void LootStore::Clear() { - for (LootTemplateMap::const_iterator itr=m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr) + for (LootTemplateMap::const_iterator itr = m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr) delete itr->second; m_LootTemplates.clear(); } @@ -101,7 +101,7 @@ void LootStore::LoadLootTable() sLog.outString("%s :", GetName()); // 0 1 2 3 4 5 6 - QueryResult* result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s",GetName()); + QueryResult* result = WorldDatabase.PQuery("SELECT entry, item, ChanceOrQuestChance, groupid, mincountOrRef, maxcount, condition_id FROM %s", GetName()); if (result) { @@ -122,7 +122,7 @@ void LootStore::LoadLootTable() if (maxcount > std::numeric_limits::max()) { - sLog.outErrorDb("Table '%s' entry %d item %d: maxcount value (%u) to large. must be less %u - skipped", GetName(), entry, item, maxcount,std::numeric_limits::max()); + sLog.outErrorDb("Table '%s' entry %d item %d: maxcount value (%u) to large. must be less %u - skipped", GetName(), entry, item, maxcount, std::numeric_limits::max()); continue; // error already printed to log/console. } @@ -137,14 +137,14 @@ void LootStore::LoadLootTable() const PlayerCondition* condition = sConditionStorage.LookupEntry(conditionId); if (!condition) { - sLog.outErrorDb("Table `%s` for entry %u, item %u has condition_id %u that does not exist in `conditions`, ignoring", GetName(), entry,item, conditionId); + sLog.outErrorDb("Table `%s` for entry %u, item %u has condition_id %u that does not exist in `conditions`, ignoring", GetName(), entry, item, conditionId); conditionId = 0; } } LootStoreItem storeitem = LootStoreItem(item, chanceOrQuestChance, group, conditionId, mincountOrRef, maxcount); - if (!storeitem.IsValid(*this,entry)) // Validity checks + if (!storeitem.IsValid(*this, entry)) // Validity checks continue; // Looking for the template of the entry @@ -179,7 +179,7 @@ void LootStore::LoadLootTable() else { sLog.outString(); - sLog.outErrorDb(">> Loaded 0 loot definitions. DB table `%s` is empty.",GetName()); + sLog.outErrorDb(">> Loaded 0 loot definitions. DB table `%s` is empty.", GetName()); } } @@ -193,7 +193,7 @@ bool LootStore::HaveQuestLootFor(uint32 loot_id) const return itr->second->HasQuestDrop(m_LootTemplates); } -bool LootStore::HaveQuestLootForPlayer(uint32 loot_id,Player* player) const +bool LootStore::HaveQuestLootForPlayer(uint32 loot_id, Player* player) const { LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id); if (tab != m_LootTemplates.end()) @@ -231,12 +231,12 @@ void LootStore::ReportUnusedIds(LootIdSet const& ids_set) const { // all still listed ids isn't referenced for (LootIdSet::const_iterator itr = ids_set.begin(); itr != ids_set.end(); ++itr) - sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr,GetEntryName()); + sLog.outErrorDb("Table '%s' entry %d isn't %s and not referenced from loot, and then useless.", GetName(), *itr, GetEntryName()); } void LootStore::ReportNotExistedId(uint32 id) const { - sLog.outErrorDb("Table '%s' entry %d (%s) not exist but used as loot id in DB.", GetName(), id,GetEntryName()); + sLog.outErrorDb("Table '%s' entry %d (%s) not exist but used as loot id in DB.", GetName(), id, GetEntryName()); } // @@ -247,17 +247,17 @@ void LootStore::ReportNotExistedId(uint32 id) const // RATE_DROP_ITEMS is no longer used for all types of entries bool LootStoreItem::Roll(bool rate) const { - if (chance>=100.0f) + if (chance >= 100.0f) 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)); ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); float qualityModifier = pProto && rate ? sWorld.getConfig(qualityToRate[pProto->Quality]) : 1.0f; - return roll_chance_f(chance*qualityModifier); + return roll_chance_f(chance * qualityModifier); } // Checks correctness of values @@ -457,17 +457,17 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner, 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; } items.reserve(MAX_NR_LOOT_ITEMS); m_questItems.reserve(MAX_NR_QUEST_ITEMS); - tab->Process(*this, store,store.IsRatesAllowed()); // Processing is done there, callback via Loot::AddItem() + tab->Process(*this, store, store.IsRatesAllowed()); // Processing is done there, callback via Loot::AddItem() // Setting access rights for group loot case - Group* pGroup=loot_owner->GetGroup(); + Group* pGroup = loot_owner->GetGroup(); if (!personal && pGroup) { for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) @@ -569,7 +569,7 @@ QuestItemList* Loot::FillNonQuestNonFFAConditionalLoot(Player* player) if (!item.is_counted) { ++unlootedCount; - item.is_counted=true; + item.is_counted = true; } } } @@ -642,7 +642,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex) break; if (j < pql.size()) - pl->SendNotifyLootItemRemoved(items.size()+j); + pl->SendNotifyLootItemRemoved(items.size() + j); } } else @@ -689,10 +689,10 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite QuestItemMap::const_iterator itr = m_playerFFAItems.find(player->GetGUIDLow()); if (itr != m_playerFFAItems.end()) { - for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) - if (iter->index==lootSlot) + for (QuestItemList::const_iterator iter = itr->second->begin(); iter != itr->second->end(); ++iter) + if (iter->index == lootSlot) { - QuestItem* ffaitem2 = (QuestItem*)&(*iter); + QuestItem* ffaitem2 = (QuestItem*) & (*iter); if (ffaitem) *ffaitem = ffaitem2; is_looted = ffaitem2->is_looted; @@ -705,11 +705,11 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite QuestItemMap::const_iterator itr = m_playerNonQuestNonFFAConditionalItems.find(player->GetGUIDLow()); if (itr != m_playerNonQuestNonFFAConditionalItems.end()) { - for (QuestItemList::const_iterator iter=itr->second->begin(); iter!= itr->second->end(); ++iter) + for (QuestItemList::const_iterator iter = itr->second->begin(); iter != itr->second->end(); ++iter) { - if (iter->index==lootSlot) + if (iter->index == lootSlot) { - QuestItem* conditem2 = (QuestItem*)&(*iter); + QuestItem* conditem2 = (QuestItem*) & (*iter); if (conditem) *conditem = conditem2; is_looted = conditem2->is_looted; @@ -835,7 +835,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv) } //update number of items shown - b.put(count_pos,itemsShown); + b.put(count_pos, itemsShown); return b; } @@ -860,9 +860,9 @@ LootStoreItem const* LootTemplate::LootGroup::Roll() const { float Roll = rand_chance_f(); - for (uint32 i=0; i=100.0f) + if (ExplicitlyChanced[i].chance >= 100.0f) return &ExplicitlyChanced[i]; Roll -= ExplicitlyChanced[i].chance; @@ -871,7 +871,7 @@ LootStoreItem const* LootTemplate::LootGroup::Roll() const } } 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 } @@ -879,10 +879,10 @@ LootStoreItem const* LootTemplate::LootGroup::Roll() const // True if group includes at least 1 quest drop entry bool LootTemplate::LootGroup::HasQuestDrop() const { - for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) + for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) if (i->needs_quest) return true; - for (LootStoreItemList::const_iterator i=EqualChanced.begin(); i != EqualChanced.end(); ++i) + for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i) if (i->needs_quest) return true; return false; @@ -891,10 +891,10 @@ bool LootTemplate::LootGroup::HasQuestDrop() const // True if group includes at least 1 quest drop entry for active quests of the player bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const { - for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) + for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) if (player->HasQuestForItem(i->itemid)) return true; - for (LootStoreItemList::const_iterator i=EqualChanced.begin(); i != EqualChanced.end(); ++i) + for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i) if (player->HasQuestForItem(i->itemid)) return true; return false; @@ -913,7 +913,7 @@ float LootTemplate::LootGroup::RawTotalChance() const { float result = 0; - for (LootStoreItemList::const_iterator i=ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) + for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i) if (!i->needs_quest) result += i->chance; @@ -947,7 +947,7 @@ void LootTemplate::LootGroup::Verify(LootStore const& lootstore, uint32 id, uint void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const { - for (LootStoreItemList::const_iterator ieItr=ExplicitlyChanced.begin(); ieItr != ExplicitlyChanced.end(); ++ieItr) + for (LootStoreItemList::const_iterator ieItr = ExplicitlyChanced.begin(); ieItr != ExplicitlyChanced.end(); ++ieItr) { if (ieItr->mincountOrRef < 0) { @@ -958,7 +958,7 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const } } - for (LootStoreItemList::const_iterator ieItr=EqualChanced.begin(); ieItr != EqualChanced.end(); ++ieItr) + for (LootStoreItemList::const_iterator ieItr = EqualChanced.begin(); ieItr != EqualChanced.end(); ++ieItr) { if (ieItr->mincountOrRef < 0) { @@ -981,7 +981,7 @@ void LootTemplate::AddEntry(LootStoreItem& item) { if (item.group >= Groups.size()) Groups.resize(item.group); // Adds new group the the loot template if needed - Groups[item.group-1].AddEntry(item); // Adds new entry to the group + Groups[item.group - 1].AddEntry(item); // Adds new entry to the group } else // Non-grouped entries and references are stored together Entries.push_back(item); @@ -995,7 +995,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8 if (groupId > Groups.size()) return; // Error message already printed at loading stage - Groups[groupId-1].Process(loot); + Groups[groupId - 1].Process(loot); return; } @@ -1012,7 +1012,7 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8 if (!Referenced) continue; // Error message already printed at loading stage - for (uint32 loop=0; loop < i->maxcount; ++loop) // Ref multiplicator + for (uint32 loop = 0; loop < i->maxcount; ++loop) // Ref multiplicator Referenced->Process(loot, store, rate, i->group); } else // Plain entries (not a reference, not grouped) @@ -1031,7 +1031,7 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con { if (groupId > Groups.size()) return false; // Error message [should be] already printed at loading stage - return Groups[groupId-1].HasQuestDrop(); + return Groups[groupId - 1].HasQuestDrop(); } for (LootStoreItemList::const_iterator i = Entries.begin(); i != Entries.end(); ++i) @@ -1039,7 +1039,7 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con if (i->mincountOrRef < 0) // References { LootTemplateMap::const_iterator Referenced = store.find(-i->mincountOrRef); - if (Referenced ==store.end()) + if (Referenced == store.end()) continue; // Error message [should be] already printed at loading stage if (Referenced->second->HasQuestDrop(store, i->group)) return true; @@ -1063,7 +1063,7 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co { if (groupId > Groups.size()) return false; // Error message already printed at loading stage - return Groups[groupId-1].HasQuestDropForPlayer(player); + return Groups[groupId - 1].HasQuestDropForPlayer(player); } // Checking non-grouped entries @@ -1093,8 +1093,8 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co void LootTemplate::Verify(LootStore const& lootstore, uint32 id) const { // Checking group chances - for (uint32 i=0; i < Groups.size(); ++i) - Groups[i].Verify(lootstore,id,i+1); + for (uint32 i = 0; i < Groups.size(); ++i) + Groups[i].Verify(lootstore, id, i + 1); // TODO: References validity checks } diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index 8eba7e79c..480c25d79 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -77,10 +77,10 @@ struct LootStoreItem uint32 itemid; // id of the item float chance; // always positive, chance to drop for both quest and non-quest items, chance to be used for refs int32 mincountOrRef; // mincount for drop items (positive) or minus referenced TemplateleId (negative) - uint8 group :7; - bool needs_quest :1; // quest drop (negative ChanceOrQuestChance in DB) - uint8 maxcount :8; // max drop count for the item (mincountOrRef positive) or Ref multiplicator (mincountOrRef negative) - uint16 conditionId :16; // additional loot condition Id + uint8 group : 7; + bool needs_quest : 1; // quest drop (negative ChanceOrQuestChance in DB) + uint8 maxcount : 8; // max drop count for the item (mincountOrRef positive) or Ref multiplicator (mincountOrRef negative) + uint16 conditionId : 16; // additional loot condition Id // Constructor, converting ChanceOrQuestChance -> (chance, needs_quest) // displayid is filled in IsValid() which must be called after @@ -99,7 +99,7 @@ struct LootItem uint32 itemid; uint32 randomSuffix; int32 randomPropertyId; - uint16 conditionId :16; // allow compiler pack structure + uint16 conditionId : 16; // allow compiler pack structure uint8 count : 8; bool is_looted : 1; bool is_blocked : 1; @@ -159,7 +159,7 @@ class LootStore bool HaveLootFor(uint32 loot_id) const { return m_LootTemplates.find(loot_id) != m_LootTemplates.end(); } bool HaveQuestLootFor(uint32 loot_id) const; - bool HaveQuestLootForPlayer(uint32 loot_id,Player* player) const; + bool HaveQuestLootForPlayer(uint32 loot_id, Player* player) const; LootTemplate const* GetLootFor(uint32 loot_id) const; @@ -318,7 +318,7 @@ struct LootView Loot& loot; Player* viewer; PermissionTypes permission; - LootView(Loot& _loot, Player* _viewer,PermissionTypes _permission = ALL_PERMISSION) + LootView(Loot& _loot, Player* _viewer, PermissionTypes _permission = ALL_PERMISSION) : loot(_loot), viewer(_viewer), permission(_permission) {} }; diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 4e51346b6..60082562e 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -227,7 +227,7 @@ void MailDraft::SendReturnToSender(uint32 sender_acc, ObjectGuid sender_guid, Ob uint32 deliver_delay = needItemDelay ? sWorld.getConfig(CONFIG_UINT32_MAIL_DELIVERY_DELAY) : 0; // will delete item or place to receiver mail list - SendMailTo(MailReceiver(receiver,receiver_guid), MailSender(MAIL_NORMAL, sender_guid.GetCounter()), MAIL_CHECK_MASK_RETURNED, deliver_delay); + SendMailTo(MailReceiver(receiver, receiver_guid), MailSender(MAIL_NORMAL, sender_guid.GetCounter()), MAIL_CHECK_MASK_RETURNED, deliver_delay); } /** * Sends a mail. diff --git a/src/game/MailHandler.cpp b/src/game/MailHandler.cpp index bf8565b9a..ce2c8e991 100644 --- a/src/game/MailHandler.cpp +++ b/src/game/MailHandler.cpp @@ -308,7 +308,7 @@ void WorldSession::HandleSendMail(WorldPacket& recv_data) if (money > 0 && GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(GetAccountId(),"GM %s (Account: %u) mail money: %u to player: %s (Account: %u)", + sLog.outCommand(GetAccountId(), "GM %s (Account: %u) mail money: %u to player: %s (Account: %u)", GetPlayerName(), GetAccountId(), money, receiver.c_str(), rc_account); } } @@ -631,9 +631,9 @@ void WorldSession::HandleGetMailList(WorldPacket& recv_data) uint8 item_count = (*itr)->items.size(); // max count is MAX_MAIL_ITEMS (12) - size_t next_mail_size = 2+4+1+((*itr)->messageType == MAIL_NORMAL ? 8 : 4)+4*8+((*itr)->subject.size()+1)+((*itr)->body.size()+1)+1+item_count*(1+4+4+7*3*4+4+4+4+4+4+4+1); + size_t next_mail_size = 2 + 4 + 1 + ((*itr)->messageType == MAIL_NORMAL ? 8 : 4) + 4 * 8 + ((*itr)->subject.size() + 1) + ((*itr)->body.size() + 1) + 1 + item_count * (1 + 4 + 4 + 7 * 3 * 4 + 4 + 4 + 4 + 4 + 4 + 4 + 1); - if (data.wpos()+next_mail_size > maxPacketSize) + if (data.wpos() + next_mail_size > maxPacketSize) { realCount += 1; continue; diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 25244449f..876fc5cbd 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -62,7 +62,7 @@ Map::~Map() sTerrainMgr.UnloadTerrain(m_TerrainData->GetMapId()); } -void Map::LoadMapAndVMap(int gx,int gy) +void Map::LoadMapAndVMap(int gx, int gy) { if (m_bLoadedGrids[gx][gx]) return; @@ -83,9 +83,9 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode) m_CreatureGuids.Set(sObjectMgr.GetFirstTemporaryCreatureLowGuid()); m_GameObjectGuids.Set(sObjectMgr.GetFirstTemporaryGameObjectLowGuid()); - for (unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j) + for (unsigned int j = 0; j < MAX_NUMBER_OF_GRIDS; ++j) { - for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) + for (unsigned int idx = 0; idx < MAX_NUMBER_OF_GRIDS; ++idx) { //z code m_bLoadedGrids[idx][j] = false; @@ -126,7 +126,7 @@ template<> void Map::AddToGrid(Corpse* obj, NGridType* grid, Cell const& cell) { // add to world object registry in grid - if (obj->GetType()!=CORPSE_BONES) + if (obj->GetType() != CORPSE_BONES) { (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); } @@ -170,7 +170,7 @@ template<> void Map::RemoveFromGrid(Corpse* obj, NGridType* grid, Cell const& cell) { // remove from world object registry in grid - if (obj->GetType()!=CORPSE_BONES) + if (obj->GetType() != CORPSE_BONES) { (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj); } @@ -207,7 +207,7 @@ Map::EnsureGridCreated(const GridPair& p) { if (!getNGrid(p.x_coord, p.y_coord)) { - setNGrid(new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld.getConfig(CONFIG_BOOL_GRID_UNLOAD)), + setNGrid(new NGridType(p.x_coord * MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld.getConfig(CONFIG_BOOL_GRID_UNLOAD)), p.x_coord, p.y_coord); // build a linkage between this map and NGridType @@ -220,7 +220,7 @@ 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); } } @@ -249,7 +249,7 @@ 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) @@ -265,12 +265,12 @@ bool Map::EnsureGridLoaded(const Cell& cell) //possible scenario: //active object A(loaded with loader.LoadN call and added to the map) //summons some active object B, while B added to map grid loading called again and so on.. - setGridObjectDataLoaded(true,cell.GridX(), cell.GridY()); + setGridObjectDataLoaded(true, cell.GridX(), cell.GridY()); ObjectGridLoader loader(*grid, this, cell); loader.LoadN(); // Add resurrectable corpses to world object list in grid - sObjectAccessor.AddCorpsesToGrid(GridPair(cell.GridX(),cell.GridY()),(*grid)(cell.CellX(), cell.CellY()), this); + sObjectAccessor.AddCorpsesToGrid(GridPair(cell.GridX(), cell.GridY()), (*grid)(cell.CellX(), cell.CellY()), this); return true; } @@ -301,7 +301,7 @@ bool Map::Add(Player* player) NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); player->GetViewPoint().Event_AddedToWorld(&(*grid)(cell.CellX(), cell.CellY())); - UpdateObjectVisibility(player,cell,p); + UpdateObjectVisibility(player, cell, p); if (i_data) i_data->OnPlayerEnter(player); @@ -333,7 +333,7 @@ Map::Add(T* obj) NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); MANGOS_ASSERT(grid != NULL); - AddToGrid(obj,grid,cell); + AddToGrid(obj, grid, cell); obj->AddToWorld(); if (obj->isActiveObject()) @@ -342,7 +342,7 @@ Map::Add(T* obj) DEBUG_LOG("%s enters grid[%u,%u]", obj->GetGuidStr().c_str(), cell.GridX(), cell.GridY()); obj->GetViewPoint().Event_AddedToWorld(&(*grid)(cell.CellX(), cell.CellY())); - UpdateObjectVisibility(obj,cell,p); + UpdateObjectVisibility(obj, cell, p); } void Map::MessageBroadcast(Player* player, WorldPacket* msg, bool to_self) @@ -384,7 +384,7 @@ void Map::MessageBroadcast(WorldObject* obj, WorldPacket* msg) //TODO: currently on continents when Visibility.Distance.InFlight > Visibility.Distance.Continents //we have alot of blinking mobs because monster move packet send is broken... - MaNGOS::ObjectMessageDeliverer post_man(*obj,msg); + MaNGOS::ObjectMessageDeliverer post_man(*obj, msg); TypeContainerVisitor message(post_man); cell.Visit(p, message, *this, *obj, GetVisibilityDistance()); } @@ -493,7 +493,7 @@ void Map::Update(const uint32& t_diff) if (!isCellMarked(cell_id)) { markCell(cell_id); - CellPair pair(x,y); + CellPair pair(x, y); Cell cell(pair); cell.SetNoCreate(); Visit(cell, grid_object_update); @@ -531,7 +531,7 @@ void Map::Update(const uint32& t_diff) if (!isCellMarked(cell_id)) { markCell(cell_id); - CellPair pair(x,y); + CellPair pair(x, y); Cell cell(pair); cell.SetNoCreate(); Visit(cell, grid_object_update); @@ -601,7 +601,7 @@ void Map::Remove(Player* player, bool remove) if (!getNGrid(cell.data.Part.grid_x, cell.data.Part.grid_y)) { - sLog.outError("Map::Remove() i_grids was NULL x:%d, y:%d",cell.data.Part.grid_x,cell.data.Part.grid_y); + sLog.outError("Map::Remove() i_grids was NULL x:%d, y:%d", cell.data.Part.grid_x, cell.data.Part.grid_y); return; } @@ -609,10 +609,10 @@ void Map::Remove(Player* player, bool remove) NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); MANGOS_ASSERT(grid != NULL); - RemoveFromGrid(player,grid,cell); + RemoveFromGrid(player, grid, cell); SendRemoveTransports(player); - UpdateObjectVisibility(player,cell,p); + UpdateObjectVisibility(player, cell, p); player->ResetMap(); if (remove) @@ -646,8 +646,8 @@ Map::Remove(T* obj, bool remove) else obj->RemoveFromWorld(); - UpdateObjectVisibility(obj,cell,p); // i think will be better to call this function while object still in grid, this changes nothing but logically is better(as for me) - RemoveFromGrid(obj,grid,cell); + UpdateObjectVisibility(obj, cell, p); // i think will be better to call this function while object still in grid, this changes nothing but logically is better(as for me) + RemoveFromGrid(obj, grid, cell); obj->ResetMap(); if (remove) @@ -680,20 +680,20 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati DEBUG_FILTER_LOG(LOG_FILTER_PLAYER_MOVES, "Player %s relocation grid[%u,%u]cell[%u,%u]->grid[%u,%u]cell[%u,%u]", player->GetName(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY()); - RemoveFromGrid(player, oldGrid,old_cell); + 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); NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); - player->GetViewPoint().Event_GridChanged(&(*newGrid)(new_cell.CellX(),new_cell.CellY())); + player->GetViewPoint().Event_GridChanged(&(*newGrid)(new_cell.CellX(), new_cell.CellY())); } player->OnRelocated(); NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); - if (!same_cell && newGrid->GetGridState()!= GRID_STATE_ACTIVE) + if (!same_cell && newGrid->GetGridState() != GRID_STATE_ACTIVE) { ResetGridExpiry(*newGrid, 0.1f); newGrid->SetGridState(GRID_STATE_ACTIVE); @@ -702,13 +702,13 @@ Map::PlayerRelocation(Player* player, float x, float y, float z, float orientati void Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang) { - MANGOS_ASSERT(CheckGridIntegrity(creature,false)); + MANGOS_ASSERT(CheckGridIntegrity(creature, false)); Cell old_cell = creature->GetCurrentCell(); Cell new_cell(MaNGOS::ComputeCellPair(x, y)); // do move or do move to respawn or remove creature if previous all fail - if (CreatureCellRelocation(creature,new_cell)) + if (CreatureCellRelocation(creature, new_cell)) { // update pos creature->Relocate(x, y, z, ang); @@ -719,10 +719,10 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa else if (!CreatureRespawnRelocation(creature)) { // ... or unload (if respawn grid also not loaded) - DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",creature->GetGUIDLow(),creature->GetEntry()); + DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.", creature->GetGUIDLow(), creature->GetEntry()); } - MANGOS_ASSERT(CheckGridIntegrity(creature,true)); + MANGOS_ASSERT(CheckGridIntegrity(creature, true)); } bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) @@ -745,7 +745,7 @@ bool Map::CreatureCellRelocation(Creature* c, Cell new_cell) NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); RemoveFromGrid(c, oldGrid, old_cell); AddToGrid(c, newGrid, new_cell); - c->GetViewPoint().Event_GridChanged(&(*newGrid)(new_cell.CellX(),new_cell.CellY())); + c->GetViewPoint().Event_GridChanged(&(*newGrid)(new_cell.CellX(), new_cell.CellY())); } return true; } @@ -764,7 +764,7 @@ bool Map::CreatureRespawnRelocation(Creature* c) DEBUG_FILTER_LOG(LOG_FILTER_CREATURE_MOVES, "Creature (GUID: %u Entry: %u) will moved from grid[%u,%u]cell[%u,%u] to respawn grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY()); // teleport it to respawn point (like normal respawn if player see) - if (CreatureCellRelocation(c,resp_cell)) + if (CreatureCellRelocation(c, resp_cell)) { c->Relocate(resp_x, resp_y, resp_z, resp_o); c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators @@ -784,7 +784,7 @@ bool Map::UnloadGrid(const uint32& x, const uint32& y, bool pForce) if (!pForce && ActiveObjectsNearGrid(x, y)) return false; - DEBUG_LOG("Unloading grid[%u,%u] for map %u", x,y, i_id); + DEBUG_LOG("Unloading grid[%u,%u] for map %u", x, y, i_id); ObjectGridUnloader unloader(*grid); // Finish remove and delete all creatures with delayed remove before moving to respawn grids @@ -813,7 +813,7 @@ bool Map::UnloadGrid(const uint32& x, const uint32& y, bool pForce) m_TerrainData->Unload(gx, gy); } - DEBUG_LOG("Unloading grid[%u,%u] for map %u finished", x,y, i_id); + DEBUG_LOG("Unloading grid[%u,%u] for map %u finished", x, y, i_id); return true; } @@ -829,7 +829,7 @@ void Map::UnloadAll(bool pForce) MapDifficulty const* Map::GetMapDifficulty() const { - return GetMapDifficultyData(GetId(),GetDifficulty()); + return GetMapDifficultyData(GetId(), GetDifficulty()); } uint32 Map::GetMaxPlayers() const @@ -864,7 +864,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const { sLog.outError("Creature (GUIDLow: %u) X: %f Y: %f (%s) in grid[%u,%u]cell[%u,%u] instead grid[%u,%u]cell[%u,%u]", c->GetGUIDLow(), - c->GetPositionX(),c->GetPositionY(),(moved ? "final" : "original"), + c->GetPositionX(), c->GetPositionY(), (moved ? "final" : "original"), cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(), xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY()); return true; // not crash at error, just output error in debug mode @@ -904,9 +904,9 @@ void Map::SendInitSelf(Player* player) // build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map if (Transport* transport = player->GetTransport()) { - for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr!=transport->GetPassengers().end(); ++itr) + for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr) { - if (player!=(*itr) && player->HaveAtClient(*itr)) + if (player != (*itr) && player->HaveAtClient(*itr)) { (*itr)->BuildCreateUpdateBlockForPlayer(&data, player); } @@ -934,7 +934,7 @@ void Map::SendInitTransports(Player* player) for (MapManager::TransportSet::const_iterator i = tset.begin(); i != tset.end(); ++i) { // send data for current transport in other place - if ((*i) != player->GetTransport() && (*i)->GetMapId()==i_id) + if ((*i) != player->GetTransport() && (*i)->GetMapId() == i_id) { (*i)->BuildCreateUpdateBlockForPlayer(&transData, player); } @@ -960,7 +960,7 @@ 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) + if ((*i) != player->GetTransport() && (*i)->GetMapId() != i_id) (*i)->BuildOutOfRangeUpdateBlock(&transData); WorldPacket packet; @@ -972,7 +972,7 @@ inline void Map::setNGrid(NGridType* grid, uint32 x, uint32 y) { if (x >= MAX_NUMBER_OF_GRIDS || y >= MAX_NUMBER_OF_GRIDS) { - sLog.outError("map::setNGrid() Invalid grid coordinates found: %d, %d!",x,y); + sLog.outError("map::setNGrid() Invalid grid coordinates found: %d, %d!", x, y); MANGOS_ASSERT(false); } i_grids[x][y] = grid; @@ -980,7 +980,7 @@ inline void Map::setNGrid(NGridType* grid, uint32 x, uint32 y) void Map::AddObjectToRemoveList(WorldObject* obj) { - MANGOS_ASSERT(obj->GetMapId()==GetId() && obj->GetInstanceId()==GetInstanceId()); + MANGOS_ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId()); obj->CleanupsBeforeDelete(); // remove or simplify at least cross referenced links @@ -1008,20 +1008,20 @@ void Map::RemoveAllObjectsInRemoveList() if (!corpse) sLog.outError("Try delete corpse/bones %u that not in map", obj->GetGUIDLow()); else - Remove(corpse,true); + Remove(corpse, true); break; } case TYPEID_DYNAMICOBJECT: - Remove((DynamicObject*)obj,true); + Remove((DynamicObject*)obj, true); break; case TYPEID_GAMEOBJECT: - Remove((GameObject*)obj,true); + Remove((GameObject*)obj, true); break; case TYPEID_UNIT: - Remove((Creature*)obj,true); + Remove((Creature*)obj, true); break; default: - sLog.outError("Non-grid object (TypeId: %u) in grid object removing list, ignored.",obj->GetTypeId()); + sLog.outError("Non-grid object (TypeId: %u) in grid object removing list, ignored.", obj->GetTypeId()); break; } } @@ -1048,8 +1048,8 @@ bool Map::ActiveObjectsNearGrid(uint32 x, uint32 y) const MANGOS_ASSERT(x < MAX_NUMBER_OF_GRIDS); MANGOS_ASSERT(y < MAX_NUMBER_OF_GRIDS); - CellPair cell_min(x*MAX_NUMBER_OF_CELLS, y*MAX_NUMBER_OF_CELLS); - CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS); + CellPair cell_min(x * MAX_NUMBER_OF_CELLS, y * MAX_NUMBER_OF_CELLS); + CellPair cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord + MAX_NUMBER_OF_CELLS); //we must find visible range in cells so we unload only non-visible cells... float viewDist = GetVisibilityDistance(); @@ -1092,12 +1092,12 @@ void Map::AddToActive(WorldObject* obj) // also not allow unloading spawn grid to prevent creating creature clone at load if (obj->GetTypeId() == TYPEID_UNIT) { - Creature* c= (Creature*)obj; + Creature* c = (Creature*)obj; if (!c->IsPet() && c->HasStaticDBSpawnData()) { - float x,y,z; - c->GetRespawnCoord(x,y,z); + float x, y, z; + 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(); @@ -1117,7 +1117,7 @@ void Map::RemoveFromActive(WorldObject* obj) if (m_activeNonPlayersIter != m_activeNonPlayers.end()) { ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj); - if (itr==m_activeNonPlayersIter) + if (itr == m_activeNonPlayersIter) ++m_activeNonPlayersIter; m_activeNonPlayers.erase(itr); } @@ -1125,14 +1125,14 @@ void Map::RemoveFromActive(WorldObject* obj) m_activeNonPlayers.erase(obj); // also allow unloading spawn grid - if (obj->GetTypeId()==TYPEID_UNIT) + if (obj->GetTypeId() == TYPEID_UNIT) { - Creature* c= (Creature*)obj; + Creature* c = (Creature*)obj; if (!c->IsPet() && c->HasStaticDBSpawnData()) { - float x,y,z; - c->GetRespawnCoord(x,y,z); + float x, y, z; + 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(); @@ -1209,8 +1209,8 @@ template void Map::Add(Creature*); template void Map::Add(GameObject*); template void Map::Add(DynamicObject*); -template void Map::Remove(Corpse*,bool); -template void Map::Remove(Creature*,bool); +template void Map::Remove(Corpse*, bool); +template void Map::Remove(Creature*, bool); template void Map::Remove(GameObject*, bool); template void Map::Remove(DynamicObject*, bool); @@ -1314,7 +1314,7 @@ bool DungeonMap::Add(Player* player) if (pGroup) { // solo saves should be reset when entering a group - InstanceGroupBind* groupBind = pGroup->GetBoundInstance(this,GetDifficulty()); + InstanceGroupBind* groupBind = pGroup->GetBoundInstance(this, GetDifficulty()); if (playerBind) { sLog.outError("DungeonMap::Add: %s is being put in instance %d,%d,%d,%d,%d,%d but he is in group (Id: %d) and is bound to instance %d,%d,%d,%d,%d,%d!", @@ -1712,7 +1712,7 @@ Pet* Map::GetPet(ObjectGuid guid) */ Corpse* Map::GetCorpse(ObjectGuid guid) { - Corpse* ret = ObjectAccessor::GetCorpseInMap(guid,GetId()); + Corpse* ret = ObjectAccessor::GetCorpseInMap(guid, GetId()); return ret && ret->GetInstanceId() == GetInstanceId() ? ret : NULL; } @@ -1782,7 +1782,7 @@ WorldObject* Map::GetWorldObject(ObjectGuid guid) case HIGHGUID_UNIT: case HIGHGUID_VEHICLE: return GetCreature(guid); case HIGHGUID_PET: return GetPet(guid); - case HIGHGUID_DYNAMICOBJECT:return GetDynamicObject(guid); + case HIGHGUID_DYNAMICOBJECT: return GetDynamicObject(guid); case HIGHGUID_CORPSE: { // corpse special case, it can be not in world diff --git a/src/game/Map.h b/src/game/Map.h index 27bd71a4f..753141d98 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -155,7 +155,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager void ResetGridExpiry(NGridType& grid, float factor = 1) const { - grid.ResetTimeTracker((time_t)((float)i_gridExpiry*factor)); + grid.ResetTimeTracker((time_t)((float)i_gridExpiry * factor)); } time_t GetGridExpiry(void) const { return i_gridExpiry; } @@ -207,7 +207,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager bool HavePlayers() const { return !m_mapRefManager.isEmpty(); } uint32 GetPlayersCountExceptGMs() const; - bool ActiveObjectsNearGrid(uint32 x,uint32 y) const; + bool ActiveObjectsNearGrid(uint32 x, uint32 y) const; void SendToPlayers(WorldPacket const* data) const; @@ -296,8 +296,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager return i_grids[x][y]; } - bool isGridObjectDataLoaded(uint32 x, uint32 y) const { return getNGrid(x,y)->isGridObjectDataLoaded(); } - void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y) { getNGrid(x,y)->setGridObjectDataLoaded(pLoaded); } + bool isGridObjectDataLoaded(uint32 x, uint32 y) const { return getNGrid(x, y)->isGridObjectDataLoaded(); } + void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y) { getNGrid(x, y)->setGridObjectDataLoaded(pLoaded); } void setNGrid(NGridType* grid, uint32 x, uint32 y); void ScriptsProcess(); @@ -432,7 +432,7 @@ Map::Visit(const Cell& cell, TypeContainerVisitor& visitor) const uint32 cell_x = cell.CellX(); const uint32 cell_y = cell.CellY(); - if (!cell.NoCreate() || loaded(GridPair(x,y))) + if (!cell.NoCreate() || loaded(GridPair(x, y))) { EnsureGridLoaded(cell); getNGrid(x, y)->Visit(cell_x, cell_y, visitor); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 69252cc1a..dce609378 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -40,7 +40,7 @@ MapManager::MapManager() MapManager::~MapManager() { - for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter) delete iter->second; for (TransportSet::iterator i = m_Transports.begin(); i != m_Transports.end(); ++i) @@ -82,7 +82,7 @@ void MapManager::UpdateGridState(grid_state_t state, Map& map, NGridType& ngrid, void MapManager::InitializeVisibilityDistanceInfo() { - for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter) (*iter).second->InitVisibilityDistance(); } @@ -182,7 +182,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) } //The player has a heroic mode and tries to enter into instance which has no a heroic mode - MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID,player->GetDifficulty(entry->map_type == MAP_RAID)); + MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID, player->GetDifficulty(entry->map_type == MAP_RAID)); if (!mapDiff) { bool isRegularTargetMap = player->GetDifficulty(entry->IsRaid()) == REGULAR_DIFFICULTY; @@ -230,7 +230,7 @@ MapManager::Update(uint32 diff) if (!i_timer.Passed()) return; - for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter) iter->second->Update((uint32)i_timer.GetCurrent()); for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) @@ -261,18 +261,18 @@ MapManager::Update(uint32 diff) void MapManager::RemoveAllObjectsInRemoveList() { - for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter) iter->second->RemoveAllObjectsInRemoveList(); } -bool MapManager::ExistMapAndVMap(uint32 mapid, float x,float y) +bool MapManager::ExistMapAndVMap(uint32 mapid, float x, float y) { - GridPair p = MaNGOS::ComputeGridPair(x,y); + GridPair p = MaNGOS::ComputeGridPair(x, y); - int gx=63-p.x_coord; - int gy=63-p.y_coord; + int gx = 63 - p.x_coord; + int gy = 63 - p.y_coord; - return GridMap::ExistMap(mapid,gx,gy) && GridMap::ExistVMap(mapid,gx,gy); + return GridMap::ExistMap(mapid, gx, gy) && GridMap::ExistVMap(mapid, gx, gy); } bool MapManager::IsValidMAP(uint32 mapid) @@ -284,7 +284,7 @@ bool MapManager::IsValidMAP(uint32 mapid) void MapManager::UnloadAll() { - for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) + for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter) iter->second->UnloadAll(true); while (!i_maps.empty()) @@ -384,7 +384,7 @@ DungeonMap* MapManager::CreateDungeonMap(uint32 id, uint32 InstanceId, Difficult if (!GetMapDifficultyData(id, difficulty)) difficulty = DUNGEON_DIFFICULTY_NORMAL; - DEBUG_LOG("MapInstanced::CreateDungeonMap: %s map instance %d for %d created with difficulty %d", save?"":"new ", InstanceId, id, difficulty); + DEBUG_LOG("MapInstanced::CreateDungeonMap: %s map instance %d for %d created with difficulty %d", save ? "" : "new ", InstanceId, id, difficulty); DungeonMap* map = new DungeonMap(id, i_gridCleanUpDelay, InstanceId, difficulty); @@ -399,7 +399,7 @@ BattleGroundMap* MapManager::CreateBattleGroundMap(uint32 id, uint32 InstanceId, { DEBUG_LOG("MapInstanced::CreateBattleGroundMap: instance:%d for map:%d and bgType:%d created.", InstanceId, id, bg->GetTypeID()); - PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(),bg->GetMinLevel()); + PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), bg->GetMinLevel()); uint8 spawnMode = bracketEntry ? bracketEntry->difficulty : REGULAR_DIFFICULTY; diff --git a/src/game/MapManager.h b/src/game/MapManager.h index 8e3640cb3..7e57a9205 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -94,24 +94,24 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton inline void MapManager::DoForAllMapsWithMapId(uint32 mapId, Do& _do) { - MapMapType::const_iterator start = i_maps.lower_bound(MapID(mapId,0)); - MapMapType::const_iterator end = i_maps.lower_bound(MapID(mapId+1,0)); + MapMapType::const_iterator start = i_maps.lower_bound(MapID(mapId, 0)); + MapMapType::const_iterator end = i_maps.lower_bound(MapID(mapId + 1, 0)); for (MapMapType::const_iterator itr = start; itr != end; ++itr) _do(itr->second); } diff --git a/src/game/MapPersistentStateMgr.cpp b/src/game/MapPersistentStateMgr.cpp index 81ae9a79a..af6959c03 100644 --- a/src/game/MapPersistentStateMgr.cpp +++ b/src/game/MapPersistentStateMgr.cpp @@ -151,7 +151,7 @@ void MapPersistentState::ClearRespawnTimes() void MapPersistentState::AddCreatureToGrid(uint32 guid, CreatureData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; m_gridObjectGuids[cell_id].creatures.insert(guid); } @@ -159,7 +159,7 @@ void MapPersistentState::AddCreatureToGrid(uint32 guid, CreatureData const* data void MapPersistentState::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; m_gridObjectGuids[cell_id].creatures.erase(guid); } @@ -167,7 +167,7 @@ void MapPersistentState::RemoveCreatureFromGrid(uint32 guid, CreatureData const* void MapPersistentState::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; m_gridObjectGuids[cell_id].gameobjects.insert(guid); } @@ -175,7 +175,7 @@ void MapPersistentState::AddGameobjectToGrid(uint32 guid, GameObjectData const* void MapPersistentState::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; m_gridObjectGuids[cell_id].gameobjects.erase(guid); } @@ -349,7 +349,7 @@ void DungeonResetScheduler::LoadResetTimes() // get the current reset times for normal instances (these may need to be updated) // these are only kept in memory for InstanceSaves that are loaded later // resettime = 0 in the DB for raid/heroic instances so those are skipped - typedef std::pair ResetTimeMapDiffType; + typedef std::pair < uint32 /*PAIR32(map,difficulty)*/, time_t > ResetTimeMapDiffType; typedef std::map InstResetTimeMapDiffType; InstResetTimeMapDiffType instResetTime; @@ -372,7 +372,7 @@ void DungeonResetScheduler::LoadResetTimes() continue; } - instResetTime[id] = ResetTimeMapDiffType(MAKE_PAIR32(mapid,difficulty), resettime); + instResetTime[id] = ResetTimeMapDiffType(MAKE_PAIR32(mapid, difficulty), resettime); } } while (result->NextRow()); @@ -403,7 +403,7 @@ void DungeonResetScheduler::LoadResetTimes() // schedule the reset times for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr) if (itr->second.second > now) - ScheduleReset(true, itr->second.second, DungeonResetEvent(RESET_EVENT_NORMAL_DUNGEON, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first)); + ScheduleReset(true, itr->second.second, DungeonResetEvent(RESET_EVENT_NORMAL_DUNGEON, PAIR32_LOPART(itr->second.first), Difficulty(PAIR32_HIPART(itr->second.first)), itr->first)); } // load the global respawn times for raid/heroic instances @@ -421,10 +421,10 @@ void DungeonResetScheduler::LoadResetTimes() MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); - if (!mapEntry || !mapEntry->IsDungeon() || !GetMapDifficultyData(mapid,difficulty)) + if (!mapEntry || !mapEntry->IsDungeon() || !GetMapDifficultyData(mapid, difficulty)) { sLog.outError("MapPersistentStateManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty); - CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid,difficulty); + CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid, difficulty); continue; } @@ -433,7 +433,7 @@ void DungeonResetScheduler::LoadResetTimes() if (oldresettime != newresettime) CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty); - SetResetTimeFor(mapid,difficulty,newresettime); + SetResetTimeFor(mapid, difficulty, newresettime); } while (result->NextRow()); delete result; @@ -461,7 +461,7 @@ void DungeonResetScheduler::LoadResetTimes() continue; uint32 period = GetMaxResetTimeFor(mapDiff); - time_t t = GetResetTimeFor(mapid,difficulty); + time_t t = GetResetTimeFor(mapid, difficulty); if (!t) { // initialize the reset time @@ -478,11 +478,11 @@ void DungeonResetScheduler::LoadResetTimes() CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty= '%u'", (uint64)t, mapid, difficulty); } - SetResetTimeFor(mapid,difficulty,t); + SetResetTimeFor(mapid, difficulty, t); // schedule the global reset/warning ResetEventType type = RESET_EVENT_INFORM_1; - for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1)) + for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type + 1)) if (t - resetEventTypeDelay[type] > now) break; @@ -540,19 +540,19 @@ void DungeonResetScheduler::Update() else { // global reset/warning for a certain map - time_t resetTime = GetResetTimeFor(event.mapid,event.difficulty); + time_t resetTime = GetResetTimeFor(event.mapid, event.difficulty); m_InstanceSaves._ResetOrWarnAll(event.mapid, event.difficulty, event.type != RESET_EVENT_INFORM_LAST, uint32(resetTime - now)); if (event.type != RESET_EVENT_INFORM_LAST) { // schedule the next warning/reset - event.type = ResetEventType(event.type+1); + event.type = ResetEventType(event.type + 1); ScheduleReset(true, resetTime - resetEventTypeDelay[event.type], event); } else { // re-schedule the next/new global reset/warning // calculate the next reset time - MapDifficulty const* mapDiff = GetMapDifficultyData(event.mapid,event.difficulty); + MapDifficulty const* mapDiff = GetMapDifficultyData(event.mapid, event.difficulty); MANGOS_ASSERT(mapDiff); time_t next_reset = DungeonResetScheduler::CalculateNextResetTime(mapDiff, resetTime); @@ -562,7 +562,7 @@ void DungeonResetScheduler::Update() SetResetTimeFor(event.mapid, event.difficulty, next_reset); ResetEventType type = RESET_EVENT_INFORM_1; - for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type+1)) + for (; type < RESET_EVENT_INFORM_LAST; type = ResetEventType(type + 1)) if (next_reset - resetEventTypeDelay[type] > now) break; @@ -699,7 +699,7 @@ void MapPersistentStateManager::RemovePersistentState(uint32 mapId, uint32 insta } } -void MapPersistentStateManager::_DelHelper(DatabaseType& db, const char* fields, const char* table, const char* queryTail,...) +void MapPersistentStateManager::_DelHelper(DatabaseType& db, const char* fields, const char* table, const char* queryTail, ...) { Tokens fieldTokens = StrSplit(fields, ", "); MANGOS_ASSERT(fieldTokens.size() != 0); @@ -857,7 +857,7 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu if (!warn) { - MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty); + MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty); if (!mapDiff || !mapDiff->resetTime) { sLog.outError("MapPersistentStateManager::ResetOrWarnAll: not valid difficulty or no reset delay for map %d", mapid); diff --git a/src/game/MapPersistentStateMgr.h b/src/game/MapPersistentStateMgr.h index 19953220f..fcbb6b656 100644 --- a/src/game/MapPersistentStateMgr.h +++ b/src/game/MapPersistentStateMgr.h @@ -50,7 +50,7 @@ struct MapCellObjectGuids CellGuidSet gameobjects; }; -typedef UNORDERED_MAP MapCellObjectGuidsMap; +typedef UNORDERED_MAP < uint32/*cell_id*/, MapCellObjectGuids > MapCellObjectGuidsMap; class MapPersistentStateManager; @@ -103,7 +103,7 @@ class MapPersistentState // pool system void InitPools(); - virtual SpawnedPoolData& GetSpawnedPoolData() =0; + virtual SpawnedPoolData& GetSpawnedPoolData() = 0; template bool IsSpawnedPoolObject(uint32 db_guid_or_pool_id) { return GetSpawnedPoolData().IsSpawnedObject(db_guid_or_pool_id); } @@ -115,7 +115,7 @@ class MapPersistentState void AddGameobjectToGrid(uint32 guid, GameObjectData const* data); void RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data); protected: - virtual bool CanBeUnload() const =0; // body provided for subclasses + virtual bool CanBeUnload() const = 0; // body provided for subclasses bool UnloadIfEmpty(); void ClearRespawnTimes(); @@ -280,8 +280,8 @@ enum ResetEventType all instances of that map reset at the same time */ struct DungeonResetEvent { - ResetEventType type :8; // if RESET_EVENT_NORMAL_DUNGEON then InstanceID == 0 and applied to all instances for pair (map,diff) - Difficulty difficulty :8; // used with mapid used as for select reset for global cooldown instances (instamceid==0 for event) + ResetEventType type : 8; // if RESET_EVENT_NORMAL_DUNGEON then InstanceID == 0 and applied to all instances for pair (map,diff) + Difficulty difficulty : 8; // used with mapid used as for select reset for global cooldown instances (instamceid==0 for event) uint16 mapid; uint32 instanceId; // used for select reset for normal dungeons @@ -300,7 +300,7 @@ class DungeonResetScheduler public: // accessors time_t GetResetTimeFor(uint32 mapid, Difficulty d) const { - ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR32(mapid,d)); + ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR32(mapid, d)); return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0; } @@ -309,7 +309,7 @@ class DungeonResetScheduler public: // modifiers void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t) { - m_resetTimeByMapDifficulty[MAKE_PAIR32(mapid,d)] = t; + m_resetTimeByMapDifficulty[MAKE_PAIR32(mapid, d)] = t; } void ScheduleReset(bool add, time_t time, DungeonResetEvent event); @@ -320,10 +320,10 @@ class DungeonResetScheduler MapPersistentStateManager& m_InstanceSaves; // fast lookup for reset times (always use existing functions for access/set) - typedef UNORDERED_MAP ResetTimeByMapDifficultyMap; + typedef UNORDERED_MAP < uint32 /*PAIR32(map,difficulty)*/, time_t /*resetTime*/ > ResetTimeByMapDifficultyMap; ResetTimeByMapDifficultyMap m_resetTimeByMapDifficulty; - typedef std::multimap ResetTimeQueue; + typedef std::multimap < time_t /*resetTime*/, DungeonResetEvent > ResetTimeQueue; ResetTimeQueue m_resetTimeQueue; }; @@ -365,7 +365,7 @@ class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton PersistentStateMap; + typedef UNORDERED_MAP < uint32 /*InstanceId or MapId*/, MapPersistentState* > PersistentStateMap; // called by scheduler for DungeonPersistentStates void _ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeleft); @@ -373,7 +373,7 @@ class MANGOS_DLL_DECL MapPersistentStateManager : public MaNGOS::Singleton> temp; // user entered string, it used as universal search pattern(guild+player name)? - if (!Utf8toWStr(temp,str[i])) + if (!Utf8toWStr(temp, str[i])) continue; wstrToLower(str[i]); @@ -201,7 +201,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recv_data) std::string pname = pl->GetName(); std::wstring wpname; - if (!Utf8toWStr(pname,wpname)) + if (!Utf8toWStr(pname, wpname)) continue; wstrToLower(wpname); @@ -210,7 +210,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recv_data) std::string gname = sGuildMgr.GetGuildNameById(pl->GetGuildId()); std::wstring wgname; - if (!Utf8toWStr(gname,wgname)) + if (!Utf8toWStr(gname, wgname)) continue; wstrToLower(wgname); @@ -296,7 +296,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket& /*recv_data*/) if ((GetPlayer()->GetPositionZ() < height + 0.1f) && !(GetPlayer()->IsInWater())) GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT); - WorldPacket data(SMSG_FORCE_MOVE_ROOT, (8+4)); // guess size + WorldPacket data(SMSG_FORCE_MOVE_ROOT, (8 + 4)); // guess size data << GetPlayer()->GetPackGUID(); data << (uint32)2; SendPacket(&data); @@ -644,7 +644,7 @@ void WorldSession::HandleReclaimCorpseOpcode(WorldPacket& recv_data) return; // prevent resurrect before 30-sec delay after body release not finished - if (corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP) > time(NULL)) + if (corpse->GetGhostTime() + GetPlayer()->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP) > time(NULL)) return; if (!corpse->IsWithinDistInMap(GetPlayer(), CORPSE_RECLAIM_RADIUS, true)) @@ -767,7 +767,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) do { // most often fast case - if (instance_map==targetMapEntry->MapID) + if (instance_map == targetMapEntry->MapID) break; InstanceTemplate const* instance = ObjectMgr::GetInstanceTemplate(instance_map); @@ -876,7 +876,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data) { SetAccountData(AccountDataType(type), 0, ""); - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4); + WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4 + 4); data << uint32(type); data << uint32(0); SendPacket(&data); @@ -909,7 +909,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket& recv_data) SetAccountData(AccountDataType(type), timestamp, adata); - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4); + WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4 + 4); data << uint32(type); data << uint32(0); SendPacket(&data); @@ -944,7 +944,7 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data) dest.resize(destSize); - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA, 8+4+4+4+destSize); + WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA, 8 + 4 + 4 + 4 + destSize); data << (_player ? _player->GetObjectGuid() : ObjectGuid());// player guid data << uint32(type); // type (0-7) data << uint32(adata->Time); // unix time @@ -967,7 +967,7 @@ void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recv_data) if (!packetData) { DETAIL_LOG("MISC: Remove action from button %u", button); - GetPlayer()->removeActionButton(GetPlayer()->GetActiveSpec(),button); + GetPlayer()->removeActionButton(GetPlayer()->GetActiveSpec(), button); } else { @@ -1165,7 +1165,7 @@ void WorldSession::HandleInspectHonorStatsOpcode(WorldPacket& recv_data) return; } - WorldPacket data(MSG_INSPECT_HONOR_STATS, 8+1+4*4); + WorldPacket data(MSG_INSPECT_HONOR_STATS, 8 + 1 + 4 * 4); data << player->GetObjectGuid(); data << uint8(player->GetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY)); data << uint32(player->GetUInt32Value(PLAYER_FIELD_KILLS)); @@ -1199,11 +1199,11 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) if (GetPlayer()->IsTaxiFlying()) { - DEBUG_LOG("Player '%s' (GUID: %u) in flight, ignore worldport command.",GetPlayer()->GetName(),GetPlayer()->GetGUIDLow()); + DEBUG_LOG("Player '%s' (GUID: %u) in flight, ignore worldport command.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); return; } - DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time/1000, mapid, PositionX, PositionY, PositionZ, Orientation); + DEBUG_LOG("Time %u sec, map=%u, x=%f, y=%f, z=%f, orient=%f", time / 1000, mapid, PositionX, PositionY, PositionZ, Orientation); if (GetSecurity() >= SEC_ADMINISTRATOR) GetPlayer()->TeleportTo(mapid, PositionX, PositionY, PositionZ, Orientation); @@ -1260,7 +1260,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) std::string msg = charname + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip; - WorldPacket data(SMSG_WHOIS, msg.size()+1); + WorldPacket data(SMSG_WHOIS, msg.size() + 1); data << msg; _player->GetSession()->SendPacket(&data); @@ -1318,7 +1318,7 @@ void WorldSession::HandleRealmSplitOpcode(WorldPacket& recv_data) std::string split_date = "01/01/01"; recv_data >> unk; - WorldPacket data(SMSG_REALM_SPLIT, 4+4+split_date.size()+1); + WorldPacket data(SMSG_REALM_SPLIT, 4 + 4 + split_date.size() + 1); data << unk; data << uint32(0x00000000); // realm split state // split states: diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index e5a582ef2..a75cd38ba 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -46,7 +46,7 @@ void MotionMaster::Initialize() m_owner->StopMoving(); // clear ALL movement generators (including default) - Clear(false,true); + Clear(false, true); // set new default movement generator if (m_owner->GetTypeId() == TYPEID_UNIT && !m_owner->hasUnitState(UNIT_STAT_CONTROLLED)) @@ -259,7 +259,7 @@ void MotionMaster::MoveTargetedHome() if (Unit* target = ((Creature*)m_owner)->GetCharmerOrOwner()) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str()); - Mutate(new FollowMovementGenerator(*target,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE)); + Mutate(new FollowMovementGenerator(*target, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE)); } else { @@ -289,9 +289,9 @@ void MotionMaster::MoveChase(Unit* target, float dist, float angle) 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)); + Mutate(new ChaseMovementGenerator(*target, dist, angle)); } void MotionMaster::MoveFollow(Unit* target, float dist, float angle) @@ -308,9 +308,9 @@ void MotionMaster::MoveFollow(Unit* target, float dist, float angle) 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)); + Mutate(new FollowMovementGenerator(*target, dist, angle)); } void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath) @@ -318,9 +318,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)); + Mutate(new PointMovementGenerator(id, x, y, z, generatePath)); } void MotionMaster::MoveSeekAssistance(float x, float y, float z) @@ -333,7 +333,7 @@ void MotionMaster::MoveSeekAssistance(float x, float y, float z) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s seek assistance (X: %f Y: %f Z: %f)", m_owner->GetGuidStr().c_str(), x, y, z); - Mutate(new AssistanceMovementGenerator(x,y,z)); + Mutate(new AssistanceMovementGenerator(x, y, z)); } } @@ -397,7 +397,7 @@ void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode) if (path < sTaxiPathNodesByPath.size()) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s taxi to (Path %u node %u)", m_owner->GetGuidStr().c_str(), path, pathnode); - FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path],pathnode); + FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path], pathnode); Mutate(mgen); } else @@ -482,8 +482,8 @@ void MotionMaster::UpdateFinalDistanceToTarget(float fDistance) void MotionMaster::MoveJump(float x, float y, float z, float horizontalSpeed, float max_height, uint32 id) { Movement::MoveSplineInit init(*m_owner); - init.MoveTo(x,y,z); - init.SetParabolic(max_height,0); + init.MoveTo(x, y, z); + init.SetParabolic(max_height, 0); init.SetVelocity(horizontalSpeed); init.Launch(); Mutate(new EffectMovementGenerator(id)); @@ -505,7 +505,7 @@ void MotionMaster::MoveFall() return; Movement::MoveSplineInit init(*m_owner); - init.MoveTo(m_owner->GetPositionX(),m_owner->GetPositionY(),tz); + init.MoveTo(m_owner->GetPositionX(), m_owner->GetPositionY(), tz); init.SetFall(); init.Launch(); Mutate(new EffectMovementGenerator(0)); diff --git a/src/game/MotionMaster.h b/src/game/MotionMaster.h index 8830dd331..7cbc5e1ad 100644 --- a/src/game/MotionMaster.h +++ b/src/game/MotionMaster.h @@ -102,8 +102,8 @@ class MANGOS_DLL_SPEC MotionMaster : private std::stack void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f); void MoveConfused(); void MoveFleeing(Unit* enemy, uint32 timeLimit = 0); - void MovePoint(uint32 id, float x,float y,float z, bool generatePath = true); - void MoveSeekAssistance(float x,float y,float z); + void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true); + void MoveSeekAssistance(float x, float y, float z); void MoveSeekAssistanceDistract(uint32 timer); void MoveWaypoint(); void MoveTaxiFlight(uint32 path, uint32 pathnode); diff --git a/src/game/MoveMap.cpp b/src/game/MoveMap.cpp index 800fde917..9169169b4 100644 --- a/src/game/MoveMap.cpp +++ b/src/game/MoveMap.cpp @@ -45,7 +45,7 @@ namespace MMAP if (!g_mmapDisabledIds) g_mmapDisabledIds = new std::set(); - uint32 strLenght = strlen(ignoreMapIds)+1; + uint32 strLenght = strlen(ignoreMapIds) + 1; char* mapList = new char[strLenght]; memcpy(mapList, ignoreMapIds, sizeof(char)*strLenght); @@ -97,9 +97,9 @@ namespace MMAP return true; // load and init dtNavMesh - read parameters from file - uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap")+1; + uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap") + 1; char* fileName = new char[pathLen]; - snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i.mmap").c_str(), mapId); + snprintf(fileName, pathLen, (sWorld.GetDataPath() + "mmaps/%03i.mmap").c_str(), mapId); FILE* file = fopen(fileName, "rb"); if (!file) @@ -159,9 +159,9 @@ namespace MMAP } // load this tile :: mmaps/MMMXXYY.mmtile - uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i%02i%02i.mmtile")+1; + uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i%02i%02i.mmtile") + 1; char* fileName = new char[pathLen]; - snprintf(fileName, pathLen, (sWorld.GetDataPath()+"mmaps/%03i%02i%02i.mmtile").c_str(), mapId, x, y); + snprintf(fileName, pathLen, (sWorld.GetDataPath() + "mmaps/%03i%02i%02i.mmtile").c_str(), mapId, x, y); FILE* file = fopen(fileName, "rb"); if (!file) diff --git a/src/game/MovementGenerator.h b/src/game/MovementGenerator.h index f01227572..0abb38688 100644 --- a/src/game/MovementGenerator.h +++ b/src/game/MovementGenerator.h @@ -108,9 +108,9 @@ class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator bool GetResetPosition(T& /*u*/, float& /*x*/, float& /*y*/, float& /*z*/) { return false; } }; -struct SelectableMovement : public FactoryHolder +struct SelectableMovement : public FactoryHolder { - SelectableMovement(MovementGeneratorType mgt) : FactoryHolder(mgt) {} + SelectableMovement(MovementGeneratorType mgt) : FactoryHolder(mgt) {} }; template @@ -121,8 +121,8 @@ struct MovementGeneratorFactory : public SelectableMovement MovementGenerator* Create(void*) const; }; -typedef FactoryHolder MovementGeneratorCreator; -typedef FactoryHolder::FactoryHolderRegistry MovementGeneratorRegistry; -typedef FactoryHolder::FactoryHolderRepository MovementGeneratorRepository; +typedef FactoryHolder MovementGeneratorCreator; +typedef FactoryHolder::FactoryHolderRegistry MovementGeneratorRegistry; +typedef FactoryHolder::FactoryHolderRepository MovementGeneratorRepository; #endif diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 05d41e3bb..4ad44ecb7 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -172,11 +172,11 @@ void WorldSession::HandleMoveWorldportAckOpcode() if (mInstance) { Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid()); - if (MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID,diff)) + if (MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID, diff)) { if (mapDiff->resetTime) { - if (time_t timeReset = sMapPersistentStateMgr.GetScheduler().GetResetTimeFor(mEntry->MapID,diff)) + if (time_t timeReset = sMapPersistentStateMgr.GetScheduler().GetResetTimeFor(mEntry->MapID, diff)) { uint32 timeleft = uint32(timeReset - time(NULL)); GetPlayer()->SendInstanceResetWarning(mEntry->MapID, diff, timeleft); @@ -211,7 +211,7 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data) uint32 counter, time; recv_data >> counter >> time; DEBUG_LOG("Guid: %s", guid.GetString().c_str()); - DEBUG_LOG("Counter %u, time %u", counter, time/IN_MILLISECONDS); + DEBUG_LOG("Counter %u, time %u", counter, time / IN_MILLISECONDS); Unit* mover = _player->GetMover(); Player* plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; @@ -353,12 +353,12 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket& recv_data) { sLog.outError("%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value", move_type_name[move_type], _player->GetName(), _player->GetSpeed(move_type), newspeed); - _player->SetSpeedRate(move_type,_player->GetSpeedRate(move_type),true); + _player->SetSpeedRate(move_type, _player->GetSpeedRate(move_type), true); } else // must be lesser - cheating { BASIC_LOG("Player %s from account id %u kicked for incorrect speed (must be %f instead %f)", - _player->GetName(),_player->GetSession()->GetAccountId(),_player->GetSpeed(move_type), newspeed); + _player->GetName(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), newspeed); _player->GetSession()->KickPlayer(); } } diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index a34974870..be74d4ac1 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -126,7 +126,7 @@ static void SendTrainerSpellHelper(WorldPacket& data, TrainerSpell const* tSpell SpellChainNode const* chain_node = sSpellMgr.GetSpellChainNode(tSpell->learnedSpell); data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case) - data << uint8(state==TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state); + data << uint8(state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state); data << uint32(floor(tSpell->spellCost * fDiscountMod)); data << uint32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0); @@ -144,7 +144,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) { DEBUG_LOG("WORLD: SendTrainerList"); - Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER); + Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); if (!unit) { DEBUG_LOG("WORLD: SendTrainerList - %s not found or you can't interact with him.", guid.GetString().c_str()); @@ -156,7 +156,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); // trainer list loaded at check; - if (!unit->IsTrainerOf(_player,true)) + if (!unit->IsTrainerOf(_player, true)) return; CreatureInfo const* ci = unit->GetCreatureInfo(); @@ -175,7 +175,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) uint32 maxcount = (cSpells ? cSpells->spellList.size() : 0) + (tSpells ? tSpells->spellList.size() : 0); uint32 trainer_type = cSpells && cSpells->trainerType ? cSpells->trainerType : (tSpells ? tSpells->trainerType : 0); - WorldPacket data(SMSG_TRAINER_LIST, 8+4+4+maxcount*38 + strTitle.size()+1); + WorldPacket data(SMSG_TRAINER_LIST, 8 + 4 + 4 + maxcount * 38 + strTitle.size() + 1); data << ObjectGuid(guid); data << uint32(trainer_type); @@ -230,7 +230,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) data << strTitle; - data.put(count_pos,count); + data.put(count_pos, count); SendPacket(&data); } @@ -423,7 +423,7 @@ void WorldSession::SendSpiritResurrect() { _player->ResurrectPlayer(0.5f, true); - _player->DurabilityLossAll(0.25f,true); + _player->DurabilityLossAll(0.25f, true); // get corpse nearest graveyard WorldSafeLocsEntry const* corpseGrave = NULL; @@ -466,7 +466,7 @@ void WorldSession::HandleBinderActivateOpcode(WorldPacket& recv_data) if (!GetPlayer()->IsInWorld() || !GetPlayer()->isAlive()) return; - Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid,UNIT_NPC_FLAG_INNKEEPER); + Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_INNKEEPER); if (!unit) { DEBUG_LOG("WORLD: HandleBinderActivateOpcode - %s not found or you can't interact with him.", npcGuid.GetString().c_str()); @@ -489,7 +489,7 @@ void WorldSession::SendBindPoint(Creature* npc) // send spell for bind 3286 bind magic npc->CastSpell(_player, 3286, true); // Bind - WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, (8+4)); + WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, (8 + 4)); data << npc->GetObjectGuid(); data << uint32(3286); // Bind SendPacket(&data); @@ -534,7 +534,7 @@ void WorldSession::SendStablePet(ObjectGuid guid) uint8 num = 0; // counter for place holder // not let move dead pet in slot - if (pet && pet->isAlive() && pet->getPetType()==HUNTER_PET) + if (pet && pet->isAlive() && pet->getPetType() == HUNTER_PET) { data << uint32(pet->GetCharmInfo()->GetPetNumber()); data << uint32(pet->GetEntry()); @@ -546,7 +546,7 @@ void WorldSession::SendStablePet(ObjectGuid guid) // 0 1 2 3 4 QueryResult* result = CharacterDatabase.PQuery("SELECT owner, id, entry, level, name FROM character_pet WHERE owner = '%u' AND slot >= '%u' AND slot <= '%u' ORDER BY slot", - _player->GetGUIDLow(),PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); + _player->GetGUIDLow(), PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_LAST_STABLE_SLOT); if (result) { @@ -629,7 +629,7 @@ void WorldSession::HandleStablePet(WorldPacket& recv_data) Pet* pet = _player->GetPet(); // can't place in stable dead pet - if (!pet||!pet->isAlive()||pet->getPetType()!=HUNTER_PET) + if (!pet || !pet->isAlive() || pet->getPetType() != HUNTER_PET) { SendStableResult(STABLE_ERR_STABLE); return; @@ -638,7 +638,7 @@ void WorldSession::HandleStablePet(WorldPacket& recv_data) uint32 free_slot = 1; QueryResult* result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot >= '%u' AND slot <= '%u' ORDER BY slot ", - _player->GetGUIDLow(),PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); + _player->GetGUIDLow(), PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_LAST_STABLE_SLOT); if (result) { do @@ -648,7 +648,7 @@ void WorldSession::HandleStablePet(WorldPacket& recv_data) uint32 slot = fields[1].GetUInt32(); // slots ordered in query, and if not equal then free - if (slot!=free_slot) + if (slot != free_slot) break; // this slot not free, skip @@ -690,7 +690,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recv_data) { QueryResult* result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot >='%u' AND slot <= '%u'", - _player->GetGUIDLow(),petnumber,PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); + _player->GetGUIDLow(), petnumber, PET_SAVE_FIRST_STABLE_SLOT, PET_SAVE_LAST_STABLE_SLOT); if (result) { Field* fields = result->Fetch(); @@ -728,7 +728,7 @@ void WorldSession::HandleUnstablePet(WorldPacket& recv_data) pet->Unsummon(PET_SAVE_AS_DELETED, _player); Pet* newpet = new Pet(HUNTER_PET); - if (!newpet->LoadPetFromDB(_player,creature_id,petnumber)) + if (!newpet->LoadPetFromDB(_player, creature_id, petnumber)) { delete newpet; newpet = NULL; @@ -758,7 +758,7 @@ void WorldSession::HandleBuyStableSlot(WorldPacket& recv_data) if (GetPlayer()->m_stableSlots < MAX_PET_STABLES) { - StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1); + StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots + 1); if (_player->GetMoney() >= SlotPrice->Price) { ++GetPlayer()->m_stableSlots; @@ -798,7 +798,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recv_data) Pet* pet = _player->GetPet(); - if (!pet || pet->getPetType()!=HUNTER_PET) + if (!pet || pet->getPetType() != HUNTER_PET) { SendStableResult(STABLE_ERR_STABLE); return; @@ -806,7 +806,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recv_data) // find swapped pet slot in stable QueryResult* result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'", - _player->GetGUIDLow(),pet_number); + _player->GetGUIDLow(), pet_number); if (!result) { SendStableResult(STABLE_ERR_STABLE); @@ -841,7 +841,7 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recv_data) // summon unstabled pet Pet* newpet = new Pet; - if (!newpet->LoadPetFromDB(_player,creature_id,pet_number)) + if (!newpet->LoadPetFromDB(_player, creature_id, pet_number)) { delete newpet; SendStableResult(STABLE_ERR_STABLE); @@ -882,7 +882,7 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket& recv_data) Item* item = _player->GetItemByGuid(itemGuid); if (item) - TotalCost= _player->DurabilityRepair(item->GetPos(), true, discountMod, (guildBank > 0)); + TotalCost = _player->DurabilityRepair(item->GetPos(), true, discountMod, (guildBank > 0)); } else { diff --git a/src/game/Object.cpp b/src/game/Object.cpp index ba487ee97..5a5601668 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -83,10 +83,10 @@ Object::~Object() void Object::_InitValues() { m_uint32Values = new uint32[ m_valuesCount ]; - memset(m_uint32Values, 0, m_valuesCount*sizeof(uint32)); + memset(m_uint32Values, 0, m_valuesCount * sizeof(uint32)); m_uint32Values_mirror = new uint32[ m_valuesCount ]; - memset(m_uint32Values_mirror, 0, m_valuesCount*sizeof(uint32)); + memset(m_uint32Values_mirror, 0, m_valuesCount * sizeof(uint32)); m_objectUpdated = false; } @@ -501,7 +501,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u if (((Unit*)this)->HasAuraStateForCaster(AURA_STATE_CONFLAGRATE, target->GetObjectGuid())) *data << m_uint32Values[index]; else - *data << (m_uint32Values[index] & ~(1 << (AURA_STATE_CONFLAGRATE-1))); + *data << (m_uint32Values[index] & ~(1 << (AURA_STATE_CONFLAGRATE - 1))); } else *data << m_uint32Values[index]; @@ -615,7 +615,7 @@ void Object::ClearUpdateMask(bool remove) { for (uint16 index = 0; index < m_valuesCount; ++index) { - if (m_uint32Values_mirror[index]!= m_uint32Values[index]) + if (m_uint32Values_mirror[index] != m_uint32Values[index]) m_uint32Values_mirror[index] = m_uint32Values[index]; } } @@ -651,7 +651,7 @@ void Object::_SetUpdateBits(UpdateMask* updateMask, Player* /*target*/) const { for (uint16 index = 0; index < m_valuesCount; ++index) { - if (m_uint32Values_mirror[index]!= m_uint32Values[index]) + if (m_uint32Values_mirror[index] != m_uint32Values[index]) updateMask->SetBit(index); } } @@ -690,7 +690,7 @@ void Object::SetUInt32Value(uint16 index, uint32 value) void Object::SetUInt64Value(uint16 index, const uint64& value) { MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); - if (*((uint64*)&(m_uint32Values[ index ])) != value) + if (*((uint64*) & (m_uint32Values[ index ])) != value) { m_uint32Values[ index ] = *((uint32*)&value); m_uint32Values[ index + 1 ] = *(((uint32*)&value) + 1); @@ -877,7 +877,7 @@ void Object::RemoveShortFlag(uint16 index, bool highpart, uint16 oldFlag) bool Object::PrintIndexError(uint32 index, bool set) const { - sLog.outError("Attempt %s nonexistent value field: %u (count: %u) for object typeid: %u type mask: %u",(set ? "set value to" : "get value from"),index,m_valuesCount,GetTypeId(),m_objectType); + sLog.outError("Attempt %s nonexistent value field: %u (count: %u) for object typeid: %u type mask: %u", (set ? "set value to" : "get value from"), index, m_valuesCount, GetTypeId(), m_objectType); // ASSERT must fail after function call return false; @@ -908,19 +908,19 @@ void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_play void Object::AddToClientUpdateList() { - sLog.outError("Unexpected call of Object::AddToClientUpdateList for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount); + sLog.outError("Unexpected call of Object::AddToClientUpdateList for object (TypeId: %u Update fields: %u)", GetTypeId(), m_valuesCount); MANGOS_ASSERT(false); } void Object::RemoveFromClientUpdateList() { - sLog.outError("Unexpected call of Object::RemoveFromClientUpdateList for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount); + sLog.outError("Unexpected call of Object::RemoveFromClientUpdateList for object (TypeId: %u Update fields: %u)", GetTypeId(), m_valuesCount); MANGOS_ASSERT(false); } void Object::BuildUpdateData(UpdateDataMapType& /*update_players */) { - sLog.outError("Unexpected call of Object::BuildUpdateData for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount); + sLog.outError("Unexpected call of Object::BuildUpdateData for object (TypeId: %u Update fields: %u)", GetTypeId(), m_valuesCount); MANGOS_ASSERT(false); } @@ -1008,7 +1008,7 @@ float WorldObject::GetDistance(const WorldObject* obj) const float dy = GetPositionY() - obj->GetPositionY(); float dz = GetPositionZ() - obj->GetPositionZ(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); - float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor; + float dist = sqrt((dx * dx) + (dy * dy) + (dz * dz)) - sizefactor; return (dist > 0 ? dist : 0); } @@ -1017,7 +1017,7 @@ float WorldObject::GetDistance2d(float x, float y) const float dx = GetPositionX() - x; float dy = GetPositionY() - y; float sizefactor = GetObjectBoundingRadius(); - float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor; + float dist = sqrt((dx * dx) + (dy * dy)) - sizefactor; return (dist > 0 ? dist : 0); } @@ -1027,7 +1027,7 @@ float WorldObject::GetDistance(float x, float y, float z) const float dy = GetPositionY() - y; float dz = GetPositionZ() - z; float sizefactor = GetObjectBoundingRadius(); - float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor; + float dist = sqrt((dx * dx) + (dy * dy) + (dz * dz)) - sizefactor; return (dist > 0 ? dist : 0); } @@ -1036,7 +1036,7 @@ float WorldObject::GetDistance2d(const WorldObject* obj) const float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); - float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor; + float dist = sqrt((dx * dx) + (dy * dy)) - sizefactor; return (dist > 0 ? dist : 0); } @@ -1053,7 +1053,7 @@ bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist2compare) float dx = GetPositionX() - x; float dy = GetPositionY() - y; float dz = GetPositionZ() - z; - float distsq = dx*dx + dy*dy + dz*dz; + float distsq = dx * dx + dy * dy + dz * dz; float sizefactor = GetObjectBoundingRadius(); float maxdist = dist2compare + sizefactor; @@ -1065,7 +1065,7 @@ bool WorldObject::IsWithinDist2d(float x, float y, float dist2compare) const { float dx = GetPositionX() - x; float dy = GetPositionY() - y; - float distsq = dx*dx + dy*dy; + float distsq = dx * dx + dy * dy; float sizefactor = GetObjectBoundingRadius(); float maxdist = dist2compare + sizefactor; @@ -1077,11 +1077,11 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool { float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); - float distsq = dx*dx + dy*dy; + float distsq = dx * dx + dy * dy; if (is3D) { float dz = GetPositionZ() - obj->GetPositionZ(); - distsq += dz*dz; + distsq += dz * dz; } float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float maxdist = dist2compare + sizefactor; @@ -1092,36 +1092,36 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const { if (!IsInMap(obj)) return false; - float ox,oy,oz; - obj->GetPosition(ox,oy,oz); + float ox, oy, oz; + obj->GetPosition(ox, oy, oz); return(IsWithinLOS(ox, oy, oz)); } bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const { - float x,y,z; - GetPosition(x,y,z); - return GetMap()->IsInLineOfSight(x, y, z+2.0f, ox, oy, oz+2.0f); + float x, y, z; + GetPosition(x, y, z); + return GetMap()->IsInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f); } bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D /* = true */) const { float dx1 = GetPositionX() - obj1->GetPositionX(); float dy1 = GetPositionY() - obj1->GetPositionY(); - float distsq1 = dx1*dx1 + dy1*dy1; + float distsq1 = dx1 * dx1 + dy1 * dy1; if (is3D) { float dz1 = GetPositionZ() - obj1->GetPositionZ(); - distsq1 += dz1*dz1; + distsq1 += dz1 * dz1; } float dx2 = GetPositionX() - obj2->GetPositionX(); float dy2 = GetPositionY() - obj2->GetPositionY(); - float distsq2 = dx2*dx2 + dy2*dy2; + float distsq2 = dx2 * dx2 + dy2 * dy2; if (is3D) { float dz2 = GetPositionZ() - obj2->GetPositionZ(); - distsq2 += dz2*dz2; + distsq2 += dz2 * dz2; } return distsq1 < distsq2; @@ -1131,11 +1131,11 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan { float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); - float distsq = dx*dx + dy*dy; + float distsq = dx * dx + dy * dy; if (is3D) { float dz = GetPositionZ() - obj->GetPositionZ(); - distsq += dz*dz; + distsq += dz * dz; } float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); @@ -1156,7 +1156,7 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange) { float dx = GetPositionX() - x; float dy = GetPositionY() - y; - float distsq = dx*dx + dy*dy; + float distsq = dx * dx + dy * dy; float sizefactor = GetObjectBoundingRadius(); @@ -1177,7 +1177,7 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m float dx = GetPositionX() - x; float dy = GetPositionY() - y; float dz = GetPositionZ() - z; - float distsq = dx*dx + dy*dy + dz*dz; + float distsq = dx * dx + dy * dy + dz * dz; float sizefactor = GetObjectBoundingRadius(); @@ -1236,10 +1236,10 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const // move angle to range -pi ... +pi angle = MapManager::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 + float lborder = -1 * (arc / 2.0f); // in range -pi..0 + float rborder = (arc / 2.0f); // in range 0..pi return ((angle >= lborder) && (angle <= rborder)); } @@ -1274,8 +1274,8 @@ void WorldObject::GetRandomPoint(float x, float y, float z, float distance, floa } // angle to face `obj` to `this` - float angle = rand_norm_f()*2*M_PI_F; - float new_dist = rand_norm_f()*distance; + float angle = rand_norm_f() * 2 * M_PI_F; + float new_dist = rand_norm_f() * distance; rand_x = x + new_dist * cos(angle); rand_y = y + new_dist * sin(angle); @@ -1283,14 +1283,14 @@ void WorldObject::GetRandomPoint(float x, float y, float z, float distance, floa MaNGOS::NormalizeMapCoord(rand_x); MaNGOS::NormalizeMapCoord(rand_y); - UpdateGroundPositionZ(rand_x,rand_y,rand_z); // update to LOS height if available + UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available } void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const { - float new_z = GetTerrain()->GetHeight(x,y,z,true); + float new_z = GetTerrain()->GetHeight(x, y, z, true); if (new_z > INVALID_HEIGHT) - z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface + z = new_z + 0.05f; // just to be sure that we are not a few pixel under the surface } void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const @@ -1359,21 +1359,21 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const bool WorldObject::IsPositionValid() const { - return MaNGOS::IsValidMapCoord(m_position.x,m_position.y,m_position.z,m_position.o); + return MaNGOS::IsValidMapCoord(m_position.x, m_position.y, m_position.z, m_position.o); } void WorldObject::MonsterSay(const char* text, uint32 language, Unit* target) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildMonsterChat(&data, GetObjectGuid(), CHAT_MSG_MONSTER_SAY, text, language, GetName(), target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : ""); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY),true); + SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), true); } void WorldObject::MonsterYell(const char* text, uint32 language, Unit* target) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildMonsterChat(&data, GetObjectGuid(), CHAT_MSG_MONSTER_YELL, text, language, GetName(), target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : ""); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL),true); + SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL), true); } void WorldObject::MonsterTextEmote(const char* text, Unit* target, bool IsBossEmote) @@ -1404,7 +1404,7 @@ namespace MaNGOS : i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(language), i_target(target) {} void operator()(WorldPacket& data, int32 loc_idx) { - char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); + char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); WorldObject::BuildMonsterChat(&data, i_object.GetObjectGuid(), i_msgtype, text, i_language, i_object.GetNameForLocaleIdx(loc_idx), i_target ? i_target->GetObjectGuid() : ObjectGuid(), i_target ? i_target->GetNameForLocaleIdx(loc_idx) : ""); } @@ -1432,7 +1432,7 @@ void WorldObject::MonsterYell(int32 textId, uint32 language, Unit* target) float range = sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL); MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, target); MaNGOS::LocalizedPacketDo say_do(say_build); - MaNGOS::CameraDistWorker > say_worker(this,range,say_do); + MaNGOS::CameraDistWorker > say_worker(this, range, say_do); Cell::VisitWorldObjects(this, say_worker, range); } @@ -1445,7 +1445,7 @@ void WorldObject::MonsterYellToZone(int32 textId, uint32 language, Unit* target) Map::PlayerList const& pList = GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) - if (itr->getSource()->GetZoneId()==zoneid) + if (itr->getSource()->GetZoneId() == zoneid) say_do(itr->getSource()); } @@ -1455,7 +1455,7 @@ void WorldObject::MonsterTextEmote(int32 textId, Unit* target, bool IsBossEmote) MaNGOS::MonsterChatBuilder say_build(*this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, target); MaNGOS::LocalizedPacketDo say_do(say_build); - MaNGOS::CameraDistWorker > say_worker(this,range,say_do); + MaNGOS::CameraDistWorker > say_worker(this, range, say_do); Cell::VisitWorldObjects(this, say_worker, range); } @@ -1480,15 +1480,15 @@ void WorldObject::BuildMonsterChat(WorldPacket* data, ObjectGuid senderGuid, uin *data << uint32(language); *data << ObjectGuid(senderGuid); *data << uint32(0); // 2.1.0 - *data << uint32(strlen(name)+1); + *data << uint32(strlen(name) + 1); *data << name; *data << ObjectGuid(targetGuid); // Unit Target if (targetGuid && !targetGuid.IsPlayer()) { - *data << uint32(strlen(targetName)+1); // target name length + *data << uint32(strlen(targetName) + 1); // target name length *data << targetName; // target name } - *data << uint32(strlen(text)+1); + *data << uint32(strlen(text) + 1); *data << text; *data << uint8(0); // ChatTag } @@ -1526,7 +1526,7 @@ void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid) void WorldObject::SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId /*= 0*/) { - WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4); + WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8 + 4); data << ObjectGuid(guid); data << uint32(animId); SendMessageToSet(&data, true); @@ -1552,7 +1552,7 @@ void WorldObject::AddObjectToRemoveList() GetMap()->AddObjectToRemoveList(this); } -Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject) +Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, bool asActiveObject) { CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(id); if (!cinfo) @@ -1564,7 +1564,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa TemporarySummon* pCreature = new TemporarySummon(GetObjectGuid()); Team team = TEAM_NONE; - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) team = ((Player*)this)->GetTeam(); CreatureCreatePos pos(GetMap(), x, y, z, ang, GetPhaseMask()); @@ -1585,7 +1585,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa pCreature->Summon(spwtype, despwtime); - if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) ((Creature*)this)->AI()->JustSummoned(pCreature); // return the creature therewith the summoner has access to it @@ -1617,7 +1617,7 @@ namespace MaNGOS y = c->GetPositionY(); } - add(c,x,y); + add(c, x, y); } template @@ -1627,12 +1627,12 @@ namespace MaNGOS if (u == i_searcher || u == &i_object) return; - float x,y; + float x, y; x = u->GetPositionX(); y = u->GetPositionY(); - add(u,x,y); + add(u, x, y); } // we must add used pos that can fill places around center @@ -1798,7 +1798,7 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update) void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/) { - WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8); + WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8); data << uint32(sound_id); data << GetObjectGuid(); if (target) diff --git a/src/game/Object.h b/src/game/Object.h index fdd276e1f..be81cf9a9 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -187,7 +187,7 @@ class MANGOS_DLL_SPEC Object const uint64& GetUInt64Value(uint16 index) const { MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , false)); - return *((uint64*)&(m_uint32Values[ index ])); + return *((uint64*) & (m_uint32Values[ index ])); } const float& GetFloatValue(uint16 index) const @@ -200,14 +200,14 @@ class MANGOS_DLL_SPEC Object { MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false)); MANGOS_ASSERT(offset < 4); - return *(((uint8*)&m_uint32Values[ index ])+offset); + return *(((uint8*)&m_uint32Values[ index ]) + offset); } uint16 GetUInt16Value(uint16 index, uint8 offset) const { MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false)); MANGOS_ASSERT(offset < 2); - return *(((uint16*)&m_uint32Values[ index ])+offset); + return *(((uint16*)&m_uint32Values[ index ]) + offset); } ObjectGuid const& GetGuidValue(uint16 index) const { return *reinterpret_cast(&GetUInt64Value(index)); } @@ -218,7 +218,7 @@ class MANGOS_DLL_SPEC Object void SetFloatValue(uint16 index, float value); void SetByteValue(uint16 index, uint8 offset, uint8 value); void SetUInt16Value(uint16 index, uint8 offset, uint16 value); - void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index,offset,(uint16)value); } + void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index, offset, (uint16)value); } void SetGuidValue(uint16 index, ObjectGuid const& value) { SetUInt64Value(index, value.GetRawValue()); } void SetStatFloatValue(uint16 index, float value); void SetStatInt32Value(uint16 index, int32 value); @@ -232,7 +232,7 @@ class MANGOS_DLL_SPEC Object void ApplyPercentModFloatValue(uint16 index, float val, bool apply) { val = val != -100.0f ? val : -99.9f ; - SetFloatValue(index, GetFloatValue(index) * (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val))); + SetFloatValue(index, GetFloatValue(index) * (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val))); } void SetFlag(uint16 index, uint32 newFlag); @@ -315,14 +315,14 @@ class MANGOS_DLL_SPEC Object { uint64 oldval = GetUInt64Value(index); uint64 newval = oldval | newFlag; - SetUInt64Value(index,newval); + SetUInt64Value(index, newval); } void RemoveFlag64(uint16 index, uint64 oldFlag) { uint64 oldval = GetUInt64Value(index); uint64 newval = oldval & ~oldFlag; - SetUInt64Value(index,newval); + SetUInt64Value(index, newval); } void ToggleFlag64(uint16 index, uint64 flag) @@ -488,7 +488,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object InstanceData* GetInstanceData() const; const char* GetName() const { return m_name.c_str(); } - void SetName(const std::string& newname) { m_name=newname; } + void SetName(const std::string& newname) { m_name = newname; } virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); } @@ -508,12 +508,12 @@ class MANGOS_DLL_SPEC WorldObject : public Object // use only if you will sure about placing both object at same map bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const { - return obj && _IsWithinDist(obj,dist2compare,is3D); + return obj && _IsWithinDist(obj, dist2compare, is3D); } bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const { - return obj && IsInMap(obj) && _IsWithinDist(obj,dist2compare,is3D); + return obj && IsInMap(obj) && _IsWithinDist(obj, dist2compare, is3D); } bool IsWithinLOS(float x, float y, float z) const; bool IsWithinLOSInMap(const WorldObject* obj) const; @@ -525,9 +525,9 @@ class MANGOS_DLL_SPEC WorldObject : public Object float GetAngle(const WorldObject* obj) const; float GetAngle(const float x, const float y) const; bool HasInArc(const float arcangle, const WorldObject* obj) const; - bool isInFrontInMap(WorldObject const* target,float distance, float arc = M_PI) const; + bool isInFrontInMap(WorldObject const* target, float distance, float arc = M_PI) const; bool isInBackInMap(WorldObject const* target, float distance, float arc = M_PI) const; - bool isInFront(WorldObject const* target,float distance, float arc = M_PI) const; + bool isInFront(WorldObject const* target, float distance, float arc = M_PI) const; bool isInBack(WorldObject const* target, float distance, float arc = M_PI) const; virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units @@ -553,8 +553,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object void SendObjectDeSpawnAnim(ObjectGuid guid); void SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId = 0); - virtual bool IsHostileTo(Unit const* unit) const =0; - virtual bool IsFriendlyTo(Unit const* unit) const =0; + virtual bool IsHostileTo(Unit const* unit) const = 0; + virtual bool IsFriendlyTo(Unit const* unit) const = 0; bool IsControlledByPlayer() const; virtual void SaveRespawnTime() {} @@ -564,7 +564,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object virtual void UpdateVisibilityAndView(); // update visibility for object and object for all around // main visibility check function in normal case (ignore grey zone distance check) - bool isVisibleFor(Player const* u, WorldObject const* viewPoint) const { return isVisibleForInState(u,viewPoint,false); } + bool isVisibleFor(Player const* u, WorldObject const* viewPoint) const { return isVisibleForInState(u, viewPoint, false); } // low level function for visibility change code, must be define in all main world object subclasses virtual bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const = 0; @@ -581,7 +581,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object void RemoveFromClientUpdateList(); void BuildUpdateData(UpdateDataMapType&); - Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject = false); + Creature* SummonCreature(uint32 id, float x, float y, float z, float ang, TempSummonType spwtype, uint32 despwtime, bool asActiveObject = false); bool isActiveObject() const { return m_isActiveObject || m_viewPoint.hasViewers(); } void SetActiveObjectState(bool active); diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index dfb390e98..ab0a5eb1f 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -141,7 +141,7 @@ ObjectAccessor::RemoveCorpse(Corpse* corpse) // build mapid*cellid -> guid_set map CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY()); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; sObjectMgr.DeleteCorpseCellData(corpse->GetMapId(), cell_id, corpse->GetOwnerGuid().GetCounter()); corpse->RemoveFromWorld(); @@ -160,13 +160,13 @@ ObjectAccessor::AddCorpse(Corpse* corpse) // build mapid*cellid -> guid_set map CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY()); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; sObjectMgr.AddCorpseCellData(corpse->GetMapId(), cell_id, corpse->GetOwnerGuid().GetCounter(), corpse->GetInstanceId()); } void -ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map) +ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair, GridType& grid, Map* map) { Guard guard(i_corpseGuard); for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 047f814e6..f0596beb7 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -116,7 +116,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton& grid.AddGridObject(obj); - addUnitState(obj,cell); + addUnitState(obj, cell); obj->SetMap(map); obj->AddToWorld(); if (obj->isActiveObject()) @@ -158,7 +158,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair& cell, CorpseMapType grid.AddWorldObject(obj); - addUnitState(obj,cell); + addUnitState(obj, cell); obj->SetMap(map); obj->AddToWorld(); if (obj->isActiveObject()) @@ -171,14 +171,14 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair& cell, CorpseMapType void ObjectGridLoader::Visit(GameObjectMapType& m) { - uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); - uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x,y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 x = (i_cell.GridX() * MAX_NUMBER_OF_CELLS) + i_cell.CellX(); + uint32 y = (i_cell.GridY() * MAX_NUMBER_OF_CELLS) + i_cell.CellY(); + CellPair cell_pair(x, y); + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); - GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY()))(i_cell.CellX(),i_cell.CellY()); + GridType& grid = (*i_map->getNGrid(i_cell.GridX(), i_cell.GridY()))(i_cell.CellX(), i_cell.CellY()); LoadHelper(cell_guids.gameobjects, cell_pair, m, i_gameObjects, i_map, grid); LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).gameobjects, cell_pair, m, i_gameObjects, i_map, grid); } @@ -186,14 +186,14 @@ ObjectGridLoader::Visit(GameObjectMapType& m) void ObjectGridLoader::Visit(CreatureMapType& m) { - uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); - uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x,y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 x = (i_cell.GridX() * MAX_NUMBER_OF_CELLS) + i_cell.CellX(); + uint32 y = (i_cell.GridY() * MAX_NUMBER_OF_CELLS) + i_cell.CellY(); + CellPair cell_pair(x, y); + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); - GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY()))(i_cell.CellX(),i_cell.CellY()); + GridType& grid = (*i_map->getNGrid(i_cell.GridX(), i_cell.GridY()))(i_cell.CellX(), i_cell.CellY()); LoadHelper(cell_guids.creatures, cell_pair, m, i_creatures, i_map, grid); LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).creatures, cell_pair, m, i_creatures, i_map, grid); } @@ -201,14 +201,14 @@ ObjectGridLoader::Visit(CreatureMapType& m) void ObjectWorldLoader::Visit(CorpseMapType& m) { - uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); - uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); - CellPair cell_pair(x,y); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 x = (i_cell.GridX() * MAX_NUMBER_OF_CELLS) + i_cell.CellX(); + uint32 y = (i_cell.GridY() * MAX_NUMBER_OF_CELLS) + i_cell.CellY(); + CellPair cell_pair(x, y); + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; // corpses are always added to spawn mode 0 and they are spawned by their instance id CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), 0, cell_id); - GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY()))(i_cell.CellX(),i_cell.CellY()); + GridType& grid = (*i_map->getNGrid(i_cell.GridX(), i_cell.GridY()))(i_cell.CellX(), i_cell.CellY()); LoadHelper(cell_guids.corpses, cell_pair, m, i_corpses, i_map, grid); } @@ -232,24 +232,24 @@ void ObjectGridLoader::LoadN(void) { i_gameObjects = 0; i_creatures = 0; i_corpses = 0; i_cell.data.Part.cell_y = 0; - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) + for (unsigned int x = 0; x < MAX_NUMBER_OF_CELLS; ++x) { i_cell.data.Part.cell_x = x; - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) + for (unsigned int y = 0; y < MAX_NUMBER_OF_CELLS; ++y) { i_cell.data.Part.cell_y = y; GridLoader loader; loader.Load(i_grid(x, y), *this); } } - DEBUG_LOG("%u GameObjects, %u Creatures, and %u Corpses/Bones loaded for grid %u on map %u", i_gameObjects, i_creatures, i_corpses,i_grid.GetGridId(), i_map->GetId()); + DEBUG_LOG("%u GameObjects, %u Creatures, and %u Corpses/Bones loaded for grid %u on map %u", i_gameObjects, i_creatures, i_corpses, i_grid.GetGridId(), i_map->GetId()); } void ObjectGridUnloader::MoveToRespawnN() { - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) + for (unsigned int x = 0; x < MAX_NUMBER_OF_CELLS; ++x) { - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) + for (unsigned int y = 0; y < MAX_NUMBER_OF_CELLS; ++y) { ObjectGridRespawnMover mover; mover.Move(i_grid(x, y)); @@ -269,7 +269,7 @@ void ObjectGridUnloader::Visit(GridRefManager& m) { // remove all cross-reference before deleting - for (typename GridRefManager::iterator iter=m.begin(); iter != m.end(); ++iter) + for (typename GridRefManager::iterator iter = m.begin(); iter != m.end(); ++iter) iter->getSource()->CleanupsBeforeDelete(); while (!m.isEmpty()) @@ -296,7 +296,7 @@ void ObjectGridStoper::Visit(CreatureMapType& m) { // stop any fights at grid de-activation and remove dynobjects created at cast by creatures - for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) + for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter) { iter->getSource()->CombatStop(); iter->getSource()->DeleteThreatList(); diff --git a/src/game/ObjectGridLoader.h b/src/game/ObjectGridLoader.h index bbfb15e11..e8ee21089 100644 --- a/src/game/ObjectGridLoader.h +++ b/src/game/ObjectGridLoader.h @@ -63,9 +63,9 @@ class MANGOS_DLL_DECL ObjectGridUnloader void MoveToRespawnN(); void UnloadN() { - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) + for (unsigned int x = 0; x < MAX_NUMBER_OF_CELLS; ++x) { - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) + for (unsigned int y = 0; y < MAX_NUMBER_OF_CELLS; ++y) { GridLoader loader; loader.Unload(i_grid(x, y), *this); @@ -87,9 +87,9 @@ class MANGOS_DLL_DECL ObjectGridStoper void MoveToRespawnN(); void StopN() { - for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) + for (unsigned int x = 0; x < MAX_NUMBER_OF_CELLS; ++x) { - for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) + for (unsigned int y = 0; y < MAX_NUMBER_OF_CELLS; ++y) { GridLoader loader; loader.Stop(i_grid(x, y), *this); diff --git a/src/game/ObjectGuid.cpp b/src/game/ObjectGuid.cpp index 6cc5ee2e1..9f42442b3 100644 --- a/src/game/ObjectGuid.cpp +++ b/src/game/ObjectGuid.cpp @@ -34,7 +34,7 @@ char const* ObjectGuid::GetTypeName(HighGuid high) case HIGHGUID_UNIT: return "Creature"; case HIGHGUID_PET: return "Pet"; case HIGHGUID_VEHICLE: return "Vehicle"; - case HIGHGUID_DYNAMICOBJECT:return "DynObject"; + case HIGHGUID_DYNAMICOBJECT: return "DynObject"; case HIGHGUID_CORPSE: return "Corpse"; case HIGHGUID_MO_TRANSPORT: return "MoTransport"; case HIGHGUID_INSTANCE: return "InstanceID"; @@ -66,9 +66,9 @@ std::string ObjectGuid::GetString() const template uint32 ObjectGuidGenerator::Generate() { - if (m_nextGuid >= ObjectGuid::GetMaxCounter(high)-1) + if (m_nextGuid >= ObjectGuid::GetMaxCounter(high) - 1) { - sLog.outError("%s guid overflow!! Can't continue, shutting down server. ",ObjectGuid::GetTypeName(high)); + sLog.outError("%s guid overflow!! Can't continue, shutting down server. ", ObjectGuid::GetTypeName(high)); World::StopNow(ERROR_EXIT_CODE); } return m_nextGuid++; diff --git a/src/game/ObjectGuid.h b/src/game/ObjectGuid.h index 78c239cbd..8e7c66f0d 100644 --- a/src/game/ObjectGuid.h +++ b/src/game/ObjectGuid.h @@ -154,7 +154,7 @@ class MANGOS_DLL_SPEC ObjectGuid case HIGHGUID_PET: return TYPEID_UNIT; case HIGHGUID_PLAYER: return TYPEID_PLAYER; case HIGHGUID_GAMEOBJECT: return TYPEID_GAMEOBJECT; - case HIGHGUID_DYNAMICOBJECT:return TYPEID_DYNAMICOBJECT; + case HIGHGUID_DYNAMICOBJECT: return TYPEID_DYNAMICOBJECT; case HIGHGUID_CORPSE: return TYPEID_CORPSE; case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT; case HIGHGUID_VEHICLE: return TYPEID_UNIT; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 98fa6382f..8823aadb2 100755 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -55,17 +55,17 @@ bool normalizePlayerName(std::string& name) if (name.empty()) return false; - wchar_t wstr_buf[MAX_INTERNAL_PLAYER_NAME+1]; + 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)) + if (!Utf8toWStr(name, &wstr_buf[0], wstr_len)) 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)) + if (!WStrToUtf8(wstr_buf, wstr_len, name)) return false; return true; @@ -127,9 +127,9 @@ bool SpellClickInfo::IsFitToRequirements(Player const* player) const template T IdGenerator::Generate() { - if (m_nextGuid >= std::numeric_limits::max()-1) + if (m_nextGuid >= std::numeric_limits::max() - 1) { - sLog.outError("%s guid overflow!! Can't continue, shutting down server. ",m_name); + sLog.outError("%s guid overflow!! Can't continue, shutting down server. ", m_name); World::StopNow(ERROR_EXIT_CODE); } return m_nextGuid++; @@ -258,26 +258,26 @@ void ObjectMgr::LoadCreatureLocales() for (int i = 1; i < MAX_LOCALE; ++i) { - std::string str = fields[1+2*(i-1)].GetCppString(); + std::string str = fields[1 + 2 * (i - 1)].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.Name.size() <= idx) - data.Name.resize(idx+1); + data.Name.resize(idx + 1); data.Name[idx] = str; } } - str = fields[1+2*(i-1)+1].GetCppString(); + str = fields[1 + 2 * (i - 1) + 1].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.SubName.size() <= idx) - data.SubName.resize(idx+1); + data.SubName.resize(idx + 1); data.SubName[idx] = str; } @@ -345,30 +345,30 @@ void ObjectMgr::LoadGossipMenuItemsLocales() continue; } - GossipMenuItemsLocale& data = mGossipMenuItemsLocaleMap[MAKE_PAIR32(menuId,id)]; + GossipMenuItemsLocale& data = mGossipMenuItemsLocaleMap[MAKE_PAIR32(menuId, id)]; for (int i = 1; i < MAX_LOCALE; ++i) { - std::string str = fields[2+2*(i-1)].GetCppString(); + std::string str = fields[2 + 2 * (i - 1)].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.OptionText.size() <= idx) - data.OptionText.resize(idx+1); + data.OptionText.resize(idx + 1); data.OptionText[idx] = str; } } - str = fields[2+2*(i-1)+1].GetCppString(); + str = fields[2 + 2 * (i - 1) + 1].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.BoxText.size() <= idx) - data.BoxText.resize(idx+1); + data.BoxText.resize(idx + 1); data.BoxText[idx] = str; } @@ -427,7 +427,7 @@ void ObjectMgr::LoadPointOfInterestLocales() if (idx >= 0) { if ((int32)data.IconName.size() <= idx) - data.IconName.resize(idx+1); + data.IconName.resize(idx + 1); data.IconName[idx] = str; } @@ -582,7 +582,7 @@ void ObjectMgr::LoadCreatureTemplates() { if (!GetCreatureTemplate(cInfo->KillCredit[k])) { - sLog.outErrorDb("Creature (Entry: %u) has nonexistent creature entry in `KillCredit%d` (%u)",cInfo->Entry,k+1,cInfo->KillCredit[k]); + sLog.outErrorDb("Creature (Entry: %u) has nonexistent creature entry in `KillCredit%d` (%u)", cInfo->Entry, k + 1, cInfo->KillCredit[k]); const_cast(cInfo)->KillCredit[k] = 0; } } @@ -598,7 +598,7 @@ void ObjectMgr::LoadCreatureTemplates() CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->ModelId[i]); if (!displayEntry) { - sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_%d (%u), can crash client", cInfo->Entry, i+1, cInfo->ModelId[i]); + sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_%d (%u), can crash client", cInfo->Entry, i + 1, cInfo->ModelId[i]); const_cast(cInfo)->ModelId[i] = 0; } else if (!displayScaleEntry) @@ -606,7 +606,7 @@ 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]); } } @@ -616,12 +616,12 @@ void ObjectMgr::LoadCreatureTemplates() // use below code for 0-checks for unit_class if (!cInfo->unit_class) ERROR_DB_STRICT_LOG("Creature (Entry: %u) not has proper unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class); - else if (((1 << (cInfo->unit_class-1)) & CLASSMASK_ALL_CREATURES) == 0) + else if (((1 << (cInfo->unit_class - 1)) & CLASSMASK_ALL_CREATURES) == 0) sLog.outErrorDb("Creature (Entry: %u) has invalid unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class); if (cInfo->dmgschool >= MAX_SPELL_SCHOOL) { - sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`",cInfo->Entry,cInfo->dmgschool); + sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`", cInfo->Entry, cInfo->dmgschool); const_cast(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL; } @@ -633,29 +633,29 @@ void ObjectMgr::LoadCreatureTemplates() if (cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK) { - sLog.outErrorDb("Creature (Entry: %u) has dynamic flag UNIT_NPC_FLAG_SPELLCLICK (%u) set, it expect to be set by code base at `npc_spellclick_spells` content.",cInfo->Entry,UNIT_NPC_FLAG_SPELLCLICK); + sLog.outErrorDb("Creature (Entry: %u) has dynamic flag UNIT_NPC_FLAG_SPELLCLICK (%u) set, it expect to be set by code base at `npc_spellclick_spells` content.", cInfo->Entry, UNIT_NPC_FLAG_SPELLCLICK); const_cast(cInfo)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK; } if ((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE) - sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u",cInfo->Entry,cInfo->trainer_type); + sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u", cInfo->Entry, cInfo->trainer_type); if (cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type)) { - sLog.outErrorDb("Creature (Entry: %u) has invalid creature type (%u) in `type`",cInfo->Entry,cInfo->type); + sLog.outErrorDb("Creature (Entry: %u) has invalid creature type (%u) in `type`", cInfo->Entry, cInfo->type); const_cast(cInfo)->type = CREATURE_TYPE_HUMANOID; } // must exist or used hidden but used in data horse case if (cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM) { - sLog.outErrorDb("Creature (Entry: %u) has invalid creature family (%u) in `family`",cInfo->Entry,cInfo->family); + sLog.outErrorDb("Creature (Entry: %u) has invalid creature family (%u) in `family`", cInfo->Entry, cInfo->family); const_cast(cInfo)->family = 0; } if (cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE) { - sLog.outErrorDb("Creature (Entry: %u) has wrong value (%u) in `InhabitType`, creature will not correctly walk/swim/fly",cInfo->Entry,cInfo->InhabitType); + sLog.outErrorDb("Creature (Entry: %u) has wrong value (%u) in `InhabitType`, creature will not correctly walk/swim/fly", cInfo->Entry, cInfo->InhabitType); const_cast(cInfo)->InhabitType = INHABIT_ANYWHERE; } @@ -670,14 +670,14 @@ void ObjectMgr::LoadCreatureTemplates() { if (cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j])) { - sLog.outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0", cInfo->Entry, j+1,cInfo->spells[j]); + sLog.outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0", cInfo->Entry, j + 1, cInfo->spells[j]); const_cast(cInfo)->spells[j] = 0; } } if (cInfo->MovementType >= MAX_DB_MOTION_TYPE) { - sLog.outErrorDb("Creature (Entry: %u) has wrong movement generator type (%u), ignore and set to IDLE.",cInfo->Entry,cInfo->MovementType); + sLog.outErrorDb("Creature (Entry: %u) has wrong movement generator type (%u), ignore and set to IDLE.", cInfo->Entry, cInfo->MovementType); const_cast(cInfo)->MovementType = IDLE_MOTION_TYPE; } @@ -716,21 +716,21 @@ void ObjectMgr::LoadCreatureTemplates() void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr) { // Now add the auras, format "spell1 spell2 ..." - char* p,*s; + char* p, *s; std::vector val; - s=p=(char*)reinterpret_cast(addon->auras); + s = p = (char*)reinterpret_cast(addon->auras); if (p) { - while (p[0]!=0) + while (p[0] != 0) { ++p; - if (p[0]==' ') + if (p[0] == ' ') { val.push_back(atoi(s)); - s=++p; + s = ++p; } } - if (p!=s) + if (p != s) val.push_back(atoi(s)); // free char* loaded memory @@ -745,7 +745,7 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* } // replace by new structures array - const_cast(addon->auras) = new uint32[val.size()+1]; + const_cast(addon->auras) = new uint32[val.size() + 1]; uint32 i = 0; for (uint32 j = 0; j < val.size(); ++j) @@ -756,7 +756,7 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* SpellEntry const* AdditionalSpellInfo = sSpellStore.LookupEntry(cAura); if (!AdditionalSpellInfo) { - sLog.outErrorDb("Creature (%s: %u) has wrong spell %u defined in `auras` field in `%s`.", guidEntryStr, addon->guidOrEntry, cAura,table); + sLog.outErrorDb("Creature (%s: %u) has wrong spell %u defined in `auras` field in `%s`.", guidEntryStr, addon->guidOrEntry, cAura, table); continue; } @@ -811,28 +811,28 @@ void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entry void ObjectMgr::LoadCreatureAddons() { - LoadCreatureAddons(sCreatureInfoAddonStorage,"Entry","creature template addons"); + LoadCreatureAddons(sCreatureInfoAddonStorage, "Entry", "creature template addons"); // check entry ids for (uint32 i = 1; i < sCreatureInfoAddonStorage.MaxEntry; ++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"); + LoadCreatureAddons(sCreatureDataAddonStorage, "GUID", "creature addons"); // check entry ids for (uint32 i = 1; i < sCreatureDataAddonStorage.MaxEntry; ++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); + if (mCreatureDataMap.find(addon->guidOrEntry) == mCreatureDataMap.end()) + sLog.outErrorDb("Creature (GUID: %u) does not exist but has a record in `creature_addon`", addon->guidOrEntry); } void ObjectMgr::LoadEquipmentTemplates() { sEquipmentStorage.Load(); - for (uint32 i=0; i < sEquipmentStorage.MaxEntry; ++i) + for (uint32 i = 0; i < sEquipmentStorage.MaxEntry; ++i) { EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry(i); @@ -847,7 +847,7 @@ void ObjectMgr::LoadEquipmentTemplates() ItemEntry const* dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]); if (!dbcitem) { - sLog.outErrorDb("Unknown item (entry=%u) in creature_equip_template.equipentry%u for entry = %u, forced to 0.", eqInfo->equipentry[j], j+1, i); + sLog.outErrorDb("Unknown item (entry=%u) in creature_equip_template.equipentry%u for entry = %u, forced to 0.", eqInfo->equipentry[j], j + 1, i); const_cast(eqInfo)->equipentry[j] = 0; continue; } @@ -863,7 +863,7 @@ void ObjectMgr::LoadEquipmentTemplates() dbcitem->InventoryType != INVTYPE_RANGEDRIGHT && dbcitem->InventoryType != INVTYPE_RELIC) { - sLog.outErrorDb("Item (entry=%u) in creature_equip_template.equipentry%u for entry = %u is not equipable in a hand, forced to 0.", eqInfo->equipentry[j], j+1, i); + sLog.outErrorDb("Item (entry=%u) in creature_equip_template.equipentry%u for entry = %u is not equipable in a hand, forced to 0.", eqInfo->equipentry[j], j + 1, i); const_cast(eqInfo)->equipentry[j] = 0; } } @@ -985,7 +985,7 @@ void ObjectMgr::LoadCreatureModelInfo() if (!raceEntry) continue; - if (!((1 << (race-1)) & RACEMASK_ALL_PLAYABLE)) + if (!((1 << (race - 1)) & RACEMASK_ALL_PLAYABLE)) continue; if (CreatureModelInfo const* minfo = GetCreatureModelInfo(raceEntry->model_f)) @@ -1195,11 +1195,11 @@ void ObjectMgr::LoadCreatures() difficultyCreatures[diff].insert(cInfo->DifficultyEntry[diff]); // build single time for check spawnmask - std::map spawnMasks; + std::map spawnMasks; for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i) if (sMapStore.LookupEntry(i)) for (int k = 0; k < MAX_DIFFICULTY; ++k) - if (GetMapDifficultyData(i,Difficulty(k))) + if (GetMapDifficultyData(i, Difficulty(k))) spawnMasks[i] |= (1 << k); BarGoLink bar(result->GetRowCount()); @@ -1245,12 +1245,12 @@ void ObjectMgr::LoadCreatures() MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid); if (!mapEntry) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u) that spawned at nonexistent map (Id: %u), skipped.",guid, data.mapid); + sLog.outErrorDb("Table `creature` have creature (GUID: %u) that spawned at nonexistent map (Id: %u), skipped.", guid, data.mapid); continue; } if (data.spawnMask & ~spawnMasks[data.mapid]) - sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).",guid, data.spawnMask, data.mapid); + sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).", guid, data.spawnMask, data.mapid); bool ok = true; for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) @@ -1282,7 +1282,7 @@ void ObjectMgr::LoadCreatures() if (cInfo->RegenHealth && data.curhealth < cInfo->minhealth) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`RegenHealth`=1 and low current health (%u), `creature_template`.`minhealth`=%u.",guid,data.id,data.curhealth, cInfo->minhealth); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`RegenHealth`=1 and low current health (%u), `creature_template`.`minhealth`=%u.", guid, data.id, data.curhealth, cInfo->minhealth); data.curhealth = cInfo->minhealth; } @@ -1302,20 +1302,20 @@ void ObjectMgr::LoadCreatures() if (data.curmana < cInfo->minmana) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with low current mana (%u), `creature_template`.`minmana`=%u.",guid,data.id,data.curmana, cInfo->minmana); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with low current mana (%u), `creature_template`.`minmana`=%u.", guid, data.id, data.curmana, cInfo->minmana); data.curmana = cInfo->minmana; } if (data.spawndist < 0.0f) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.",guid,data.id); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.", guid, data.id); data.spawndist = 0.0f; } else if (data.movementType == RANDOM_MOTION_TYPE) { if (data.spawndist == 0.0f) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).",guid,data.id); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).", guid, data.id); data.movementType = IDLE_MOTION_TYPE; } } @@ -1323,18 +1323,18 @@ void ObjectMgr::LoadCreatures() { if (data.spawndist != 0.0f) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.",guid,data.id); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.", guid, data.id); data.spawndist = 0.0f; } } - if (data.phaseMask==0) + if (data.phaseMask == 0) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id); data.phaseMask = 1; } - if (gameEvent==0 && GuidPoolId==0 && EntryPoolId==0)// if not this is to be managed by GameEvent System or Pool system + if (gameEvent == 0 && GuidPoolId == 0 && EntryPoolId == 0) // if not this is to be managed by GameEvent System or Pool system AddCreatureToGrid(guid, &data); ++count; @@ -1356,9 +1356,9 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.creatures.insert(guid); } } @@ -1372,9 +1372,9 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.creatures.erase(guid); } } @@ -1407,11 +1407,11 @@ void ObjectMgr::LoadGameObjects() } // build single time for check spawnmask - std::map spawnMasks; + std::map spawnMasks; for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i) if (sMapStore.LookupEntry(i)) for (int k = 0; k < MAX_DIFFICULTY; ++k) - if (GetMapDifficultyData(i,Difficulty(k))) + if (GetMapDifficultyData(i, Difficulty(k))) spawnMasks[i] |= (1 << k); BarGoLink bar(result->GetRowCount()); @@ -1529,7 +1529,7 @@ void ObjectMgr::LoadGameObjects() data.phaseMask = 1; } - if (gameEvent==0 && GuidPoolId==0 && EntryPoolId==0)// if not this is to be managed by GameEvent System or Pool system + if (gameEvent == 0 && GuidPoolId == 0 && EntryPoolId == 0) // if not this is to be managed by GameEvent System or Pool system AddGameobjectToGrid(guid, &data); ++count; @@ -1558,7 +1558,7 @@ void ObjectMgr::LoadGameObjectAddon() if (!GetGODataPair(addon->guid)) { - sLog.outErrorDb("Gameobject (GUID: %u) does not exist but has a record in `gameobject_addon`",addon->guid); + sLog.outErrorDb("Gameobject (GUID: %u) does not exist but has a record in `gameobject_addon`", addon->guid); continue; } @@ -1578,9 +1578,9 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.gameobjects.insert(guid); } } @@ -1594,9 +1594,9 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); - uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; + uint32 cell_id = (cell_pair.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id]; + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid, i)][cell_id]; cell_guids.gameobjects.erase(guid); } } @@ -1735,27 +1735,27 @@ void ObjectMgr::LoadItemLocales() for (int i = 1; i < MAX_LOCALE; ++i) { - std::string str = fields[1+2*(i-1)].GetCppString(); + std::string str = fields[1 + 2 * (i - 1)].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.Name.size() <= idx) - data.Name.resize(idx+1); + data.Name.resize(idx + 1); data.Name[idx] = str; } } - str = fields[1+2*(i-1)+1].GetCppString(); + str = fields[1 + 2 * (i - 1) + 1].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.Description.size() <= idx) - data.Description.resize(idx+1); + data.Description.resize(idx + 1); data.Description[idx] = str; } @@ -1804,7 +1804,7 @@ void ObjectMgr::LoadItemPrototypes() { if (proto->Class != dbcitem->Class) { - sLog.outErrorDb("Item (Entry: %u) not correct class %u, must be %u (still using DB value).",i,proto->Class,dbcitem->Class); + sLog.outErrorDb("Item (Entry: %u) not correct class %u, must be %u (still using DB value).", i, proto->Class, dbcitem->Class); // It safe let use Class from DB } /* disabled: have some strange wrong cases for Subclass values. @@ -1818,53 +1818,53 @@ void ObjectMgr::LoadItemPrototypes() if (proto->Unk0 != dbcitem->Unk0) { - sLog.outErrorDb("Item (Entry: %u) not correct %i Unk0, must be %i (still using DB value).",i,proto->Unk0,dbcitem->Unk0); + sLog.outErrorDb("Item (Entry: %u) not correct %i Unk0, must be %i (still using DB value).", i, proto->Unk0, dbcitem->Unk0); // It safe let use Unk0 from DB } if (proto->Material != dbcitem->Material) { - sLog.outErrorDb("Item (Entry: %u) not correct %i material, must be %i (still using DB value).",i,proto->Material,dbcitem->Material); + sLog.outErrorDb("Item (Entry: %u) not correct %i material, must be %i (still using DB value).", i, proto->Material, dbcitem->Material); // It safe let use Material from DB } if (proto->InventoryType != dbcitem->InventoryType) { - sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType); + sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).", i, proto->InventoryType, dbcitem->InventoryType); // It safe let use InventoryType from DB } if (proto->DisplayInfoID != dbcitem->DisplayId) { - sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId); + sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).", i, proto->DisplayInfoID, dbcitem->DisplayId); const_cast(proto)->DisplayInfoID = dbcitem->DisplayId; } if (proto->Sheath != dbcitem->Sheath) { - sLog.outErrorDb("Item (Entry: %u) not correct %u sheath, must be %u (using it).",i,proto->Sheath,dbcitem->Sheath); + sLog.outErrorDb("Item (Entry: %u) not correct %u sheath, must be %u (using it).", i, proto->Sheath, dbcitem->Sheath); const_cast(proto)->Sheath = dbcitem->Sheath; } } else { - sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existing items).",i); + sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existing items).", i); } if (proto->Class >= MAX_ITEM_CLASS) { - sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class); + sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)", i, proto->Class); const_cast(proto)->Class = ITEM_CLASS_MISC; } if (proto->SubClass >= MaxItemSubclassValues[proto->Class]) { - sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class); + sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u", i, proto->SubClass, proto->Class); const_cast(proto)->SubClass = 0;// exist for all item classes } if (proto->Quality >= MAX_ITEM_QUALITY) { - sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality); + sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)", i, proto->Quality); const_cast(proto)->Quality = ITEM_QUALITY_NORMAL; } @@ -1889,13 +1889,13 @@ void ObjectMgr::LoadItemPrototypes() if (proto->BuyCount <= 0) { - sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount); + sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).", i, proto->BuyCount); const_cast(proto)->BuyCount = 1; } if (proto->InventoryType >= MAX_INVTYPE) { - sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType); + sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)", i, proto->InventoryType); const_cast(proto)->InventoryType = INVTYPE_NON_EQUIP; } @@ -1930,13 +1930,13 @@ void ObjectMgr::LoadItemPrototypes() if (proto->RequiredSkill >= MAX_SKILL_TYPE) { - sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill); + sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)", i, proto->RequiredSkill); const_cast(proto)->RequiredSkill = 0; } { // can be used in equip slot, as page read use in inventory, or spell casting at use - bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText; + bool req = proto->InventoryType != INVTYPE_NON_EQUIP || proto->PageText; if (!req) { for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) @@ -1952,55 +1952,55 @@ 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); } } if (proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) { - sLog.outErrorDb("Item (Entry: %u) have wrong (nonexistent) spell in RequiredSpell (%u)",i,proto->RequiredSpell); + sLog.outErrorDb("Item (Entry: %u) have wrong (nonexistent) spell in RequiredSpell (%u)", i, proto->RequiredSpell); const_cast(proto)->RequiredSpell = 0; } 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) { if (!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) { - sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction); + sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)", i, proto->RequiredReputationFaction); const_cast(proto)->RequiredReputationFaction = 0; } 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); + sLog.outErrorDb("Item (Entry: %u) has RequiredReputationFaction ==0 but RequiredReputationRank > 0, rank setting is useless.", i); if (proto->MaxCount < -1) { - sLog.outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.",i,proto->MaxCount); + sLog.outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.", i, proto->MaxCount); const_cast(proto)->MaxCount = -1; } if (proto->Stackable == 0) { - sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.",i,proto->Stackable); + sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.", i, proto->Stackable); const_cast(proto)->Stackable = 1; } else if (proto->Stackable < -1) { - sLog.outErrorDb("Item (Entry: %u) has too large negative in stackable (%i), replace by value (-1) no stacking limits.",i,proto->Stackable); + sLog.outErrorDb("Item (Entry: %u) has too large negative in stackable (%i), replace by value (-1) no stacking limits.", i, proto->Stackable); const_cast(proto)->Stackable = -1; } else if (proto->Stackable > 1000) { - sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (1000).",i,proto->Stackable); + sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (1000).", i, proto->Stackable); const_cast(proto)->Stackable = 1000; } @@ -2008,14 +2008,14 @@ void ObjectMgr::LoadItemPrototypes() { if (proto->ContainerSlots > MAX_BAG_SIZE) { - sLog.outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).",i,proto->ContainerSlots,MAX_BAG_SIZE); + sLog.outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).", i, proto->ContainerSlots, MAX_BAG_SIZE); const_cast(proto)->ContainerSlots = MAX_BAG_SIZE; } } if (proto->StatsCount > MAX_ITEM_PROTO_STATS) { - sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS); + sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).", i, proto->StatsCount, MAX_ITEM_PROTO_STATS); const_cast(proto)->StatsCount = MAX_ITEM_PROTO_STATS; } @@ -2024,7 +2024,7 @@ void ObjectMgr::LoadItemPrototypes() // for ItemStatValue != 0 if (proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) { - sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); + sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)", i, j + 1, proto->ItemStat[j].ItemStatType); const_cast(proto)->ItemStat[j].ItemStatType = 0; } @@ -2032,7 +2032,7 @@ void ObjectMgr::LoadItemPrototypes() { case ITEM_MOD_SPELL_HEALING_DONE: case ITEM_MOD_SPELL_DAMAGE_DONE: - sLog.outErrorDb("Item (Entry: %u) has deprecated stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); + sLog.outErrorDb("Item (Entry: %u) has deprecated stat_type%d (%u)", i, j + 1, proto->ItemStat[j].ItemStatType); break; default: break; @@ -2043,7 +2043,7 @@ void ObjectMgr::LoadItemPrototypes() { if (proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL) { - sLog.outErrorDb("Item (Entry: %u) has wrong dmg_type%d (%u)",i,j+1,proto->Damage[j].DamageType); + sLog.outErrorDb("Item (Entry: %u) has wrong dmg_type%d (%u)", i, j + 1, proto->Damage[j].DamageType); const_cast(proto)->Damage[j].DamageType = 0; } } @@ -2054,7 +2054,7 @@ void ObjectMgr::LoadItemPrototypes() // spell_1 if (proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",i,0+1,proto->Spells[0].SpellTrigger); + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format", i, 0 + 1, proto->Spells[0].SpellTrigger); const_cast(proto)->Spells[0].SpellId = 0; const_cast(proto)->Spells[0].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; const_cast(proto)->Spells[1].SpellId = 0; @@ -2064,14 +2064,14 @@ void ObjectMgr::LoadItemPrototypes() // spell_2 have learning spell if (proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",i,1+1,proto->Spells[1].SpellTrigger); + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.", i, 1 + 1, proto->Spells[1].SpellTrigger); const_cast(proto)->Spells[0].SpellId = 0; const_cast(proto)->Spells[1].SpellId = 0; const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } else if (!proto->Spells[1].SpellId) { - sLog.outErrorDb("Item (Entry: %u) not has expected spell in spellid_%d in special learning format.",i,1+1); + sLog.outErrorDb("Item (Entry: %u) not has expected spell in spellid_%d in special learning format.", i, 1 + 1); const_cast(proto)->Spells[0].SpellId = 0; const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } @@ -2080,15 +2080,15 @@ void ObjectMgr::LoadItemPrototypes() SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId); if (!spellInfo) { - sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); + sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)", i, 1 + 1, proto->Spells[1].SpellId); const_cast(proto)->Spells[0].SpellId = 0; const_cast(proto)->Spells[1].SpellId = 0; const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } // allowed only in special format - else if ((proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN_PET)) + else if ((proto->Spells[1].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId == SPELL_ID_GENERIC_LEARN_PET)) { - sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); + sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)", i, 1 + 1, proto->Spells[1].SpellId); const_cast(proto)->Spells[0].SpellId = 0; const_cast(proto)->Spells[1].SpellId = 0; const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; @@ -2100,13 +2100,13 @@ void ObjectMgr::LoadItemPrototypes() { if (proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)", i, j + 1, proto->Spells[j].SpellTrigger); const_cast(proto)->Spells[j].SpellId = 0; const_cast(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } else if (proto->Spells[j].SpellId != 0) { - sLog.outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%u) for learning special format",i,j+1,proto->Spells[j].SpellId); + sLog.outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%u) for learning special format", i, j + 1, proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; } } @@ -2118,7 +2118,7 @@ void ObjectMgr::LoadItemPrototypes() { if (proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID) { - sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); + sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)", i, j + 1, proto->Spells[j].SpellTrigger); const_cast(proto)->Spells[j].SpellId = 0; const_cast(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } @@ -2126,7 +2126,7 @@ void ObjectMgr::LoadItemPrototypes() else if (proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_CHANCE_ON_HIT) { if (proto->Class != ITEM_CLASS_WEAPON) - sLog.outErrorDb("Item (Entry: %u) isn't weapon (Class: %u) but has on hit spelltrigger_%d (%u), it will not triggered.",i,proto->Class,j+1,proto->Spells[j].SpellTrigger); + sLog.outErrorDb("Item (Entry: %u) isn't weapon (Class: %u) but has on hit spelltrigger_%d (%u), it will not triggered.", i, proto->Class, j + 1, proto->Spells[j].SpellTrigger); } if (proto->Spells[j].SpellId) @@ -2134,13 +2134,13 @@ void ObjectMgr::LoadItemPrototypes() SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId); if (!spellInfo) { - sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); + sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)", i, j + 1, proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; } // allowed only in special format - else if ((proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN_PET)) + else if ((proto->Spells[j].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId == SPELL_ID_GENERIC_LEARN_PET)) { - sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); + sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)", i, j + 1, proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; } } @@ -2148,32 +2148,32 @@ 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) { - sLog.outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",i,proto->Sheath); + sLog.outErrorDb("Item (Entry: %u) has wrong Sheath (%u)", i, proto->Sheath); const_cast(proto)->Sheath = SHEATHETYPE_NONE; } if (proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty))) { - sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",i,proto->RandomProperty); + sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)", i, proto->RandomProperty); const_cast(proto)->RandomProperty = 0; } if (proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix))) { - sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",i,proto->RandomSuffix); + sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)", i, proto->RandomSuffix); const_cast(proto)->RandomSuffix = 0; } @@ -2206,7 +2206,7 @@ void ObjectMgr::LoadItemPrototypes() if (!(proto->BagFamily & mask)) continue; - ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1); + ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j + 1); if (!bf) { sLog.outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit", i); @@ -2233,7 +2233,7 @@ void ObjectMgr::LoadItemPrototypes() { if (proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color) { - sLog.outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)", i, j+1, proto->Socket[j].Color); + sLog.outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)", i, j + 1, proto->Socket[j].Color); const_cast(proto)->Socket[j].Color = 0; } } @@ -2527,7 +2527,7 @@ void ObjectMgr::LoadItemRequiredTarget() if (!pItemProto) { - sLog.outErrorDb("Table `item_required_target`: Entry %u listed for TargetEntry %u does not exist in `item_template`.",uiItemId,uiTargetEntry); + sLog.outErrorDb("Table `item_required_target`: Entry %u listed for TargetEntry %u does not exist in `item_template`.", uiItemId, uiTargetEntry); continue; } @@ -2562,29 +2562,29 @@ void ObjectMgr::LoadItemRequiredTarget() if (!bIsItemSpellValid) { - sLog.outErrorDb("Table `item_required_target`: Spell used by item %u does not have implicit target TARGET_CHAIN_DAMAGE(6), TARGET_DUELVSPLAYER(25), already listed in `spell_script_target` or doesn't have item spelltrigger.",uiItemId); + sLog.outErrorDb("Table `item_required_target`: Spell used by item %u does not have implicit target TARGET_CHAIN_DAMAGE(6), TARGET_DUELVSPLAYER(25), already listed in `spell_script_target` or doesn't have item spelltrigger.", uiItemId); continue; } if (!uiType || uiType > MAX_ITEM_REQ_TARGET_TYPE) { - sLog.outErrorDb("Table `item_required_target`: Type %u for TargetEntry %u is incorrect.",uiType,uiTargetEntry); + sLog.outErrorDb("Table `item_required_target`: Type %u for TargetEntry %u is incorrect.", uiType, uiTargetEntry); continue; } if (!uiTargetEntry) { - sLog.outErrorDb("Table `item_required_target`: TargetEntry == 0 for Type (%u).",uiType); + sLog.outErrorDb("Table `item_required_target`: TargetEntry == 0 for Type (%u).", uiType); continue; } if (!sCreatureStorage.LookupEntry(uiTargetEntry)) { - sLog.outErrorDb("Table `item_required_target`: creature template entry %u does not exist.",uiTargetEntry); + sLog.outErrorDb("Table `item_required_target`: creature template entry %u does not exist.", uiTargetEntry); continue; } - m_ItemRequiredTarget.insert(ItemRequiredTargetMap::value_type(uiItemId,ItemRequiredTarget(ItemRequiredTargetType(uiType),uiTargetEntry))); + m_ItemRequiredTarget.insert(ItemRequiredTargetMap::value_type(uiItemId, ItemRequiredTarget(ItemRequiredTargetType(uiType), uiTargetEntry))); ++count; } @@ -2625,7 +2625,7 @@ void ObjectMgr::LoadPetLevelInfo() uint32 creature_id = fields[0].GetUInt32(); if (!sCreatureStorage.LookupEntry(creature_id)) { - sLog.outErrorDb("Wrong creature id %u in `pet_levelstats` table, ignoring.",creature_id); + sLog.outErrorDb("Wrong creature id %u in `pet_levelstats` table, ignoring.", creature_id); continue; } @@ -2633,27 +2633,27 @@ 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); + DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `pet_levelstats` table, ignoring.", current_level); ++count; // make result loading percent "expected" correct in case disabled detail mode for example. } continue; } else if (current_level < 1) { - sLog.outErrorDb("Wrong (<1) level %u in `pet_levelstats` table, ignoring.",current_level); + sLog.outErrorDb("Wrong (<1) level %u in `pet_levelstats` table, ignoring.", current_level); continue; } PetLevelInfo*& pInfoMapEntry = petInfo[creature_id]; - if (pInfoMapEntry==NULL) + if (pInfoMapEntry == NULL) 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]; + PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1]; pLevelInfo->health = fields[2].GetUInt16(); pLevelInfo->mana = fields[3].GetUInt16(); @@ -2661,7 +2661,7 @@ void ObjectMgr::LoadPetLevelInfo() for (int i = 0; i < MAX_STATS; i++) { - pLevelInfo->stats[i] = fields[i+4].GetUInt16(); + pLevelInfo->stats[i] = fields[i + 4].GetUInt16(); } bar.step(); @@ -2683,7 +2683,7 @@ void ObjectMgr::LoadPetLevelInfo() // fatal error if no level 1 data if (!pInfo || pInfo[0].health == 0) { - sLog.outErrorDb("Creature %u does not have pet stats data for Level 1!",itr->first); + sLog.outErrorDb("Creature %u does not have pet stats data for Level 1!", itr->first); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -2693,8 +2693,8 @@ void ObjectMgr::LoadPetLevelInfo() { if (pInfo[level].health == 0) { - sLog.outErrorDb("Creature %u has no data for Level %i pet stats data, using data of Level %i.",itr->first,level+1, level); - pInfo[level] = pInfo[level-1]; + sLog.outErrorDb("Creature %u has no data for Level %i pet stats data, using data of Level %i.", itr->first, level + 1, level); + pInfo[level] = pInfo[level - 1]; } } } @@ -2709,7 +2709,7 @@ PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) if (itr == petInfo.end()) return NULL; - return &itr->second[level-1]; // data for level 1 stored in [0] array element, ... + return &itr->second[level - 1]; // data for level 1 stored in [0] array element, ... } void ObjectMgr::LoadPlayerInfo() @@ -2748,29 +2748,29 @@ void ObjectMgr::LoadPlayerInfo() float orientation = fields[7].GetFloat(); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); - if (!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE)) + if (!rEntry || !((1 << (current_race - 1)) & RACEMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race); + sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.", current_race); continue; } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class); - if (!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) + if (!cEntry || !((1 << (current_class - 1)) & CLASSMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class); + sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.", current_class); continue; } // accept DB data only for valid position (and non instanceable) - if (!MapManager::IsValidMapCoord(mapId,positionX,positionY,positionZ, orientation)) + if (!MapManager::IsValidMapCoord(mapId, positionX, positionY, positionZ, orientation)) { - sLog.outErrorDb("Wrong home position for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); + sLog.outErrorDb("Wrong home position for class %u race %u pair in `playercreateinfo` table, ignoring.", current_class, current_race); continue; } if (sMapStore.LookupEntry(mapId)->Instanceable()) { - sLog.outErrorDb("Home position in instanceable map for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); + sLog.outErrorDb("Home position in instanceable map for class %u race %u pair in `playercreateinfo` table, ignoring.", current_class, current_race); continue; } @@ -2825,16 +2825,16 @@ void ObjectMgr::LoadPlayerInfo() uint32 current_class = fields[1].GetUInt32(); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); - if (!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE)) + if (!rEntry || !((1 << (current_race - 1)) & RACEMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong race %u in `playercreateinfo_item` table, ignoring.",current_race); + sLog.outErrorDb("Wrong race %u in `playercreateinfo_item` table, ignoring.", current_race); continue; } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class); - if (!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) + if (!cEntry || !((1 << (current_class - 1)) & CLASSMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong class %u in `playercreateinfo_item` table, ignoring.",current_class); + sLog.outErrorDb("Wrong class %u in `playercreateinfo_item` table, ignoring.", current_class); continue; } @@ -2844,7 +2844,7 @@ void ObjectMgr::LoadPlayerInfo() if (!GetItemPrototype(item_id)) { - sLog.outErrorDb("Item id %u (race %u class %u) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.",item_id,current_race,current_class); + sLog.outErrorDb("Item id %u (race %u class %u) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.", item_id, current_race, current_class); continue; } @@ -2852,7 +2852,7 @@ void ObjectMgr::LoadPlayerInfo() if (!amount) { - sLog.outErrorDb("Item id %u (class %u race %u) have amount==0 in `playercreateinfo_item` table, ignoring.",item_id,current_race,current_class); + sLog.outErrorDb("Item id %u (class %u race %u) have amount==0 in `playercreateinfo_item` table, ignoring.", item_id, current_race, current_class); continue; } @@ -2897,16 +2897,16 @@ void ObjectMgr::LoadPlayerInfo() uint32 current_class = fields[1].GetUInt32(); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); - if (!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE)) + if (!rEntry || !((1 << (current_race - 1)) & RACEMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong race %u in `playercreateinfo_spell` table, ignoring.",current_race); + sLog.outErrorDb("Wrong race %u in `playercreateinfo_spell` table, ignoring.", current_race); continue; } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class); - if (!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) + if (!cEntry || !((1 << (current_class - 1)) & CLASSMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.",current_class); + sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.", current_class); continue; } @@ -2959,16 +2959,16 @@ void ObjectMgr::LoadPlayerInfo() uint32 current_class = fields[1].GetUInt32(); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); - if (!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE)) + if (!rEntry || !((1 << (current_race - 1)) & RACEMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong race %u in `playercreateinfo_action` table, ignoring.",current_race); + sLog.outErrorDb("Wrong race %u in `playercreateinfo_action` table, ignoring.", current_race); continue; } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class); - if (!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) + if (!cEntry || !((1 << (current_class - 1)) & CLASSMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong class %u in `playercreateinfo_action` table, ignoring.",current_class); + sLog.outErrorDb("Wrong class %u in `playercreateinfo_action` table, ignoring.", current_class); continue; } @@ -2976,11 +2976,11 @@ void ObjectMgr::LoadPlayerInfo() uint32 action = fields[3].GetUInt32(); uint8 action_type = fields[4].GetUInt8(); - if (!Player::IsActionButtonDataValid(action_button,action,action_type,NULL)) + if (!Player::IsActionButtonDataValid(action_button, action, action_type, NULL)) continue; PlayerInfo* pInfo = &playerInfo[current_race][current_class]; - pInfo->action.push_back(PlayerCreateInfoAction(action_button,action,action_type)); + pInfo->action.push_back(PlayerCreateInfoAction(action_button, action, action_type)); bar.step(); ++count; @@ -3021,23 +3021,23 @@ void ObjectMgr::LoadPlayerInfo() uint32 current_class = fields[0].GetUInt32(); if (current_class >= MAX_CLASSES) { - sLog.outErrorDb("Wrong class %u in `player_classlevelstats` table, ignoring.",current_class); + sLog.outErrorDb("Wrong class %u in `player_classlevelstats` table, ignoring.", current_class); continue; } uint32 current_level = fields[1].GetUInt32(); if (current_level == 0) { - sLog.outErrorDb("Wrong level %u in `player_classlevelstats` table, ignoring.",current_level); + sLog.outErrorDb("Wrong level %u in `player_classlevelstats` table, ignoring.", current_level); continue; } else 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_classlevelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level); + sLog.outErrorDb("Wrong (> %u) level %u in `player_classlevelstats` table, ignoring.", STRONG_MAX_LEVEL, current_level); else { - DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_classlevelstats` table, ignoring.",current_level); + DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_classlevelstats` table, ignoring.", current_level); ++count; // make result loading percent "expected" correct in case disabled detail mode for example. } continue; @@ -3048,7 +3048,7 @@ void ObjectMgr::LoadPlayerInfo() if (!pClassInfo->levelInfo) pClassInfo->levelInfo = new PlayerClassLevelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)]; - PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level-1]; + PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level - 1]; pClassLevelInfo->basehealth = fields[2].GetUInt16(); pClassLevelInfo->basemana = fields[3].GetUInt16(); @@ -3076,7 +3076,7 @@ void ObjectMgr::LoadPlayerInfo() // fatal error if no level 1 data if (!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0) { - sLog.outErrorDb("Class %i Level 1 does not have health/mana data!",class_); + sLog.outErrorDb("Class %i Level 1 does not have health/mana data!", class_); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -3086,8 +3086,8 @@ void ObjectMgr::LoadPlayerInfo() { if (pClassInfo->levelInfo[level].basehealth == 0) { - sLog.outErrorDb("Class %i Level %i does not have health/mana data. Using stats data of level %i.",class_,level+1, level); - pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level-1]; + sLog.outErrorDb("Class %i Level %i does not have health/mana data. Using stats data of level %i.", class_, level + 1, level); + pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level - 1]; } } } @@ -3120,16 +3120,16 @@ void ObjectMgr::LoadPlayerInfo() uint32 current_class = fields[1].GetUInt32(); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); - if (!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE)) + if (!rEntry || !((1 << (current_race - 1)) & RACEMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong race %u in `player_levelstats` table, ignoring.",current_race); + sLog.outErrorDb("Wrong race %u in `player_levelstats` table, ignoring.", current_race); continue; } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class); - if (!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) + if (!cEntry || !((1 << (current_class - 1)) & CLASSMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Wrong class %u in `player_levelstats` table, ignoring.",current_class); + sLog.outErrorDb("Wrong class %u in `player_levelstats` table, ignoring.", current_class); continue; } @@ -3137,10 +3137,10 @@ 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); + DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_levelstats` table, ignoring.", current_level); ++count; // make result loading percent "expected" correct in case disabled detail mode for example. } continue; @@ -3151,10 +3151,10 @@ void ObjectMgr::LoadPlayerInfo() if (!pInfo->levelInfo) pInfo->levelInfo = new PlayerLevelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)]; - PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level-1]; + PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level - 1]; for (int i = 0; i < MAX_STATS; ++i) - pLevelInfo->stats[i] = fields[i+3].GetUInt8(); + pLevelInfo->stats[i] = fields[i + 3].GetUInt8(); bar.step(); ++count; @@ -3171,13 +3171,13 @@ void ObjectMgr::LoadPlayerInfo() for (int race = 0; race < MAX_RACES; ++race) { // skip nonexistent races - if (!((1 << (race-1)) & RACEMASK_ALL_PLAYABLE) || !sChrRacesStore.LookupEntry(race)) + if (!((1 << (race - 1)) & RACEMASK_ALL_PLAYABLE) || !sChrRacesStore.LookupEntry(race)) continue; for (int class_ = 0; class_ < MAX_CLASSES; ++class_) { // skip nonexistent classes - if (!((1 << (class_-1)) & CLASSMASK_ALL_PLAYABLE) || !sChrClassesStore.LookupEntry(class_)) + if (!((1 << (class_ - 1)) & CLASSMASK_ALL_PLAYABLE) || !sChrClassesStore.LookupEntry(class_)) continue; PlayerInfo* pInfo = &playerInfo[race][class_]; @@ -3197,7 +3197,7 @@ void ObjectMgr::LoadPlayerInfo() // fatal error if no level 1 data if (!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0) { - sLog.outErrorDb("Race %i Class %i Level 1 does not have stats data!",race,class_); + sLog.outErrorDb("Race %i Class %i Level 1 does not have stats data!", race, class_); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -3207,8 +3207,8 @@ void ObjectMgr::LoadPlayerInfo() { if (pInfo->levelInfo[level].stats[0] == 0) { - sLog.outErrorDb("Race %i Class %i Level %i does not have stats data. Using stats data of level %i.",race,class_,level+1, level); - pInfo->levelInfo[level] = pInfo->levelInfo[level-1]; + sLog.outErrorDb("Race %i Class %i Level %i does not have stats data. Using stats data of level %i.", race, class_, level + 1, level); + pInfo->levelInfo[level] = pInfo->levelInfo[level - 1]; } } } @@ -3248,10 +3248,10 @@ 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); + DETAIL_LOG("Unused (> MaxPlayerLevel in mangosd.conf) level %u in `player_xp_for_levels` table, ignoring.", current_level); ++count; // make result loading percent "expected" correct in case disabled detail mode for example. } continue; @@ -3274,8 +3274,8 @@ void ObjectMgr::LoadPlayerInfo() { if (mPlayerXPperLevel[level] == 0) { - sLog.outErrorDb("Level %i does not have XP for level data. Using data of level [%i] + 100.",level+1, level); - mPlayerXPperLevel[level] = mPlayerXPperLevel[level-1]+100; + sLog.outErrorDb("Level %i does not have XP for level data. Using data of level [%i] + 100.", level + 1, level); + mPlayerXPperLevel[level] = mPlayerXPperLevel[level - 1] + 100; } } } @@ -3290,7 +3290,7 @@ void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClass if (level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) level = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); - *info = pInfo->levelInfo[level-1]; + *info = pInfo->levelInfo[level - 1]; } void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const @@ -3299,86 +3299,86 @@ void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, Pla return; PlayerInfo const* pInfo = &playerInfo[race][class_]; - if (pInfo->displayId_m==0 || pInfo->displayId_f==0) + if (pInfo->displayId_m == 0 || pInfo->displayId_f == 0) 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); + BuildPlayerLevelInfo(race, class_, level, info); } void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, PlayerLevelInfo* info) const { // base data (last known level) - *info = playerInfo[race][_class].levelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)-1]; + *info = playerInfo[race][_class].levelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) - 1]; - for (int lvl = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl) + for (int lvl = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL) - 1; lvl < level; ++lvl) { switch (_class) { case CLASS_WARRIOR: - info->stats[STAT_STRENGTH] += (lvl > 23 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_STAMINA] += (lvl > 23 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 36 ? 1: (lvl > 6 && (lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl%2) ? 1: 0); + info->stats[STAT_STRENGTH] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0)); + info->stats[STAT_STAMINA] += (lvl > 23 ? 2 : (lvl > 1 ? 1 : 0)); + info->stats[STAT_AGILITY] += (lvl > 36 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0)); + info->stats[STAT_INTELLECT] += (lvl > 9 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_SPIRIT] += (lvl > 9 && !(lvl % 2) ? 1 : 0); break; case CLASS_PALADIN: - info->stats[STAT_STRENGTH] += (lvl > 3 ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 33 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 38 ? 1: (lvl > 7 && !(lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 7 ? 1: 0); + info->stats[STAT_STRENGTH] += (lvl > 3 ? 1 : 0); + info->stats[STAT_STAMINA] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0)); + info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 7 && !(lvl % 2) ? 1 : 0)); + info->stats[STAT_INTELLECT] += (lvl > 6 && (lvl % 2) ? 1 : 0); + info->stats[STAT_SPIRIT] += (lvl > 7 ? 1 : 0); break; case CLASS_HUNTER: - info->stats[STAT_STRENGTH] += (lvl > 4 ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 33 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 1: (lvl > 9 && !(lvl%2) ? 1: 0)); + info->stats[STAT_STRENGTH] += (lvl > 4 ? 1 : 0); + info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0); + info->stats[STAT_AGILITY] += (lvl > 33 ? 2 : (lvl > 1 ? 1 : 0)); + info->stats[STAT_INTELLECT] += (lvl > 8 && (lvl % 2) ? 1 : 0); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0)); break; case CLASS_ROGUE: - info->stats[STAT_STRENGTH] += (lvl > 5 ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 16 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl%2) ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 1: (lvl > 9 && !(lvl%2) ? 1: 0)); + info->stats[STAT_STRENGTH] += (lvl > 5 ? 1 : 0); + info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0); + info->stats[STAT_AGILITY] += (lvl > 16 ? 2 : (lvl > 1 ? 1 : 0)); + info->stats[STAT_INTELLECT] += (lvl > 8 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 1 : (lvl > 9 && !(lvl % 2) ? 1 : 0)); break; case CLASS_PRIEST: - info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 5 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 38 ? 1: (lvl > 8 && (lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 22 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 3 ? 1: 0); + info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0); + info->stats[STAT_AGILITY] += (lvl > 38 ? 1 : (lvl > 8 && (lvl % 2) ? 1 : 0)); + info->stats[STAT_INTELLECT] += (lvl > 22 ? 2 : (lvl > 1 ? 1 : 0)); + info->stats[STAT_SPIRIT] += (lvl > 3 ? 1 : 0); break; case CLASS_SHAMAN: - info->stats[STAT_STRENGTH] += (lvl > 34 ? 1: (lvl > 6 && (lvl%2) ? 1: 0)); - info->stats[STAT_STAMINA] += (lvl > 4 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl%2) ? 1: 0); - info->stats[STAT_INTELLECT] += (lvl > 5 ? 1: 0); - info->stats[STAT_SPIRIT] += (lvl > 4 ? 1: 0); + info->stats[STAT_STRENGTH] += (lvl > 34 ? 1 : (lvl > 6 && (lvl % 2) ? 1 : 0)); + info->stats[STAT_STAMINA] += (lvl > 4 ? 1 : 0); + info->stats[STAT_AGILITY] += (lvl > 7 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_INTELLECT] += (lvl > 5 ? 1 : 0); + info->stats[STAT_SPIRIT] += (lvl > 4 ? 1 : 0); break; case CLASS_MAGE: - info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 5 ? 1: 0); - info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_INTELLECT] += (lvl > 24 ? 2: (lvl > 1 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 33 ? 2: (lvl > 2 ? 1: 0)); + info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_STAMINA] += (lvl > 5 ? 1 : 0); + info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_INTELLECT] += (lvl > 24 ? 2 : (lvl > 1 ? 1 : 0)); + info->stats[STAT_SPIRIT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0)); break; case CLASS_WARLOCK: - info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_STAMINA] += (lvl > 38 ? 2: (lvl > 3 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl%2) ? 1: 0); - info->stats[STAT_INTELLECT] += (lvl > 33 ? 2: (lvl > 2 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 2: (lvl > 3 ? 1: 0)); + info->stats[STAT_STRENGTH] += (lvl > 9 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_STAMINA] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0)); + info->stats[STAT_AGILITY] += (lvl > 9 && !(lvl % 2) ? 1 : 0); + info->stats[STAT_INTELLECT] += (lvl > 33 ? 2 : (lvl > 2 ? 1 : 0)); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 2 : (lvl > 3 ? 1 : 0)); break; case CLASS_DRUID: - info->stats[STAT_STRENGTH] += (lvl > 38 ? 2: (lvl > 6 && (lvl%2) ? 1: 0)); - info->stats[STAT_STAMINA] += (lvl > 32 ? 2: (lvl > 4 ? 1: 0)); - info->stats[STAT_AGILITY] += (lvl > 38 ? 2: (lvl > 8 && (lvl%2) ? 1: 0)); - info->stats[STAT_INTELLECT] += (lvl > 38 ? 3: (lvl > 4 ? 1: 0)); - info->stats[STAT_SPIRIT] += (lvl > 38 ? 3: (lvl > 5 ? 1: 0)); + info->stats[STAT_STRENGTH] += (lvl > 38 ? 2 : (lvl > 6 && (lvl % 2) ? 1 : 0)); + info->stats[STAT_STAMINA] += (lvl > 32 ? 2 : (lvl > 4 ? 1 : 0)); + info->stats[STAT_AGILITY] += (lvl > 38 ? 2 : (lvl > 8 && (lvl % 2) ? 1 : 0)); + info->stats[STAT_INTELLECT] += (lvl > 38 ? 3 : (lvl > 4 ? 1 : 0)); + info->stats[STAT_SPIRIT] += (lvl > 38 ? 3 : (lvl > 5 ? 1 : 0)); } } } @@ -3633,7 +3633,7 @@ void ObjectMgr::LoadGroups() void ObjectMgr::LoadQuests() { // For reload case - for (QuestMap::const_iterator itr=mQuestTemplates.begin(); itr != mQuestTemplates.end(); ++itr) + for (QuestMap::const_iterator itr = mQuestTemplates.begin(); itr != mQuestTemplates.end(); ++itr) delete itr->second; mQuestTemplates.clear(); @@ -3712,7 +3712,7 @@ void ObjectMgr::LoadQuests() // Post processing - std::map usedMailTemplates; + std::map usedMailTemplates; for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); ++iter) { @@ -3722,7 +3722,7 @@ void ObjectMgr::LoadQuests() if (qinfo->GetQuestMethod() >= 3) { - sLog.outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.",qinfo->GetQuestId(),qinfo->GetQuestMethod()); + sLog.outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.", qinfo->GetQuestId(), qinfo->GetQuestMethod()); } if (qinfo->m_SpecialFlags > QUEST_SPECIAL_FLAG_DB_ALLOWED) @@ -3732,7 +3732,7 @@ void ObjectMgr::LoadQuests() if (qinfo->HasQuestFlag(QUEST_FLAGS_DAILY) && qinfo->HasQuestFlag(QUEST_FLAGS_WEEKLY)) { - sLog.outErrorDb("Weekly Quest %u is marked as daily quest in `QuestFlags`, removed daily flag.",qinfo->GetQuestId()); + sLog.outErrorDb("Weekly Quest %u is marked as daily quest in `QuestFlags`, removed daily flag.", qinfo->GetQuestId()); qinfo->m_QuestFlags &= ~QUEST_FLAGS_DAILY; } @@ -3740,7 +3740,7 @@ void ObjectMgr::LoadQuests() { if (!qinfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_REPEATABLE)) { - sLog.outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.",qinfo->GetQuestId()); + sLog.outErrorDb("Daily Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId()); qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAG_REPEATABLE); } } @@ -3749,7 +3749,7 @@ void ObjectMgr::LoadQuests() { if (!qinfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_REPEATABLE)) { - sLog.outErrorDb("Weekly Quest %u not marked as repeatable in `SpecialFlags`, added.",qinfo->GetQuestId()); + sLog.outErrorDb("Weekly Quest %u not marked as repeatable in `SpecialFlags`, added.", qinfo->GetQuestId()); qinfo->SetSpecialFlag(QUEST_SPECIAL_FLAG_REPEATABLE); } } @@ -3771,7 +3771,7 @@ void ObjectMgr::LoadQuests() if (uint32 id = qinfo->RewChoiceItemId[j]) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(), j + 1, id, j + 1); // no changes, quest ignore this data } } @@ -3783,7 +3783,7 @@ void ObjectMgr::LoadQuests() if (!GetAreaEntryByAreaID(qinfo->ZoneOrSort)) { sLog.outErrorDb("Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.", - qinfo->GetQuestId(),qinfo->ZoneOrSort); + qinfo->GetQuestId(), qinfo->ZoneOrSort); // no changes, quest not dependent from this value but can have problems at client } } @@ -3794,7 +3794,7 @@ void ObjectMgr::LoadQuests() if (!qSort) { sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (sort case) but quest sort with this id does not exist.", - qinfo->GetQuestId(),qinfo->ZoneOrSort); + qinfo->GetQuestId(), qinfo->ZoneOrSort); // no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check) } } @@ -3834,7 +3834,7 @@ void ObjectMgr::LoadQuests() if (qinfo->RequiredSkillValue > sWorld.GetConfigMaxSkillValue()) { sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue()); + qinfo->GetQuestId(), qinfo->RequiredSkillValue, sWorld.GetConfigMaxSkillValue()); // no changes, quest can't be done for this requirement } } @@ -3843,63 +3843,63 @@ void ObjectMgr::LoadQuests() if (qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction)) { sLog.outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction); + qinfo->GetQuestId(), qinfo->RepObjectiveFaction, qinfo->RepObjectiveFaction); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction)) { sLog.outErrorDb("Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction); + qinfo->GetQuestId(), qinfo->RequiredMinRepFaction, qinfo->RequiredMinRepFaction); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction)) { sLog.outErrorDb("Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction); + qinfo->GetQuestId(), qinfo->RequiredMaxRepFaction, qinfo->RequiredMaxRepFaction); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > ReputationMgr::Reputation_Cap) { sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMinRepValue,ReputationMgr::Reputation_Cap); + qinfo->GetQuestId(), qinfo->RequiredMinRepValue, ReputationMgr::Reputation_Cap); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue) { sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue); + qinfo->GetQuestId(), qinfo->RequiredMaxRepValue, qinfo->RequiredMinRepValue); // no changes, quest can't be done for this requirement } if (!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0) { sLog.outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RepObjectiveValue); + qinfo->GetQuestId(), qinfo->RepObjectiveValue); // warning } if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0) { sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RequiredMinRepValue); + qinfo->GetQuestId(), qinfo->RequiredMinRepValue); // warning } if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0) { sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RequiredMaxRepValue); + qinfo->GetQuestId(), qinfo->RequiredMaxRepValue); // warning } if (qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId)) { sLog.outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", - qinfo->GetQuestId(),qinfo->GetCharTitleId(),qinfo->GetCharTitleId()); + qinfo->GetQuestId(), qinfo->GetCharTitleId(), qinfo->GetCharTitleId()); qinfo->CharTitleId = 0; // quest can't reward this title } @@ -3909,21 +3909,21 @@ void ObjectMgr::LoadQuests() if (!sItemStorage.LookupEntry(qinfo->SrcItemId)) { sLog.outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId); + qinfo->GetQuestId(), qinfo->SrcItemId, qinfo->SrcItemId); qinfo->SrcItemId = 0; // quest can't be done for this requirement } - else if (qinfo->SrcItemCount==0) + else if (qinfo->SrcItemCount == 0) { sLog.outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.", - qinfo->GetQuestId(),qinfo->SrcItemId); + qinfo->GetQuestId(), qinfo->SrcItemId); qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB } } - else if (qinfo->SrcItemCount>0) + else if (qinfo->SrcItemCount > 0) { sLog.outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.", - qinfo->GetQuestId(),qinfo->SrcItemCount); - qinfo->SrcItemCount=0; // no quest work changes in fact + qinfo->GetQuestId(), qinfo->SrcItemCount); + qinfo->SrcItemCount = 0; // no quest work changes in fact } if (qinfo->SrcSpell) @@ -3932,13 +3932,13 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); + qinfo->GetQuestId(), qinfo->SrcSpell, qinfo->SrcSpell); qinfo->SrcSpell = 0; // quest can't be done for this requirement } else if (!SpellMgr::IsSpellValid(spellInfo)) { sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); + qinfo->GetQuestId(), qinfo->SrcSpell, qinfo->SrcSpell); qinfo->SrcSpell = 0; // quest can't be done for this requirement } } @@ -3950,7 +3950,7 @@ void ObjectMgr::LoadQuests() if (qinfo->ReqItemCount[j] == 0) { sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(), j+1, id, j+1); + qinfo->GetQuestId(), j + 1, id, j + 1); // no changes, quest can't be done for this requirement } @@ -3959,14 +3959,14 @@ void ObjectMgr::LoadQuests() if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(), j+1, id, id); + qinfo->GetQuestId(), j + 1, id, id); qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest } } else if (qinfo->ReqItemCount[j] > 0) { sLog.outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.", - qinfo->GetQuestId(), j+1, j+1, qinfo->ReqItemCount[j]); + qinfo->GetQuestId(), j + 1, j + 1, qinfo->ReqItemCount[j]); qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest } } @@ -3978,16 +3978,16 @@ void ObjectMgr::LoadQuests() if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(), j + 1, id, id); // no changes, quest can't be done for this requirement } } else { - if (qinfo->ReqSourceCount[j]>0) + if (qinfo->ReqSourceCount[j] > 0) { sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceCount[j]); + qinfo->GetQuestId(), j + 1, j + 1, qinfo->ReqSourceCount[j]); // no changes, quest ignore this data } } @@ -4001,7 +4001,7 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(), j + 1, id, id); continue; } @@ -4022,7 +4022,7 @@ void ObjectMgr::LoadQuests() { if (!qinfo->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT)) { - sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.",spellInfo->Id,qinfo->QuestId,j+1,j+1); + sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.", spellInfo->Id, qinfo->QuestId, j + 1, j + 1); // this will prevent quest completing without objective const_cast(qinfo)->SetSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT); @@ -4031,7 +4031,7 @@ void ObjectMgr::LoadQuests() else { sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u and ReqCreatureOrGOId%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1,id); + qinfo->GetQuestId(), j + 1, id, j + 1, id); // no changes, quest can't be done for this requirement } } @@ -4044,14 +4044,14 @@ void ObjectMgr::LoadQuests() if (id < 0 && !sGOStorage.LookupEntry(-id)) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,uint32(-id)); + qinfo->GetQuestId(), j + 1, id, uint32(-id)); qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement } if (id > 0 && !sCreatureStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,uint32(id)); + qinfo->GetQuestId(), j + 1, id, uint32(id)); qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement } @@ -4064,27 +4064,27 @@ void ObjectMgr::LoadQuests() if (!qinfo->ReqCreatureOrGOCount[j]) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(), j + 1, id, j + 1); // no changes, quest can be incorrectly done, but we already report this } } - else if (qinfo->ReqCreatureOrGOCount[j]>0) + else if (qinfo->ReqCreatureOrGOCount[j] > 0) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqCreatureOrGOCount[j]); + qinfo->GetQuestId(), j + 1, j + 1, qinfo->ReqCreatureOrGOCount[j]); // no changes, quest ignore this data } } bool choice_found = false; - for (int j = QUEST_REWARD_CHOICES_COUNT-1; j >=0; --j) + for (int j = QUEST_REWARD_CHOICES_COUNT - 1; j >= 0; --j) { if (uint32 id = qinfo->RewChoiceItemId[j]) { if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(), j + 1, id, id); qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this } else @@ -4093,22 +4093,22 @@ void ObjectMgr::LoadQuests() if (!qinfo->RewChoiceItemCount[j]) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(), j + 1, id, j + 1); // no changes, quest can't be done } } else if (choice_found) // client crash if have gap in item reward choices { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemId%d` = %u, client can crash at like data.", - qinfo->GetQuestId(),j+1,j+2,qinfo->RewChoiceItemId[j+1]); + qinfo->GetQuestId(), j + 1, j + 2, qinfo->RewChoiceItemId[j + 1]); // fill gap by clone later filled choice - qinfo->RewChoiceItemId[j] = qinfo->RewChoiceItemId[j+1]; - qinfo->RewChoiceItemCount[j] = qinfo->RewChoiceItemCount[j+1]; + qinfo->RewChoiceItemId[j] = qinfo->RewChoiceItemId[j + 1]; + qinfo->RewChoiceItemCount[j] = qinfo->RewChoiceItemCount[j + 1]; } - else if (qinfo->RewChoiceItemCount[j]>0) + else if (qinfo->RewChoiceItemCount[j] > 0) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewChoiceItemCount[j]); + qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewChoiceItemCount[j]); // no changes, quest ignore this data } } @@ -4120,21 +4120,21 @@ void ObjectMgr::LoadQuests() if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(), j + 1, id, id); qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item } if (!qinfo->RewItemCount[j]) { sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(), j + 1, id, j + 1); // no changes } } - else if (qinfo->RewItemCount[j]>0) + else if (qinfo->RewItemCount[j] > 0) { sLog.outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewItemCount[j]); + qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewItemCount[j]); // no changes, quest ignore this data } } @@ -4144,19 +4144,19 @@ void ObjectMgr::LoadQuests() if (qinfo->RewRepFaction[j]) { if (abs(qinfo->RewRepValueId[j]) > 9) - sLog.outErrorDb("Quest %u has RewRepValueId%d = %i but value is not valid.", qinfo->GetQuestId(), j+1, qinfo->RewRepValueId[j]); + sLog.outErrorDb("Quest %u has RewRepValueId%d = %i but value is not valid.", qinfo->GetQuestId(), j + 1, qinfo->RewRepValueId[j]); if (!sFactionStore.LookupEntry(qinfo->RewRepFaction[j])) { sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", - qinfo->GetQuestId(),j+1,qinfo->RewRepFaction[j] ,qinfo->RewRepFaction[j]); + qinfo->GetQuestId(), j + 1, qinfo->RewRepFaction[j] , qinfo->RewRepFaction[j]); qinfo->RewRepFaction[j] = 0; // quest will not reward this } } else if (qinfo->RewRepValue[j] != 0) { sLog.outErrorDb("Quest %u has `RewRepFaction%d` = 0 but `RewRepValue%d` = %i.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewRepValue[j]); + qinfo->GetQuestId(), j + 1, j + 1, qinfo->RewRepValue[j]); // no changes, quest ignore this data } } @@ -4168,19 +4168,19 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell); qinfo->RewSpell = 0; // no spell reward will display for this quest } else if (!SpellMgr::IsSpellValid(spellInfo)) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell); qinfo->RewSpell = 0; // no spell reward will display for this quest } else if (GetTalentSpellCost(qinfo->RewSpell)) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->GetQuestId(), qinfo->RewSpell, qinfo->RewSpell); qinfo->RewSpell = 0; // no spell reward will display for this quest } } @@ -4192,19 +4192,19 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast); qinfo->RewSpellCast = 0; // no spell will be casted on player } else if (!SpellMgr::IsSpellValid(spellInfo)) { sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast); qinfo->RewSpellCast = 0; // no spell will be casted on player } else if (GetTalentSpellCost(qinfo->RewSpellCast)) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->GetQuestId(), qinfo->RewSpellCast, qinfo->RewSpellCast); qinfo->RewSpellCast = 0; // no spell will be casted on player } } @@ -4214,15 +4214,15 @@ void ObjectMgr::LoadQuests() if (!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId)) { sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", - qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId); + qinfo->GetQuestId(), qinfo->RewMailTemplateId, qinfo->RewMailTemplateId); qinfo->RewMailTemplateId = 0; // no mail will send to player qinfo->RewMailDelaySecs = 0; // no mail will send to player } else if (usedMailTemplates.find(qinfo->RewMailTemplateId) != usedMailTemplates.end()) { - std::map::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewMailTemplateId); + std::map::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewMailTemplateId); sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.", - qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId,used_mt_itr->second); + qinfo->GetQuestId(), qinfo->RewMailTemplateId, qinfo->RewMailTemplateId, used_mt_itr->second); qinfo->RewMailTemplateId = 0; // no mail will send to player qinfo->RewMailDelaySecs = 0; // no mail will send to player } @@ -4236,7 +4236,7 @@ void ObjectMgr::LoadQuests() if (qNextItr == mQuestTemplates.end()) { sLog.outErrorDb("Quest %u has `NextQuestInChain` = %u but quest %u does not exist, quest chain will not work.", - qinfo->GetQuestId(),qinfo->NextQuestInChain ,qinfo->NextQuestInChain); + qinfo->GetQuestId(), qinfo->NextQuestInChain , qinfo->NextQuestInChain); qinfo->NextQuestInChain = 0; } else @@ -4360,100 +4360,100 @@ void ObjectMgr::LoadQuestLocales() for (int i = 1; i < MAX_LOCALE; ++i) { - std::string str = fields[1+11*(i-1)].GetCppString(); + std::string str = fields[1 + 11 * (i - 1)].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.Title.size() <= idx) - data.Title.resize(idx+1); + data.Title.resize(idx + 1); data.Title[idx] = str; } } - str = fields[1+11*(i-1)+1].GetCppString(); + str = fields[1 + 11 * (i - 1) + 1].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.Details.size() <= idx) - data.Details.resize(idx+1); + data.Details.resize(idx + 1); data.Details[idx] = str; } } - str = fields[1+11*(i-1)+2].GetCppString(); + str = fields[1 + 11 * (i - 1) + 2].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.Objectives.size() <= idx) - data.Objectives.resize(idx+1); + data.Objectives.resize(idx + 1); data.Objectives[idx] = str; } } - str = fields[1+11*(i-1)+3].GetCppString(); + str = fields[1 + 11 * (i - 1) + 3].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.OfferRewardText.size() <= idx) - data.OfferRewardText.resize(idx+1); + data.OfferRewardText.resize(idx + 1); data.OfferRewardText[idx] = str; } } - str = fields[1+11*(i-1)+4].GetCppString(); + str = fields[1 + 11 * (i - 1) + 4].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.RequestItemsText.size() <= idx) - data.RequestItemsText.resize(idx+1); + data.RequestItemsText.resize(idx + 1); data.RequestItemsText[idx] = str; } } - str = fields[1+11*(i-1)+5].GetCppString(); + str = fields[1 + 11 * (i - 1) + 5].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.EndText.size() <= idx) - data.EndText.resize(idx+1); + data.EndText.resize(idx + 1); data.EndText[idx] = str; } } - str = fields[1+11*(i-1)+6].GetCppString(); + str = fields[1 + 11 * (i - 1) + 6].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.CompletedText.size() <= idx) - data.CompletedText.resize(idx+1); + data.CompletedText.resize(idx + 1); data.CompletedText[idx] = str; } } for (int k = 0; k < 4; ++k) { - str = fields[1+11*(i-1)+7+k].GetCppString(); + str = fields[1 + 11 * (i - 1) + 7 + k].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); 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; } @@ -4486,7 +4486,7 @@ void ObjectMgr::LoadPageTexts() if (page->Next_Page && !sPageTextStore.LookupEntry(page->Next_Page)) { - sLog.outErrorDb("Page text (Id: %u) has not existing next page (Id:%u)", i,page->Next_Page); + sLog.outErrorDb("Page text (Id: %u) has not existing next page (Id:%u)", i, page->Next_Page); continue; } @@ -4497,14 +4497,14 @@ void ObjectMgr::LoadPageTexts() if (!pageItr->Next_Page) break; checkedPages.insert(pageItr->Page_ID); - if (checkedPages.find(pageItr->Next_Page)!=checkedPages.end()) + if (checkedPages.find(pageItr->Next_Page) != checkedPages.end()) { std::ostringstream ss; - ss<< "The text page(s) "; - for (std::set::iterator itr= checkedPages.begin(); itr!=checkedPages.end(); ++itr) + ss << "The text page(s) "; + for (std::set::iterator itr = checkedPages.begin(); itr != checkedPages.end(); ++itr) ss << *itr << " "; ss << "create(s) a circular reference, which can cause the server to freeze. Changing Next_Page of page " - << pageItr->Page_ID <<" to 0"; + << pageItr->Page_ID << " to 0"; sLog.outErrorDb("%s", ss.str().c_str()); const_cast(pageItr)->Next_Page = 0; break; @@ -4557,7 +4557,7 @@ void ObjectMgr::LoadPageTextLocales() if (idx >= 0) { if ((int32)data.Text.size() <= idx) - data.Text.resize(idx+1); + data.Text.resize(idx + 1); data.Text[idx] = str; } @@ -4696,7 +4696,7 @@ void ObjectMgr::LoadInstanceTemplate() if (parentEntry->IsContinent()) { sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: parent point to continent map id %u for instance template %d template, ignored, need be set only for non-continent parents!", - parentEntry->MapID,temp->map); + parentEntry->MapID, temp->map); const_cast(temp)->parent = 0; continue; } @@ -4880,30 +4880,30 @@ void ObjectMgr::LoadGossipTextLocales() NpcTextLocale& data = mNpcTextLocaleMap[entry]; - for (int i=1; i= 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; } } - std::string str1 = fields[1+8*2*(i-1)+2*j+1].GetCppString(); + std::string str1 = fields[1 + 8 * 2 * (i - 1) + 2 * j + 1].GetCppString(); if (!str1.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); 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; } @@ -5004,7 +5004,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) { // mail will be returned: CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" UI64FMTD "', deliver_time = '" UI64FMTD "',cod = '0', checked = '%u' WHERE id = '%u'", - m->receiverGuid.GetCounter(), m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); + m->receiverGuid.GetCounter(), m->sender, (uint64)(basetime + 30 * DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) { // update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete @@ -5069,13 +5069,13 @@ void ObjectMgr::LoadQuestAreaTriggers() Quest const* quest = GetQuestTemplate(quest_ID); if (!quest) { - sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not existing quest %u",trigger_ID,quest_ID); + sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not existing quest %u", trigger_ID, quest_ID); continue; } if (!quest->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT)) { - sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not quest %u, but quest not have flag QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.",trigger_ID,quest_ID); + sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not quest %u, but quest not have flag QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.", trigger_ID, quest_ID); // this will prevent quest completing without objective const_cast(quest)->SetSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT); @@ -5153,13 +5153,13 @@ uint32 ObjectMgr::GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Te continue; uint8 field = (uint8)((i - 1) / 32); - uint32 submask = 1<<((i-1)%32); + uint32 submask = 1 << ((i - 1) % 32); // skip not taxi network nodes - if ((sTaxiNodesMask[field] & submask)==0) + if ((sTaxiNodesMask[field] & submask) == 0) continue; - float dist2 = (node->x - x)*(node->x - x)+(node->y - y)*(node->y - y)+(node->z - z)*(node->z - z); + float dist2 = (node->x - x) * (node->x - x) + (node->y - y) * (node->y - y) + (node->z - z) * (node->z - z); if (found) { if (dist2 < dist) @@ -5182,7 +5182,7 @@ uint32 ObjectMgr::GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Te void ObjectMgr::GetTaxiPath(uint32 source, uint32 destination, uint32& path, uint32& cost) { TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source); - if (src_i==sTaxiPathSetBySource.end()) + if (src_i == sTaxiPathSetBySource.end()) { path = 0; cost = 0; @@ -5192,7 +5192,7 @@ void ObjectMgr::GetTaxiPath(uint32 source, uint32 destination, uint32& path, uin TaxiPathSetForSource& pathSet = src_i->second; TaxiPathSetForSource::iterator dest_i = pathSet.find(destination); - if (dest_i==pathSet.end()) + if (dest_i == pathSet.end()) { path = 0; cost = 0; @@ -5275,7 +5275,7 @@ void ObjectMgr::LoadGraveyardZones() WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(safeLocId); if (!entry) { - sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",safeLocId); + sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.", safeLocId); continue; } @@ -5372,8 +5372,8 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float } // at entrance map calculate distance (2D); - float dist2 = (entry->x - mapEntry->ghost_entrance_x)*(entry->x - mapEntry->ghost_entrance_x) - +(entry->y - mapEntry->ghost_entrance_y)*(entry->y - mapEntry->ghost_entrance_y); + float dist2 = (entry->x - mapEntry->ghost_entrance_x) * (entry->x - mapEntry->ghost_entrance_x) + + (entry->y - mapEntry->ghost_entrance_y) * (entry->y - mapEntry->ghost_entrance_y); if (foundEntr) { if (dist2 < distEntr) @@ -5392,7 +5392,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float // find now nearest graveyard at same map else { - float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z); + float dist2 = (entry->x - x) * (entry->x - x) + (entry->y - y) * (entry->y - y) + (entry->z - z) * (entry->z - z); if (foundNear) { if (dist2 < distNear) @@ -5575,7 +5575,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() QuestMap::iterator qReqItr = mQuestTemplates.find(at.requiredQuest); if (qReqItr == mQuestTemplates.end()) { - sLog.outErrorDb("Table `areatrigger_teleport` has nonexistent required quest %u for trigger %u, remove quest done requirement.",at.requiredQuest,Trigger_ID); + sLog.outErrorDb("Table `areatrigger_teleport` has nonexistent required quest %u for trigger %u, remove quest done requirement.", at.requiredQuest, Trigger_ID); at.requiredQuest = 0; } } @@ -5585,7 +5585,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() QuestMap::iterator qReqItr = mQuestTemplates.find(at.requiredQuestHeroic); if (qReqItr == mQuestTemplates.end()) { - sLog.outErrorDb("Table `areatrigger_teleport` has nonexistent required heroic quest %u for trigger %u, remove quest done requirement.",at.requiredQuestHeroic,Trigger_ID); + sLog.outErrorDb("Table `areatrigger_teleport` has nonexistent required heroic quest %u for trigger %u, remove quest done requirement.", at.requiredQuestHeroic, Trigger_ID); at.requiredQuestHeroic = 0; } } @@ -5597,9 +5597,9 @@ void ObjectMgr::LoadAreaTriggerTeleports() continue; } - if (at.target_X==0 && at.target_Y==0 && at.target_Z==0) + if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0) { - sLog.outErrorDb("Table `areatrigger_teleport` has area trigger (ID:%u) without target coordinates.",Trigger_ID); + sLog.outErrorDb("Table `areatrigger_teleport` has area trigger (ID:%u) without target coordinates.", Trigger_ID); continue; } @@ -5715,28 +5715,28 @@ void ObjectMgr::SetHighestGuids() QueryResult* result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters"); if (result) { - m_CharGuids.Set((*result)[0].GetUInt32()+1); + m_CharGuids.Set((*result)[0].GetUInt32() + 1); delete result; } result = WorldDatabase.Query("SELECT MAX(guid) FROM creature"); if (result) { - m_FirstTemporaryCreatureGuid = (*result)[0].GetUInt32()+1; + m_FirstTemporaryCreatureGuid = (*result)[0].GetUInt32() + 1; delete result; } result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance"); if (result) { - m_ItemGuids.Set((*result)[0].GetUInt32()+1); + m_ItemGuids.Set((*result)[0].GetUInt32() + 1); delete result; } result = CharacterDatabase.Query("SELECT MAX(id) FROM instance"); if (result) { - m_InstanceGuids.Set((*result)[0].GetUInt32()+1); + m_InstanceGuids.Set((*result)[0].GetUInt32() + 1); delete result; } @@ -5751,56 +5751,56 @@ void ObjectMgr::SetHighestGuids() result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject"); if (result) { - m_FirstTemporaryGameObjectGuid = (*result)[0].GetUInt32()+1; + m_FirstTemporaryGameObjectGuid = (*result)[0].GetUInt32() + 1; delete result; } result = CharacterDatabase.Query("SELECT MAX(id) FROM auction"); if (result) { - m_AuctionIds.Set((*result)[0].GetUInt32()+1); + m_AuctionIds.Set((*result)[0].GetUInt32() + 1); delete result; } result = CharacterDatabase.Query("SELECT MAX(id) FROM mail"); if (result) { - m_MailIds.Set((*result)[0].GetUInt32()+1); + m_MailIds.Set((*result)[0].GetUInt32() + 1); delete result; } result = CharacterDatabase.Query("SELECT MAX(guid) FROM corpse"); if (result) { - m_CorpseGuids.Set((*result)[0].GetUInt32()+1); + m_CorpseGuids.Set((*result)[0].GetUInt32() + 1); delete result; } result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team"); if (result) { - m_ArenaTeamIds.Set((*result)[0].GetUInt32()+1); + m_ArenaTeamIds.Set((*result)[0].GetUInt32() + 1); delete result; } result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets"); if (result) { - m_EquipmentSetIds.Set((*result)[0].GetUInt64()+1); + m_EquipmentSetIds.Set((*result)[0].GetUInt64() + 1); delete result; } result = CharacterDatabase.Query("SELECT MAX(guildid) FROM guild"); if (result) { - m_GuildIds.Set((*result)[0].GetUInt32()+1); + m_GuildIds.Set((*result)[0].GetUInt32() + 1); delete result; } result = CharacterDatabase.Query("SELECT MAX(groupId) FROM groups"); if (result) { - m_GroupGuids.Set((*result)[0].GetUInt32()+1); + m_GroupGuids.Set((*result)[0].GetUInt32() + 1); delete result; } @@ -5858,7 +5858,7 @@ void ObjectMgr::LoadGameObjectLocales() if (idx >= 0) { if ((int32)data.Name.size() <= idx) - data.Name.resize(idx+1); + data.Name.resize(idx + 1); data.Name[idx] = str; } @@ -5867,14 +5867,14 @@ void ObjectMgr::LoadGameObjectLocales() for (int i = 1; i < MAX_LOCALE; ++i) { - std::string str = fields[i+(MAX_LOCALE-1)].GetCppString(); + std::string str = fields[i + (MAX_LOCALE - 1)].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { if ((int32)data.CastBarCaption.size() <= idx) - data.CastBarCaption.resize(idx+1); + data.CastBarCaption.resize(idx + 1); data.CastBarCaption[idx] = str; } @@ -5899,68 +5899,68 @@ struct SQLGameObjectLoader : public SQLStorageLoaderBase } }; -inline void CheckGOLockId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) +inline void CheckGOLockId(GameObjectInfo const* goInfo, uint32 dataN, uint32 N) { if (sLockStore.LookupEntry(dataN)) return; sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but lock (Id: %u) not found.", - goInfo->id,goInfo->type,N,dataN,dataN); + goInfo->id, goInfo->type, N, dataN, dataN); } -inline void CheckGOLinkedTrapId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) +inline void CheckGOLinkedTrapId(GameObjectInfo const* goInfo, uint32 dataN, uint32 N) { if (GameObjectInfo const* trapInfo = sGOStorage.LookupEntry(dataN)) { - if (trapInfo->type!=GAMEOBJECT_TYPE_TRAP) + if (trapInfo->type != GAMEOBJECT_TYPE_TRAP) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", - goInfo->id,goInfo->type,N,dataN,dataN,GAMEOBJECT_TYPE_TRAP); + goInfo->id, goInfo->type, N, dataN, dataN, GAMEOBJECT_TYPE_TRAP); } else // too many error reports about nonexistent trap templates ERROR_DB_STRICT_LOG("Gameobject (Entry: %u GoType: %u) have data%d=%u but trap GO (Entry %u) not exist in `gameobject_template`.", - goInfo->id,goInfo->type,N,dataN,dataN); + goInfo->id, goInfo->type, N, dataN, dataN); } -inline void CheckGOSpellId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) +inline void CheckGOSpellId(GameObjectInfo const* goInfo, uint32 dataN, uint32 N) { if (sSpellStore.LookupEntry(dataN)) 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); + goInfo->id, goInfo->type, N, dataN, dataN); } -inline void CheckAndFixGOChairHeightId(GameObjectInfo const* goInfo,uint32 const& 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)) + if (dataN <= (UNIT_STAND_STATE_SIT_HIGH_CHAIR - UNIT_STAND_STATE_SIT_LOW_CHAIR)) 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); + goInfo->id, goInfo->type, N, dataN, UNIT_STAND_STATE_SIT_HIGH_CHAIR - UNIT_STAND_STATE_SIT_LOW_CHAIR); // prevent client and server unexpected work const_cast(dataN) = 0; } -inline void CheckGONoDamageImmuneId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) +inline void CheckGONoDamageImmuneId(GameObjectInfo const* goInfo, uint32 dataN, uint32 N) { // 0/1 correct values if (dataN <= 1) 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); + goInfo->id, goInfo->type, N, dataN); } -inline void CheckGOConsumable(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) +inline void CheckGOConsumable(GameObjectInfo const* goInfo, uint32 dataN, uint32 N) { // 0/1 correct values if (dataN <= 1) 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); + goInfo->id, goInfo->type, N, dataN); } inline void CheckAndFixGOCaptureMinTime(GameObjectInfo const* goInfo, uint32 const& dataN, uint32 N) @@ -6002,41 +6002,41 @@ void ObjectMgr::LoadGameobjectInfo() case GAMEOBJECT_TYPE_DOOR: //0 { if (goInfo->door.lockId) - CheckGOLockId(goInfo,goInfo->door.lockId,1); - CheckGONoDamageImmuneId(goInfo,goInfo->door.noDamageImmune,3); + 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); - CheckGONoDamageImmuneId(goInfo,goInfo->button.noDamageImmune,4); + 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); - CheckGONoDamageImmuneId(goInfo,goInfo->questgiver.noDamageImmune,5); + 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); + 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); @@ -6044,7 +6044,7 @@ void ObjectMgr::LoadGameobjectInfo() break; } case GAMEOBJECT_TYPE_CHAIR: //7 - CheckAndFixGOChairHeightId(goInfo,goInfo->chair.height,1); + CheckAndFixGOChairHeightId(goInfo, goInfo->chair.height, 1); break; case GAMEOBJECT_TYPE_SPELL_FOCUS: //8 { @@ -6052,45 +6052,45 @@ void ObjectMgr::LoadGameobjectInfo() { if (!sSpellFocusObjectStore.LookupEntry(goInfo->spellFocus.focusId)) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but SpellFocus (Id: %u) not exist.", - id,goInfo->type,goInfo->spellFocus.focusId,goInfo->spellFocus.focusId); + id, goInfo->type, goInfo->spellFocus.focusId, goInfo->spellFocus.focusId); } 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); + CheckGOConsumable(goInfo, goInfo->goober.consumable, 3); if (goInfo->goober.pageId) // pageId { if (!sPageTextStore.LookupEntry(goInfo->goober.pageId)) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data7=%u but PageText (Entry %u) not exist.", - id,goInfo->type,goInfo->goober.pageId,goInfo->goober.pageId); + id, goInfo->type, goInfo->goober.pageId, goInfo->goober.pageId); } /* disable check for while, too many nonexistent spells if (goInfo->goober.spellId) // spell CheckGOSpellId(goInfo,goInfo->goober.spellId,10); */ - CheckGONoDamageImmuneId(goInfo,goInfo->goober.noDamageImmune,11); + 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_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 @@ -6099,7 +6099,7 @@ void ObjectMgr::LoadGameobjectInfo() { if (goInfo->moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[goInfo->moTransport.taxiPathId].empty()) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but TaxiPath (Id: %u) not exist.", - id,goInfo->type,goInfo->moTransport.taxiPathId,goInfo->moTransport.taxiPathId); + id, goInfo->type, goInfo->moTransport.taxiPathId, goInfo->moTransport.taxiPathId); } break; } @@ -6114,27 +6114,27 @@ void ObjectMgr::LoadGameobjectInfo() case GAMEOBJECT_TYPE_SPELLCASTER: //22 { // always must have spell - CheckGOSpellId(goInfo,goInfo->spellcaster.spellId,0); + CheckGOSpellId(goInfo, goInfo->spellcaster.spellId, 0); break; } case GAMEOBJECT_TYPE_FLAGSTAND: //24 { if (goInfo->flagstand.lockId) - CheckGOLockId(goInfo,goInfo->flagstand.lockId,0); - CheckGONoDamageImmuneId(goInfo,goInfo->flagstand.noDamageImmune,5); + 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); - CheckGONoDamageImmuneId(goInfo,goInfo->flagdrop.noDamageImmune,3); + CheckGOLockId(goInfo, goInfo->flagdrop.lockId, 0); + CheckGONoDamageImmuneId(goInfo, goInfo->flagdrop.noDamageImmune, 3); break; } case GAMEOBJECT_TYPE_CAPTURE_POINT: //29 @@ -6143,7 +6143,7 @@ void ObjectMgr::LoadGameobjectInfo() break; } case GAMEOBJECT_TYPE_BARBER_CHAIR: //32 - CheckAndFixGOChairHeightId(goInfo,goInfo->barberChair.chairheight,0); + CheckAndFixGOChairHeightId(goInfo, goInfo->barberChair.chairheight, 0); break; } } @@ -6246,7 +6246,7 @@ void ObjectMgr::LoadPetNumber() if (result) { Field* fields = result->Fetch(); - m_PetNumbers.Set(fields[0].GetUInt32()+1); + m_PetNumbers.Set(fields[0].GetUInt32() + 1); delete result; } @@ -6271,7 +6271,7 @@ std::string ObjectMgr::GeneratePetName(uint32 entry) return std::string(petname); } - return *(list0.begin()+urand(0, list0.size()-1)) + *(list1.begin()+urand(0, list1.size()-1)); + return *(list0.begin() + urand(0, list0.size() - 1)) + *(list1.begin() + urand(0, list1.size() - 1)); } void ObjectMgr::LoadCorpses() @@ -6306,7 +6306,7 @@ void ObjectMgr::LoadCorpses() uint32 guid = fields[0].GetUInt32(); Corpse* corpse = new Corpse; - if (!corpse->LoadFromDB(guid,fields)) + if (!corpse->LoadFromDB(guid, fields)) { delete corpse; continue; @@ -6437,7 +6437,7 @@ void ObjectMgr::LoadReputationOnKill() if (!GetCreatureTemplate(creature_id)) { - sLog.outErrorDb("Table `creature_onkill_reputation` have data for nonexistent creature entry (%u), skipped",creature_id); + sLog.outErrorDb("Table `creature_onkill_reputation` have data for nonexistent creature entry (%u), skipped", creature_id); continue; } @@ -6446,7 +6446,7 @@ void ObjectMgr::LoadReputationOnKill() FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1); if (!factionEntry1) { - sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction1); + sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`", repOnKill.repfaction1); continue; } } @@ -6456,7 +6456,7 @@ void ObjectMgr::LoadReputationOnKill() FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2); if (!factionEntry2) { - sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction2); + sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`", repOnKill.repfaction2); continue; } } @@ -6630,9 +6630,9 @@ void ObjectMgr::LoadPointsOfInterest() POI.data = fields[5].GetUInt32(); POI.icon_name = fields[6].GetCppString(); - if (!MaNGOS::IsValidMapCoord(POI.x,POI.y)) + if (!MaNGOS::IsValidMapCoord(POI.x, POI.y)) { - sLog.outErrorDb("Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.",point_id,POI.x,POI.y); + sLog.outErrorDb("Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.", point_id, POI.x, POI.y); continue; } @@ -6903,26 +6903,26 @@ void ObjectMgr::LoadWeatherZoneChances() for (int season = 0; season < WEATHER_SEASONS; ++season) { - wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE-1) + 1].GetUInt32(); - wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE-1) + 2].GetUInt32(); - wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE-1) + 3].GetUInt32(); + wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE - 1) + 1].GetUInt32(); + wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE - 1) + 2].GetUInt32(); + wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE - 1) + 3].GetUInt32(); if (wzc.data[season].rainChance > 100) { wzc.data[season].rainChance = 25; - sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%%",zone_id,season); + sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%%", zone_id, season); } if (wzc.data[season].snowChance > 100) { wzc.data[season].snowChance = 25; - sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%%",zone_id,season); + sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%%", zone_id, season); } if (wzc.data[season].stormChance > 100) { wzc.data[season].stormChance = 25; - sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%%",zone_id,season); + sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%%", zone_id, season); } } @@ -6959,14 +6959,14 @@ void ObjectMgr::DeleteGOData(uint32 guid) void ObjectMgr::AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance) { // corpses are always added to spawn mode 0 and they are spawned by their instance id - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid]; + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid, 0)][cellid]; cell_guids.corpses[player_guid] = instance; } void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid) { // corpses are always added to spawn mode 0 and they are spawned by their instance id - CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid]; + CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid, 0)][cellid]; cell_guids.corpses.erase(player_guid); } @@ -6976,7 +6976,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab uint32 count = 0; - QueryResult* result = WorldDatabase.PQuery("SELECT id,quest FROM %s",table); + QueryResult* result = WorldDatabase.PQuery("SELECT id,quest FROM %s", table); if (!result) { @@ -6985,7 +6985,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab bar.step(); sLog.outString(); - sLog.outErrorDb(">> Loaded 0 quest relations from %s. DB table `%s` is empty.",table,table); + sLog.outErrorDb(">> Loaded 0 quest relations from %s. DB table `%s` is empty.", table, table); return; } @@ -7001,7 +7001,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab if (mQuestTemplates.find(quest) == mQuestTemplates.end()) { - sLog.outErrorDb("Table `%s: Quest %u listed for entry %u does not exist.",table,quest,id); + sLog.outErrorDb("Table `%s: Quest %u listed for entry %u does not exist.", table, quest, id); continue; } @@ -7014,7 +7014,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab delete result; sLog.outString(); - sLog.outString(">> Loaded %u quest relations from %s", count,table); + sLog.outString(">> Loaded %u quest relations from %s", count, table); } void ObjectMgr::LoadGameobjectQuestRelations() @@ -7025,9 +7025,9 @@ void ObjectMgr::LoadGameobjectQuestRelations() { GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); if (!goInfo) - sLog.outErrorDb("Table `gameobject_questrelation` have data for nonexistent gameobject entry (%u) and existing quest %u",itr->first,itr->second); + sLog.outErrorDb("Table `gameobject_questrelation` 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 `gameobject_questrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second); + sLog.outErrorDb("Table `gameobject_questrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); } } @@ -7039,9 +7039,9 @@ void ObjectMgr::LoadGameobjectInvolvedRelations() { GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); if (!goInfo) - sLog.outErrorDb("Table `gameobject_involvedrelation` have data for nonexistent gameobject entry (%u) and existing quest %u",itr->first,itr->second); + sLog.outErrorDb("Table `gameobject_involvedrelation` 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 `gameobject_involvedrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second); + sLog.outErrorDb("Table `gameobject_involvedrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second); } } @@ -7053,9 +7053,9 @@ void ObjectMgr::LoadCreatureQuestRelations() { CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); if (!cInfo) - sLog.outErrorDb("Table `creature_questrelation` have data for nonexistent creature entry (%u) and existing quest %u",itr->first,itr->second); + sLog.outErrorDb("Table `creature_questrelation` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER)) - sLog.outErrorDb("Table `creature_questrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second); + sLog.outErrorDb("Table `creature_questrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); } } @@ -7067,9 +7067,9 @@ void ObjectMgr::LoadCreatureInvolvedRelations() { CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); if (!cInfo) - sLog.outErrorDb("Table `creature_involvedrelation` have data for nonexistent creature entry (%u) and existing quest %u",itr->first,itr->second); + sLog.outErrorDb("Table `creature_involvedrelation` have data for nonexistent creature entry (%u) and existing quest %u", itr->first, itr->second); else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER)) - sLog.outErrorDb("Table `creature_involvedrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second); + sLog.outErrorDb("Table `creature_involvedrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second); } } @@ -7098,10 +7098,10 @@ void ObjectMgr::LoadReservedPlayersNames() { bar.step(); fields = result->Fetch(); - std::string name= fields[0].GetCppString(); + std::string name = fields[0].GetCppString(); std::wstring wstr; - if (!Utf8toWStr(name,wstr)) + if (!Utf8toWStr(name, wstr)) { sLog.outError("Table `reserved_name` have invalid name: %s", name.c_str()); continue; @@ -7123,7 +7123,7 @@ void ObjectMgr::LoadReservedPlayersNames() bool ObjectMgr::IsReservedName(const std::string& name) const { std::wstring wstr; - if (!Utf8toWStr(name,wstr)) + if (!Utf8toWStr(name, wstr)) return false; wstrToLower(wstr); @@ -7170,13 +7170,13 @@ static LanguageType GetRealmLanguageType(bool create) bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create = false) { - if (strictMask==0) // any language, ignore realm + if (strictMask == 0) // any language, ignore realm { - if (isExtendedLatinString(wstr,numericOrSpace)) + if (isExtendedLatinString(wstr, numericOrSpace)) return true; - if (isCyrillicString(wstr,numericOrSpace)) + if (isCyrillicString(wstr, numericOrSpace)) return true; - if (isEastAsianString(wstr,numericOrSpace)) + if (isEastAsianString(wstr, numericOrSpace)) return true; return false; } @@ -7185,19 +7185,19 @@ bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bo { LanguageType lt = GetRealmLanguageType(create); if (lt & LT_EXTENDEN_LATIN) - if (isExtendedLatinString(wstr,numericOrSpace)) + if (isExtendedLatinString(wstr, numericOrSpace)) return true; if (lt & LT_CYRILLIC) - if (isCyrillicString(wstr,numericOrSpace)) + if (isCyrillicString(wstr, numericOrSpace)) return true; if (lt & LT_EAST_ASIA) - if (isEastAsianString(wstr,numericOrSpace)) + if (isEastAsianString(wstr, numericOrSpace)) return true; } if (strictMask & 0x1) // basic Latin { - if (isBasicLatinString(wstr,numericOrSpace)) + if (isBasicLatinString(wstr, numericOrSpace)) return true; } @@ -7207,7 +7207,7 @@ bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bo uint8 ObjectMgr::CheckPlayerName(const std::string& name, bool create) { std::wstring wname; - if (!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name, wname)) return CHAR_NAME_INVALID_CHARACTER; if (wname.size() > MAX_PLAYER_NAME) @@ -7218,7 +7218,7 @@ uint8 ObjectMgr::CheckPlayerName(const std::string& name, bool create) return CHAR_NAME_TOO_SHORT; uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_PLAYER_NAMES); - if (!isValidString(wname,strictMask,false,create)) + if (!isValidString(wname, strictMask, false, create)) return CHAR_NAME_MIXED_LANGUAGES; return CHAR_NAME_SUCCESS; @@ -7227,7 +7227,7 @@ uint8 ObjectMgr::CheckPlayerName(const std::string& name, bool create) bool ObjectMgr::IsValidCharterName(const std::string& name) { std::wstring wname; - if (!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name, wname)) return false; if (wname.size() > MAX_CHARTER_NAME) @@ -7239,13 +7239,13 @@ bool ObjectMgr::IsValidCharterName(const std::string& name) uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_CHARTER_NAMES); - return isValidString(wname,strictMask,true); + return isValidString(wname, strictMask, true); } PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) { std::wstring wname; - if (!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name, wname)) return PET_NAME_INVALID; if (wname.size() > MAX_PET_NAME) @@ -7256,7 +7256,7 @@ PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) return PET_NAME_TOO_SHORT; uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_PET_NAMES); - if (!isValidString(wname,strictMask,false)) + if (!isValidString(wname, strictMask, false)) return PET_NAME_MIXED_LANGUAGES; return PET_NAME_SUCCESS; @@ -7264,11 +7264,11 @@ PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) int ObjectMgr::GetIndexForLocale(LocaleConstant loc) { - if (loc==LOCALE_enUS) + if (loc == LOCALE_enUS) return -1; - for (size_t i=0; i < m_LocalForIndex.size(); ++i) - if (m_LocalForIndex[i]==loc) + for (size_t i = 0; i < m_LocalForIndex.size(); ++i) + if (m_LocalForIndex[i] == loc) return i; return -1; @@ -7276,7 +7276,7 @@ int ObjectMgr::GetIndexForLocale(LocaleConstant loc) LocaleConstant ObjectMgr::GetLocaleForIndex(int i) { - if (i<0 || i>=(int32)m_LocalForIndex.size()) + if (i < 0 || i >= (int32)m_LocalForIndex.size()) return LOCALE_enUS; return m_LocalForIndex[i]; @@ -7284,15 +7284,15 @@ LocaleConstant ObjectMgr::GetLocaleForIndex(int i) int ObjectMgr::GetOrNewIndexForLocale(LocaleConstant loc) { - if (loc==LOCALE_enUS) + if (loc == LOCALE_enUS) return -1; - for (size_t i=0; i < m_LocalForIndex.size(); ++i) - if (m_LocalForIndex[i]==loc) + for (size_t i = 0; i < m_LocalForIndex.size(); ++i) + if (m_LocalForIndex[i] == loc) return i; m_LocalForIndex.push_back(loc); - return m_LocalForIndex.size()-1; + return m_LocalForIndex.size() - 1; } void ObjectMgr::LoadGameObjectForQuests() @@ -7390,12 +7390,12 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min { if (end_value >= start_value) { - sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.",table,min_value,max_value); + sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.", table, min_value, max_value); return false; } // real range (max+1,min+1) exaple: (-10,-1000) -> -999...-10+1 - std::swap(start_value,end_value); + std::swap(start_value, end_value); ++start_value; ++end_value; } @@ -7403,7 +7403,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min { if (start_value >= end_value) { - sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.",table,min_value,max_value); + sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.", table, min_value, max_value); return false; } } @@ -7417,7 +7417,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min ++itr; } - QueryResult* result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s",table); + QueryResult* result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s", table); if (!result) { @@ -7427,9 +7427,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. Cannot continue.",table); + sLog.outErrorDb(">> Loaded 0 mangos strings. DB table `%s` is empty. Cannot continue.", table); else - sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.",table); + sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.", table); return false; } @@ -7444,14 +7444,14 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min int32 entry = fields[0].GetInt32(); - if (entry==0) + if (entry == 0) { - sLog.outErrorDb("Table `%s` contain reserved entry 0, ignored.",table); + sLog.outErrorDb("Table `%s` contain reserved entry 0, ignored.", table); continue; } else if (entry < start_value || entry >= end_value) { - sLog.outErrorDb("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,min_value,max_value); + sLog.outErrorDb("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.", table, entry, min_value, max_value); continue; } @@ -7459,7 +7459,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min if (data.Content.size() > 0) { - sLog.outErrorDb("Table `%s` contain data for already loaded entry %i (from another table?), ignored.",table,entry); + sLog.outErrorDb("Table `%s` contain data for already loaded entry %i (from another table?), ignored.", table, entry); continue; } @@ -7471,17 +7471,17 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min for (int i = 1; i < MAX_LOCALE; ++i) { - std::string str = fields[i+1].GetCppString(); + std::string str = fields[i + 1].GetCppString(); if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); if (idx >= 0) { // 0 -> default, idx in to idx+1 - if ((int32)data.Content.size() <= idx+1) - data.Content.resize(idx+2); + if ((int32)data.Content.size() <= idx + 1) + data.Content.resize(idx + 2); - data.Content[idx+1] = str; + data.Content[idx + 1] = str; } } } @@ -7492,9 +7492,9 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min sLog.outString(); 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 string templates from %s", count,table); + sLog.outString(">> Loaded %u string templates from %s", count, table); return true; } @@ -7505,20 +7505,20 @@ const char* ObjectMgr::GetMangosString(int32 entry, int locale_idx) const // Content[0] always exist if exist MangosStringLocale 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(); + if ((int32)msl->Content.size() > locale_idx + 1 && !msl->Content[locale_idx + 1].empty()) + return msl->Content[locale_idx + 1].c_str(); else return msl->Content[0].c_str(); } if (entry > MIN_DB_SCRIPT_STRING_ID) - sLog.outErrorDb("Entry %i not found in `db_script_string` table.",entry); + sLog.outErrorDb("Entry %i not found in `db_script_string` table.", entry); else if (entry > 0) - sLog.outErrorDb("Entry %i not found in `mangos_string` table.",entry); + sLog.outErrorDb("Entry %i not found in `mangos_string` table.", entry); else if (entry > MAX_CREATURE_AI_TEXT_STRING_ID) - sLog.outErrorDb("Entry %i not found in `creature_ai_texts` table.",entry); + sLog.outErrorDb("Entry %i not found in `creature_ai_texts` table.", entry); else - sLog.outErrorDb("Mangos string entry %i not found in DB.",entry); + sLog.outErrorDb("Mangos string entry %i not found in DB.", entry); return ""; } @@ -7553,7 +7553,7 @@ void ObjectMgr::LoadFishingBaseSkillLevel() AreaTableEntry const* fArea = GetAreaEntryByAreaID(entry); if (!fArea) { - sLog.outErrorDb("AreaId %u defined in `skill_fishing_base_level` does not exist",entry); + sLog.outErrorDb("AreaId %u defined in `skill_fishing_base_level` does not exist", entry); continue; } @@ -7573,7 +7573,7 @@ void ObjectMgr::LoadFishingBaseSkillLevel() uint16 ObjectMgr::GetConditionId(ConditionType condition, uint32 value1, uint32 value2) { PlayerCondition lc = PlayerCondition(0, condition, value1, value2); - for (uint16 i=0; i < mConditions.size(); ++i) + for (uint16 i = 0; i < mConditions.size(); ++i) { if (lc == mConditions[i]) return i; @@ -7604,13 +7604,13 @@ bool ObjectMgr::IsPlayerMeetToNEWCondition(Player const* pPlayer, uint16 conditi bool ObjectMgr::CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names) { - for (int i =0; i < MAX_DECLINED_NAME_CASES; ++i) + for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i) { std::wstring wname; - if (!Utf8toWStr(names.name[i],wname)) + if (!Utf8toWStr(names.name[i], wname)) return false; - if (mainpart!=GetMainPartOfName(wname,i+1)) + if (mainpart != GetMainPartOfName(wname, i + 1)) return false; } return true; @@ -7640,11 +7640,11 @@ bool PlayerCondition::Meets(Player const* player) const case CONDITION_ITEM: return player->HasItemCount(m_value1, m_value2); case CONDITION_ITEM_EQUIPPED: - return player->HasItemOrGemWithIdEquipped(m_value1,1); + return player->HasItemOrGemWithIdEquipped(m_value1, 1); case CONDITION_AREAID: { uint32 zone, area; - player->GetZoneAndAreaId(zone,area); + player->GetZoneAndAreaId(zone, area); return (zone == m_value1 || area == m_value1) == (m_value2 == 0); } case CONDITION_REPUTATION_RANK_MIN: @@ -7666,7 +7666,7 @@ bool PlayerCondition::Meets(Player const* player) const { 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) + 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 false; } @@ -7882,7 +7882,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu } if (value2 >= MAX_EFFECT_INDEX) { - sLog.outErrorDb("Aura condition (entry %u, type %u) requires to have non existing effect index (%u) (must be 0..%u), skipped", entry, condition, value2, MAX_EFFECT_INDEX-1); + sLog.outErrorDb("Aura condition (entry %u, type %u) requires to have non existing effect index (%u) (must be 0..%u), skipped", entry, condition, value2, MAX_EFFECT_INDEX - 1); return false; } break; @@ -7944,7 +7944,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu if (value2 >= MAX_REPUTATION_RANK) { - sLog.outErrorDb("Reputation condition (entry %u, type %u) has invalid rank requirement (value2 = %u) - must be between %u and %u, skipped", entry, condition, value2, MIN_REPUTATION_RANK, MAX_REPUTATION_RANK-1); + sLog.outErrorDb("Reputation condition (entry %u, type %u) has invalid rank requirement (value2 = %u) - must be between %u and %u, skipped", entry, condition, value2, MIN_REPUTATION_RANK, MAX_REPUTATION_RANK - 1); return false; } break; @@ -8007,7 +8007,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu } if (value2 > MAX_EFFECT_INDEX) { - sLog.outErrorDb("Aura condition (entry %u, type %u) requires to have non existing effect index (%u) (must be 0..%u), skipped", entry, condition, value2, MAX_EFFECT_INDEX-1); + sLog.outErrorDb("Aura condition (entry %u, type %u) requires to have non existing effect index (%u) (must be 0..%u), skipped", entry, condition, value2, MAX_EFFECT_INDEX - 1); return false; } break; @@ -8159,7 +8159,7 @@ SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial) { case SKILL_CATEGORY_LANGUAGES: return SKILL_RANGE_LANGUAGE; case SKILL_CATEGORY_WEAPON: - if (pSkill->id!=SKILL_FIST_WEAPONS) + if (pSkill->id != SKILL_FIST_WEAPONS) return SKILL_RANGE_LEVEL; else return SKILL_RANGE_MONO; @@ -8222,15 +8222,15 @@ void ObjectMgr::LoadGameTele() gt.mapId = fields[5].GetUInt32(); gt.name = fields[6].GetCppString(); - if (!MapManager::IsValidMapCoord(gt.mapId,gt.position_x,gt.position_y,gt.position_z,gt.orientation)) + if (!MapManager::IsValidMapCoord(gt.mapId, gt.position_x, gt.position_y, gt.position_z, gt.orientation)) { - sLog.outErrorDb("Wrong position for id %u (name: %s) in `game_tele` table, ignoring.",id,gt.name.c_str()); + sLog.outErrorDb("Wrong position for id %u (name: %s) in `game_tele` table, ignoring.", id, gt.name.c_str()); continue; } - if (!Utf8toWStr(gt.name,gt.wnameLow)) + if (!Utf8toWStr(gt.name, gt.wnameLow)) { - sLog.outErrorDb("Wrong UTF8 name for id %u in `game_tele` table, ignoring.",id); + sLog.outErrorDb("Wrong UTF8 name for id %u in `game_tele` table, ignoring.", id); continue; } @@ -8251,7 +8251,7 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const { // explicit name case std::wstring wname; - if (!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name, wname)) return NULL; // converting string that we try to find to lower case @@ -8299,7 +8299,7 @@ bool ObjectMgr::DeleteGameTele(const std::string& name) { // explicit name case std::wstring wname; - if (!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name, wname)) return false; // converting string that we try to find to lower case @@ -8309,7 +8309,7 @@ bool ObjectMgr::DeleteGameTele(const std::string& name) { if (itr->second.wnameLow == wname) { - WorldDatabase.PExecuteLog("DELETE FROM game_tele WHERE name = '%s'",itr->second.name.c_str()); + WorldDatabase.PExecuteLog("DELETE FROM game_tele WHERE name = '%s'", itr->second.name.c_str()); m_GameTeleMap.erase(itr); return true; } @@ -8351,29 +8351,29 @@ void ObjectMgr::LoadMailLevelRewards() if (level > MAX_LEVEL) { - sLog.outErrorDb("Table `mail_level_reward` have data for level %u that more supported by client (%u), ignoring.",level,MAX_LEVEL); + sLog.outErrorDb("Table `mail_level_reward` have data for level %u that more supported by client (%u), ignoring.", level, MAX_LEVEL); continue; } if (!(raceMask & RACEMASK_ALL_PLAYABLE)) { - sLog.outErrorDb("Table `mail_level_reward` have raceMask (%u) for level %u that not include any player races, ignoring.",raceMask,level); + sLog.outErrorDb("Table `mail_level_reward` have raceMask (%u) for level %u that not include any player races, ignoring.", raceMask, level); continue; } if (!sMailTemplateStore.LookupEntry(mailTemplateId)) { - sLog.outErrorDb("Table `mail_level_reward` have invalid mailTemplateId (%u) for level %u that invalid not include any player races, ignoring.",mailTemplateId,level); + sLog.outErrorDb("Table `mail_level_reward` have invalid mailTemplateId (%u) for level %u that invalid not include any player races, ignoring.", mailTemplateId, level); continue; } if (!GetCreatureTemplate(senderEntry)) { - sLog.outErrorDb("Table `mail_level_reward` have nonexistent sender creature entry (%u) for level %u that invalid not include any player races, ignoring.",senderEntry,level); + sLog.outErrorDb("Table `mail_level_reward` have nonexistent sender creature entry (%u) for level %u that invalid not include any player races, ignoring.", senderEntry, level); continue; } - m_mailLevelRewardMap[level].push_back(MailLevelReward(raceMask,mailTemplateId,senderEntry)); + m_mailLevelRewardMap[level].push_back(MailLevelReward(raceMask, mailTemplateId, senderEntry)); ++count; } @@ -8675,7 +8675,7 @@ void ObjectMgr::LoadNpcGossips() BarGoLink bar(result->GetRowCount()); uint32 count = 0; - uint32 guid,textid; + uint32 guid, textid; do { bar.step(); @@ -8687,7 +8687,7 @@ void ObjectMgr::LoadNpcGossips() if (!GetCreatureData(guid)) { - sLog.outErrorDb("Table `npc_gossip` have nonexistent creature (GUID: %u) entry, ignore. ",guid); + sLog.outErrorDb("Table `npc_gossip` have nonexistent creature (GUID: %u) entry, ignore. ", guid); continue; } if (!GetGossipText(textid)) @@ -9042,15 +9042,15 @@ void ObjectMgr::LoadGossipMenus() sLog.outErrorDb("Table `gossip_scripts` contains unused script, id %u.", *itr); } -void ObjectMgr::AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost) +void ObjectMgr::AddVendorItem(uint32 entry, uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost) { VendorItemData& vList = m_mCacheVendorItemMap[entry]; - vList.AddItem(item,maxcount,incrtime,extendedcost); + vList.AddItem(item, maxcount, incrtime, extendedcost); - WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",entry, item, maxcount,incrtime,extendedcost); + WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')", entry, item, maxcount, incrtime, extendedcost); } -bool ObjectMgr::RemoveVendorItem(uint32 entry,uint32 item) +bool ObjectMgr::RemoveVendorItem(uint32 entry, uint32 item) { CacheVendorItemMap::iterator iter = m_mCacheVendorItemMap.find(entry); if (iter == m_mCacheVendorItemMap.end()) @@ -9059,7 +9059,7 @@ bool ObjectMgr::RemoveVendorItem(uint32 entry,uint32 item) if (!iter->second.RemoveItem(item)) return false; - WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'",entry, item); + WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'", entry, item); return true; } @@ -9082,7 +9082,7 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 if (!(cInfo->npcflag & UNIT_NPC_FLAG_VENDOR)) { - if (!skip_vendors || skip_vendors->count(vendor_entry)==0) + if (!skip_vendors || skip_vendors->count(vendor_entry) == 0) { if (pl) ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); @@ -9109,7 +9109,7 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 if (ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost)) { if (pl) - ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,ExtendedCost); + ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost); else sLog.outErrorDb("Table `%s` contain item (Entry: %u) with wrong ExtendedCost (%u) for %s %u, ignoring", tableName, item_id, ExtendedCost, idStr, vendor_entry); @@ -9125,7 +9125,7 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 tableName, maxcount, item_id, idStr, vendor_entry); return false; } - else if (maxcount==0 && incrtime > 0) + else if (maxcount == 0 && incrtime > 0) { if (pl) ChatHandler(pl).PSendSysMessage("MaxCount==0 but IncrTime<>=0"); @@ -9286,17 +9286,17 @@ void ObjectMgr::GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::strin } // Functions for scripting access -bool LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value, int32 end_value) +bool LoadMangosStrings(DatabaseType& db, char const* table, int32 start_value, int32 end_value) { // MAX_DB_SCRIPT_STRING_ID is max allowed negative value for scripts (scrpts can use only more deep negative values // start/end reversed for negative values if (start_value > MAX_DB_SCRIPT_STRING_ID || end_value >= start_value) { - sLog.outErrorDb("Table '%s' attempt loaded with reserved by mangos range (%d - %d), strings not loaded.",table,start_value,end_value+1); + sLog.outErrorDb("Table '%s' attempt loaded with reserved by mangos range (%d - %d), strings not loaded.", table, start_value, end_value + 1); return false; } - return sObjectMgr.LoadMangosStrings(db,table,start_value,end_value); + return sObjectMgr.LoadMangosStrings(db, table, start_value, end_value); } CreatureInfo const* GetCreatureTemplateStore(uint32 entry) diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index 697603577..84a92af6f 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -72,7 +72,7 @@ struct SpellClickInfo }; typedef std::multimap SpellClickInfoMap; -typedef std::pair SpellClickInfoMapBounds; +typedef std::pair SpellClickInfoMapBounds; struct AreaTrigger { @@ -91,15 +91,15 @@ struct AreaTrigger float target_Orientation; }; -typedef std::map CellCorpseSet; +typedef std::map < uint32/*player guid*/, uint32/*instance*/ > CellCorpseSet; struct CellObjectGuids { CellGuidSet creatures; CellGuidSet gameobjects; CellCorpseSet corpses; }; -typedef UNORDERED_MAP CellObjectGuidsMap; -typedef UNORDERED_MAP MapObjectGuids; +typedef UNORDERED_MAP < uint32/*cell_id*/, CellObjectGuids > CellObjectGuidsMap; +typedef UNORDERED_MAP < uint32/*(mapid,spawnMode) pair*/, CellObjectGuidsMap > MapObjectGuids; // mangos string ranges #define MIN_MANGOS_STRING_ID 1 // 'mangos_string' @@ -114,7 +114,7 @@ struct MangosStringLocale std::vector Content; // 0 -> default, i -> i-1 locale index }; -typedef UNORDERED_MAP CreatureDataMap; +typedef UNORDERED_MAP CreatureDataMap; typedef CreatureDataMap::value_type CreatureDataPair; class FindCreatureData @@ -137,7 +137,7 @@ class FindCreatureData float i_spawnedDist; }; -typedef UNORDERED_MAP GameObjectDataMap; +typedef UNORDERED_MAP GameObjectDataMap; typedef GameObjectDataMap::value_type GameObjectDataPair; class FindGOData @@ -160,16 +160,16 @@ class FindGOData float i_spawnedDist; }; -typedef UNORDERED_MAP CreatureLocaleMap; -typedef UNORDERED_MAP GameObjectLocaleMap; -typedef UNORDERED_MAP ItemLocaleMap; -typedef UNORDERED_MAP QuestLocaleMap; -typedef UNORDERED_MAP NpcTextLocaleMap; -typedef UNORDERED_MAP PageTextLocaleMap; -typedef UNORDERED_MAP MangosStringLocaleMap; -typedef UNORDERED_MAP GossipMenuItemsLocaleMap; -typedef UNORDERED_MAP PointOfInterestLocaleMap; -typedef UNORDERED_MAP ItemConvertMap; +typedef UNORDERED_MAP CreatureLocaleMap; +typedef UNORDERED_MAP GameObjectLocaleMap; +typedef UNORDERED_MAP ItemLocaleMap; +typedef UNORDERED_MAP QuestLocaleMap; +typedef UNORDERED_MAP NpcTextLocaleMap; +typedef UNORDERED_MAP PageTextLocaleMap; +typedef UNORDERED_MAP MangosStringLocaleMap; +typedef UNORDERED_MAP GossipMenuItemsLocaleMap; +typedef UNORDERED_MAP PointOfInterestLocaleMap; +typedef UNORDERED_MAP ItemConvertMap; typedef std::multimap ExclusiveQuestGroupsMap; typedef std::multimap ItemRequiredTargetMap; @@ -180,7 +180,7 @@ typedef std::pair MailLevelRewardList; -typedef UNORDERED_MAP MailLevelRewardMap; +typedef UNORDERED_MAP MailLevelRewardMap; // We assume the rate is in general the same for all three types below, but chose to keep three for scalability and customization struct RepRewardRate @@ -270,9 +270,9 @@ struct GossipMenus uint16 conditionId; }; -typedef std::multimap GossipMenusMap; +typedef std::multimap GossipMenusMap; typedef std::pair GossipMenusMapBounds; -typedef std::multimap GossipMenuItemsMap; +typedef std::multimap GossipMenuItemsMap; typedef std::pair GossipMenuItemsMapBounds; struct QuestPOIPoint @@ -333,7 +333,7 @@ struct GraveYardData uint32 safeLocId; Team team; }; -typedef std::multimap GraveYardMap; +typedef std::multimap < uint32 /*zoneId*/, GraveYardData > GraveYardMap; typedef std::pair GraveYardMapBounds; enum ConditionType @@ -514,17 +514,17 @@ class ObjectMgr if (class_ >= MAX_CLASSES) return NULL; return &playerClassInfo[class_]; } - void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const; + void GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const; PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const { if (race >= MAX_RACES) return NULL; if (class_ >= MAX_CLASSES) return NULL; PlayerInfo const* info = &playerInfo[race][class_]; - if (info->displayId_m==0 || info->displayId_f==0) return NULL; + if (info->displayId_m == 0 || info->displayId_f == 0) return NULL; return info; } - void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const; + void GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const; ObjectGuid GetPlayerGuidByName(std::string name) const; bool GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const; @@ -651,7 +651,7 @@ class ObjectMgr void LoadCreatureInvolvedRelations(); bool LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value); - bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase,"mangos_string",MIN_MANGOS_STRING_ID,MAX_MANGOS_STRING_ID); } + bool LoadMangosStrings() { return LoadMangosStrings(WorldDatabase, "mangos_string", MIN_MANGOS_STRING_ID, MAX_MANGOS_STRING_ID); } void LoadCreatureLocales(); void LoadCreatureTemplates(); void LoadCreatures(); @@ -720,7 +720,7 @@ class ObjectMgr std::string GeneratePetName(uint32 entry); uint32 GetBaseXP(uint32 level) const; uint32 GetXPForLevel(uint32 level) const; - uint32 GetXPForPetLevel(uint32 level) const { return GetXPForLevel(level)/20; } + uint32 GetXPForPetLevel(uint32 level) const { return GetXPForLevel(level) / 20; } int32 GetFishingBaseSkillLevel(uint32 entry) const { @@ -754,7 +754,7 @@ class ObjectMgr uint32 GenerateMailID() { return m_MailIds.Generate(); } uint32 GeneratePetNumber() { return m_PetNumbers.Generate(); } - MailLevelReward const* GetMailLevelReward(uint32 level,uint32 raceMask) + MailLevelReward const* GetMailLevelReward(uint32 level, uint32 raceMask) { MailLevelRewardMap::const_iterator map_itr = m_mailLevelRewardMap.find(level); if (map_itr == m_mailLevelRewardMap.end()) @@ -779,7 +779,7 @@ class ObjectMgr CreatureDataPair const* GetCreatureDataPair(uint32 guid) const { CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid); - if (itr==mCreatureDataMap.end()) return NULL; + if (itr == mCreatureDataMap.end()) return NULL; return &*itr; } @@ -803,7 +803,7 @@ class ObjectMgr CreatureLocale const* GetCreatureLocale(uint32 entry) const { CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry); - if (itr==mCreatureLocaleMap.end()) return NULL; + if (itr == mCreatureLocaleMap.end()) return NULL; return &itr->second; } @@ -812,14 +812,14 @@ class ObjectMgr GameObjectLocale const* GetGameObjectLocale(uint32 entry) const { GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry); - if (itr==mGameObjectLocaleMap.end()) return NULL; + if (itr == mGameObjectLocaleMap.end()) return NULL; return &itr->second; } ItemLocale const* GetItemLocale(uint32 entry) const { ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry); - if (itr==mItemLocaleMap.end()) return NULL; + if (itr == mItemLocaleMap.end()) return NULL; return &itr->second; } @@ -828,7 +828,7 @@ class ObjectMgr QuestLocale const* GetQuestLocale(uint32 entry) const { QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry); - if (itr==mQuestLocaleMap.end()) return NULL; + if (itr == mQuestLocaleMap.end()) return NULL; return &itr->second; } @@ -837,7 +837,7 @@ class ObjectMgr NpcTextLocale const* GetNpcTextLocale(uint32 entry) const { NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry); - if (itr==mNpcTextLocaleMap.end()) return NULL; + if (itr == mNpcTextLocaleMap.end()) return NULL; return &itr->second; } @@ -848,28 +848,28 @@ class ObjectMgr PageTextLocale const* GetPageTextLocale(uint32 entry) const { PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry); - if (itr==mPageTextLocaleMap.end()) return NULL; + if (itr == mPageTextLocaleMap.end()) return NULL; return &itr->second; } GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const { GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry); - if (itr==mGossipMenuItemsLocaleMap.end()) return NULL; + if (itr == mGossipMenuItemsLocaleMap.end()) return NULL; return &itr->second; } PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const { PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id); - if (itr==mPointOfInterestLocaleMap.end()) return NULL; + if (itr == mPointOfInterestLocaleMap.end()) return NULL; return &itr->second; } GameObjectDataPair const* GetGODataPair(uint32 guid) const { GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid); - if (itr==mGameObjectDataMap.end()) return NULL; + if (itr == mGameObjectDataMap.end()) return NULL; return &*itr; } @@ -893,19 +893,19 @@ class ObjectMgr MangosStringLocale const* GetMangosStringLocale(int32 entry) const { MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry); - if (itr==mMangosStringLocaleMap.end()) return NULL; + if (itr == mMangosStringLocaleMap.end()) return NULL; return &itr->second; } const char* GetMangosString(int32 entry, int locale_idx) const; - const char* GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); } + const char* GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry, DBCLocaleIndex); } int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } // global grid objects state (static DB spawns, global spawn mods from gameevent system) CellObjectGuids const& GetCellObjectGuids(uint16 mapid, uint8 spawnMode, uint32 cell_id) { - return mMapObjectGuids[MAKE_PAIR32(mapid,spawnMode)][cell_id]; + return mMapObjectGuids[MAKE_PAIR32(mapid, spawnMode)][cell_id]; } // modifiers for global grid objects state (static DB spawns, global spawn mods from gameevent system) @@ -947,7 +947,7 @@ class ObjectMgr GameTele const* GetGameTele(uint32 id) const { GameTeleMap::const_iterator itr = m_GameTeleMap.find(id); - if (itr==m_GameTeleMap.end()) return NULL; + if (itr == m_GameTeleMap.end()) return NULL; return &itr->second; } @@ -1001,8 +1001,8 @@ class ObjectMgr return &iter->second; } - void AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost); - bool RemoveVendorItem(uint32 entry,uint32 item); + void AddVendorItem(uint32 entry, uint32 item, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost); + bool RemoveVendorItem(uint32 entry, uint32 item); bool IsVendorItemValid(bool isTemplate, char const* tableName, uint32 vendor_entry, uint32 item, uint32 maxcount, uint32 ptime, uint32 ExtendedCost, Player* pl = NULL, std::set* skip_vendors = NULL) const; int GetOrNewIndexForLocale(LocaleConstant loc); @@ -1170,7 +1170,7 @@ class ObjectMgr MailLevelRewardMap m_mailLevelRewardMap; - typedef std::map PetLevelInfoMap; + typedef std::map PetLevelInfoMap; // PetLevelInfoMap[creature_id][level] PetLevelInfoMap petInfo; // [creature_id][level] @@ -1182,13 +1182,13 @@ class ObjectMgr typedef std::vector PlayerXPperLevel; // [level] PlayerXPperLevel mPlayerXPperLevel; - typedef std::map BaseXPMap; // [area level][base xp] + typedef std::map BaseXPMap; // [area level][base xp] BaseXPMap mBaseXPTable; - typedef std::map FishingBaseSkillMap; // [areaId][base skill level] + typedef std::map FishingBaseSkillMap; // [areaId][base skill level] FishingBaseSkillMap mFishingBaseForArea; - typedef std::map > HalfNameMap; + typedef std::map > HalfNameMap; HalfNameMap PetHalfName0; HalfNameMap PetHalfName1; @@ -1222,7 +1222,7 @@ class ObjectMgr #define sObjectMgr MaNGOS::Singleton::Instance() // scripting access functions -MANGOS_DLL_SPEC bool LoadMangosStrings(DatabaseType& db, char const* table,int32 start_value = MAX_CREATURE_AI_TEXT_STRING_ID, int32 end_value = std::numeric_limits::min()); +MANGOS_DLL_SPEC bool LoadMangosStrings(DatabaseType& db, char const* table, int32 start_value = MAX_CREATURE_AI_TEXT_STRING_ID, int32 end_value = std::numeric_limits::min()); MANGOS_DLL_SPEC CreatureInfo const* GetCreatureTemplateStore(uint32 entry); MANGOS_DLL_SPEC Quest const* GetQuestTemplateStore(uint32 entry); diff --git a/src/game/ObjectPosSelector.cpp b/src/game/ObjectPosSelector.cpp index 7c85fa05e..f0b58a83c 100644 --- a/src/game/ObjectPosSelector.cpp +++ b/src/game/ObjectPosSelector.cpp @@ -26,7 +26,7 @@ ObjectPosSelector::ObjectPosSelector(float x, float y, float dist, float searche if (m_searcherSize == 0.0f) m_searcherSize = DEFAULT_WORLD_OBJECT_SIZE; - m_searcherHalfSize = asin(m_searcherSize/m_searcherDist); + m_searcherHalfSize = asin(m_searcherSize / m_searcherDist); // Really init in InitilizeAngle m_nextUsedAreaItr[USED_POS_PLUS] = m_UsedAreaLists[USED_POS_PLUS].begin(); diff --git a/src/game/ObjectPosSelector.h b/src/game/ObjectPosSelector.h index 1da012370..6c8bbeb87 100644 --- a/src/game/ObjectPosSelector.h +++ b/src/game/ObjectPosSelector.h @@ -37,7 +37,7 @@ inline float SignOf(UsedAreaSide side) struct ObjectPosSelector { - typedef std::multimap UsedAreaList; // angle pos -> angle offset + typedef std::multimap UsedAreaList; // angle pos -> angle offset typedef UsedAreaList::value_type UsedArea; ObjectPosSelector(float x, float y, float dist, float searcher_size); diff --git a/src/game/Opcodes.cpp b/src/game/Opcodes.cpp index 2c45d041a..c6318ccb8 100644 --- a/src/game/Opcodes.cpp +++ b/src/game/Opcodes.cpp @@ -666,7 +666,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x27D*/ { "CMSG_ENABLE_DAMAGE_LOG", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x27E*/ { "CMSG_GROUP_CHANGE_SUB_GROUP", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupChangeSubGroupOpcode }, /*0x27F*/ { "CMSG_REQUEST_PARTY_MEMBER_STATS", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleRequestPartyMemberStatsOpcode}, - /*0x280*/ { "CMSG_GROUP_SWAP_SUB_GROUP", STATUS_UNHANDLED,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x280*/ { "CMSG_GROUP_SWAP_SUB_GROUP", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x281*/ { "CMSG_RESET_FACTION_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x282*/ { "CMSG_AUTOSTORE_BANK_ITEM", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAutoStoreBankItemOpcode }, /*0x283*/ { "CMSG_AUTOBANK_ITEM", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleAutoBankItemOpcode }, @@ -684,7 +684,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x28F*/ { "CMSG_GROUP_ASSISTANT_LEADER", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleGroupAssistantLeaderOpcode}, /*0x290*/ { "CMSG_BUYBACK_ITEM", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBuybackItem }, /*0x291*/ { "SMSG_SERVER_MESSAGE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x292*/ { "CMSG_SET_SAVED_INSTANCE_EXTEND", STATUS_UNHANDLED,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x292*/ { "CMSG_SET_SAVED_INSTANCE_EXTEND", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x293*/ { "SMSG_LFG_OFFER_CONTINUE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x294*/ { "CMSG_TEST_DROP_RATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x295*/ { "SMSG_TEST_DROP_RATE_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, @@ -856,9 +856,9 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x33B*/ { "SMSG_INSTANCE_DIFFICULTY", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x33C*/ { "MSG_GM_RESETINSTANCELIMIT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x33D*/ { "SMSG_MOTD", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x33E*/ { "SMSG_MOVE_SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY",STATUS_NEVER,PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x33F*/ { "SMSG_MOVE_UNSET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY",STATUS_NEVER,PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x340*/ { "CMSG_MOVE_SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY_ACK",STATUS_NEVER,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x33E*/ { "SMSG_MOVE_SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x33F*/ { "SMSG_MOVE_UNSET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x340*/ { "CMSG_MOVE_SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY_ACK", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x341*/ { "MSG_MOVE_START_SWIM_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x342*/ { "MSG_MOVE_STOP_SWIM_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x343*/ { "SMSG_MOVE_SET_CAN_FLY", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, @@ -868,7 +868,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x347*/ { "CMSG_SOCKET_GEMS", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSocketOpcode }, /*0x348*/ { "CMSG_ARENA_TEAM_CREATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x349*/ { "SMSG_ARENA_TEAM_COMMAND_RESULT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x34A*/ { "MSG_MOVE_UPDATE_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY",STATUS_NEVER,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x34A*/ { "MSG_MOVE_UPDATE_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x34B*/ { "CMSG_ARENA_TEAM_QUERY", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleArenaTeamQueryOpcode }, /*0x34C*/ { "SMSG_ARENA_TEAM_QUERY_RESPONSE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x34D*/ { "CMSG_ARENA_TEAM_ROSTER", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleArenaTeamRosterOpcode }, @@ -904,10 +904,10 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x36B*/ { "CMSG_LFG_SET_NEEDS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x36C*/ { "CMSG_LFG_BOOT_PLAYER_VOTE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x36D*/ { "SMSG_LFG_BOOT_PLAYER", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x36E*/ { "CMSG_LFG_GET_PLAYER_INFO", STATUS_UNHANDLED,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x36E*/ { "CMSG_LFG_GET_PLAYER_INFO", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x36F*/ { "SMSG_LFG_PLAYER_INFO", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x370*/ { "CMSG_LFG_TELEPORT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x371*/ { "CMSG_LFG_GET_PARTY_INFO", STATUS_UNHANDLED,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x371*/ { "CMSG_LFG_GET_PARTY_INFO", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x372*/ { "SMSG_LFG_PARTY_INFO", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x373*/ { "SMSG_TITLE_EARNED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x374*/ { "CMSG_SET_TITLE", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetTitleOpcode }, @@ -950,7 +950,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x399*/ { "CMSG_ACTIVE_PVP_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x39A*/ { "CMSG_CHEAT_DUMP_ITEMS_DEBUG_ONLY", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x39B*/ { "SMSG_CHEAT_DUMP_ITEMS_DEBUG_ONLY_RESPONSE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x39C*/ { "SMSG_CHEAT_DUMP_ITEMS_DEBUG_ONLY_RESPONSE_WRITE_FILE",STATUS_NEVER,PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x39C*/ { "SMSG_CHEAT_DUMP_ITEMS_DEBUG_ONLY_RESPONSE_WRITE_FILE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x39D*/ { "SMSG_UPDATE_COMBO_POINTS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x39E*/ { "SMSG_VOICE_SESSION_ROSTER_UPDATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x39F*/ { "SMSG_VOICE_SESSION_LEAVE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, @@ -959,7 +959,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x3A2*/ { "SMSG_VOICE_SET_TALKER_MUTED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x3A3*/ { "SMSG_INIT_EXTRA_AURA_INFO_OBSOLETE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x3A4*/ { "SMSG_SET_EXTRA_AURA_INFO_OBSOLETE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x3A5*/ { "SMSG_SET_EXTRA_AURA_INFO_NEED_UPDATE_OBSOLETE",STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x3A5*/ { "SMSG_SET_EXTRA_AURA_INFO_NEED_UPDATE_OBSOLETE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x3A6*/ { "SMSG_CLEAR_EXTRA_AURA_INFO_OBSOLETE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x3A7*/ { "MSG_MOVE_START_DESCEND", STATUS_LOGGEDIN, PROCESS_THREADSAFE, &WorldSession::HandleMovementOpcodes }, /*0x3A8*/ { "CMSG_IGNORE_REQUIREMENTS_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, @@ -1066,7 +1066,7 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x40D*/ { "CMSG_GRANT_LEVEL", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x40E*/ { "CMSG_REFER_A_FRIEND", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x40F*/ { "MSG_GM_CHANGE_ARENA_RATING", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x410*/ { "CMSG_DECLINE_CHANNEL_INVITE", STATUS_UNHANDLED,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x410*/ { "CMSG_DECLINE_CHANNEL_INVITE", STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x411*/ { "SMSG_GROUPACTION_THROTTLED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x412*/ { "SMSG_OVERRIDE_LIGHT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x413*/ { "SMSG_TOTEM_CREATED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, @@ -1273,18 +1273,18 @@ OpcodeHandler opcodeTable[NUM_MSG_TYPES] = /*0x4DC*/ { "SMSG_PVP_QUEUE_STATS", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4DD*/ { "CMSG_SET_PAID_SERVICE_CHEAT", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4DE*/ { "SMSG_BATTLEFIELD_MANAGER_ENTRY_INVITE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x4DF*/ { "CMSG_BATTLEFIELD_MANAGER_ENTRY_INVITE_RESPONSE",STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x4DF*/ { "CMSG_BATTLEFIELD_MANAGER_ENTRY_INVITE_RESPONSE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4E0*/ { "SMSG_BATTLEFIELD_MANAGER_ENTERING", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4E1*/ { "SMSG_BATTLEFIELD_MANAGER_QUEUE_INVITE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, - /*0x4E2*/ { "CMSG_BATTLEFIELD_MANAGER_QUEUE_INVITE_RESPONSE",STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x4E2*/ { "CMSG_BATTLEFIELD_MANAGER_QUEUE_INVITE_RESPONSE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4E3*/ { "CMSG_BATTLEFIELD_MANAGER_QUEUE_REQUEST", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x4E4*/ { "SMSG_BATTLEFIELD_MANAGER_QUEUE_REQUEST_RESPONSE",STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, + /*0x4E4*/ { "SMSG_BATTLEFIELD_MANAGER_QUEUE_REQUEST_RESPONSE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4E5*/ { "SMSG_BATTLEFIELD_MANAGER_EJECT_PENDING", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4E6*/ { "SMSG_BATTLEFIELD_MANAGER_EJECTED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4E7*/ { "CMSG_BATTLEFIELD_MANAGER_EXIT_REQUEST", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4E8*/ { "SMSG_BATTLEFIELD_MANAGER_STATE_CHANGED", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, /*0x4E9*/ { "CMSG_BATTLEFIELD_MANAGER_ADVANCE_STATE", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, - /*0x4EA*/ { "CMSG_BATTLEFIELD_MANAGER_SET_NEXT_TRANSITION_TIME",STATUS_NEVER,PROCESS_INPLACE, &WorldSession::Handle_NULL }, + /*0x4EA*/ { "CMSG_BATTLEFIELD_MANAGER_SET_NEXT_TRANSITION_TIME", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4EB*/ { "MSG_SET_RAID_DIFFICULTY", STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleSetRaidDifficultyOpcode }, /*0x4EC*/ { "CMSG_XPGAIN", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_NULL }, /*0x4ED*/ { "SMSG_XPGAIN", STATUS_NEVER, PROCESS_INPLACE, &WorldSession::Handle_ServerSide }, diff --git a/src/game/Path.h b/src/game/Path.h index 0ae170c56..2be3105fe 100644 --- a/src/game/Path.h +++ b/src/game/Path.h @@ -56,31 +56,31 @@ class Path float GetTotalLength(uint32 start, uint32 end) const { float len = 0.0f; - for (unsigned int idx=start+1; idx < end; ++idx) + for (unsigned int idx = start + 1; idx < end; ++idx) { PathNode const& node = i_nodes[idx]; - PathNode const& prev = i_nodes[idx-1]; + PathNode const& prev = i_nodes[idx - 1]; float xd = node.x - prev.x; float yd = node.y - prev.y; float zd = node.z - prev.z; - len += sqrtf(xd*xd + yd*yd + zd*zd); + len += sqrtf(xd * xd + yd * yd + zd * zd); } return len; } - float GetTotalLength() const { return GetTotalLength(0,size()); } + float GetTotalLength() const { return GetTotalLength(0, size()); } float GetPassedLength(uint32 curnode, float x, float y, float z) const { - float len = GetTotalLength(0,curnode); + float len = GetTotalLength(0, curnode); if (curnode > 0) { - PathNode const& node = i_nodes[curnode-1]; + PathNode const& node = i_nodes[curnode - 1]; float xd = x - node.x; float yd = y - node.y; float zd = z - node.z; - len += sqrtf(xd*xd + yd*yd + zd*zd); + len += sqrtf(xd * xd + yd * yd + zd * zd); } return len; diff --git a/src/game/PathFinder.cpp b/src/game/PathFinder.cpp index d3d72d456..7f9b4ad0f 100644 --- a/src/game/PathFinder.cpp +++ b/src/game/PathFinder.cpp @@ -224,7 +224,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) if (DT_SUCCESS == m_navMeshQuery->closestPointOnPoly(endPoly, endPoint, closestPoint)) { dtVcopy(endPoint, closestPoint); - setActualEndPosition(Vector3(endPoint[2],endPoint[0],endPoint[1])); + setActualEndPosition(Vector3(endPoint[2], endPoint[0], endPoint[1])); } m_type = PATHFIND_INCOMPLETE; @@ -269,7 +269,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) } } - for (pathEndIndex = m_polyLength-1; pathEndIndex > pathStartIndex; --pathEndIndex) + for (pathEndIndex = m_polyLength - 1; pathEndIndex > pathStartIndex; --pathEndIndex) if (m_pathPolyRefs[pathEndIndex] == endPoly) { endPolyFound = true; @@ -286,7 +286,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) // just "cut" it out m_polyLength = pathEndIndex - pathStartIndex + 1; - memmove(m_pathPolyRefs, m_pathPolyRefs+pathStartIndex, m_polyLength*sizeof(dtPolyRef)); + memmove(m_pathPolyRefs, m_pathPolyRefs + pathStartIndex, m_polyLength * sizeof(dtPolyRef)); } else if (startPolyFound && !endPolyFound) { @@ -304,10 +304,10 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) // take ~80% of the original length // TODO : play with the values here - uint32 prefixPolyLength = uint32(m_polyLength*0.8f + 0.5f); - memmove(m_pathPolyRefs, m_pathPolyRefs+pathStartIndex, prefixPolyLength*sizeof(dtPolyRef)); + uint32 prefixPolyLength = uint32(m_polyLength * 0.8f + 0.5f); + memmove(m_pathPolyRefs, m_pathPolyRefs + pathStartIndex, prefixPolyLength * sizeof(dtPolyRef)); - dtPolyRef suffixStartPoly = m_pathPolyRefs[prefixPolyLength-1]; + dtPolyRef suffixStartPoly = m_pathPolyRefs[prefixPolyLength - 1]; // we need any point on our suffix start poly to generate poly-path, so we need last poly in prefix data float suffixEndPoint[VERTEX_SIZE]; @@ -316,7 +316,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) // we can hit offmesh connection as last poly - closestPointOnPoly() don't like that // try to recover by using prev polyref --prefixPolyLength; - suffixStartPoly = m_pathPolyRefs[prefixPolyLength-1]; + suffixStartPoly = m_pathPolyRefs[prefixPolyLength - 1]; if (DT_SUCCESS != m_navMeshQuery->closestPointOnPoly(suffixStartPoly, endPoint, suffixEndPoint)) { // suffixStartPoly is still invalid, error state @@ -336,7 +336,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) &m_filter, // polygon search filter m_pathPolyRefs + prefixPolyLength - 1, // [out] path (int*)&suffixPolyLength, - MAX_PATH_LENGTH-prefixPolyLength); // max number of polygons in output path + MAX_PATH_LENGTH - prefixPolyLength); // max number of polygons in output path if (!suffixPolyLength || dtResult != DT_SUCCESS) { @@ -346,7 +346,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) sLog.outError("%u's Path Build failed: 0 length path", m_sourceUnit->GetGUIDLow()); } - DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ m_polyLength=%u prefixPolyLength=%u suffixPolyLength=%u \n",m_polyLength, prefixPolyLength, suffixPolyLength); + DEBUG_FILTER_LOG(LOG_FILTER_PATHFINDING, "++ m_polyLength=%u prefixPolyLength=%u suffixPolyLength=%u \n", m_polyLength, prefixPolyLength, suffixPolyLength); // new path = prefix + suffix - overlap m_polyLength = prefixPolyLength + suffixPolyLength - 1; @@ -394,7 +394,7 @@ void PathFinder::BuildPolyPath(const Vector3& startPos, const Vector3& endPos) void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint) { - float pathPoints[MAX_POINT_PATH_LENGTH*VERTEX_SIZE]; + float pathPoints[MAX_POINT_PATH_LENGTH * VERTEX_SIZE]; uint32 pointCount = 0; dtStatus dtResult = DT_FAILURE; if (m_useStraightPath) @@ -435,10 +435,10 @@ void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint) m_pathPoints.resize(pointCount); for (uint32 i = 0; i < pointCount; ++i) - m_pathPoints[i] = Vector3(pathPoints[i*VERTEX_SIZE+2], pathPoints[i*VERTEX_SIZE], pathPoints[i*VERTEX_SIZE+1]); + m_pathPoints[i] = Vector3(pathPoints[i * VERTEX_SIZE + 2], pathPoints[i * VERTEX_SIZE], pathPoints[i * VERTEX_SIZE + 1]); // first point is always our current location - we need the next one - setActualEndPosition(m_pathPoints[pointCount-1]); + setActualEndPosition(m_pathPoints[pointCount - 1]); // force the given destination, if needed if (m_forceDestination && @@ -449,7 +449,7 @@ void PathFinder::BuildPointPath(const float* startPoint, const float* endPoint) 0.3f * dist3DSqr(getStartPosition(), getEndPosition())) { setActualEndPosition(getEndPosition()); - m_pathPoints[m_pathPoints.size()-1] = getEndPosition(); + m_pathPoints[m_pathPoints.size() - 1] = getEndPosition(); } else { @@ -556,10 +556,10 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath, int32 furthestVisited = -1; // Find furthest common polygon. - for (int32 i = npath-1; i >= 0; --i) + for (int32 i = npath - 1; i >= 0; --i) { bool found = false; - for (int32 j = nvisited-1; j >= 0; --j) + for (int32 j = nvisited - 1; j >= 0; --j) { if (path[i] == visited[j]) { @@ -580,19 +580,19 @@ uint32 PathFinder::fixupCorridor(dtPolyRef* path, uint32 npath, uint32 maxPath, // Adjust beginning of the buffer to include the visited. uint32 req = nvisited - furthestVisited; - uint32 orig = uint32(furthestPath+1) < npath ? furthestPath+1 : npath; - uint32 size = npath-orig > 0 ? npath-orig : 0; - if (req+size > maxPath) - size = maxPath-req; + uint32 orig = uint32(furthestPath + 1) < npath ? furthestPath + 1 : npath; + uint32 size = npath - orig > 0 ? npath - orig : 0; + if (req + size > maxPath) + 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) - path[i] = visited[(nvisited-1)-i]; + path[i] = visited[(nvisited - 1) - i]; - return req+size; + return req + size; } bool PathFinder::getSteerTarget(const float* startPos, const float* endPos, @@ -601,7 +601,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos, { // Find steer target. static const uint32 MAX_STEER_POINTS = 3; - float steerPath[MAX_STEER_POINTS*VERTEX_SIZE]; + float steerPath[MAX_STEER_POINTS * VERTEX_SIZE]; unsigned char steerPathFlags[MAX_STEER_POINTS]; dtPolyRef steerPathPolys[MAX_STEER_POINTS]; uint32 nsteerPath = 0; @@ -616,7 +616,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos, { // Stop at Off-Mesh link or when point is further than slop away. if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_CONNECTION) || - !inRangeYZX(&steerPath[ns*VERTEX_SIZE], startPos, minTargetDist, 1000.0f)) + !inRangeYZX(&steerPath[ns * VERTEX_SIZE], startPos, minTargetDist, 1000.0f)) break; ns++; } @@ -624,7 +624,7 @@ bool PathFinder::getSteerTarget(const float* startPos, const float* endPos, if (ns >= nsteerPath) return false; - dtVcopy(steerPos, &steerPath[ns*VERTEX_SIZE]); + dtVcopy(steerPos, &steerPath[ns * VERTEX_SIZE]); steerPos[1] = startPos[1]; // keep Z value steerPosFlag = steerPathFlags[ns]; steerPosRef = steerPathPolys[ns]; @@ -647,10 +647,10 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[0], startPos, iterPos)) return DT_FAILURE; - if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys-1], endPos, targetPos)) + if (DT_SUCCESS != m_navMeshQuery->closestPointOnPolyBoundary(polys[npolys - 1], endPos, targetPos)) return DT_FAILURE; - dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos); + dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos); nsmoothPath++; // Move towards target a small advancement at a time until target reached or @@ -671,7 +671,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, // Find movement delta. float delta[VERTEX_SIZE]; dtVsub(delta, steerPos, iterPos); - float len = dtSqrt(dtVdot(delta,delta)); + 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; @@ -701,7 +701,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, dtVcopy(iterPos, targetPos); if (nsmoothPath < maxSmoothPathSize) { - dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos); + dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos); nsmoothPath++; } break; @@ -720,7 +720,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, } for (uint32 i = npos; i < npolys; ++i) - polys[i-npos] = polys[i]; + polys[i - npos] = polys[i]; npolys -= npos; @@ -730,7 +730,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, { if (nsmoothPath < maxSmoothPathSize) { - dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], startPos); + dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], startPos); nsmoothPath++; } // Move position at the other side of the off-mesh link. @@ -744,7 +744,7 @@ dtStatus PathFinder::findSmoothPath(const float* startPos, const float* endPos, // Store results. if (nsmoothPath < maxSmoothPathSize) { - dtVcopy(&smoothPath[nsmoothPath*VERTEX_SIZE], iterPos); + dtVcopy(&smoothPath[nsmoothPath * VERTEX_SIZE], iterPos); nsmoothPath++; } } @@ -760,16 +760,16 @@ bool PathFinder::inRangeYZX(const float* v1, const float* v2, float r, float h) const float dx = v2[0] - v1[0]; const float dy = v2[1] - v1[1]; // elevation const float dz = v2[2] - v1[2]; - return (dx*dx + dz*dz) < r*r && fabsf(dy) < h; + return (dx * dx + dz * dz) < r * r && fabsf(dy) < h; } bool PathFinder::inRange(const Vector3& p1, const Vector3& p2, float r, float h) const { - Vector3 d = p1-p2; - return (d.x*d.x + d.y*d.y) < r*r && fabsf(d.z) < h; + Vector3 d = p1 - p2; + return (d.x * d.x + d.y * d.y) < r * r && fabsf(d.z) < h; } float PathFinder::dist3DSqr(const Vector3& p1, const Vector3& p2) const { - return (p1-p2).squaredLength(); + return (p1 - p2).squaredLength(); } diff --git a/src/game/PathFinder.h b/src/game/PathFinder.h index d521de1d3..9c04c6f95 100644 --- a/src/game/PathFinder.h +++ b/src/game/PathFinder.h @@ -64,7 +64,7 @@ class PathFinder // option setters - use optional void setUseStrightPath(bool useStraightPath) { m_useStraightPath = useStraightPath; }; - void setPathLengthLimit(float distance) { m_pointPathLimit = std::min(uint32(distance/SMOOTH_PATH_STEP_SIZE), MAX_POINT_PATH_LENGTH); }; + void setPathLengthLimit(float distance) { m_pointPathLimit = std::min(uint32(distance / SMOOTH_PATH_STEP_SIZE), MAX_POINT_PATH_LENGTH); }; // result getters Vector3 getStartPosition() const { return m_startPosition; } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index 0733b15a4..cd08d4e99 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -96,13 +96,13 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " "FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ", - ownerid, petentry,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); + ownerid, petentry, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT); else // any current or other non-stabled pet (for hunter "call pet") // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, curhappiness, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " "FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u') ", - ownerid,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); + ownerid, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT); if (!result) return false; @@ -194,7 +194,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c switch (getPetType()) { case SUMMON_PET: - petlevel=owner->getLevel(); + petlevel = owner->getLevel(); break; case HUNTER_PET: SetByteFlag(UNIT_FIELD_BYTES_2, 2, fields[9].GetBool() ? UNIT_CAN_BE_ABANDONED : UNIT_CAN_BE_RENAMED | UNIT_CAN_BE_ABANDONED); @@ -358,7 +358,7 @@ void Pet::SavePetToDB(PetSaveMode mode) pOwner->GetTemporaryUnsummonedPetNumber() != m_charmInfo->GetPetNumber()) { // pet will lost anyway at restore temporary unsummoned - if (getPetType()==HUNTER_PET) + if (getPetType() == HUNTER_PET) return; // for warlock case @@ -396,7 +396,7 @@ void Pet::SavePetToDB(PetSaveMode mode) } // prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT - if (getPetType()==HUNTER_PET && (mode==PET_SAVE_AS_CURRENT||mode > PET_SAVE_LAST_STABLE_SLOT)) + if (getPetType() == HUNTER_PET && (mode == PET_SAVE_AS_CURRENT || mode > PET_SAVE_LAST_STABLE_SLOT)) { static SqlStatementID del ; @@ -480,10 +480,10 @@ void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction) void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState { Creature::SetDeathState(s); - if (getDeathState()==CORPSE) + if (getDeathState() == CORPSE) { //remove summoned pet (no corpse) - if (getPetType()==SUMMON_PET) + if (getPetType() == SUMMON_PET) Unsummon(PET_SAVE_NOT_IN_SLOT); // other will despawn at corpse desppawning (Pet::Update code) else @@ -500,7 +500,7 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } } - else if (getDeathState()==ALIVE) + else if (getDeathState() == ALIVE) { RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); CastPetAuras(true); @@ -518,7 +518,7 @@ void Pet::Update(uint32 update_diff, uint32 diff) { if (m_corpseDecayTimer <= update_diff) { - MANGOS_ASSERT(getPetType()!=SUMMON_PET && "Must be already removed."); + MANGOS_ASSERT(getPetType() != SUMMON_PET && "Must be already removed."); Unsummon(PET_SAVE_NOT_IN_SLOT); //hunters' pets never get removed because of death, NEVER! return; } @@ -711,7 +711,7 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) if (GetOwnerGuid() != owner->GetObjectGuid()) return; - Player* p_owner = owner->GetTypeId()==TYPEID_PLAYER ? (Player*)owner : NULL; + Player* p_owner = owner->GetTypeId() == TYPEID_PLAYER ? (Player*)owner : NULL; if (p_owner) { @@ -818,7 +818,7 @@ void Pet::GivePetLevel(uint32 level) if (!level || level == getLevel()) return; - if (getPetType()==HUNTER_PET) + if (getPetType() == HUNTER_PET) { SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, sObjectMgr.GetXPForPetLevel(level)); @@ -924,7 +924,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) SetMeleeDamageSchool(SpellSchools(cinfo->dmgschool)); - SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(petlevel*50)); + SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(petlevel * 50)); SetAttackTime(BASE_ATTACK, BASE_ATTACK_TIME); SetAttackTime(OFF_ATTACK, BASE_ATTACK_TIME); @@ -933,7 +933,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0); CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family); - if (cFamily && cFamily->minScale > 0.0f && getPetType()==HUNTER_PET) + if (cFamily && cFamily->minScale > 0.0f && getPetType() == HUNTER_PET) { float scale; if (getLevel() >= cFamily->maxScaleLevel) @@ -948,7 +948,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) } m_bonusdamage = 0; - int32 createResistance[MAX_SPELL_SCHOOL] = {0,0,0,0,0,0,0}; + int32 createResistance[MAX_SPELL_SCHOOL] = {0, 0, 0, 0, 0, 0, 0}; if (getPetType() != HUNTER_PET) { @@ -1015,7 +1015,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) } else // not exist in DB, use some default fake data { - sLog.outErrorDb("Summoned pet (Entry: %u) not have pet stats data in DB",cinfo->Entry); + sLog.outErrorDb("Summoned pet (Entry: %u) not have pet stats data in DB", cinfo->Entry); // remove elite bonuses included in DB values SetCreateHealth(uint32(((float(cinfo->maxhealth) / cinfo->maxlevel) / (1 + 2 * cinfo->rank)) * petlevel)); @@ -1072,8 +1072,8 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner) SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, 0); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000); - SetCreateMana(28 + 10*petlevel); - SetCreateHealth(28 + 30*petlevel); + SetCreateMana(28 + 10 * petlevel); + SetCreateHealth(28 + 30 * petlevel); // FIXME: this is wrong formula, possible each guardian pet have own damage formula //these formula may not be correct; however, it is designed to be close to what it should be @@ -1112,7 +1112,7 @@ bool Pet::HaveInDiet(ItemPrototype const* item) const return false; uint32 diet = cFamily->petFoodMask; - uint32 FoodMask = 1 << (item->FoodType-1); + uint32 FoodMask = 1 << (item->FoodType - 1); return diet & FoodMask; } @@ -1137,13 +1137,13 @@ void Pet::_LoadSpellCooldowns() m_CreatureSpellCooldowns.clear(); m_CreatureCategoryCooldowns.clear(); - QueryResult* result = CharacterDatabase.PQuery("SELECT spell,time FROM pet_spell_cooldown WHERE guid = '%u'",m_charmInfo->GetPetNumber()); + QueryResult* result = CharacterDatabase.PQuery("SELECT spell,time FROM pet_spell_cooldown WHERE guid = '%u'", m_charmInfo->GetPetNumber()); if (result) { time_t curTime = time(NULL); - WorldPacket data(SMSG_SPELL_COOLDOWN, (8+1+size_t(result->GetRowCount())*8)); + WorldPacket data(SMSG_SPELL_COOLDOWN, (8 + 1 + size_t(result->GetRowCount()) * 8)); data << ObjectGuid(GetObjectGuid()); data << uint8(0x0); // flags (0x1, 0x2) @@ -1156,7 +1156,7 @@ void Pet::_LoadSpellCooldowns() if (!sSpellStore.LookupEntry(spell_id)) { - sLog.outError("Pet %u have unknown spell %u in `pet_spell_cooldown`, skipping.",m_charmInfo->GetPetNumber(),spell_id); + sLog.outError("Pet %u have unknown spell %u in `pet_spell_cooldown`, skipping.", m_charmInfo->GetPetNumber(), spell_id); continue; } @@ -1165,11 +1165,11 @@ void Pet::_LoadSpellCooldowns() continue; data << uint32(spell_id); - data << uint32(uint32(db_time-curTime)*IN_MILLISECONDS); + data << uint32(uint32(db_time - curTime)*IN_MILLISECONDS); - _AddCreatureSpellCooldown(spell_id,db_time); + _AddCreatureSpellCooldown(spell_id, db_time); - DEBUG_LOG("Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time-curTime)); + DEBUG_LOG("Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time - curTime)); } while (result->NextRow()); @@ -1208,7 +1208,7 @@ void Pet::_SaveSpellCooldowns() void Pet::_LoadSpells() { - QueryResult* result = CharacterDatabase.PQuery("SELECT spell,active FROM pet_spell WHERE guid = '%u'",m_charmInfo->GetPetNumber()); + QueryResult* result = CharacterDatabase.PQuery("SELECT spell,active FROM pet_spell WHERE guid = '%u'", m_charmInfo->GetPetNumber()); if (result) { @@ -1290,8 +1290,8 @@ void Pet::_LoadAuras(uint32 timediff) for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - damage[i] = fields[i+5].GetInt32(); - periodicTime[i] = fields[i+8].GetUInt32(); + damage[i] = fields[i + 5].GetInt32(); + periodicTime[i] = fields[i + 8].GetUInt32(); } int32 maxduration = fields[11].GetInt32(); @@ -1301,7 +1301,7 @@ void Pet::_LoadAuras(uint32 timediff) SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); if (!spellproto) { - sLog.outError("Unknown spell (spellid %u), ignore.",spellid); + sLog.outError("Unknown spell (spellid %u), ignore.", spellid); continue; } @@ -1311,10 +1311,10 @@ void Pet::_LoadAuras(uint32 timediff) if (remaintime != -1 && !IsPositiveSpell(spellproto)) { - if (remaintime/IN_MILLISECONDS <= int32(timediff)) + if (remaintime / IN_MILLISECONDS <= int32(timediff)) continue; - remaintime -= timediff*IN_MILLISECONDS; + remaintime -= timediff * IN_MILLISECONDS; } // prevent wrong values of remaincharges @@ -1438,7 +1438,7 @@ void Pet::_SaveAuras() } } -bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpellState state /*= PETSPELL_NEW*/, PetSpellType type /*= PETSPELL_NORMAL*/) +bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpellState state /*= PETSPELL_NEW*/, PetSpellType type /*= PETSPELL_NORMAL*/) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id); if (!spellInfo) @@ -1446,11 +1446,11 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel // do pet spell book cleanup if (state == PETSPELL_UNCHANGED) // spell load case { - sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request, deleting for all pets in `pet_spell`.",spell_id); - CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'",spell_id); + sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request, deleting for all pets in `pet_spell`.", spell_id); + CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'", spell_id); } else - sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request.",spell_id); + sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request.", spell_id); return false; } @@ -1500,30 +1500,30 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel { if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id)) { - for (int i=0; i < MAX_TALENT_RANK; ++i) + for (int i = 0; i < MAX_TALENT_RANK; ++i) { // skip learning spell and no rank spell case uint32 rankSpellId = talentInfo->RankID[i]; - if (!rankSpellId || rankSpellId==spell_id) + if (!rankSpellId || rankSpellId == spell_id) continue; // skip unknown ranks if (!HasSpell(rankSpellId)) continue; - removeSpell(rankSpellId,false,false); + removeSpell(rankSpellId, false, false); } } } - else if (sSpellMgr.GetSpellRank(spell_id)!=0) + else if (sSpellMgr.GetSpellRank(spell_id) != 0) { for (PetSpellMap::const_iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2) { if (itr2->second.state == PETSPELL_REMOVED) continue; - if (sSpellMgr.IsRankSpellDueToSpell(spellInfo,itr2->first)) + if (sSpellMgr.IsRankSpellDueToSpell(spellInfo, itr2->first)) { // replace by new high rank - if (sSpellMgr.IsHighRankOfSpell(spell_id,itr2->first)) + if (sSpellMgr.IsHighRankOfSpell(spell_id, itr2->first)) { newspell.active = itr2->second.active; @@ -1531,11 +1531,11 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel ToggleAutocast(itr2->first, false); oldspell_id = itr2->first; - unlearnSpell(itr2->first,false,false); + unlearnSpell(itr2->first, false, false); break; } // ignore new lesser rank - else if (sSpellMgr.IsHighRankOfSpell(itr2->first,spell_id)) + else if (sSpellMgr.IsHighRankOfSpell(itr2->first, spell_id)) return false; } } @@ -1554,7 +1554,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel uint32 talentCost = GetTalentSpellCost(spell_id); if (talentCost) { - m_usedTalentCount+=talentCost; + m_usedTalentCount += talentCost; UpdateFreeTalentPoints(false); } return true; @@ -1592,7 +1592,7 @@ void Pet::InitLevelupSpellsForLevel() { // will called first if level down if (itr->first > level) - unlearnSpell(itr->second,true); // will learn prev rank if any + unlearnSpell(itr->second, true); // will learn prev rank if any // will called if level up else learnSpell(itr->second); // will unlearn prev rank if any @@ -1612,7 +1612,7 @@ void Pet::InitLevelupSpellsForLevel() // will called first if level down if (spellEntry->spellLevel > level) - unlearnSpell(spellEntry->Id,true); + unlearnSpell(spellEntry->Id, true); // will called if level up else learnSpell(spellEntry->Id); @@ -1622,7 +1622,7 @@ void Pet::InitLevelupSpellsForLevel() bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab) { - if (removeSpell(spell_id,learn_prev,clear_ab)) + if (removeSpell(spell_id, learn_prev, clear_ab)) { if (!m_loading) { @@ -1661,7 +1661,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) if (talentCost > 0) { if (m_usedTalentCount > talentCost) - m_usedTalentCount-=talentCost; + m_usedTalentCount -= talentCost; else m_usedTalentCount = 0; @@ -1697,7 +1697,7 @@ 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() @@ -1713,12 +1713,12 @@ void Pet::InitPetCreateSpells() bool Pet::resetTalents(bool no_cost) { Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId()!=TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return false; // not need after this call if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) - ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true); + ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS, true); CreatureInfo const* ci = GetCreatureInfo(); if (!ci) @@ -1766,7 +1766,7 @@ bool Pet::resetTalents(bool no_cost) for (int j = 0; j < MAX_TALENT_RANK; j++) if (talentInfo->RankID[j]) - removeSpell(talentInfo->RankID[j],!IsPassiveSpell(talentInfo->RankID[j]),false); + removeSpell(talentInfo->RankID[j], !IsPassiveSpell(talentInfo->RankID[j]), false); } UpdateFreeTalentPoints(false); @@ -1786,7 +1786,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) { // not need after this call if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) - ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true); + ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS, true); // reset for online if (online_pet) @@ -1797,7 +1797,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) QueryResult* resultPets = CharacterDatabase.PQuery( "SELECT id FROM character_pet WHERE owner = '%u' AND id <> '%u'", - owner->GetGUIDLow(),except_petnumber); + owner->GetGUIDLow(), except_petnumber); // no offline pets if (!resultPets) @@ -1806,7 +1806,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) QueryResult* result = CharacterDatabase.PQuery( "SELECT DISTINCT pet_spell.spell FROM pet_spell, character_pet " "WHERE character_pet.owner = '%u' AND character_pet.id = pet_spell.guid AND character_pet.id <> %u", - owner->GetGUIDLow(),except_petnumber); + owner->GetGUIDLow(), except_petnumber); if (!result) { @@ -1904,20 +1904,20 @@ void Pet::InitTalentForLevel() uint32 Pet::resetTalentsCost() const { - uint32 days = uint32(sWorld.GetGameTime() - m_resetTalentsTime)/DAY; + uint32 days = uint32(sWorld.GetGameTime() - m_resetTalentsTime) / DAY; // 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; + if (m_resetTalentsCost < 10 * SILVER || days > 0) + return 10 * SILVER; // then 50 silver - else if (m_resetTalentsCost < 50*SILVER) - return 50*SILVER; + else if (m_resetTalentsCost < 50 * SILVER) + return 50 * SILVER; // then 1 gold - else if (m_resetTalentsCost < 1*GOLD) - return 1*GOLD; + else if (m_resetTalentsCost < 1 * GOLD) + return 1 * GOLD; // then increasing at a rate of 1 gold; cap 10 gold else - return (m_resetTalentsCost + 1*GOLD > 10*GOLD ? 10*GOLD : m_resetTalentsCost + 1*GOLD); + return (m_resetTalentsCost + 1 * GOLD > 10 * GOLD ? 10 * GOLD : m_resetTalentsCost + 1 * GOLD); } uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) @@ -1925,7 +1925,7 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) uint8 points = (level >= 20) ? ((level - 16) / 4) : 0; // Mod points from owner SPELL_AURA_MOD_PET_TALENT_POINTS if (Unit* owner = GetOwner()) - points+=owner->GetTotalAuraModifier(SPELL_AURA_MOD_PET_TALENT_POINTS); + points += owner->GetTotalAuraModifier(SPELL_AURA_MOD_PET_TALENT_POINTS); return points; } @@ -2050,7 +2050,7 @@ void Pet::LearnPetPassives() void Pet::CastPetAuras(bool current) { Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId()!=TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end();) @@ -2092,7 +2092,7 @@ void Pet::learnSpellHighRank(uint32 spellid) learnSpell(spellid); DoPetLearnSpell worker(*this); - sSpellMgr.doForHighRanks(spellid,worker); + sSpellMgr.doForHighRanks(spellid, worker); } void Pet::SynchronizeLevelWithOwner() @@ -2127,7 +2127,7 @@ void Pet::ApplyModeFlags(PetModeFlags mode, bool apply) m_petModeFlags = PetModeFlags(m_petModeFlags & ~mode); Unit* owner = GetOwner(); - if (!owner || owner->GetTypeId()!=TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; WorldPacket data(SMSG_PET_MODE, 12); diff --git a/src/game/Pet.h b/src/game/Pet.h index 923a8685e..fed2f0c04 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -144,14 +144,14 @@ class MANGOS_DLL_SPEC Pet : public Creature PetType getPetType() const { return m_petType; } void setPetType(PetType type) { m_petType = type; } - bool isControlled() const { return getPetType()==SUMMON_PET || getPetType()==HUNTER_PET; } + bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; } bool isTemporarySummoned() const { return m_duration > 0; } bool IsPermanentPetFor(Player* owner); // pet have tab in character windows and set UNIT_FIELD_PETNUMBER bool Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* cinfo, uint32 pet_number); bool CreateBaseAtCreature(Creature* creature); - bool LoadPetFromDB(Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false); + bool LoadPetFromDB(Player* owner, uint32 petentry = 0, uint32 petnumber = 0, bool current = false); void SavePetToDB(PetSaveMode mode); void Unsummon(PetSaveMode mode, Unit* owner = NULL); static void DeleteFromDB(uint32 guidlow, bool separate_transaction = true); @@ -211,7 +211,7 @@ class MANGOS_DLL_SPEC Pet : public Creature void _LoadSpells(); void _SaveSpells(); - bool addSpell(uint32 spell_id,ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL); + bool addSpell(uint32 spell_id, ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL); bool learnSpell(uint32 spell_id); void learnSpellHighRank(uint32 spellid); void InitLevelupSpellsForLevel(); diff --git a/src/game/PetAI.cpp b/src/game/PetAI.cpp index 140290ac7..123906879 100644 --- a/src/game/PetAI.cpp +++ b/src/game/PetAI.cpp @@ -73,7 +73,7 @@ void PetAI::AttackStart(Unit* u) if (!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET)) return; - if (m_creature->Attack(u,true)) + if (m_creature->Attack(u, true)) { // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function // thus with the following clear the original TMG gets invalidated and crash, doh @@ -110,7 +110,7 @@ void PetAI::_stopAttack() if (owner && m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->HasCommandState(COMMAND_FOLLOW)) { - m_creature->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE); + m_creature->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); } else { @@ -182,7 +182,7 @@ void PetAI::UpdateAI(const uint32 diff) { if (!m_creature->hasUnitState(UNIT_STAT_FOLLOW)) { - m_creature->GetMotionMaster()->MoveFollow(owner,PET_FOLLOW_DIST,PET_FOLLOW_ANGLE); + m_creature->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); } } } @@ -302,8 +302,8 @@ void PetAI::UpdateAI(const uint32 diff) bool PetAI::_isVisible(Unit* u) const { - return m_creature->IsWithinDist(u,sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER)) - && u->isVisibleForOrDetect(m_creature,m_creature,true); + return m_creature->IsWithinDist(u, sWorld.getConfig(CONFIG_FLOAT_SIGHT_GUARDER)) + && u->isVisibleForOrDetect(m_creature, m_creature, true); } void PetAI::UpdateAllies() @@ -311,7 +311,7 @@ void PetAI::UpdateAllies() Unit* owner = m_creature->GetCharmerOrOwner(); Group* pGroup = NULL; - m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance + m_updateAlliesTimer = 10 * IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance if (!owner) return; diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index e40a7f9d7..1edf25d96 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -92,7 +92,7 @@ void WorldSession::HandlePetAction(WorldPacket& recv_data) break; case COMMAND_FOLLOW: // spellid=1792 //FOLLOW pet->AttackStop(); - pet->GetMotionMaster()->MoveFollow(_player, PET_FOLLOW_DIST,PET_FOLLOW_ANGLE); + pet->GetMotionMaster()->MoveFollow(_player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); charmInfo->SetCommandState(COMMAND_FOLLOW); break; case COMMAND_ATTACK: // spellid=1792 // ATTACK @@ -315,7 +315,7 @@ void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid); if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber) { - WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+1+4+1)); + WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 1 + 4 + 1)); data << uint32(petnumber); data << uint8(0); data << uint32(0); @@ -333,7 +333,7 @@ void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber) sObjectMgr.GetCreatureLocaleStrings(pet->GetEntry(), loc_idx, &name); } - WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+strlen(name)+1)); + WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 4 + strlen(name) + 1)); data << uint32(petnumber); data << name; data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP)); diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp index 29cba1231..ffa75130f 100644 --- a/src/game/PetitionsHandler.cpp +++ b/src/game/PetitionsHandler.cpp @@ -271,7 +271,7 @@ void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recv_data) DEBUG_LOG("CMSG_PETITION_SHOW_SIGNATURES petition: %s", petitionguid.GetString().c_str()); - WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8+8+4+1+signs*12)); + WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signs * 12)); data << ObjectGuid(petitionguid); // petition guid data << _player->GetObjectGuid(); // owner guid data << uint32(petitionguid_low); // guild guid (in mangos always same as GUID_LOPART(petitionguid) @@ -335,7 +335,7 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid) return; } - WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4+8+name.size()+1+1+4*12+2+10)); + WorldPacket data(SMSG_PETITION_QUERY_RESPONSE, (4 + 8 + name.size() + 1 + 1 + 4 * 12 + 2 + 10)); data << uint32(petitionLowGuid); // guild/team guid (in mangos always same as GUID_LOPART(petition guid) data << ObjectGuid(ownerGuid); // charter owner guid data << name; // name (guild/arena team) @@ -348,8 +348,8 @@ void WorldSession::SendPetitionQueryOpcode(ObjectGuid petitionguid) } else { - data << uint32(type-1); - data << uint32(type-1); + data << uint32(type - 1); + data << uint32(type - 1); data << uint32(type); // bypass client - side limitation, a different value is needed here for each petition } data << uint32(0); // 5 @@ -438,7 +438,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recv_data) DEBUG_LOG("Petition %s renamed to '%s'", petitionGuid.GetString().c_str(), newname.c_str()); - WorldPacket data(MSG_PETITION_RENAME, (8+newname.size()+1)); + WorldPacket data(MSG_PETITION_RENAME, (8 + newname.size() + 1)); data << ObjectGuid(petitionGuid); data << newname; SendPacket(&data); @@ -542,7 +542,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recv_data) if (result) { delete result; - WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4)); + WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8 + 8 + 4)); data << ObjectGuid(petitionGuid); data << ObjectGuid(_player->GetObjectGuid()); data << uint32(PETITION_SIGN_ALREADY_SIGNED); @@ -561,7 +561,7 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recv_data) DEBUG_LOG("PETITION SIGN: %s by %s", petitionGuid.GetString().c_str(), _player->GetGuidStr().c_str()); - WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8+8+4)); + WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8 + 8 + 4)); data << ObjectGuid(petitionGuid); data << ObjectGuid(_player->GetObjectGuid()); data << uint32(PETITION_SIGN_OK); @@ -696,7 +696,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recv_data) signs = (uint8)result->GetRowCount(); /// Send response - WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8+8+4+signs+signs*12)); + WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + signs + signs * 12)); data << ObjectGuid(petitionGuid); // petition guid data << ObjectGuid(_player->GetObjectGuid()); // owner guid data << uint32(petitionGuid.GetCounter()); // guild guid (in mangos always same as low part of petition guid) @@ -932,7 +932,7 @@ void WorldSession::SendPetitionShowList(ObjectGuid guid) else count = 3; - WorldPacket data(SMSG_PETITION_SHOWLIST, 8+1+4*6); + WorldPacket data(SMSG_PETITION_SHOWLIST, 8 + 1 + 4 * 6); data << ObjectGuid(guid); // npc guid data << uint8(count); // count if (count == 1) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 05e6a2c55..24b0d0e55 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -175,7 +175,7 @@ void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 leve case HORDE: SetTaximaskNode(99); break; } // level dependent taxi hubs - if (level>=68) + if (level >= 68) SetTaximaskNode(213); //Shattered Sun Staging Area } @@ -197,12 +197,12 @@ void PlayerTaxi::AppendTaximaskTo(ByteBuffer& data, bool all) { if (all) { - for (uint8 i=0; imapId); - Relocate(info->positionX,info->positionY,info->positionZ, info->orientation); + Relocate(info->positionX, info->positionY, info->positionZ, info->orientation); SetMap(sMapMgr.CreateMap(info->mapId, this)); @@ -745,7 +745,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c // original action bar for (PlayerCreateInfoActions::const_iterator action_itr = info->action.begin(); action_itr != info->action.end(); ++action_itr) - addActionButton(0, action_itr->button,action_itr->action,action_itr->type); + addActionButton(0, action_itr->button, action_itr->action, action_itr->type); // original items uint32 raceClassGender = GetUInt32Value(UNIT_FIELD_BYTES_0) & 0x00FFFFFF; @@ -781,12 +781,12 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c int32 count = iProto->BuyCount; // special amount for foor/drink - if (iProto->Class==ITEM_CLASS_CONSUMABLE && iProto->SubClass==ITEM_SUBCLASS_FOOD) + if (iProto->Class == ITEM_CLASS_CONSUMABLE && iProto->SubClass == ITEM_SUBCLASS_FOOD) { switch (iProto->Spells[0].SpellCategory) { case 11: // food - count = getClass()==CLASS_DEATH_KNIGHT ? 10 : 4; + count = getClass() == CLASS_DEATH_KNIGHT ? 10 : 4; break; case 59: // drink count = 2; @@ -825,7 +825,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c msg = CanStoreItem(NULL_BAG, NULL_SLOT, sDest, pItem, false); if (msg == EQUIP_ERR_OK) { - RemoveItem(INVENTORY_SLOT_BAG_0, i,true); + RemoveItem(INVENTORY_SLOT_BAG_0, i, true); pItem = StoreItem(sDest, pItem, true); } @@ -843,7 +843,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) { - DEBUG_LOG("STORAGE: Creating initial item, itemId = %u, count = %u",titem_id, titem_amount); + DEBUG_LOG("STORAGE: Creating initial item, itemId = %u, count = %u", titem_id, titem_amount); // attempt equip by one while (titem_amount > 0) @@ -872,7 +872,7 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) } // item can't be added - sLog.outError("STORAGE: Can't equip or store initial item %u for race %u class %u , error msg = %u",titem_id,getRace(),getClass(),msg); + sLog.outError("STORAGE: Can't equip or store initial item %u for race %u class %u , error msg = %u", titem_id, getRace(), getClass(), msg); return false; } @@ -931,13 +931,13 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) else if (type == DAMAGE_SLIME) CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist); - damage-=absorb+resist; + damage -= absorb + resist; - DealDamageMods(this,damage,&absorb); + DealDamageMods(this, damage, &absorb); WorldPacket data(SMSG_ENVIRONMENTALDAMAGELOG, (21)); data << GetObjectGuid(); - data << uint8(type!=DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL); + data << uint8(type != DAMAGE_FALL_TO_VOID ? type : DAMAGE_FALL); data << uint32(damage); data << uint32(absorb); data << uint32(resist); @@ -947,10 +947,10 @@ uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) if (!isAlive()) { - if (type==DAMAGE_FALL) // DealDamage not apply item durability loss at self damage + if (type == DAMAGE_FALL) // DealDamage not apply item durability loss at self damage { DEBUG_LOG("We are fall to death, loosing 10 percents durability"); - DurabilityLossAll(0.10f,false); + DurabilityLossAll(0.10f, false); // durability lost message WorldPacket data2(SMSG_DURABILITY_DAMAGE_DEATH, 0); GetSession()->SendPacket(&data2); @@ -969,13 +969,13 @@ int32 Player::getMaxTimer(MirrorTimerType timer) case FATIGUE_TIMER: if (GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_GMLEVEL)) return DISABLED_MIRROR_TIMER; - return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_MAX)*IN_MILLISECONDS; + return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_MAX) * IN_MILLISECONDS; case BREATH_TIMER: { if (!isAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_GMLEVEL)) return DISABLED_MIRROR_TIMER; - int32 UnderWaterTime = sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_MAX)*IN_MILLISECONDS; + int32 UnderWaterTime = sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_MAX) * IN_MILLISECONDS; AuraList const& mModWaterBreathing = GetAurasByType(SPELL_AURA_MOD_WATER_BREATHING); for (AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i) UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetModifier()->m_amount) / 100.0f); @@ -985,7 +985,7 @@ int32 Player::getMaxTimer(MirrorTimerType timer) { if (!isAlive() || GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL)) return DISABLED_MIRROR_TIMER; - return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_MAX)*IN_MILLISECONDS; + return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_MAX) * IN_MILLISECONDS; } default: return 0; @@ -1016,14 +1016,14 @@ void Player::HandleDrowning(uint32 time_diff) } else { - m_MirrorTimer[BREATH_TIMER]-=time_diff; + m_MirrorTimer[BREATH_TIMER] -= time_diff; // Timer limit - need deal damage if (m_MirrorTimer[BREATH_TIMER] < 0) { m_MirrorTimer[BREATH_TIMER] += 2 * IN_MILLISECONDS; // Calculate and deal damage // TODO: Check this formula - uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1); + uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel() - 1); EnvironmentalDamage(DAMAGE_DROWNING, damage); } else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need @@ -1034,7 +1034,7 @@ void Player::HandleDrowning(uint32 time_diff) { int32 UnderWaterTime = getMaxTimer(BREATH_TIMER); // Need breath regen - m_MirrorTimer[BREATH_TIMER]+=10*time_diff; + m_MirrorTimer[BREATH_TIMER] += 10 * time_diff; if (m_MirrorTimer[BREATH_TIMER] >= UnderWaterTime || !isAlive()) StopMirrorTimer(BREATH_TIMER); else if (m_MirrorTimerFlagsLast & UNDERWATER_INWATER) @@ -1052,14 +1052,14 @@ void Player::HandleDrowning(uint32 time_diff) } else { - m_MirrorTimer[FATIGUE_TIMER]-=time_diff; + m_MirrorTimer[FATIGUE_TIMER] -= time_diff; // Timer limit - need deal damage or teleport ghost to graveyard if (m_MirrorTimer[FATIGUE_TIMER] < 0) { m_MirrorTimer[FATIGUE_TIMER] += 2 * IN_MILLISECONDS; if (isAlive()) // Calculate and deal damage { - uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1); + uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel() - 1); EnvironmentalDamage(DAMAGE_EXHAUSTED, damage); } else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard @@ -1072,28 +1072,28 @@ void Player::HandleDrowning(uint32 time_diff) else if (m_MirrorTimer[FATIGUE_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer { int32 DarkWaterTime = getMaxTimer(FATIGUE_TIMER); - m_MirrorTimer[FATIGUE_TIMER]+=10*time_diff; + m_MirrorTimer[FATIGUE_TIMER] += 10 * time_diff; if (m_MirrorTimer[FATIGUE_TIMER] >= DarkWaterTime || !isAlive()) StopMirrorTimer(FATIGUE_TIMER); else if (m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER) SendMirrorTimer(FATIGUE_TIMER, DarkWaterTime, m_MirrorTimer[FATIGUE_TIMER], 10); } - if (m_MirrorTimerFlags & (UNDERWATER_INLAVA|UNDERWATER_INSLIME)) + if (m_MirrorTimerFlags & (UNDERWATER_INLAVA | UNDERWATER_INSLIME)) { // Breath timer not activated - activate it if (m_MirrorTimer[FIRE_TIMER] == DISABLED_MIRROR_TIMER) m_MirrorTimer[FIRE_TIMER] = getMaxTimer(FIRE_TIMER); else { - m_MirrorTimer[FIRE_TIMER]-=time_diff; + m_MirrorTimer[FIRE_TIMER] -= time_diff; if (m_MirrorTimer[FIRE_TIMER] < 0) { m_MirrorTimer[FIRE_TIMER] += 2 * IN_MILLISECONDS; // Calculate and deal damage // TODO: Check this formula uint32 damage = urand(600, 700); - if (m_MirrorTimerFlags&UNDERWATER_INLAVA) + if (m_MirrorTimerFlags & UNDERWATER_INLAVA) EnvironmentalDamage(DAMAGE_LAVA, damage); // need to skip Slime damage in Undercity, // maybe someone can find better way to handle environmental damage @@ -1106,11 +1106,11 @@ void Player::HandleDrowning(uint32 time_diff) m_MirrorTimer[FIRE_TIMER] = DISABLED_MIRROR_TIMER; // Recheck timers flag - m_MirrorTimerFlags&=~UNDERWATER_EXIST_TIMERS; - for (int i = 0; i< MAX_TIMERS; ++i) - if (m_MirrorTimer[i]!=DISABLED_MIRROR_TIMER) + m_MirrorTimerFlags &= ~UNDERWATER_EXIST_TIMERS; + for (int i = 0; i < MAX_TIMERS; ++i) + if (m_MirrorTimer[i] != DISABLED_MIRROR_TIMER) { - m_MirrorTimerFlags|=UNDERWATER_EXIST_TIMERS; + m_MirrorTimerFlags |= UNDERWATER_EXIST_TIMERS; break; } m_MirrorTimerFlagsLast = m_MirrorTimerFlags; @@ -1147,14 +1147,14 @@ void Player::SetDrunkValue(uint16 newDrunkenValue, uint32 itemId) // special drunk invisibility detection if (newDrunkenState >= DRUNKEN_DRUNK) - m_detectInvisibilityMask |= (1<<6); + m_detectInvisibilityMask |= (1 << 6); else - m_detectInvisibilityMask &= ~(1<<6); + m_detectInvisibilityMask &= ~(1 << 6); if (newDrunkenState == oldDrunkenState) return; - WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8+4+4)); + WorldPacket data(SMSG_CROSSED_INEBRIATION_THRESHOLD, (8 + 4 + 4)); data << GetObjectGuid(); data << uint32(newDrunkenState); data << uint32(itemId); @@ -1357,7 +1357,7 @@ void Player::Update(uint32 update_diff, uint32 p_time) { m_drunkTimer += update_diff; - if (m_drunkTimer > 10*IN_MILLISECONDS) + if (m_drunkTimer > 10 * IN_MILLISECONDS) HandleSobering(); } @@ -1436,8 +1436,8 @@ void Player::SetDeathState(DeathState s) SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); // restore default warrior stance - if (getClass()== CLASS_WARRIOR) - CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); + if (getClass() == CLASS_WARRIOR) + CastSpell(this, SPELL_ID_PASSIVE_BATTLE_STANCE, true); } } @@ -1558,7 +1558,7 @@ bool Player::BuildEnumData(QueryResult* result, WorldPacket* p_data) for (uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot) { // values stored in 2 uint16 - uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot*16); + uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16); if (!enchantId) continue; @@ -1783,7 +1783,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati if (!GetSession()->PlayerLogout()) { // send transfer packet to display load screen - WorldPacket data(SMSG_TRANSFER_PENDING, (4+4+4)); + WorldPacket data(SMSG_TRANSFER_PENDING, (4 + 4 + 4)); data << uint32(mapid); if (m_transport) { @@ -1952,18 +1952,18 @@ void Player::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacke { float addRage; - float rageconversion = float((0.0091107836 * getLevel()*getLevel())+3.225598133*getLevel())+4.2652911f; + float rageconversion = float((0.0091107836 * getLevel() * getLevel()) + 3.225598133 * getLevel()) + 4.2652911f; if (attacker) { - addRage = ((damage/rageconversion*7.5f + weaponSpeedHitFactor)/2.0f); + addRage = ((damage / rageconversion * 7.5f + weaponSpeedHitFactor) / 2.0f); // talent who gave more rage on attack addRage *= 1.0f + GetTotalAuraModifier(SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT) / 100.0f; } else { - addRage = damage/rageconversion*2.5f; + addRage = damage / rageconversion * 2.5f; // Berserker Rage effect if (HasAura(18499, EFFECT_INDEX_0)) @@ -1972,7 +1972,7 @@ void Player::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacke addRage *= sWorld.getConfig(CONFIG_FLOAT_RATE_POWER_RAGE_INCOME); - ModifyPower(POWER_RAGE, uint32(addRage*10)); + ModifyPower(POWER_RAGE, uint32(addRage * 10)); } void Player::RegenerateAll(uint32 diff) @@ -2054,7 +2054,7 @@ void Player::Regenerate(Powers power, uint32 diff) uint32 cd_diff = diff; AuraList const& ModPowerRegenPCTAuras = GetAurasByType(SPELL_AURA_MOD_POWER_REGEN_PERCENT); for (AuraList::const_iterator i = ModPowerRegenPCTAuras.begin(); i != ModPowerRegenPCTAuras.end(); ++i) - if ((*i)->GetModifier()->m_miscvalue == int32(power) && (*i)->GetMiscBValue()==GetCurrentRune(rune)) + if ((*i)->GetModifier()->m_miscvalue == int32(power) && (*i)->GetMiscBValue() == GetCurrentRune(rune)) cd_diff = cd_diff * ((*i)->GetModifier()->m_amount + 100) / 100; SetRuneCooldown(rune, (cd < cd_diff) ? 0 : cd - cd_diff); @@ -2109,11 +2109,11 @@ void Player::RegenerateHealth(uint32 diff) // polymorphed case if (IsPolymorphed()) - addvalue = (float)GetMaxHealth()/3; + addvalue = (float)GetMaxHealth() / 3; // normal regen case (maybe partly in combat case) else if (!isInCombat() || HasAuraType(SPELL_AURA_MOD_REGEN_DURING_COMBAT)) { - addvalue = OCTRegenHPPerSpirit()* HealthIncreaseRate; + addvalue = OCTRegenHPPerSpirit() * HealthIncreaseRate; if (!isInCombat()) { AuraList const& mModHealthRegenPct = GetAurasByType(SPELL_AURA_MOD_HEALTH_REGEN_PERCENT); @@ -2209,7 +2209,7 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameo maxdist = 10.0f; break; case GAMEOBJECT_TYPE_FISHINGHOLE: - maxdist = 20.0f+CONTACT_DISTANCE; // max spell range + maxdist = 20.0f + CONTACT_DISTANCE; // max spell range break; default: maxdist = INTERACTION_DISTANCE; @@ -2228,12 +2228,12 @@ GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, uint32 gameo bool Player::IsUnderWater() const { - return GetTerrain()->IsUnderWater(GetPositionX(), GetPositionY(), GetPositionZ()+2); + return GetTerrain()->IsUnderWater(GetPositionX(), GetPositionY(), GetPositionZ() + 2); } void Player::SetInWater(bool apply) { - if (m_isInWater==apply) + if (m_isInWater == apply) return; //define player in water by opcodes @@ -2278,7 +2278,7 @@ void Player::SetGameMaster(bool on) setFaction(35); SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM); - CallForAllControlledUnits(SetGameMasterOnHelper(), CONTROLLED_PET|CONTROLLED_TOTEMS|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); + CallForAllControlledUnits(SetGameMasterOnHelper(), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); SetFFAPvP(false); ResetContestedPvP(); @@ -2286,7 +2286,7 @@ void Player::SetGameMaster(bool on) getHostileRefManager().setOnlineOfflineState(false); CombatStopWithPets(); - SetPhaseMask(PHASEMASK_ANYWHERE,false); // see and visible in all phases + SetPhaseMask(PHASEMASK_ANYWHERE, false); // see and visible in all phases } else { @@ -2296,9 +2296,9 @@ void Player::SetGameMaster(bool on) // restore phase AuraList const& phases = GetAurasByType(SPELL_AURA_PHASE); - SetPhaseMask(!phases.empty() ? phases.front()->GetMiscValue() : PHASEMASK_NORMAL,false); + SetPhaseMask(!phases.empty() ? phases.front()->GetMiscValue() : PHASEMASK_NORMAL, false); - CallForAllControlledUnits(SetGameMasterOffHelper(getFaction()), CONTROLLED_PET|CONTROLLED_TOTEMS|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); + CallForAllControlledUnits(SetGameMasterOffHelper(getFaction()), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); // restore FFA PvP Server state if (sWorld.IsFFAPvPRealm()) @@ -2346,14 +2346,14 @@ bool Player::IsGroupVisibleFor(Player* p) const { default: return IsInSameGroupWith(p); case 1: return IsInSameRaidWith(p); - case 2: return GetTeam()==p->GetTeam(); + case 2: return GetTeam() == p->GetTeam(); } } bool Player::IsInSameGroupWith(Player const* p) const { - return (p==this || (GetGroup() != NULL && - GetGroup()->SameSubGroup((Player*)this, (Player*)p))); + return (p == this || (GetGroup() != NULL && + GetGroup()->SameSubGroup((Player*)this, (Player*)p))); } ///- If the player is invited, remove him. If the group if then only 1 person, disband the group. @@ -2398,7 +2398,7 @@ void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP) { WorldPacket data(SMSG_LOG_XPGAIN, 21); data << (victim ? victim->GetObjectGuid() : ObjectGuid());// guid - data << uint32(GivenXP+RestXP); // given experience + data << uint32(GivenXP + RestXP); // given experience data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type if (victim) { @@ -2428,20 +2428,20 @@ void Player::GiveXP(uint32 xp, Unit* victim) // handle SPELL_AURA_MOD_KILL_XP_PCT auras Unit::AuraList const& ModXPPctAuras = GetAurasByType(SPELL_AURA_MOD_KILL_XP_PCT); for (Unit::AuraList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i) - xp = uint32(xp*(1.0f + (*i)->GetModifier()->m_amount / 100.0f)); + xp = uint32(xp * (1.0f + (*i)->GetModifier()->m_amount / 100.0f)); } else { // handle SPELL_AURA_MOD_QUEST_XP_PCT auras Unit::AuraList const& ModXPPctAuras = GetAurasByType(SPELL_AURA_MOD_QUEST_XP_PCT); for (Unit::AuraList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i) - xp = uint32(xp*(1.0f + (*i)->GetModifier()->m_amount / 100.0f)); + xp = uint32(xp * (1.0f + (*i)->GetModifier()->m_amount / 100.0f)); } // XP resting bonus for kill uint32 rested_bonus_xp = victim ? GetXPRestBonus(xp) : 0; - SendLogXPGain(xp,victim,rested_bonus_xp); + SendLogXPGain(xp, victim, rested_bonus_xp); uint32 curXP = GetUInt32Value(PLAYER_XP); uint32 nextLvlXP = GetUInt32Value(PLAYER_NEXT_LEVEL_XP); @@ -2469,13 +2469,13 @@ void Player::GiveLevel(uint32 level) return; PlayerLevelInfo info; - sObjectMgr.GetPlayerLevelInfo(getRace(),getClass(),level,&info); + sObjectMgr.GetPlayerLevelInfo(getRace(), getClass(), level, &info); PlayerClassLevelInfo classInfo; - sObjectMgr.GetPlayerClassLevelInfo(getClass(),level,&classInfo); + sObjectMgr.GetPlayerClassLevelInfo(getClass(), level, &classInfo); // send levelup info to client - WorldPacket data(SMSG_LEVELUP_INFO, (4+4+MAX_POWERS*4+MAX_STATS*4)); + WorldPacket data(SMSG_LEVELUP_INFO, (4 + 4 + MAX_POWERS * 4 + MAX_STATS * 4)); data << uint32(level); data << uint32(int32(classInfo.basehealth) - int32(GetCreateHealth())); // for(int i = 0; i < MAX_POWERS; ++i) // Powers loop (0-6) @@ -2532,8 +2532,8 @@ void Player::GiveLevel(uint32 level) if (Pet* pet = GetPet()) pet->SynchronizeLevelWithOwner(); - if (MailLevelReward const* mailReward = sObjectMgr.GetMailLevelReward(level,getRaceMask())) - MailDraft(mailReward->mailTemplateId).SendMailTo(this,MailSender(MAIL_CREATURE,mailReward->senderEntry)); + if (MailLevelReward const* mailReward = sObjectMgr.GetMailLevelReward(level, getRaceMask())) + MailDraft(mailReward->mailTemplateId).SendMailTo(this, MailSender(MAIL_CREATURE, mailReward->senderEntry)); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL); } @@ -2566,7 +2566,7 @@ void Player::UpdateFreeTalentPoints(bool resetIfNeed) } // else update amount of free points else - SetFreeTalentPoints(talentPointsForLevel-m_usedTalentCount); + SetFreeTalentPoints(talentPointsForLevel - m_usedTalentCount); } } @@ -2584,10 +2584,10 @@ void Player::InitStatsForLevel(bool reapplyMods) _RemoveAllStatBonuses(); PlayerClassLevelInfo classInfo; - sObjectMgr.GetPlayerClassLevelInfo(getClass(),getLevel(),&classInfo); + sObjectMgr.GetPlayerClassLevelInfo(getClass(), getLevel(), &classInfo); PlayerLevelInfo info; - sObjectMgr.GetPlayerLevelInfo(getRace(),getClass(),getLevel(),&info); + sObjectMgr.GetPlayerLevelInfo(getRace(), getClass(), getLevel(), &info); SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)); SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr.GetXPForLevel(getLevel())); @@ -2612,7 +2612,7 @@ void Player::InitStatsForLevel(bool reapplyMods) //set create powers SetCreateMana(classInfo.basemana); - SetArmor(int32(m_createStats[STAT_AGILITY]*2)); + SetArmor(int32(m_createStats[STAT_AGILITY] * 2)); InitStatBuffMods(); @@ -2620,12 +2620,12 @@ void Player::InitStatsForLevel(bool reapplyMods) for (uint16 index = PLAYER_FIELD_COMBAT_RATING_1; index < PLAYER_FIELD_COMBAT_RATING_1 + MAX_COMBAT_RATING; ++index) SetUInt32Value(index, 0); - SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS,0); + SetUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, 0); for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) { - SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG+i, 0); - SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, 0); - SetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT+i, 1.00f); + SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, 0); + SetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, 0); + SetFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, 1.00f); } //reset attack power, damage and attack speed fields @@ -2642,19 +2642,19 @@ void Player::InitStatsForLevel(bool reapplyMods) SetInt32Value(UNIT_FIELD_ATTACK_POWER, 0); SetInt32Value(UNIT_FIELD_ATTACK_POWER_MODS, 0); - SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER,0.0f); + SetFloatValue(UNIT_FIELD_ATTACK_POWER_MULTIPLIER, 0.0f); SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0); - SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS,0); - SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER,0.0f); + SetInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER_MODS, 0); + SetFloatValue(UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER, 0.0f); // Base crit values (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset - SetFloatValue(PLAYER_CRIT_PERCENTAGE,0.0f); - SetFloatValue(PLAYER_OFFHAND_CRIT_PERCENTAGE,0.0f); - SetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE,0.0f); + SetFloatValue(PLAYER_CRIT_PERCENTAGE, 0.0f); + SetFloatValue(PLAYER_OFFHAND_CRIT_PERCENTAGE, 0.0f); + SetFloatValue(PLAYER_RANGED_CRIT_PERCENTAGE, 0.0f); // Init spell schools (will be recalculated in UpdateAllStats() at loading and in _ApplyAllStatBonuses() at reset for (uint8 i = 0; i < MAX_SPELL_SCHOOL; ++i) - SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1+i, 0.0f); + SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1 + i, 0.0f); SetFloatValue(PLAYER_PARRY_PERCENTAGE, 0.0f); SetFloatValue(PLAYER_BLOCK_PERCENTAGE, 0.0f); @@ -2664,7 +2664,7 @@ void Player::InitStatsForLevel(bool reapplyMods) SetFloatValue(PLAYER_DODGE_PERCENTAGE, 0.0f); // set armor (resistance 0) to original value (create_agility*2) - SetArmor(int32(m_createStats[STAT_AGILITY]*2)); + SetArmor(int32(m_createStats[STAT_AGILITY] * 2)); SetResistanceBuffMods(SpellSchools(0), true, 0.0f); SetResistanceBuffMods(SpellSchools(0), false, 0.0f); // set other resistance to original value (0) @@ -2675,12 +2675,12 @@ void Player::InitStatsForLevel(bool reapplyMods) SetResistanceBuffMods(SpellSchools(i), false, 0.0f); } - SetUInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE,0); - SetUInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE,0); + SetUInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, 0); + SetUInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, 0); for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) { - SetUInt32Value(UNIT_FIELD_POWER_COST_MODIFIER+i,0); - SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+i,0.0f); + SetUInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, 0); + SetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, 0.0f); } // Reset no reagent cost field for (int i = 0; i < 3; ++i) @@ -2707,7 +2707,7 @@ void Player::InitStatsForLevel(bool reapplyMods) UNIT_FLAG_SKINNABLE | UNIT_FLAG_MOUNT | UNIT_FLAG_TAXI_FLIGHT); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); // must be set - SetFlag(UNIT_FIELD_FLAGS_2,UNIT_FLAG2_REGENERATE_POWER);// must be set + SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_REGENERATE_POWER); // must be set // cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example. RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST); @@ -2743,7 +2743,7 @@ void Player::SendInitialSpells() uint16 spellCount = 0; - WorldPacket data(SMSG_INITIAL_SPELLS, (1+2+4*m_spells.size()+2+m_spellCooldowns.size()*(2+2+2+4+4))); + WorldPacket data(SMSG_INITIAL_SPELLS, (1 + 2 + 4 * m_spells.size() + 2 + m_spellCooldowns.size() * (2 + 2 + 2 + 4 + 4))); data << uint8(0); size_t countPos = data.wpos(); @@ -2760,14 +2760,14 @@ void Player::SendInitialSpells() data << uint32(itr->first); data << uint16(0); // it's not slot id - spellCount +=1; + spellCount += 1; } - data.put(countPos,spellCount); // write real count value + data.put(countPos, spellCount); // write real count value uint16 spellCooldowns = m_spellCooldowns.size(); data << uint16(spellCooldowns); - for (SpellCooldowns::const_iterator itr=m_spellCooldowns.begin(); itr!=m_spellCooldowns.end(); ++itr) + for (SpellCooldowns::const_iterator itr = m_spellCooldowns.begin(); itr != m_spellCooldowns.end(); ++itr) { SpellEntry const* sEntry = sSpellStore.LookupEntry(itr->first); if (!sEntry) @@ -2786,7 +2786,7 @@ void Player::SendInitialSpells() continue; } - time_t cooldown = itr->second.end > curTime ? (itr->second.end-curTime)*IN_MILLISECONDS : 0; + time_t cooldown = itr->second.end > curTime ? (itr->second.end - curTime) * IN_MILLISECONDS : 0; if (sEntry->Category) // may be wrong, but anyway better than nothing... { @@ -2820,7 +2820,7 @@ void Player::RemoveMail(uint32 id) void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResponseResult mailError, uint32 equipError, uint32 item_guid, uint32 item_count) { - WorldPacket data(SMSG_SEND_MAIL_RESULT, (4+4+4+(mailError == MAIL_ERR_EQUIP_ERROR?4:(mailAction == MAIL_ITEM_TAKEN?4+4:0)))); + WorldPacket data(SMSG_SEND_MAIL_RESULT, (4 + 4 + 4 + (mailError == MAIL_ERR_EQUIP_ERROR ? 4 : (mailAction == MAIL_ITEM_TAKEN ? 4 + 4 : 0)))); data << (uint32) mailId; data << (uint32) mailAction; data << (uint32) mailError; @@ -2883,25 +2883,25 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen // do character spell book cleanup (all characters) if (!IsInWorld() && !learning) // spell load case { - sLog.outError("Player::addSpell: nonexistent in SpellStore spell #%u request, deleting for all characters in `character_spell`.",spell_id); - CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); + sLog.outError("Player::addSpell: nonexistent in SpellStore spell #%u request, deleting for all characters in `character_spell`.", spell_id); + CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'", spell_id); } else - sLog.outError("Player::addSpell: nonexistent in SpellStore spell #%u request.",spell_id); + sLog.outError("Player::addSpell: nonexistent in SpellStore spell #%u request.", spell_id); return false; } - if (!SpellMgr::IsSpellValid(spellInfo,this,false)) + if (!SpellMgr::IsSpellValid(spellInfo, this, false)) { // do character spell book cleanup (all characters) if (!IsInWorld() && !learning) // spell load case { - sLog.outError("Player::addSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.",spell_id); - CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id); + sLog.outError("Player::addSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.", spell_id); + CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'", spell_id); } else - sLog.outError("Player::addSpell: Broken spell #%u learning not allowed.",spell_id); + sLog.outError("Player::addSpell: Broken spell #%u learning not allowed.", spell_id); return false; } @@ -3028,7 +3028,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen { if (TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentPos->talent_id)) { - for (int i=0; i < MAX_TALENT_RANK; ++i) + for (int i = 0; i < MAX_TALENT_RANK; ++i) { // skip learning spell and no rank spell case uint32 rankSpellId = talentInfo->RankID[i]; @@ -3067,7 +3067,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen { if (itr2->second.active) { - if (sSpellMgr.IsHighRankOfSpell(spell_id,itr2->first)) + if (sSpellMgr.IsHighRankOfSpell(spell_id, itr2->first)) { if (IsInWorld()) // not send spell (re-/over-)learn packets at loading { @@ -3083,7 +3083,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen itr2->second.state = PLAYERSPELL_CHANGED; superceded_old = true; // new spell replace old in action bars and spell book. } - else if (sSpellMgr.IsHighRankOfSpell(itr2->first,spell_id)) + else if (sSpellMgr.IsHighRankOfSpell(itr2->first, spell_id)) { if (IsInWorld()) // not send spell (re-/over-)learn packets at loading { @@ -3143,12 +3143,12 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if (uint32 freeProfs = GetFreePrimaryProfessionPoints()) { if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) - SetFreePrimaryProfessions(freeProfs-1); + SetFreePrimaryProfessions(freeProfs - 1); } // cast talents with SPELL_EFFECT_LEARN_SPELL (other dependent spells will learned later as not auto-learned) // note: all spells with SPELL_EFFECT_LEARN_SPELL isn't passive - if (talentPos && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_LEARN_SPELL)) + if (talentPos && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_LEARN_SPELL)) { // ignore stance requirement for talent learn spell (stance set for spell only for client spell description show) CastSpell(this, spell_id, true); @@ -3158,7 +3158,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen { CastSpell(this, spell_id, true); } - else if (IsSpellHaveEffect(spellInfo,SPELL_EFFECT_SKILL_STEP)) + else if (IsSpellHaveEffect(spellInfo, SPELL_EFFECT_SKILL_STEP)) { CastSpell(this, spell_id, true); return false; @@ -3200,7 +3200,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if (_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL || // lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL - ((pSkill->id==SKILL_LOCKPICKING || pSkill->id==SKILL_RUNEFORGING) && _spell_idx->second->max_value==0)) + ((pSkill->id == SKILL_LOCKPICKING || pSkill->id == SKILL_RUNEFORGING) && _spell_idx->second->max_value == 0)) { switch (GetSkillRangeType(pSkill, _spell_idx->second->racemask != 0)) { @@ -3228,7 +3228,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen if (!itr2->second.autoLearned) { if (!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save - addSpell(itr2->second.spell,itr2->second.active,true,true,false); + addSpell(itr2->second.spell, itr2->second.active, true, true, false); else // at normal learning learnSpell(itr2->second.spell, true); } @@ -3239,11 +3239,11 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen // not ranked skills for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx) { - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE,_spell_idx->second->skillId); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS,_spell_idx->second->skillId); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE, _spell_idx->second->skillId); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS, _spell_idx->second->skillId); } - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL,spell_id); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL, spell_id); } // return true (for send learn packet) only if spell active (in case ranked spells) and not replace old spell @@ -3356,7 +3356,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo m_talents[m_activeSpec].erase(iter); } else - sLog.outError("removeSpell: Player (GUID: %u) has talent spell (id: %u) but doesn't have talent",GetGUIDLow(), spell_id); + sLog.outError("removeSpell: Player (GUID: %u) has talent spell (id: %u) but doesn't have talent", GetGUIDLow(), spell_id); // free talent points uint32 talentCosts = GetTalentSpellCost(talentPos); @@ -3372,7 +3372,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo // update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning) if (sSpellMgr.IsPrimaryProfessionFirstRankSpell(spell_id)) { - uint32 freeProfs = GetFreePrimaryProfessionPoints()+1; + uint32 freeProfs = GetFreePrimaryProfessionPoints() + 1; uint32 maxProfs = GetSession()->GetSecurity() < AccountTypes(sWorld.getConfig(CONFIG_UINT32_TRADE_SKILL_GMIGNORE_MAX_PRIMARY_COUNT)) ? sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL) : 10; if (freeProfs <= maxProfs) SetFreePrimaryProfessions(freeProfs); @@ -3596,7 +3596,7 @@ void Player::_LoadSpellCooldowns(QueryResult* result) if (!sSpellStore.LookupEntry(spell_id)) { - sLog.outError("Player %u has unknown spell %u in `character_spell_cooldown`, skipping.",GetGUIDLow(),spell_id); + sLog.outError("Player %u has unknown spell %u in `character_spell_cooldown`, skipping.", GetGUIDLow(), spell_id); continue; } @@ -3606,7 +3606,7 @@ void Player::_LoadSpellCooldowns(QueryResult* result) AddSpellCooldown(spell_id, item_id, db_time); - DEBUG_LOG("Player (GUID: %u) spell %u, item %u cooldown loaded (%u secs).", GetGUIDLow(), spell_id, item_id, uint32(db_time-curTime)); + DEBUG_LOG("Player (GUID: %u) spell %u, item %u cooldown loaded (%u secs).", GetGUIDLow(), spell_id, item_id, uint32(db_time - curTime)); } while (result->NextRow()); @@ -3644,31 +3644,31 @@ void Player::_SaveSpellCooldowns() uint32 Player::resetTalentsCost() const { // The first time reset costs 1 gold - if (m_resetTalentsCost < 1*GOLD) - return 1*GOLD; + if (m_resetTalentsCost < 1 * GOLD) + return 1 * GOLD; // then 5 gold - else if (m_resetTalentsCost < 5*GOLD) - return 5*GOLD; + else if (m_resetTalentsCost < 5 * GOLD) + return 5 * GOLD; // After that it increases in increments of 5 gold - else if (m_resetTalentsCost < 10*GOLD) - return 10*GOLD; + else if (m_resetTalentsCost < 10 * GOLD) + return 10 * GOLD; else { - time_t months = (sWorld.GetGameTime() - m_resetTalentsTime)/MONTH; + time_t months = (sWorld.GetGameTime() - m_resetTalentsTime) / MONTH; if (months > 0) { // This cost will be reduced by a rate of 5 gold per month - int32 new_cost = int32((m_resetTalentsCost) - 5*GOLD*months); + int32 new_cost = int32((m_resetTalentsCost) - 5 * GOLD * months); // to a minimum of 10 gold. - return uint32(new_cost < 10*GOLD ? 10*GOLD : new_cost); + return uint32(new_cost < 10 * GOLD ? 10 * GOLD : new_cost); } else { // After that it increases in increments of 5 gold - int32 new_cost = m_resetTalentsCost + 5*GOLD; + int32 new_cost = m_resetTalentsCost + 5 * GOLD; // until it hits a cap of 50 gold. - if (new_cost > 50*GOLD) - new_cost = 50*GOLD; + if (new_cost > 50 * GOLD) + new_cost = 50 * GOLD; return new_cost; } } @@ -3678,7 +3678,7 @@ bool Player::resetTalents(bool no_cost, bool all_specs) { // not need after this call if (HasAtLoginFlag(AT_LOGIN_RESET_TALENTS) && all_specs) - RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS,true); + RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS, true); if (m_usedTalentCount == 0 && !all_specs) { @@ -3733,7 +3733,7 @@ bool Player::resetTalents(bool no_cost, bool all_specs) for (int j = 0; j < MAX_TALENT_RANK; ++j) if (talentInfo->RankID[j]) - removeSpell(talentInfo->RankID[j],!IsPassiveSpell(talentInfo->RankID[j]),false); + removeSpell(talentInfo->RankID[j], !IsPassiveSpell(talentInfo->RankID[j]), false); iter = m_talents[m_activeSpec].begin(); } @@ -4124,7 +4124,7 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe uint32 mail_id = fields[0].GetUInt32(); uint16 mailType = fields[1].GetUInt16(); - uint16 mailTemplateId= fields[2].GetUInt16(); + uint16 mailTemplateId = fields[2].GetUInt16(); uint32 sender = fields[3].GetUInt32(); std::string subject = fields[4].GetCppString(); std::string body = fields[5].GetCppString(); @@ -4313,7 +4313,7 @@ void Player::DeleteOldCharacters(uint32 keepDays) QueryResult* resultChars = CharacterDatabase.PQuery("SELECT guid, deleteInfos_Account FROM characters WHERE deleteDate IS NOT NULL AND deleteDate < '" UI64FMTD "'", uint64(time(NULL) - time_t(keepDays * DAY))); if (resultChars) { - sLog.outString("Player::DeleteOldChars: Found %u character(s) to delete",uint32(resultChars->GetRowCount())); + sLog.outString("Player::DeleteOldChars: Found %u character(s) to delete", uint32(resultChars->GetRowCount())); do { Field* charFields = resultChars->Fetch(); @@ -4330,12 +4330,12 @@ void Player::SetMovement(PlayerMovementType pType) WorldPacket data; switch (pType) { - case MOVE_ROOT: data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size()+4); break; - case MOVE_UNROOT: data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size()+4); break; - case MOVE_WATER_WALK: data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size()+4); break; - case MOVE_LAND_WALK: data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size()+4); break; + case MOVE_ROOT: data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size() + 4); break; + case MOVE_UNROOT: data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size() + 4); break; + case MOVE_WATER_WALK: data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size() + 4); break; + case MOVE_LAND_WALK: data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size() + 4); break; default: - sLog.outError("Player::SetMovement: Unsupported move type (%d), data not sent to client.",pType); + sLog.outError("Player::SetMovement: Unsupported move type (%d), data not sent to client.", pType); return; } data << GetPackGUID(); @@ -4400,7 +4400,7 @@ void Player::BuildPlayerRepop() void Player::ResurrectPlayer(float restore_percent, bool applySickness) { - WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // remove spirit healer position + WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4 * 4); // remove spirit healer position data << uint32(-1); data << float(0); data << float(0); @@ -4424,7 +4424,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) m_deathTimer = 0; // set health/powers (0- will be set in caller) - if (restore_percent>0.0f) + if (restore_percent > 0.0f) { SetHealth(uint32(GetMaxHealth()*restore_percent)); SetPower(POWER_MANA, uint32(GetMaxPower(POWER_MANA)*restore_percent)); @@ -4434,8 +4434,8 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) // trigger update zone for alive state zone updates uint32 newzone, newarea; - GetZoneAndAreaId(newzone,newarea); - UpdateZone(newzone,newarea); + GetZoneAndAreaId(newzone, newarea); + UpdateZone(newzone, newarea); // update visibility of world around viewpoint m_camera.UpdateVisibilityForOwner(); @@ -4454,16 +4454,16 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) if (int32(getLevel()) >= startLevel) { // set resurrection sickness - CastSpell(this,SPELL_ID_PASSIVE_RESURRECTION_SICKNESS,true); + CastSpell(this, SPELL_ID_PASSIVE_RESURRECTION_SICKNESS, true); // not full duration - if (int32(getLevel()) < startLevel+9) + if (int32(getLevel()) < startLevel + 9) { - int32 delta = (int32(getLevel()) - startLevel + 1)*MINUTE; + int32 delta = (int32(getLevel()) - startLevel + 1) * MINUTE; if (SpellAuraHolder* holder = GetSpellAuraHolder(SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) { - holder->SetAuraDuration(delta*IN_MILLISECONDS); + holder->SetAuraDuration(delta * IN_MILLISECONDS); holder->SendAuraUpdate(false); } } @@ -4483,7 +4483,7 @@ void Player::KillPlayer() ApplyModByteFlag(PLAYER_FIELD_BYTES, 0, PLAYER_FIELD_BYTE_RELEASE_TIMER, !sMapStore.LookupEntry(GetMapId())->Instanceable()); // 6 minutes until repop at graveyard - m_deathTimer = 6*MINUTE*IN_MILLISECONDS; + m_deathTimer = 6 * MINUTE * IN_MILLISECONDS; UpdateCorpseReclaimDelay(); // dependent at use SetDeathPvP() call before kill @@ -4575,7 +4575,7 @@ void Player::DurabilityLossAll(double percent, bool inventory) { for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - DurabilityLoss(pItem,percent); + DurabilityLoss(pItem, percent); if (inventory) { @@ -4584,7 +4584,7 @@ void Player::DurabilityLossAll(double percent, bool inventory) for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - DurabilityLoss(pItem,percent); + DurabilityLoss(pItem, percent); // keys not have durability //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) @@ -4593,7 +4593,7 @@ void Player::DurabilityLossAll(double percent, bool inventory) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = GetItemByPos(i, j)) - DurabilityLoss(pItem,percent); + DurabilityLoss(pItem, percent); } } @@ -4607,19 +4607,19 @@ void Player::DurabilityLoss(Item* item, double percent) if (!pMaxDurability) return; - uint32 pDurabilityLoss = uint32(pMaxDurability*percent); + uint32 pDurabilityLoss = uint32(pMaxDurability * percent); if (pDurabilityLoss < 1) pDurabilityLoss = 1; - DurabilityPointsLoss(item,pDurabilityLoss); + DurabilityPointsLoss(item, pDurabilityLoss); } void Player::DurabilityPointsLossAll(int32 points, bool inventory) { for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - DurabilityPointsLoss(pItem,points); + DurabilityPointsLoss(pItem, points); if (inventory) { @@ -4628,7 +4628,7 @@ void Player::DurabilityPointsLossAll(int32 points, bool inventory) for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - DurabilityPointsLoss(pItem,points); + DurabilityPointsLoss(pItem, points); // keys not have durability //for(int i = KEYRING_SLOT_START; i < KEYRING_SLOT_END; ++i) @@ -4637,7 +4637,7 @@ void Player::DurabilityPointsLossAll(int32 points, bool inventory) if (Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i)) for (uint32 j = 0; j < pBag->GetBagSize(); ++j) if (Item* pItem = GetItemByPos(i, j)) - DurabilityPointsLoss(pItem,points); + DurabilityPointsLoss(pItem, points); } } @@ -4656,13 +4656,13 @@ void Player::DurabilityPointsLoss(Item* item, int32 points) { // modify item stats _before_ Durability set to 0 to pass _ApplyItemMods internal check if (pNewDurability == 0 && pOldDurability > 0 && item->IsEquipped()) - _ApplyItemMods(item,item->GetSlot(), false); + _ApplyItemMods(item, item->GetSlot(), false); item->SetUInt32Value(ITEM_FIELD_DURABILITY, pNewDurability); // modify item stats _after_ restore durability to pass _ApplyItemMods internal check if (pNewDurability > 0 && pOldDurability == 0 && item->IsEquipped()) - _ApplyItemMods(item,item->GetSlot(), true); + _ApplyItemMods(item, item->GetSlot(), true); item->SetState(ITEM_CHANGED, this); } @@ -4671,7 +4671,7 @@ void Player::DurabilityPointsLoss(Item* item, int32 points) void Player::DurabilityPointLossForEquipSlot(EquipmentSlots slot) { if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) - DurabilityPointsLoss(pItem,1); + DurabilityPointsLoss(pItem, 1); } uint32 Player::DurabilityRepairAll(bool cost, float discountMod, bool guildBank) @@ -4679,14 +4679,14 @@ uint32 Player::DurabilityRepairAll(bool cost, float discountMod, bool guildBank) uint32 TotalCost = 0; // equipped, backpack, bags itself for (int i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) - TotalCost += DurabilityRepair(((INVENTORY_SLOT_BAG_0 << 8) | i),cost,discountMod, guildBank); + TotalCost += DurabilityRepair(((INVENTORY_SLOT_BAG_0 << 8) | i), cost, discountMod, guildBank); // bank, buyback and keys not repaired // items in inventory bags for (int j = INVENTORY_SLOT_BAG_START; j < INVENTORY_SLOT_BAG_END; ++j) for (int i = 0; i < MAX_BAG_SIZE; ++i) - TotalCost += DurabilityRepair(((j << 8) | i),cost,discountMod, guildBank); + TotalCost += DurabilityRepair(((j << 8) | i), cost, discountMod, guildBank); return TotalCost; } @@ -4707,7 +4707,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g if (cost) { uint32 LostDurability = maxDurability - curDurability; - if (LostDurability>0) + if (LostDurability > 0) { ItemPrototype const* ditemProto = item->GetProto(); @@ -4718,7 +4718,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g return TotalCost; } - uint32 dQualitymodEntryId = (ditemProto->Quality+1)*2; + uint32 dQualitymodEntryId = (ditemProto->Quality + 1) * 2; DurabilityQualityEntry const* dQualitymodEntry = sDurabilityQualityStore.LookupEntry(dQualitymodEntryId); if (!dQualitymodEntry) { @@ -4726,17 +4726,17 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g return TotalCost; } - uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class,ditemProto->SubClass)]; - uint32 costs = uint32(LostDurability*dmultiplier*double(dQualitymodEntry->quality_mod)); + uint32 dmultiplier = dcost->multiplier[ItemSubClassToDurabilityMultiplierId(ditemProto->Class, ditemProto->SubClass)]; + uint32 costs = uint32(LostDurability * dmultiplier * double(dQualitymodEntry->quality_mod)); costs = uint32(costs * discountMod); - if (costs==0) //fix for ITEM_QUALITY_ARTIFACT + if (costs == 0) //fix for ITEM_QUALITY_ARTIFACT costs = 1; if (guildBank) { - if (GetGuildId()==0) + if (GetGuildId() == 0) { DEBUG_LOG("You are not member of a guild"); return TotalCost; @@ -4782,7 +4782,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g // reapply mods for total broken and repaired item if equipped if (IsEquipmentPos(pos) && !curDurability) - _ApplyItemMods(item,pos & 255, true); + _ApplyItemMods(item, pos & 255, true); return TotalCost; } @@ -4818,7 +4818,7 @@ void Player::RepopAtGraveyard() TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation()); if (isDead()) // not send if alive, because it used in TeleportTo() { - WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap + WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4 * 4); // show spirit healer position on minimap data << ClosestGrave->map_id; data << ClosestGrave->x; data << ClosestGrave->y; @@ -4884,15 +4884,15 @@ void Player::UpdateLocalChannels(uint32 newZone) // new channel char new_channel_name_buf[100]; - snprintf(new_channel_name_buf,100,ch->pattern[m_session->GetSessionDbcLocale()],current_zone_name.c_str()); - Channel* new_channel = cMgr->GetJoinChannel(new_channel_name_buf,ch->ChannelID); + snprintf(new_channel_name_buf, 100, ch->pattern[m_session->GetSessionDbcLocale()], current_zone_name.c_str()); + Channel* new_channel = cMgr->GetJoinChannel(new_channel_name_buf, ch->ChannelID); - if ((*i)!=new_channel) + if ((*i) != new_channel) { - new_channel->Join(GetObjectGuid(),""); // will output Changed Channel: N. Name + new_channel->Join(GetObjectGuid(), ""); // will output Changed Channel: N. Name // leave old channel - (*i)->Leave(GetObjectGuid(),false); // not send leave channel, it already replaced at client + (*i)->Leave(GetObjectGuid(), false); // not send leave channel, it already replaced at client std::string name = (*i)->GetName(); // store name, (*i)erase in LeftChannel LeftChannel(*i); // remove from player's channel list cMgr->LeftChannel(name); // delete if empty @@ -4917,7 +4917,7 @@ void Player::UpdateDefense() { uint32 defense_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_DEFENSE); - if (UpdateSkill(SKILL_DEFENSE,defense_skill_gain)) + if (UpdateSkill(SKILL_DEFENSE, defense_skill_gain)) { // update dependent from defense skill part UpdateDefenseBonusesMod(); @@ -4944,7 +4944,7 @@ void Player::HandleBaseModValue(BaseModGroup modGroup, BaseModType modType, floa amount = -200.0f; val = (100.0f + amount) / 100.0f; - m_auraBaseMod[modGroup][modType] *= apply ? val : (1.0f/val); + m_auraBaseMod[modGroup][modType] *= apply ? val : (1.0f / val); break; } @@ -4991,7 +4991,7 @@ float Player::GetTotalBaseModValue(BaseModGroup modGroup) const uint32 Player::GetShieldBlockValue() const { - float value = (m_auraBaseMod[SHIELD_BLOCK_VALUE][FLAT_MOD] + GetStat(STAT_STRENGTH) * 0.5f - 10)*m_auraBaseMod[SHIELD_BLOCK_VALUE][PCT_MOD]; + float value = (m_auraBaseMod[SHIELD_BLOCK_VALUE][FLAT_MOD] + GetStat(STAT_STRENGTH) * 0.5f - 10) * m_auraBaseMod[SHIELD_BLOCK_VALUE][PCT_MOD]; value = (value < 0) ? 0 : value; @@ -5003,15 +5003,15 @@ float Player::GetMeleeCritFromAgility() uint32 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); - GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (critBase==NULL || critRatio==NULL) + GtChanceToMeleeCritBaseEntry const* critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass - 1); + GtChanceToMeleeCritEntry const* critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + if (critBase == NULL || critRatio == NULL) return 0.0f; - float crit=critBase->base + GetStat(STAT_AGILITY)*critRatio->ratio; - return crit*100.0f; + float crit = critBase->base + GetStat(STAT_AGILITY) * critRatio->ratio; + return crit * 100.0f; } void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing) @@ -5034,35 +5034,35 @@ void Player::GetDodgeFromAgility(float& diminishing, float& nondiminishing) // Crit/agility to dodge/agility coefficient multipliers; 3.2.0 increased required agility by 15% const float crit_to_dodge[MAX_CLASSES] = { - 0.85f/1.15f, // Warrior - 1.00f/1.15f, // Paladin - 1.11f/1.15f, // Hunter - 2.00f/1.15f, // Rogue - 1.00f/1.15f, // Priest - 0.85f/1.15f, // DK - 1.60f/1.15f, // Shaman - 1.00f/1.15f, // Mage - 0.97f/1.15f, // Warlock (?) + 0.85f / 1.15f, // Warrior + 1.00f / 1.15f, // Paladin + 1.11f / 1.15f, // Hunter + 2.00f / 1.15f, // Rogue + 1.00f / 1.15f, // Priest + 0.85f / 1.15f, // DK + 1.60f / 1.15f, // Shaman + 1.00f / 1.15f, // Mage + 0.97f / 1.15f, // Warlock (?) 0.0f, // ?? - 2.00f/1.15f // Druid + 2.00f / 1.15f // Druid }; uint32 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; // Dodge per agility is proportional to crit per agility, which is available from DBC files - GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (dodgeRatio==NULL || pclass > MAX_CLASSES) + GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + if (dodgeRatio == NULL || pclass > MAX_CLASSES) return; // TODO: research if talents/effects that increase total agility by x% should increase non-diminishing part float base_agility = GetCreateStat(STAT_AGILITY) * m_auraModifiersGroup[UNIT_MOD_STAT_START + STAT_AGILITY][BASE_PCT]; float bonus_agility = GetStat(STAT_AGILITY) - base_agility; // calculate diminishing (green in char screen) and non-diminishing (white) contribution - diminishing = 100.0f * bonus_agility * dodgeRatio->ratio * crit_to_dodge[pclass-1]; - nondiminishing = 100.0f * (dodge_base[pclass-1] + base_agility * dodgeRatio->ratio * crit_to_dodge[pclass-1]); + diminishing = 100.0f * bonus_agility * dodgeRatio->ratio * crit_to_dodge[pclass - 1]; + nondiminishing = 100.0f * (dodge_base[pclass - 1] + base_agility * dodgeRatio->ratio * crit_to_dodge[pclass - 1]); } float Player::GetSpellCritFromIntellect() @@ -5070,26 +5070,26 @@ float Player::GetSpellCritFromIntellect() uint32 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1); - GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (critBase==NULL || critRatio==NULL) + GtChanceToSpellCritBaseEntry const* critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass - 1); + GtChanceToSpellCritEntry const* critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + if (critBase == NULL || critRatio == NULL) return 0.0f; - float crit=critBase->base + GetStat(STAT_INTELLECT)*critRatio->ratio; - return crit*100.0f; + float crit = critBase->base + GetStat(STAT_INTELLECT) * critRatio->ratio; + return crit * 100.0f; } float Player::GetRatingMultiplier(CombatRating cr) const { uint32 level = getLevel(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); + GtCombatRatingsEntry const* Rating = sGtCombatRatingsStore.LookupEntry(cr * GT_MAX_LEVEL + level - 1); // gtOCTClassCombatRatingScalarStore.dbc starts with 1, CombatRating with zero, so cr+1 - GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass()-1)*GT_MAX_RATING+cr+1); + GtOCTClassCombatRatingScalarEntry const* classRating = sGtOCTClassCombatRatingScalarStore.LookupEntry((getClass() - 1) * GT_MAX_RATING + cr + 1); if (!Rating || !classRating) return 1.0f; // By default use minimum coefficient (not must be called) @@ -5120,17 +5120,17 @@ float Player::OCTRegenHPPerSpirit() uint32 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; - GtOCTRegenHPEntry const* baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenHPPerSptEntry const* moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (baseRatio==NULL || moreRatio==NULL) + GtOCTRegenHPEntry const* baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + GtRegenHPPerSptEntry const* moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + if (baseRatio == NULL || moreRatio == NULL) return 0.0f; // Formula from PaperDollFrame script float spirit = GetStat(STAT_SPIRIT); float baseSpirit = spirit; - if (baseSpirit>50) baseSpirit = 50; + if (baseSpirit > 50) baseSpirit = 50; float moreSpirit = spirit - baseSpirit; float regen = baseSpirit * baseRatio->ratio + moreSpirit * moreRatio->ratio; return regen; @@ -5141,11 +5141,11 @@ float Player::OCTRegenMPPerSpirit() uint32 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; // GtOCTRegenMPEntry const *baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (moreRatio==NULL) + GtRegenMPPerSptEntry const* moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass - 1) * GT_MAX_LEVEL + level - 1); + if (moreRatio == NULL) return 0.0f; // Formula get from PaperDollFrame script @@ -5156,7 +5156,7 @@ float Player::OCTRegenMPPerSpirit() void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply) { - m_baseRatingValue[cr]+=(apply ? value : -value); + m_baseRatingValue[cr] += (apply ? value : -value); // explicit affected values switch (cr) @@ -5164,8 +5164,8 @@ void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply) case CR_HASTE_MELEE: { float RatingChange = value * GetRatingMultiplier(cr); - ApplyAttackTimePercentMod(BASE_ATTACK,RatingChange,apply); - ApplyAttackTimePercentMod(OFF_ATTACK,RatingChange,apply); + ApplyAttackTimePercentMod(BASE_ATTACK, RatingChange, apply); + ApplyAttackTimePercentMod(OFF_ATTACK, RatingChange, apply); break; } case CR_HASTE_RANGED: @@ -5177,7 +5177,7 @@ void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply) case CR_HASTE_SPELL: { float RatingChange = value * GetRatingMultiplier(cr); - ApplyCastTimePercentMod(RatingChange,apply); + ApplyCastTimePercentMod(RatingChange, apply); break; } default: @@ -5194,7 +5194,7 @@ void Player::UpdateRating(CombatRating cr) // stat used stored in miscValueB for this aura AuraList const& modRatingFromStat = GetAurasByType(SPELL_AURA_MOD_RATING_FROM_STAT); for (AuraList::const_iterator i = modRatingFromStat.begin(); i != modRatingFromStat.end(); ++i) - if ((*i)->GetMiscValue() & (1<GetMiscValue() & (1 << cr)) amount += int32(GetStat(Stats((*i)->GetMiscBValue())) * (*i)->GetModifier()->m_amount / 100.0f); if (amount < 0) amount = 0; @@ -5283,7 +5283,7 @@ void Player::SetRegularAttackTime() { for (int i = 0; i < MAX_ATTACK; ++i) { - Item* tmpitem = GetWeaponForAttack(WeaponAttackType(i),true,false); + Item* tmpitem = GetWeaponForAttack(WeaponAttackType(i), true, false); if (tmpitem) { ItemPrototype const* proto = tmpitem->GetProto(); @@ -5313,16 +5313,16 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) if ((!max) || (!value) || (value >= max)) return false; - if (value*512 < max*urand(0,512)) + if (value * 512 < max * urand(0, 512)) { - uint32 new_value = value+step; + uint32 new_value = value + step; if (new_value > max) new_value = max; - SetUInt32Value(valueIndex,MAKE_SKILL_VALUE(new_value,max)); + SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(new_value, max)); if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,skill_id); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, skill_id); return true; } @@ -5332,12 +5332,12 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step) inline int SkillGainChance(uint32 SkillValue, uint32 GrayLevel, uint32 GreenLevel, uint32 YellowLevel) { if (SkillValue >= GrayLevel) - return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREY)*10; + return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREY) * 10; if (SkillValue >= GreenLevel) - return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREEN)*10; + return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_GREEN) * 10; if (SkillValue >= YellowLevel) - return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_YELLOW)*10; - return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_ORANGE)*10; + return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_YELLOW) * 10; + return sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_ORANGE) * 10; } bool Player::UpdateCraftSkill(uint32 spellid) @@ -5364,7 +5364,7 @@ bool Player::UpdateCraftSkill(uint32 spellid) return UpdateSkillPro(_spell_idx->second->skillId, SkillGainChance(SkillValue, _spell_idx->second->max_value, - (_spell_idx->second->max_value + _spell_idx->second->min_value)/2, + (_spell_idx->second->max_value + _spell_idx->second->min_value) / 2, _spell_idx->second->min_value), craft_skill_gain); } @@ -5385,17 +5385,17 @@ bool Player::UpdateGatherSkill(uint32 SkillId, uint32 SkillValue, uint32 RedLeve case SKILL_LOCKPICKING: case SKILL_JEWELCRAFTING: case SKILL_INSCRIPTION: - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); case SKILL_SKINNING: - if (sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS)==0) - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); + if (sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS) == 0) + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); else - return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain); + return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_SKINNING_STEPS)), gathering_skill_gain); case SKILL_MINING: - if (sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_MINING_STEPS)==0) - return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator,gathering_skill_gain); + if (sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_MINING_STEPS) == 0) + return UpdateSkillPro(SkillId, SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator, gathering_skill_gain); else - return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel+100, RedLevel+50, RedLevel+25)*Multiplicator) >> (SkillValue/sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_MINING_STEPS)),gathering_skill_gain); + return UpdateSkillPro(SkillId, (SkillGainChance(SkillValue, RedLevel + 100, RedLevel + 50, RedLevel + 25) * Multiplicator) >> (SkillValue / sWorld.getConfig(CONFIG_UINT32_SKILL_CHANCE_MINING_STEPS)), gathering_skill_gain); } return false; } @@ -5406,27 +5406,27 @@ bool Player::UpdateFishingSkill() uint32 SkillValue = GetPureSkillValue(SKILL_FISHING); - int32 chance = SkillValue < 75 ? 100 : 2500/(SkillValue-50); + int32 chance = SkillValue < 75 ? 100 : 2500 / (SkillValue - 50); uint32 gathering_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_GATHERING); - return UpdateSkillPro(SKILL_FISHING,chance*10,gathering_skill_gain); + return UpdateSkillPro(SKILL_FISHING, chance * 10, gathering_skill_gain); } // levels sync. with spell requirement for skill levels to learn // bonus abilities in sSkillLineAbilityStore // Used only to avoid scan DBC at each skill grow -static uint32 bonusSkillLevels[] = {75,150,225,300,375,450}; +static uint32 bonusSkillLevels[] = {75, 150, 225, 300, 375, 450}; bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) { - DEBUG_LOG("UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance/10.0); + DEBUG_LOG("UpdateSkillPro(SkillId %d, Chance %3.1f%%)", SkillId, Chance / 10.0); if (!SkillId) return false; if (Chance <= 0) // speedup in 0 chance case { - DEBUG_LOG("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); + DEBUG_LOG("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance / 10.0); return false; } @@ -5443,15 +5443,15 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) if (!MaxValue || !SkillValue || SkillValue >= MaxValue) return false; - int32 Roll = irand(1,1000); + int32 Roll = irand(1, 1000); if (Roll <= Chance) { - uint32 new_value = SkillValue+step; + uint32 new_value = SkillValue + step; if (new_value > MaxValue) new_value = MaxValue; - SetUInt32Value(valueIndex,MAKE_SKILL_VALUE(new_value,MaxValue)); + SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(new_value, MaxValue)); if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; for (uint32* bsl = &bonusSkillLevels[0]; *bsl; ++bsl) @@ -5462,12 +5462,12 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step) break; } } - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,SkillId); - DEBUG_LOG("Player::UpdateSkillPro Chance=%3.1f%% taken", Chance/10.0); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, SkillId); + DEBUG_LOG("Player::UpdateSkillPro Chance=%3.1f%% taken", Chance / 10.0); return true; } - DEBUG_LOG("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance/10.0); + DEBUG_LOG("Player::UpdateSkillPro Chance=%3.1f%% missed", Chance / 10.0); return false; } @@ -5534,7 +5534,7 @@ void Player::UpdateCombatSkills(Unit* pVictim, WeaponAttackType attType, bool de return; } -void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) +void Player::ModifySkillBonus(uint32 skillid, int32 val, bool talent) { SkillStatusMap::const_iterator itr = mSkillStatus.find(skillid); if (itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED) @@ -5547,9 +5547,9 @@ void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) int16 perm_bonus = SKILL_PERM_BONUS(bonus_val); if (talent) // permanent bonus stored in high part - SetUInt32Value(bonusIndex,MAKE_SKILL_BONUS(temp_bonus,perm_bonus+val)); + SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus, perm_bonus + val)); else // temporary/item bonus stored in low part - SetUInt32Value(bonusIndex,MAKE_SKILL_BONUS(temp_bonus+val,perm_bonus)); + SetUInt32Value(bonusIndex, MAKE_SKILL_BONUS(temp_bonus + val, perm_bonus)); } void Player::UpdateSkillsForLevel() @@ -5570,7 +5570,7 @@ void Player::UpdateSkillsForLevel() if (!pSkill) continue; - if (GetSkillRangeType(pSkill,false) != SKILL_RANGE_LEVEL) + if (GetSkillRangeType(pSkill, false) != SKILL_RANGE_LEVEL) continue; uint32 valueIndex = PLAYER_SKILL_VALUE_INDEX(itr->second.pos); @@ -5579,19 +5579,19 @@ void Player::UpdateSkillsForLevel() uint32 val = SKILL_VALUE(data); /// update only level dependent max skill values - if (max!=1) + if (max != 1) { /// maximize skill always if (alwaysMaxSkill) { - SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(maxSkill,maxSkill)); + SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(maxSkill, maxSkill)); if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, pskill); } else if (max != maxconfskill) /// update max skill value if current max skill not maximized { - SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(val,maxSkill)); + SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(val, maxSkill)); if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; } @@ -5616,7 +5616,7 @@ void Player::UpdateSkillsToMaxSkillsForLevel() if (max > 1) { - SetUInt32Value(valueIndex,MAKE_SKILL_VALUE(max,max)); + SetUInt32Value(valueIndex, MAKE_SKILL_VALUE(max, max)); if (itr->second.uState != SKILL_NEW) itr->second.uState = SKILL_CHANGED; GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, pskill); @@ -5685,7 +5685,7 @@ void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0 } SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id, step)); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal, maxVal)); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i), MAKE_SKILL_VALUE(currVal, maxVal)); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id); @@ -5830,7 +5830,7 @@ void Player::SendInitialActionButtons() const { DETAIL_LOG("Initializing Action Buttons for '%u' spec '%u'", GetGUIDLow(), m_activeSpec); - WorldPacket data(SMSG_ACTION_BUTTONS, 1+(MAX_ACTION_BUTTONS*4)); + WorldPacket data(SMSG_ACTION_BUTTONS, 1 + (MAX_ACTION_BUTTONS * 4)); data << uint8(1); // talent spec amount (in packet) ActionButtonList const& currentActionButtonList = m_actionButtons[m_activeSpec]; for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) @@ -5950,14 +5950,14 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type, Pl ActionButton* Player::addActionButton(uint8 spec, uint8 button, uint32 action, uint8 type) { // check action only for active spec (so not check at copy/load passive spec) - if (spec == GetActiveSpec() && !IsActionButtonDataValid(button,action,type,this)) + if (spec == GetActiveSpec() && !IsActionButtonDataValid(button, action, type, this)) return NULL; // it create new button (NEW state) if need or return existing ActionButton& ab = m_actionButtons[spec][button]; // set data and update to CHANGED if not NEW - ab.SetActionAndType(action,ActionButtonType(type)); + ab.SetActionAndType(action, ActionButtonType(type)); DETAIL_LOG("Player '%u' Added Action '%u' (type %u) to Button '%u' for spec %u", GetGUIDLow(), action, uint32(type), button, spec); return &ab; @@ -5982,7 +5982,7 @@ ActionButton const* Player::GetActionButton(uint8 button) { ActionButtonList& currentActionButtonList = m_actionButtons[m_activeSpec]; ActionButtonList::iterator buttonItr = currentActionButtonList.find(button); - if (buttonItr==currentActionButtonList.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED) + if (buttonItr == currentActionButtonList.end() || buttonItr->second.uState == ACTIONBUTTON_DELETED) return NULL; return &buttonItr->second; @@ -5991,9 +5991,9 @@ ActionButton const* Player::GetActionButton(uint8 button) bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) { // prevent crash when a bad coord is sent by the client - if (!MaNGOS::IsValidMapCoord(x,y,z,orientation)) + if (!MaNGOS::IsValidMapCoord(x, y, z, orientation)) { - DEBUG_LOG("Player::SetPosition(%f, %f, %f, %f, %d) .. bad coordinates for player %d!",x,y,z,orientation,teleport,GetGUIDLow()); + DEBUG_LOG("Player::SetPosition(%f, %f, %f, %f, %d) .. bad coordinates for player %d!", x, y, z, orientation, teleport, GetGUIDLow()); return false; } @@ -6104,7 +6104,7 @@ void Player::CheckAreaExploreAndOutdoor() return; bool isOutdoor; - uint16 areaFlag = GetTerrain()->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ(), &isOutdoor); + uint16 areaFlag = GetTerrain()->GetAreaFlag(GetPositionX(), GetPositionY(), GetPositionZ(), &isOutdoor); if (isOutdoor) { @@ -6121,13 +6121,13 @@ void Player::CheckAreaExploreAndOutdoor() else if (sWorld.getConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK) && !isGameMaster()) RemoveAurasWithAttribute(SPELL_ATTR_OUTDOORS_ONLY); - if (areaFlag==0xffff) + if (areaFlag == 0xffff) return; int offset = areaFlag / 32; if (offset >= PLAYER_EXPLORED_ZONES_SIZE) { - sLog.outError("Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < %u ).",areaFlag,GetPositionX(),GetPositionY(),offset,offset, PLAYER_EXPLORED_ZONES_SIZE); + sLog.outError("Wrong area flag %u in map data for (X: %f Y: %f) point to field PLAYER_EXPLORED_ZONES_1 + %u ( %u must be < %u ).", areaFlag, GetPositionX(), GetPositionY(), offset, offset, PLAYER_EXPLORED_ZONES_SIZE); return; } @@ -6140,17 +6140,17 @@ void Player::CheckAreaExploreAndOutdoor() GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EXPLORE_AREA); - AreaTableEntry const* p = GetAreaEntryByAreaFlagAndMap(areaFlag,GetMapId()); + AreaTableEntry const* p = GetAreaEntryByAreaFlagAndMap(areaFlag, GetMapId()); if (!p) { - sLog.outError("PLAYER: Player %u discovered unknown area (x: %f y: %f map: %u", GetGUIDLow(), GetPositionX(),GetPositionY(),GetMapId()); + sLog.outError("PLAYER: Player %u discovered unknown area (x: %f y: %f map: %u", GetGUIDLow(), GetPositionX(), GetPositionY(), GetMapId()); } else if (p->area_level > 0) { uint32 area = p->ID; if (getLevel() >= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { - SendExplorationExperience(area,0); + SendExplorationExperience(area, 0); } else { @@ -6158,25 +6158,25 @@ void Player::CheckAreaExploreAndOutdoor() uint32 XP = 0; if (diff < -5) { - XP = uint32(sObjectMgr.GetBaseXP(getLevel()+5)*sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE)); + XP = uint32(sObjectMgr.GetBaseXP(getLevel() + 5) * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE)); } else if (diff > 5) { - int32 exploration_percent = (100-((diff-5)*5)); + int32 exploration_percent = (100 - ((diff - 5) * 5)); if (exploration_percent > 100) exploration_percent = 100; else if (exploration_percent < 0) exploration_percent = 0; - XP = uint32(sObjectMgr.GetBaseXP(p->area_level)*exploration_percent/100*sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE)); + XP = uint32(sObjectMgr.GetBaseXP(p->area_level) * exploration_percent / 100 * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE)); } else { - XP = uint32(sObjectMgr.GetBaseXP(p->area_level)*sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE)); + XP = uint32(sObjectMgr.GetBaseXP(p->area_level) * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_EXPLORE)); } GiveXP(XP, NULL); - SendExplorationExperience(area,XP); + SendExplorationExperience(area, XP); } DETAIL_LOG("PLAYER: Player %u discovered a new area: %u", GetGUIDLow(), area); } @@ -6188,7 +6188,7 @@ Team Player::TeamForRace(uint8 race) ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); if (!rEntry) { - sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); + sLog.outError("Race %u not found in DBC: wrong DBC files?", uint32(race)); return ALLIANCE; } @@ -6198,7 +6198,7 @@ Team Player::TeamForRace(uint8 race) case 1: return HORDE; } - sLog.outError("Race %u have wrong teamid %u in DBC: wrong DBC files?",uint32(race),rEntry->TeamID); + sLog.outError("Race %u have wrong teamid %u in DBC: wrong DBC files?", uint32(race), rEntry->TeamID); return TEAM_NONE; } @@ -6207,7 +6207,7 @@ uint32 Player::getFactionForRace(uint8 race) ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race); if (!rEntry) { - sLog.outError("Race %u not found in DBC: wrong DBC files?",uint32(race)); + sLog.outError("Race %u not found in DBC: wrong DBC files?", uint32(race)); return 0; } @@ -6284,7 +6284,7 @@ int32 Player::CalculateReputationGain(ReputationSource source, int32 rep, int32 percent *= repRate; } - return int32(sWorld.getConfig(CONFIG_FLOAT_RATE_REPUTATION_GAIN)*rep*percent/100.0f); + return int32(sWorld.getConfig(CONFIG_FLOAT_RATE_REPUTATION_GAIN) * rep * percent / 100.0f); } //Calculates how many reputation points player gains in victim's enemy factions @@ -6299,10 +6299,10 @@ void Player::RewardReputation(Unit* pVictim, float rate) if (!Rep) return; - if (Rep->repfaction1 && (!Rep->team_dependent || GetTeam()==ALLIANCE)) + if (Rep->repfaction1 && (!Rep->team_dependent || GetTeam() == ALLIANCE)) { int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue1, Rep->repfaction1, pVictim->getLevel()); - donerep1 = int32(donerep1*rate); + donerep1 = int32(donerep1 * rate); FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(Rep->repfaction1); uint32 current_reputation_rank1 = GetReputationMgr().GetRank(factionEntry1); if (factionEntry1 && current_reputation_rank1 <= Rep->reputation_max_cap1) @@ -6317,10 +6317,10 @@ void Player::RewardReputation(Unit* pVictim, float rate) } } - if (Rep->repfaction2 && (!Rep->team_dependent || GetTeam()==HORDE)) + if (Rep->repfaction2 && (!Rep->team_dependent || GetTeam() == HORDE)) { int32 donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, Rep->repvalue2, Rep->repfaction2, pVictim->getLevel()); - donerep2 = int32(donerep2*rate); + donerep2 = int32(donerep2 * rate); FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(Rep->repfaction2); uint32 current_reputation_rank2 = GetReputationMgr().GetRank(factionEntry2); if (factionEntry2 && current_reputation_rank2 <= Rep->reputation_max_cap2) @@ -6348,7 +6348,7 @@ void Player::RewardReputation(Quest const* pQuest) // No diplomacy mod are applied to the final value (flat). Note the formula (finalValue = DBvalue/100) if (pQuest->RewRepValue[i]) { - int32 rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, pQuest->RewRepValue[i]/100, pQuest->RewRepFaction[i], GetQuestLevelForPlayer(pQuest), true); + int32 rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, pQuest->RewRepValue[i] / 100, pQuest->RewRepFaction[i], GetQuestLevelForPlayer(pQuest), true); if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(pQuest->RewRepFaction[i])) GetReputationMgr().ModifyReputation(factionEntry, rep); @@ -6400,7 +6400,7 @@ void Player::UpdateHonorFields() // this is the first update today, reset today's contribution SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, 0); - SetUInt32Value(PLAYER_FIELD_KILLS, MAKE_PAIR32(0,kills_today)); + SetUInt32Value(PLAYER_FIELD_KILLS, MAKE_PAIR32(0, kills_today)); } else { @@ -6484,14 +6484,14 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) k_grey = MaNGOS::XP::GetGrayLevel(k_level); - if (v_level<=k_grey) + if (v_level <= k_grey) return false; float diff_level = (k_level == k_grey) ? 1 : ((float(v_level) - float(k_grey)) / (float(k_level) - float(k_grey))); - int32 v_rank =1; //need more info + int32 v_rank = 1; //need more info - honor = ((f * diff_level * (190 + v_rank*10))/6); + honor = ((f * diff_level * (190 + v_rank * 10)) / 6); honor *= float(k_level) / 70.0f; //factor of dependence on levels of the killer // count the number of playerkills in one day @@ -6517,12 +6517,12 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, float honor) if (uVictim != NULL) { honor *= sWorld.getConfig(CONFIG_FLOAT_RATE_HONOR); - honor *= (GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN) + 100.0f)/100.0f; + honor *= (GetMaxPositiveAuraModifier(SPELL_AURA_MOD_HONOR_GAIN) + 100.0f) / 100.0f; if (groupsize > 1) honor /= groupsize; - honor *= (((float)urand(8,12))/10); // approx honor: 80% - 120% of real honor + honor *= (((float)urand(8, 12)) / 10); // approx honor: 80% - 120% of real honor } // honor - for show honor points in log @@ -6639,7 +6639,7 @@ uint32 Player::GetZoneIdFromDB(ObjectGuid guid) float posz = fields[3].GetFloat(); delete result; - zone = sTerrainMgr.GetZoneId(map,posx,posy,posz); + zone = sTerrainMgr.GetZoneId(map, posx, posy, posz); if (zone > 0) CharacterDatabase.PExecute("UPDATE characters SET zone='%u' WHERE guid='%u'", zone, lowguid); @@ -6761,7 +6761,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea) } else // in friendly area { - if (IsPvP() && !HasFlag(PLAYER_FLAGS,PLAYER_FLAGS_IN_PVP) && pvpInfo.endTimer == 0) + if (IsPvP() && !HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP) && pvpInfo.endTimer == 0) pvpInfo.endTimer = time(0); // start toggle-off } @@ -6834,7 +6834,7 @@ void Player::CheckDuelDistance(time_t currTime) WorldPacket data(SMSG_DUEL_INBOUNDS, 0); GetSession()->SendPacket(&data); } - else if (currTime >= (duel->outOfBound+10)) + else if (currTime >= (duel->outOfBound + 10)) { DuelComplete(DUEL_FLED); } @@ -6854,11 +6854,11 @@ void Player::DuelComplete(DuelCompleteType type) if (type != DUEL_INTERUPTED) { - data.Initialize(SMSG_DUEL_WINNER, (1+20)); // we guess size - data << (uint8)((type==DUEL_WON) ? 0 : 1); // 0 = just won; 1 = fled + data.Initialize(SMSG_DUEL_WINNER, (1 + 20)); // we guess size + data << (uint8)((type == DUEL_WON) ? 0 : 1); // 0 = just won; 1 = fled data << duel->opponent->GetName(); data << GetName(); - SendMessageToSet(&data,true); + SendMessageToSet(&data, true); } if (type == DUEL_WON) @@ -6881,7 +6881,7 @@ void Player::DuelComplete(DuelCompleteType type) auras2remove.push_back(i->second->GetId()); } - for (size_t i=0; iopponent->RemoveAurasDueToSpell(auras2remove[i]); auras2remove.clear(); @@ -6891,7 +6891,7 @@ void Player::DuelComplete(DuelCompleteType type) if (!i->second->IsPositive() && i->second->GetCasterGuid() == duel->opponent->GetObjectGuid() && i->second->GetAuraApplyTime() >= duel->startTime) auras2remove.push_back(i->second->GetId()); } - for (size_t i=0; i= INVENTORY_SLOT_BAG_END || !item) return; @@ -6933,18 +6933,18 @@ void Player::_ApplyItemMods(Item* item, uint8 slot,bool apply) if (!proto) return; - DETAIL_LOG("applying mods for item %u ",item->GetGUIDLow()); + DETAIL_LOG("applying mods for item %u ", item->GetGUIDLow()); uint32 attacktype = Player::GetAttackBySlot(slot); if (attacktype < MAX_ATTACK) - _ApplyWeaponDependentAuraMods(item,WeaponAttackType(attacktype),apply); + _ApplyWeaponDependentAuraMods(item, WeaponAttackType(attacktype), apply); - _ApplyItemBonuses(proto,slot,apply); + _ApplyItemBonuses(proto, slot, apply); - if (slot==EQUIPMENT_SLOT_RANGED) + if (slot == EQUIPMENT_SLOT_RANGED) _ApplyAmmoBonuses(); - ApplyItemEquipSpell(item,apply); + ApplyItemEquipSpell(item, apply); ApplyEnchantment(item, apply); if (proto->Socket[0].Color) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items @@ -7207,7 +7207,7 @@ void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool appl { attType = RANGED_ATTACK; } - else if (slot==EQUIPMENT_SLOT_OFFHAND) + else if (slot == EQUIPMENT_SLOT_OFFHAND) { attType = OFF_ATTACK; } @@ -7258,30 +7258,30 @@ void Player::_ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool appl if (proto->Delay) { if (slot == EQUIPMENT_SLOT_RANGED) - SetAttackTime(RANGED_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); - else if (slot==EQUIPMENT_SLOT_MAINHAND) - SetAttackTime(BASE_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); - else if (slot==EQUIPMENT_SLOT_OFFHAND) - SetAttackTime(OFF_ATTACK, apply ? proto->Delay: BASE_ATTACK_TIME); + SetAttackTime(RANGED_ATTACK, apply ? proto->Delay : BASE_ATTACK_TIME); + else if (slot == EQUIPMENT_SLOT_MAINHAND) + SetAttackTime(BASE_ATTACK, apply ? proto->Delay : BASE_ATTACK_TIME); + else if (slot == EQUIPMENT_SLOT_OFFHAND) + SetAttackTime(OFF_ATTACK, apply ? proto->Delay : BASE_ATTACK_TIME); } if (CanModifyStats() && (damage || proto->Delay)) UpdateDamagePhysical(attType); } -void Player::_ApplyWeaponDependentAuraMods(Item* item,WeaponAttackType attackType,bool apply) +void Player::_ApplyWeaponDependentAuraMods(Item* item, WeaponAttackType attackType, bool apply) { AuraList const& auraCritList = GetAurasByType(SPELL_AURA_MOD_CRIT_PERCENT); - for (AuraList::const_iterator itr = auraCritList.begin(); itr!=auraCritList.end(); ++itr) - _ApplyWeaponDependentAuraCritMod(item,attackType,*itr,apply); + for (AuraList::const_iterator itr = auraCritList.begin(); itr != auraCritList.end(); ++itr) + _ApplyWeaponDependentAuraCritMod(item, attackType, *itr, apply); AuraList const& auraDamageFlatList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); - for (AuraList::const_iterator itr = auraDamageFlatList.begin(); itr!=auraDamageFlatList.end(); ++itr) - _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); + for (AuraList::const_iterator itr = auraDamageFlatList.begin(); itr != auraDamageFlatList.end(); ++itr) + _ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply); AuraList const& auraDamagePCTList = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); - for (AuraList::const_iterator itr = auraDamagePCTList.begin(); itr!=auraDamagePCTList.end(); ++itr) - _ApplyWeaponDependentAuraDamageMod(item,attackType,*itr,apply); + for (AuraList::const_iterator itr = auraDamagePCTList.begin(); itr != auraDamagePCTList.end(); ++itr) + _ApplyWeaponDependentAuraDamageMod(item, attackType, *itr, apply); } void Player::_ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attackType, Aura* aura, bool apply) @@ -7309,7 +7309,7 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType att { // ignore spell mods for not wands Modifier const* modifier = aura->GetModifier(); - if ((modifier->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)==0 && (getClassMask() & CLASSMASK_WAND_USERS)==0) + if ((modifier->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) == 0 && (getClassMask() & CLASSMASK_WAND_USERS) == 0) return; // generic not weapon specific case processes in aura code @@ -7335,7 +7335,7 @@ void Player::_ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType att if (item->IsFitToSpellRequirements(aura->GetSpellProto())) { - HandleStatModifier(unitMod, unitModType, float(modifier->m_amount),apply); + HandleStatModifier(unitMod, unitModType, float(modifier->m_amount), apply); } } @@ -7376,7 +7376,7 @@ void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change) if (!spellproto) continue; - ApplyEquipSpell(spellproto,item,apply,form_change); + ApplyEquipSpell(spellproto, item, apply, form_change); } } @@ -7391,7 +7391,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply if (form_change) // check aura active state from other form { bool found = false; - for (int k=0; k < MAX_EFFECT_INDEX; ++k) + for (int k = 0; k < MAX_EFFECT_INDEX; ++k) { SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellInfo->Id); for (SpellAuraHolderMap::const_iterator iter = spair.first; iter != spair.second; ++iter) @@ -7412,7 +7412,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply DEBUG_LOG("WORLD: cast %s Equip spellId - %i", (item ? "item" : "itemset"), spellInfo->Id); - CastSpell(this,spellInfo,true,item); + CastSpell(this, spellInfo, true, item); } else { @@ -7424,7 +7424,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply } if (item) - RemoveAurasDueToItemSpell(item,spellInfo->Id); // un-apply all spells , not only at-equipped + RemoveAurasDueToItemSpell(item, spellInfo->Id); // un-apply all spells , not only at-equipped else RemoveAurasDueToSpell(spellInfo->Id); // un-apply spell (item set case) } @@ -7436,8 +7436,8 @@ void Player::UpdateEquipSpellsAtFormChange() { if (m_items[i] && !m_items[i]->IsBroken()) { - ApplyItemEquipSpell(m_items[i],false,true); // remove spells that not fit to form - ApplyItemEquipSpell(m_items[i],true,true); // add spells that fit form but not active + ApplyItemEquipSpell(m_items[i], false, true); // remove spells that not fit to form + ApplyItemEquipSpell(m_items[i], true, true); // add spells that fit form but not active } } @@ -7448,14 +7448,14 @@ void Player::UpdateEquipSpellsAtFormChange() if (!eff) continue; - for (uint32 y=0; y<8; ++y) + for (uint32 y = 0; y < 8; ++y) { SpellEntry const* spellInfo = eff->spells[y]; if (!spellInfo) continue; - ApplyEquipSpell(spellInfo,NULL,false,true); // remove spells that not fit to form - ApplyEquipSpell(spellInfo,NULL,true,true); // add spells that fit form but not active + ApplyEquipSpell(spellInfo, NULL, false, true); // remove spells that not fit to form + ApplyEquipSpell(spellInfo, NULL, true, true); // add spells that fit form but not active } } } @@ -7604,7 +7604,7 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) } // not allow proc extra attack spell at extra attack - if (m_extraAttacks && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_ADD_EXTRA_ATTACKS)) + if (m_extraAttacks && IsSpellHaveEffect(spellInfo, SPELL_EFFECT_ADD_EXTRA_ATTACKS)) return; float chance = (float)spellInfo->procChance; @@ -7651,8 +7651,8 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) : pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance(); - ApplySpellMod(spellInfo->Id,SPELLMOD_CHANCE_OF_SUCCESS, chance); - ApplySpellMod(spellInfo->Id,SPELLMOD_FREQUENCY_OF_SUCCESS, chance); + ApplySpellMod(spellInfo->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance); + ApplySpellMod(spellInfo->Id, SPELLMOD_FREQUENCY_OF_SUCCESS, chance); if (roll_chance_f(chance)) { @@ -7671,11 +7671,11 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType) } } -void Player::CastItemUseSpell(Item* item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex) +void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex) { ItemPrototype const* proto = item->GetProto(); // special learning case - if (proto->Spells[0].SpellId==SPELL_ID_GENERIC_LEARN || proto->Spells[0].SpellId==SPELL_ID_GENERIC_LEARN_PET) + if (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN || proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET) { uint32 learn_spell_id = proto->Spells[0].SpellId; uint32 learning_spell_id = proto->Spells[1].SpellId; @@ -7683,7 +7683,7 @@ void Player::CastItemUseSpell(Item* item,SpellCastTargets const& targets,uint8 c SpellEntry const* spellInfo = sSpellStore.LookupEntry(learn_spell_id); if (!spellInfo) { - sLog.outError("Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring ",proto->ItemId, learn_spell_id); + sLog.outError("Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring ", proto->ItemId, learn_spell_id); SendEquipError(EQUIP_ERR_NONE, item); return; } @@ -7715,7 +7715,7 @@ void Player::CastItemUseSpell(Item* item,SpellCastTargets const& targets,uint8 c SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellData.SpellId); if (!spellInfo) { - sLog.outError("Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring",proto->ItemId, spellData.SpellId); + sLog.outError("Player::CastItemUseSpell: Item (Entry: %u) in have wrong spell id %u, ignoring", proto->ItemId, spellData.SpellId); continue; } @@ -7738,7 +7738,7 @@ void Player::CastItemUseSpell(Item* item,SpellCastTargets const& targets,uint8 c for (int s = 0; s < 3; ++s) { - if (pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_USE_SPELL) + if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_USE_SPELL) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(pEnchant->spellid[s]); @@ -7773,12 +7773,12 @@ void Player::_RemoveAllItemMods() // item set bonuses not dependent from item broken state if (proto->ItemSet) - RemoveItemsSetItem(this,proto); + RemoveItemsSetItem(this, proto); if (m_items[i]->IsBroken()) continue; - ApplyItemEquipSpell(m_items[i],false); + ApplyItemEquipSpell(m_items[i], false); ApplyEnchantment(m_items[i], false); } } @@ -7795,9 +7795,9 @@ void Player::_RemoveAllItemMods() uint32 attacktype = Player::GetAttackBySlot(i); if (attacktype < MAX_ATTACK) - _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),false); + _ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), false); - _ApplyItemBonuses(proto,i, false); + _ApplyItemBonuses(proto, i, false); if (i == EQUIPMENT_SLOT_RANGED) _ApplyAmmoBonuses(); @@ -7824,9 +7824,9 @@ void Player::_ApplyAllItemMods() uint32 attacktype = Player::GetAttackBySlot(i); if (attacktype < MAX_ATTACK) - _ApplyWeaponDependentAuraMods(m_items[i],WeaponAttackType(attacktype),true); + _ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), true); - _ApplyItemBonuses(proto,i, true); + _ApplyItemBonuses(proto, i, true); if (i == EQUIPMENT_SLOT_RANGED) _ApplyAmmoBonuses(); @@ -7843,12 +7843,12 @@ void Player::_ApplyAllItemMods() // item set bonuses not dependent from item broken state if (proto->ItemSet) - AddItemsSetItem(this,m_items[i]); + AddItemsSetItem(this, m_items[i]); if (m_items[i]->IsBroken()) continue; - ApplyItemEquipSpell(m_items[i],true); + ApplyItemEquipSpell(m_items[i], true); ApplyEnchantment(m_items[i], true); } } @@ -7869,7 +7869,7 @@ void Player::_ApplyAllLevelScaleItemMods(bool apply) if (!proto) continue; - _ApplyItemBonuses(proto,i, apply, true); + _ApplyItemBonuses(proto, i, apply, true); } } } @@ -7884,7 +7884,7 @@ void Player::_ApplyAmmoBonuses() float currentAmmoDPS; ItemPrototype const* ammo_proto = ObjectMgr::GetItemPrototype(ammo_id); - if (!ammo_proto || ammo_proto->Class!=ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) + if (!ammo_proto || ammo_proto->Class != ITEM_CLASS_PROJECTILE || !CheckAmmoCompatibility(ammo_proto)) currentAmmoDPS = 0.0f; else currentAmmoDPS = ammo_proto->Damage[0].DamageMin; @@ -7909,7 +7909,7 @@ bool Player::CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const return false; ItemPrototype const* weapon_proto = weapon->GetProto(); - if (!weapon_proto || weapon_proto->Class!=ITEM_CLASS_WEAPON) + if (!weapon_proto || weapon_proto->Class != ITEM_CLASS_WEAPON) return false; // check ammo ws. weapon compatibility @@ -7917,11 +7917,11 @@ bool Player::CheckAmmoCompatibility(const ItemPrototype* ammo_proto) const { case ITEM_SUBCLASS_WEAPON_BOW: case ITEM_SUBCLASS_WEAPON_CROSSBOW: - if (ammo_proto->SubClass!=ITEM_SUBCLASS_ARROW) + if (ammo_proto->SubClass != ITEM_SUBCLASS_ARROW) return false; break; case ITEM_SUBCLASS_WEAPON_GUN: - if (ammo_proto->SubClass!=ITEM_SUBCLASS_BULLET) + if (ammo_proto->SubClass != ITEM_SUBCLASS_BULLET) return false; break; default: @@ -7968,7 +7968,7 @@ void Player::RemovedInsignia(Player* looterPlr) void Player::SendLootRelease(ObjectGuid guid) { - WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8+1)); + WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8 + 1)); data << guid; data << uint8(1); SendDirectMessage(&data); @@ -7992,7 +7992,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // not check distance for GO in case owned GO (fishing bobber case, for example) // And permit out of range GO with no owner in case fishing hole - if (!go || (loot_type != LOOT_FISHINGHOLE && (loot_type != LOOT_FISHING && loot_type != LOOT_FISHING_FAIL || go->GetOwnerGuid() != GetObjectGuid()) && !go->IsWithinDistInMap(this,INTERACTION_DISTANCE))) + if (!go || (loot_type != LOOT_FISHINGHOLE && (loot_type != LOOT_FISHING && loot_type != LOOT_FISHING_FAIL || go->GetOwnerGuid() != GetObjectGuid()) && !go->IsWithinDistInMap(this, INTERACTION_DISTANCE))) { SendLootRelease(guid); return; @@ -8059,7 +8059,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) } } else if (loot_type == LOOT_FISHING) - go->getFishLoot(loot,this); + go->getFishLoot(loot, this); go->SetLootState(GO_ACTIVATED); } @@ -8153,7 +8153,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) loot->FillLoot(0, LootTemplates_Creature, this, false); // It may need a better formula // Now it works like this: lvl10: ~6copper, lvl70: ~9silver - bones->loot.gold = (uint32)(urand(50, 150) * 0.016f * pow(((float)pLevel)/5.76f, 2.5f) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); + bones->loot.gold = (uint32)(urand(50, 150) * 0.016f * pow(((float)pLevel) / 5.76f, 2.5f) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); } if (bones->lootRecipient != this) @@ -8168,7 +8168,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) Creature* creature = GetMap()->GetCreature(guid); // must be in range and creature must be alive for pickpocket and must be dead for another loot - if (!creature || creature->isAlive()!=(loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this,INTERACTION_DISTANCE)) + if (!creature || creature->isAlive() != (loot_type == LOOT_PICKPOCKETING) || !creature->IsWithinDistInMap(this, INTERACTION_DISTANCE)) { SendLootRelease(guid); return; @@ -8193,8 +8193,8 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) loot->FillLoot(lootid, LootTemplates_Pickpocketing, this, false); // Generate extra money for pick pocket loot - const uint32 a = urand(0, creature->getLevel()/2); - const uint32 b = urand(0, getLevel()/2); + const uint32 a = urand(0, creature->getLevel() / 2); + const uint32 b = urand(0, getLevel() / 2); loot->gold = uint32(10 * (a + b) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); permission = OWNER_PERMISSION; } @@ -8223,11 +8223,11 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) if (uint32 lootid = creature->GetCreatureInfo()->lootid) loot->FillLoot(lootid, LootTemplates_Creature, recipient, false); - loot->generateMoneyLoot(creature->GetCreatureInfo()->mingold,creature->GetCreatureInfo()->maxgold); + loot->generateMoneyLoot(creature->GetCreatureInfo()->mingold, creature->GetCreatureInfo()->maxgold); if (Group* group = creature->GetGroupLootRecipient()) { - group->UpdateLooterGuid(creature,true); + group->UpdateLooterGuid(creature, true); switch (group->GetLootMethod()) { @@ -8314,7 +8314,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type) // need know merged fishing/corpse loot type for achievements loot->loot_type = loot_type; - WorldPacket data(SMSG_LOOT_RESPONSE, (9+50)); // we guess size + WorldPacket data(SMSG_LOOT_RESPONSE, (9 + 50)); // we guess size data << ObjectGuid(guid); data << uint8(loot_type); data << LootView(*loot, this, permission); @@ -8439,8 +8439,8 @@ static WorldStatePair WS_world_states[] = { 0x641, 0x3 }, // 1601 12 unk (max flag captures?) { 0x922, 0x1 }, // 2338 13 horde (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) { 0x923, 0x1 }, // 2339 14 alliance (0 - hide, 1 - flag ok, 2 - flag picked up (flashing), 3 - flag picked up (not flashing) - { 0x1097,0x1 }, // 4247 15 show time limit? - { 0x1098,0x19 }, // 4248 16 time remaining in minutes + { 0x1097, 0x1 }, // 4247 15 show time limit? + { 0x1098, 0x19 }, // 4248 16 time remaining in minutes { 0x0, 0x0 } }; @@ -8610,7 +8610,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) uint32 count = 0; // count of world states in packet - WorldPacket data(SMSG_INIT_WORLD_STATES, (4+4+4+2+8*8));// guess + WorldPacket data(SMSG_INIT_WORLD_STATES, (4 + 4 + 4 + 2 + 8 * 8)); // guess data << uint32(mapid); // mapid data << uint32(zoneid); // zone id data << uint32(areaid); // area id, new 2.1.0 @@ -8654,43 +8654,43 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) if (bg && bg->GetTypeID() == BATTLEGROUND_AV) bg->FillInitialWorldStates(data, count); else - FillInitialWorldState(data,count, AV_world_states); + FillInitialWorldState(data, count, AV_world_states); break; case 3277: // WS if (bg && bg->GetTypeID() == BATTLEGROUND_WS) bg->FillInitialWorldStates(data, count); else - FillInitialWorldState(data,count, WS_world_states); + FillInitialWorldState(data, count, WS_world_states); break; case 3358: // AB if (bg && bg->GetTypeID() == BATTLEGROUND_AB) bg->FillInitialWorldStates(data, count); else - FillInitialWorldState(data,count, AB_world_states); + FillInitialWorldState(data, count, AB_world_states); break; case 3820: // EY if (bg && bg->GetTypeID() == BATTLEGROUND_EY) bg->FillInitialWorldStates(data, count); else - FillInitialWorldState(data,count, EY_world_states); + FillInitialWorldState(data, count, EY_world_states); break; case 3483: // Hellfire Peninsula - FillInitialWorldState(data,count, HP_world_states); + FillInitialWorldState(data, count, HP_world_states); break; case 3519: // Terokkar Forest - FillInitialWorldState(data,count, TF_world_states); + FillInitialWorldState(data, count, TF_world_states); break; case 3521: // Zangarmarsh - FillInitialWorldState(data,count, ZM_world_states); + FillInitialWorldState(data, count, ZM_world_states); break; case 3698: // Nagrand Arena if (bg && bg->GetTypeID() == BATTLEGROUND_NA) bg->FillInitialWorldStates(data, count); else { - FillInitialWorldState(data,count,0xa0f,0x0);// 2575 7 - FillInitialWorldState(data,count,0xa10,0x0);// 2576 8 - FillInitialWorldState(data,count,0xa11,0x0);// 2577 9 show + FillInitialWorldState(data, count, 0xa0f, 0x0); // 2575 7 + FillInitialWorldState(data, count, 0xa10, 0x0); // 2576 8 + FillInitialWorldState(data, count, 0xa11, 0x0); // 2577 9 show } break; case 3702: // Blade's Edge Arena @@ -8698,9 +8698,9 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) bg->FillInitialWorldStates(data, count); else { - FillInitialWorldState(data,count,0x9f0,0x0);// 2544 7 gold - FillInitialWorldState(data,count,0x9f1,0x0);// 2545 8 green - FillInitialWorldState(data,count,0x9f3,0x0);// 2547 9 show + FillInitialWorldState(data, count, 0x9f0, 0x0); // 2544 7 gold + FillInitialWorldState(data, count, 0x9f1, 0x0); // 2545 8 green + FillInitialWorldState(data, count, 0x9f3, 0x0); // 2547 9 show } break; case 3968: // Ruins of Lordaeron @@ -8708,24 +8708,24 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) bg->FillInitialWorldStates(data, count); else { - FillInitialWorldState(data,count,0xbb8,0x0);// 3000 7 gold - FillInitialWorldState(data,count,0xbb9,0x0);// 3001 8 green - FillInitialWorldState(data,count,0xbba,0x0);// 3002 9 show + FillInitialWorldState(data, count, 0xbb8, 0x0); // 3000 7 gold + FillInitialWorldState(data, count, 0xbb9, 0x0); // 3001 8 green + FillInitialWorldState(data, count, 0xbba, 0x0); // 3002 9 show } break; case 3703: // Shattrath City break; default: - FillInitialWorldState(data,count, 0x914, 0x0); // 2324 7 - FillInitialWorldState(data,count, 0x913, 0x0); // 2323 8 - FillInitialWorldState(data,count, 0x912, 0x0); // 2322 9 - FillInitialWorldState(data,count, 0x915, 0x0); // 2325 10 + FillInitialWorldState(data, count, 0x914, 0x0); // 2324 7 + FillInitialWorldState(data, count, 0x913, 0x0); // 2323 8 + FillInitialWorldState(data, count, 0x912, 0x0); // 2322 9 + FillInitialWorldState(data, count, 0x915, 0x0); // 2325 10 break; } - FillBGWeekendWorldStates(data,count); + FillBGWeekendWorldStates(data, count); - data.put(count_pos,count); // set actual world state amount + data.put(count_pos, count); // set actual world state amount GetSession()->SendPacket(&data); } @@ -8754,7 +8754,7 @@ uint32 Player::GetXPRestBonus(uint32 xp) SetRestBonus(GetRestBonus() - rested_bonus); - DETAIL_LOG("Player gain %u xp (+ %u Rested Bonus). Rested points=%f",xp+rested_bonus,rested_bonus,GetRestBonus()); + DETAIL_LOG("Player gain %u xp (+ %u Rested Bonus). Rested points=%f", xp + rested_bonus, rested_bonus, GetRestBonus()); return rested_bonus; } @@ -8767,7 +8767,7 @@ void Player::SetBindPoint(ObjectGuid guid) void Player::SendTalentWipeConfirm(ObjectGuid guid) { - WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4)); + WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8 + 4)); data << ObjectGuid(guid); data << uint32(resetTalentsCost()); GetSession()->SendPacket(&data); @@ -8778,7 +8778,7 @@ void Player::SendPetSkillWipeConfirm() Pet* pet = GetPet(); if (!pet) return; - WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8+4)); + WorldPacket data(SMSG_PET_UNLEARN_CONFIRM, (8 + 4)); data << ObjectGuid(pet->GetObjectGuid()); data << uint32(pet->resetTalentsCost()); GetSession()->SendPacket(&data); @@ -8799,10 +8799,10 @@ void Player::SetVirtualItemSlot(uint8 i, Item* item) if (charges == 0) return; if (charges > 1) - item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT,charges-1); + item->SetEnchantmentCharges(TEMP_ENCHANTMENT_SLOT, charges - 1); else if (charges <= 1) { - ApplyEnchantment(item,TEMP_ENCHANTMENT_SLOT,false); + ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, false); item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT); } } @@ -8813,25 +8813,25 @@ void Player::SetSheath(SheathState sheathed) switch (sheathed) { case SHEATH_STATE_UNARMED: // no prepared weapon - SetVirtualItemSlot(0,NULL); - SetVirtualItemSlot(1,NULL); - SetVirtualItemSlot(2,NULL); + SetVirtualItemSlot(0, NULL); + SetVirtualItemSlot(1, NULL); + SetVirtualItemSlot(2, NULL); break; case SHEATH_STATE_MELEE: // prepared melee weapon { - SetVirtualItemSlot(0,GetWeaponForAttack(BASE_ATTACK,true,true)); - SetVirtualItemSlot(1,GetWeaponForAttack(OFF_ATTACK,true,true)); - SetVirtualItemSlot(2,NULL); + SetVirtualItemSlot(0, GetWeaponForAttack(BASE_ATTACK, true, true)); + SetVirtualItemSlot(1, GetWeaponForAttack(OFF_ATTACK, true, true)); + SetVirtualItemSlot(2, NULL); }; break; case SHEATH_STATE_RANGED: // prepared ranged weapon - SetVirtualItemSlot(0,NULL); - SetVirtualItemSlot(1,NULL); - SetVirtualItemSlot(2,GetWeaponForAttack(RANGED_ATTACK,true,true)); + SetVirtualItemSlot(0, NULL); + SetVirtualItemSlot(1, NULL); + SetVirtualItemSlot(2, GetWeaponForAttack(RANGED_ATTACK, true, true)); break; default: - SetVirtualItemSlot(0,NULL); - SetVirtualItemSlot(1,NULL); - SetVirtualItemSlot(2,NULL); + SetVirtualItemSlot(0, NULL); + SetVirtualItemSlot(1, NULL); + SetVirtualItemSlot(2, NULL); break; } Unit::SetSheath(sheathed); // this must visualize Sheath changing for other players... @@ -8987,7 +8987,7 @@ uint8 Player::FindEquipSlot(ItemPrototype const* proto, uint32 slot, bool swap) if (slots[i] != NULL_SLOT && !GetItemByPos(INVENTORY_SLOT_BAG_0, slots[i])) { // in case 2hand equipped weapon (without titan grip) offhand slot empty but not free - if (slots[i]!=EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed()) + if (slots[i] != EQUIPMENT_SLOT_OFFHAND || !IsTwoHandUsed()) return slots[i]; } } @@ -9089,7 +9089,7 @@ uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const { Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pBag) - count += pBag->GetItemCount(item,skipItem); + count += pBag->GetItemCount(item, skipItem); } if (skipItem && skipItem->GetProto()->GemProperties) @@ -9114,7 +9114,7 @@ uint32 Player::GetItemCount(uint32 item, bool inBankAlso, Item* skipItem) const { Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pBag) - count += pBag->GetItemCount(item,skipItem); + count += pBag->GetItemCount(item, skipItem); } if (skipItem && skipItem->GetProto()->GemProperties) @@ -9509,7 +9509,7 @@ bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_ uint32 tempcount = 0; for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - if (i==int(except_slot)) + if (i == int(except_slot)) continue; Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); @@ -9526,7 +9526,7 @@ bool Player::HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_ { for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - if (i==int(except_slot)) + if (i == int(except_slot)) continue; Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); @@ -9547,7 +9547,7 @@ bool Player::HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 uint32 tempcount = 0; for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { - if (i==int(except_slot)) + if (i == int(except_slot)) continue; Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); @@ -9594,7 +9594,7 @@ InventoryResult Player::_CanTakeMoreSimilarItems(uint32 entry, uint32 count, Ite if (curcount + count > uint32(pProto->MaxCount)) { if (no_space_count) - *no_space_count = count +curcount - pProto->MaxCount; + *no_space_count = count + curcount - pProto->MaxCount; return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } } @@ -9632,13 +9632,13 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) { pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory, TotemCategory)) return true; } for (uint8 i = KEYRING_SLOT_START; i < CURRENCYTOKEN_SLOT_END; ++i) { pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory, TotemCategory)) return true; } for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) @@ -9648,7 +9648,7 @@ bool Player::HasItemTotemCategory(uint32 TotemCategory) const for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { pItem = GetItemByPos(i, j); - if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory,TotemCategory)) + if (pItem && IsTotemCategoryCompatiableWith(pItem->GetProto()->TotemCategory, TotemCategory)) return true; } } @@ -9661,7 +9661,7 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, Item Item* pItem2 = GetItemByPos(bag, slot); // ignore move item (this slot will be empty at move) - if (pItem2==pSrcItem) + if (pItem2 == pSrcItem) pItem2 = NULL; uint32 need_space; @@ -9672,7 +9672,7 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, Item if (bag == INVENTORY_SLOT_BAG_0) { // keyring case - if (slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START+GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS)) + if (slot >= KEYRING_SLOT_START && slot < KEYRING_SLOT_START + GetMaxKeyringSize() && !(pProto->BagFamily & BAG_FAMILY_MASK_KEYS)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; // currencytoken case @@ -9696,7 +9696,7 @@ InventoryResult Player::_CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, Item if (slot >= pBagProto->ContainerSlots) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - if (!ItemCanGoIntoBag(pProto,pBagProto)) + if (!ItemCanGoIntoBag(pProto, pBagProto)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; } @@ -9735,7 +9735,7 @@ InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, It // skip nonexistent bag or self targeted bag Bag* pBag = (Bag*)GetItemByPos(INVENTORY_SLOT_BAG_0, bag); - if (!pBag || pBag==pSrcItem) + if (!pBag || pBag == pSrcItem) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; ItemPrototype const* pBagProto = pBag->GetProto(); @@ -9746,13 +9746,13 @@ InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, It if (non_specialized != (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; - if (!ItemCanGoIntoBag(pProto,pBagProto)) + if (!ItemCanGoIntoBag(pProto, pBagProto)) return EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG; for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot - if (j==skip_slot) + if (j == skip_slot) continue; Item* pItem2 = GetItemByPos(bag, j); @@ -9787,7 +9787,7 @@ InventoryResult Player::_CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, It dest.push_back(newPosition); count -= need_space; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } @@ -9799,7 +9799,7 @@ InventoryResult Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 s for (uint32 j = slot_begin; j < slot_end; ++j) { // skip specific slot already processed in first called _CanStoreItem_InSpecificSlot - if (INVENTORY_SLOT_BAG_0==skip_bag && j==skip_slot) + if (INVENTORY_SLOT_BAG_0 == skip_bag && j == skip_slot) continue; Item* pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, j); @@ -9834,7 +9834,7 @@ InventoryResult Player::_CanStoreItem_InInventorySlots(uint8 slot_begin, uint8 s dest.push_back(newPosition); count -= need_space; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } @@ -9850,7 +9850,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de { if (no_space_count) *no_space_count = count; - return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED :EQUIP_ERR_ITEM_NOT_FOUND; + return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_ITEM_NOT_FOUND; } if (pItem) @@ -9873,7 +9873,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de // check count of items (skip for auto move for same player from bank) uint32 no_similar_count = 0; // can't store this amount similar items - InventoryResult res = _CanTakeMoreSimilarItems(entry,count,pItem,&no_similar_count); + InventoryResult res = _CanTakeMoreSimilarItems(entry, count, pItem, &no_similar_count); if (res != EQUIP_ERR_OK) { if (count == no_similar_count) @@ -9888,7 +9888,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de // in specific slot if (bag != NULL_BAG && slot != NULL_SLOT) { - res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem); + res = _CanStoreItem_InSpecificSlot(bag, slot, dest, pProto, count, swap, pItem); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -9917,7 +9917,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de { if (bag == INVENTORY_SLOT_BAG_0) // inventory { - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,true,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -9935,7 +9935,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -9956,9 +9956,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de else // equipped bag { // we need check 2 time (specialized/non_specialized), use NULL_BAG to prevent skipping bag - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot); + res = _CanStoreItem_InBag(bag, dest, pProto, count, true, false, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot); + res = _CanStoreItem_InBag(bag, dest, pProto, count, true, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) { @@ -9986,8 +9986,8 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START + keyringSize, dest, pProto, count, false, pItem, bag, slot); + if (res != EQUIP_ERR_OK) { if (no_space_count) *no_space_count = count + no_similar_count; @@ -9996,7 +9996,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { - if (no_similar_count==0) + if (no_similar_count == 0) return EQUIP_ERR_OK; if (no_space_count) @@ -10004,7 +10004,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } - res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10024,8 +10024,8 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de } else if (pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { - res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); + if (res != EQUIP_ERR_OK) { if (no_space_count) *no_space_count = count + no_similar_count; @@ -10043,7 +10043,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de } } - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10063,9 +10063,9 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de } else // equipped bag { - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,false,pItem,NULL_BAG,slot); + res = _CanStoreItem_InBag(bag, dest, pProto, count, false, false, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,false,true,pItem,NULL_BAG,slot); + res = _CanStoreItem_InBag(bag, dest, pProto, count, false, true, pItem, NULL_BAG, slot); if (res != EQUIP_ERR_OK) { @@ -10091,7 +10091,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de // search stack for merge to if (pProto->Stackable != 1) { - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,true,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10109,7 +10109,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de return EQUIP_ERR_CANT_CARRY_MORE_OF_THIS; } - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10131,7 +10131,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de { for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); + res = _CanStoreItem_InBag(i, dest, pProto, count, true, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -10149,13 +10149,13 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); + res = _CanStoreItem_InBag(i, dest, pProto, count, true, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; if (count == 0) { - if (no_similar_count==0) + if (no_similar_count == 0) return EQUIP_ERR_OK; if (no_space_count) @@ -10171,7 +10171,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START,KEYRING_SLOT_START+keyringSize,dest,pProto,count,false,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(KEYRING_SLOT_START, KEYRING_SLOT_START + keyringSize, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10191,7 +10191,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de } else if (pProto->BagFamily & BAG_FAMILY_MASK_CURRENCY_TOKENS) { - res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START,CURRENCYTOKEN_SLOT_END,dest,pProto,count,false,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(CURRENCYTOKEN_SLOT_START, CURRENCYTOKEN_SLOT_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10212,13 +10212,13 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); + res = _CanStoreItem_InBag(i, dest, pProto, count, false, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; if (count == 0) { - if (no_similar_count==0) + if (no_similar_count == 0) return EQUIP_ERR_OK; if (no_space_count) @@ -10233,7 +10233,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de return EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG; // search free slot - res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START,INVENTORY_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(INVENTORY_SLOT_ITEM_START, INVENTORY_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); if (res != EQUIP_ERR_OK) { if (no_space_count) @@ -10243,7 +10243,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de if (count == 0) { - if (no_similar_count==0) + if (no_similar_count == 0) return EQUIP_ERR_OK; if (no_space_count) @@ -10253,7 +10253,7 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); + res = _CanStoreItem_InBag(i, dest, pProto, count, false, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) continue; @@ -10275,20 +10275,20 @@ InventoryResult Player::_CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& de } ////////////////////////////////////////////////////////////////////////// -InventoryResult Player::CanStoreItems(Item** pItems,int count) const +InventoryResult Player::CanStoreItems(Item** pItems, int count) const { Item* pItem2; // fill space table - int inv_slot_items[INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START]; - int inv_bags[INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START][MAX_BAG_SIZE]; - int inv_keys[KEYRING_SLOT_END-KEYRING_SLOT_START]; - int inv_tokens[CURRENCYTOKEN_SLOT_END-CURRENCYTOKEN_SLOT_START]; + int inv_slot_items[INVENTORY_SLOT_ITEM_END - INVENTORY_SLOT_ITEM_START]; + int inv_bags[INVENTORY_SLOT_BAG_END - INVENTORY_SLOT_BAG_START][MAX_BAG_SIZE]; + int inv_keys[KEYRING_SLOT_END - KEYRING_SLOT_START]; + int inv_tokens[CURRENCYTOKEN_SLOT_END - CURRENCYTOKEN_SLOT_START]; - memset(inv_slot_items,0,sizeof(int)*(INVENTORY_SLOT_ITEM_END-INVENTORY_SLOT_ITEM_START)); - memset(inv_bags,0,sizeof(int)*(INVENTORY_SLOT_BAG_END-INVENTORY_SLOT_BAG_START)*MAX_BAG_SIZE); - memset(inv_keys,0,sizeof(int)*(KEYRING_SLOT_END-KEYRING_SLOT_START)); - memset(inv_tokens,0,sizeof(int)*(CURRENCYTOKEN_SLOT_END-CURRENCYTOKEN_SLOT_START)); + memset(inv_slot_items, 0, sizeof(int) * (INVENTORY_SLOT_ITEM_END - INVENTORY_SLOT_ITEM_START)); + memset(inv_bags, 0, sizeof(int) * (INVENTORY_SLOT_BAG_END - INVENTORY_SLOT_BAG_START)*MAX_BAG_SIZE); + memset(inv_keys, 0, sizeof(int) * (KEYRING_SLOT_END - KEYRING_SLOT_START)); + memset(inv_tokens, 0, sizeof(int) * (CURRENCYTOKEN_SLOT_END - CURRENCYTOKEN_SLOT_START)); for (int i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i) { @@ -10296,7 +10296,7 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const if (pItem2 && !pItem2->IsInTrade()) { - inv_slot_items[i-INVENTORY_SLOT_ITEM_START] = pItem2->GetCount(); + inv_slot_items[i - INVENTORY_SLOT_ITEM_START] = pItem2->GetCount(); } } @@ -10306,7 +10306,7 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const if (pItem2 && !pItem2->IsInTrade()) { - inv_keys[i-KEYRING_SLOT_START] = pItem2->GetCount(); + inv_keys[i - KEYRING_SLOT_START] = pItem2->GetCount(); } } @@ -10316,7 +10316,7 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const if (pItem2 && !pItem2->IsInTrade()) { - inv_tokens[i-CURRENCYTOKEN_SLOT_START] = pItem2->GetCount(); + inv_tokens[i - CURRENCYTOKEN_SLOT_START] = pItem2->GetCount(); } } @@ -10329,7 +10329,7 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const pItem2 = GetItemByPos(i, j); if (pItem2 && !pItem2->IsInTrade()) { - inv_bags[i-INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); + inv_bags[i - INVENTORY_SLOT_BAG_START][j] = pItem2->GetCount(); } } } @@ -10343,7 +10343,7 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const // no item if (!pItem) continue; - DEBUG_LOG("STORAGE: CanStoreItems %i. item = %u, count = %u", k+1, pItem->GetEntry(), pItem->GetCount()); + DEBUG_LOG("STORAGE: CanStoreItems %i. item = %u, count = %u", k + 1, pItem->GetEntry(), pItem->GetCount()); ItemPrototype const* pProto = pItem->GetProto(); // strange item @@ -10374,9 +10374,9 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const for (int t = KEYRING_SLOT_START; t < KEYRING_SLOT_END; ++t) { pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, t); - if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_keys[t-KEYRING_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) + if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_keys[t - KEYRING_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) { - inv_keys[t-KEYRING_SLOT_START] += pItem->GetCount(); + inv_keys[t - KEYRING_SLOT_START] += pItem->GetCount(); b_found = true; break; } @@ -10386,9 +10386,9 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const for (int t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, t); - if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_tokens[t-CURRENCYTOKEN_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) + if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_tokens[t - CURRENCYTOKEN_SLOT_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) { - inv_tokens[t-CURRENCYTOKEN_SLOT_START] += pItem->GetCount(); + inv_tokens[t - CURRENCYTOKEN_SLOT_START] += pItem->GetCount(); b_found = true; break; } @@ -10398,9 +10398,9 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const for (int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, t); - if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_slot_items[t-INVENTORY_SLOT_ITEM_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) + if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_slot_items[t - INVENTORY_SLOT_ITEM_START] + pItem->GetCount() <= pProto->GetMaxStackSize()) { - inv_slot_items[t-INVENTORY_SLOT_ITEM_START] += pItem->GetCount(); + inv_slot_items[t - INVENTORY_SLOT_ITEM_START] += pItem->GetCount(); b_found = true; break; } @@ -10415,9 +10415,9 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { pItem2 = GetItemByPos(t, j); - if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_bags[t-INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->GetMaxStackSize()) + if (pItem2 && pItem2->CanBeMergedPartlyWith(pProto) == EQUIP_ERR_OK && inv_bags[t - INVENTORY_SLOT_BAG_START][j] + pItem->GetCount() <= pProto->GetMaxStackSize()) { - inv_bags[t-INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); + inv_bags[t - INVENTORY_SLOT_BAG_START][j] += pItem->GetCount(); b_found = true; break; } @@ -10434,11 +10434,11 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const if (pProto->BagFamily & BAG_FAMILY_MASK_KEYS) { uint32 keyringSize = GetMaxKeyringSize(); - for (uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START+keyringSize; ++t) + for (uint32 t = KEYRING_SLOT_START; t < KEYRING_SLOT_START + keyringSize; ++t) { - if (inv_keys[t-KEYRING_SLOT_START] == 0) + if (inv_keys[t - KEYRING_SLOT_START] == 0) { - inv_keys[t-KEYRING_SLOT_START] = 1; + inv_keys[t - KEYRING_SLOT_START] = 1; b_found = true; break; } @@ -10451,9 +10451,9 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const { for (uint32 t = CURRENCYTOKEN_SLOT_START; t < CURRENCYTOKEN_SLOT_END; ++t) { - if (inv_tokens[t-CURRENCYTOKEN_SLOT_START] == 0) + if (inv_tokens[t - CURRENCYTOKEN_SLOT_START] == 0) { - inv_tokens[t-CURRENCYTOKEN_SLOT_START] = 1; + inv_tokens[t - CURRENCYTOKEN_SLOT_START] = 1; b_found = true; break; } @@ -10471,13 +10471,13 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const // not plain container check if (pBagProto && (pBagProto->Class != ITEM_CLASS_CONTAINER || pBagProto->SubClass != ITEM_SUBCLASS_CONTAINER) && - ItemCanGoIntoBag(pProto,pBagProto)) + ItemCanGoIntoBag(pProto, pBagProto)) { for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - if (inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0) + if (inv_bags[t - INVENTORY_SLOT_BAG_START][j] == 0) { - inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; + inv_bags[t - INVENTORY_SLOT_BAG_START][j] = 1; b_found = true; break; } @@ -10492,9 +10492,9 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const bool b_found = false; for (int t = INVENTORY_SLOT_ITEM_START; t < INVENTORY_SLOT_ITEM_END; ++t) { - if (inv_slot_items[t-INVENTORY_SLOT_ITEM_START] == 0) + if (inv_slot_items[t - INVENTORY_SLOT_ITEM_START] == 0) { - inv_slot_items[t-INVENTORY_SLOT_ITEM_START] = 1; + inv_slot_items[t - INVENTORY_SLOT_ITEM_START] = 1; b_found = true; break; } @@ -10515,9 +10515,9 @@ InventoryResult Player::CanStoreItems(Item** pItems,int count) const for (uint32 j = 0; j < pBag->GetBagSize(); ++j) { - if (inv_bags[t-INVENTORY_SLOT_BAG_START][j] == 0) + if (inv_bags[t - INVENTORY_SLOT_BAG_START][j] == 0) { - inv_bags[t-INVENTORY_SLOT_BAG_START][j] = 1; + inv_bags[t - INVENTORY_SLOT_BAG_START][j] = 1; b_found = true; break; } @@ -10594,7 +10594,7 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool if (GetSession()->isLogingOut()) return EQUIP_ERR_YOU_ARE_STUNNED; - if (isInCombat()&& pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer != 0) + if (isInCombat() && pProto->Class == ITEM_CLASS_WEAPON && m_weaponChangeTimer != 0) return EQUIP_ERR_CANT_DO_RIGHT_NOW; // maybe exist better err if (IsNonMeleeSpellCasted(false)) @@ -10631,7 +10631,7 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool { if (ItemPrototype const* pBagProto = pBag->GetProto()) { - if (pBagProto->Class==pProto->Class && (!swap || pBag->GetSlot() != eslot)) + if (pBagProto->Class == pProto->Class && (!swap || pBag->GetSlot() != eslot)) return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH) ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER; @@ -10677,7 +10677,7 @@ InventoryResult Player::CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool Item* offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); ItemPosCountVec off_dest; if (offItem && (!direct_action || - CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND,false) != EQUIP_ERR_OK || + CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND, false) != EQUIP_ERR_OK || CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false) != EQUIP_ERR_OK)) return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL; } @@ -10775,11 +10775,11 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest return res; } - res = _CanStoreItem_InSpecificSlot(bag,slot,dest,pProto,count,swap,pItem); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InSpecificSlot(bag, slot, dest, pProto, count, swap, pItem); + if (res != EQUIP_ERR_OK) return res; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } @@ -10800,23 +10800,23 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest { if (bag == INVENTORY_SLOT_BAG_0) { - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); + if (res != EQUIP_ERR_OK) return res; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } else { - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,false,pItem,NULL_BAG,slot); - if (res!=EQUIP_ERR_OK) - res = _CanStoreItem_InBag(bag,dest,pProto,count,true,true,pItem,NULL_BAG,slot); + res = _CanStoreItem_InBag(bag, dest, pProto, count, true, false, pItem, NULL_BAG, slot); + if (res != EQUIP_ERR_OK) + res = _CanStoreItem_InBag(bag, dest, pProto, count, true, true, pItem, NULL_BAG, slot); - if (res!=EQUIP_ERR_OK) + if (res != EQUIP_ERR_OK) return res; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } @@ -10824,11 +10824,11 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest // search free slot in bag if (bag == INVENTORY_SLOT_BAG_0) { - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + if (res != EQUIP_ERR_OK) return res; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } else @@ -10851,7 +10851,7 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest if (pProto->Stackable != 1) { // in slots - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,true,pItem,bag,slot); + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, true, pItem, bag, slot); if (res != EQUIP_ERR_OK) return res; @@ -10863,22 +10863,22 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest { for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,false,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(i, dest, pProto, count, true, false, pItem, bag, slot); + if (res != EQUIP_ERR_OK) continue; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,true,true,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(i, dest, pProto, count, true, true, pItem, bag, slot); + if (res != EQUIP_ERR_OK) continue; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } @@ -10888,30 +10888,30 @@ InventoryResult Player::CanBankItem(uint8 bag, uint8 slot, ItemPosCountVec& dest { for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,false,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(i, dest, pProto, count, false, false, pItem, bag, slot); + if (res != EQUIP_ERR_OK) continue; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } } // search free space - res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START,BANK_SLOT_ITEM_END,dest,pProto,count,false,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InInventorySlots(BANK_SLOT_ITEM_START, BANK_SLOT_ITEM_END, dest, pProto, count, false, pItem, bag, slot); + if (res != EQUIP_ERR_OK) return res; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i) { - res = _CanStoreItem_InBag(i,dest,pProto,count,false,true,pItem,bag,slot); - if (res!=EQUIP_ERR_OK) + res = _CanStoreItem_InBag(i, dest, pProto, count, false, true, pItem, bag, slot); + if (res != EQUIP_ERR_OK) continue; - if (count==0) + if (count == 0) return EQUIP_ERR_OK; } return EQUIP_ERR_BANK_FULL; @@ -11030,7 +11030,7 @@ InventoryResult Player::CanUseAmmo(uint32 item) const ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item); if (pProto) { - if (pProto->InventoryType!= INVTYPE_AMMO) + if (pProto->InventoryType != INVTYPE_AMMO) return EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE; InventoryResult msg = CanUseItem(pProto); @@ -11086,7 +11086,7 @@ void Player::RemoveAmmo() } // Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case. -Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update,int32 randomPropertyId) +Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId) { uint32 count = 0; for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) @@ -11119,11 +11119,11 @@ Item* Player::StoreItem(ItemPosCountVec const& dest, Item* pItem, bool update) if (itr == dest.end()) { - lastItem = _StoreItem(pos,pItem,count,false,update); + lastItem = _StoreItem(pos, pItem, count, false, update); break; } - lastItem = _StoreItem(pos,pItem,count,true,update); + lastItem = _StoreItem(pos, pItem, count, true, update); } GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, entry); @@ -11289,7 +11289,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) { m_weaponChangeTimer = spellProto->StartRecoveryTime; - WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+4); + WorldPacket data(SMSG_SPELL_COOLDOWN, 8 + 1 + 4); data << GetObjectGuid(); data << uint8(1); data << uint32(cooldownSpell); @@ -11349,7 +11349,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) // only for full equip instead adding to stack GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, slot+1); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, slot + 1); return pItem; } @@ -11375,7 +11375,7 @@ void Player::QuickEquipItem(uint16 pos, Item* pItem) CastSpell(this, 49152, true); GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_ITEM, pItem->GetEntry()); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, slot+1); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EQUIP_EPIC_ITEM, slot + 1); } } @@ -11508,7 +11508,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) // Common operation need to remove item from inventory without delete in trade, auction, guild bank, mail.... void Player::MoveItemFromInventory(uint8 bag, uint8 slot, bool update) { - if (Item* it = GetItemByPos(bag,slot)) + if (Item* it = GetItemByPos(bag, slot)) { ItemRemovedQuestCheck(it->GetEntry(), it->GetCount()); RemoveItem(bag, slot, update); @@ -11887,13 +11887,13 @@ void Player::DestroyItemCount(Item* pItem, uint32& count, bool update) if (!pItem) return; - DEBUG_LOG("STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(),pItem->GetEntry(), count); + DEBUG_LOG("STORAGE: DestroyItemCount item (GUID: %u, Entry: %u) count = %u", pItem->GetGUIDLow(), pItem->GetEntry(), count); if (pItem->GetCount() <= count) { count -= pItem->GetCount(); - DestroyItem(pItem->GetBagSlot(),pItem->GetSlot(), update); + DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), update); } else { @@ -12244,7 +12244,7 @@ void Player::SwapItem(uint16 src, uint16 dst) uint32 count = 0; - for (uint32 i=0; i < fullBag->GetBagSize(); ++i) + for (uint32 i = 0; i < fullBag->GetBagSize(); ++i) { Item* bagItem = fullBag->GetItemByPos(i); if (!bagItem) @@ -12270,7 +12270,7 @@ void Player::SwapItem(uint16 src, uint16 dst) // Items swap count = 0; // will pos in new bag - for (uint32 i = 0; i< fullBag->GetBagSize(); ++i) + for (uint32 i = 0; i < fullBag->GetBagSize(); ++i) { Item* bagItem = fullBag->GetItemByPos(i); if (!bagItem) @@ -12319,7 +12319,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) uint32 oldest_time = GetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1); uint32 oldest_slot = BUYBACK_SLOT_START; - for (uint32 i = BUYBACK_SLOT_START+1; i < BUYBACK_SLOT_END; ++i) + for (uint32 i = BUYBACK_SLOT_START + 1; i < BUYBACK_SLOT_END; ++i) { // found empty if (!m_items[i]) @@ -12398,7 +12398,7 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint32 itemid /*= 0*/) const { DEBUG_LOG("WORLD: Sent SMSG_INVENTORY_CHANGE_FAILURE (%u)", msg); - WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 1+8+8+1); + WorldPacket data(SMSG_INVENTORY_CHANGE_FAILURE, 1 + 8 + 8 + 1); data << uint8(msg); if (msg != EQUIP_ERR_OK) @@ -12441,7 +12441,7 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint void Player::SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param) { DEBUG_LOG("WORLD: Sent SMSG_BUY_FAILED"); - WorldPacket data(SMSG_BUY_FAILED, (8+4+4+1)); + WorldPacket data(SMSG_BUY_FAILED, (8 + 4 + 4 + 1)); data << (pCreature ? pCreature->GetObjectGuid() : ObjectGuid()); data << uint32(item); if (param > 0) @@ -12453,7 +12453,7 @@ void Player::SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint3 void Player::SendSellError(SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param) { DEBUG_LOG("WORLD: Sent SMSG_SELL_ITEM"); - WorldPacket data(SMSG_SELL_ITEM,(8+8+(param?4:0)+1)); // last check 2.0.10 + WorldPacket data(SMSG_SELL_ITEM, (8 + 8 + (param ? 4 : 0) + 1)); // last check 2.0.10 data << (pCreature ? pCreature->GetObjectGuid() : ObjectGuid()); data << ObjectGuid(itemGuid); if (param > 0) @@ -12495,13 +12495,13 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) ++itr; // current element can be erased in UpdateDuration if ((realtimeonly && (item->GetProto()->ExtraFlags & ITEM_EXTRA_REAL_TIME_DURATION)) || !realtimeonly) - item->UpdateDuration(this,time); + item->UpdateDuration(this, time); } } void Player::UpdateEnchantTime(uint32 time) { - for (EnchantDurationList::iterator itr = m_enchantDuration.begin(),next; itr != m_enchantDuration.end(); itr=next) + for (EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr = next) { MANGOS_ASSERT(itr->item); next = itr; @@ -12591,7 +12591,7 @@ void Player::RemoveAllEnchantments(EnchantmentSlot slot) } // duration == 0 will remove item enchant -void Player::AddEnchantmentDuration(Item* item,EnchantmentSlot slot,uint32 duration) +void Player::AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 duration) { if (!item) return; @@ -12610,12 +12610,12 @@ void Player::AddEnchantmentDuration(Item* item,EnchantmentSlot slot,uint32 durat } if (item && duration > 0) { - GetSession()->SendItemEnchantTimeUpdate(GetObjectGuid(), item->GetObjectGuid(), slot, uint32(duration/1000)); + GetSession()->SendItemEnchantTimeUpdate(GetObjectGuid(), item->GetObjectGuid(), slot, uint32(duration / 1000)); m_enchantDuration.push_back(EnchantDuration(item, slot, duration)); } } -void Player::ApplyEnchantment(Item* item,bool apply) +void Player::ApplyEnchantment(Item* item, bool apply) { for (uint32 slot = 0; slot < MAX_ENCHANTMENT_SLOT; ++slot) ApplyEnchantment(item, EnchantmentSlot(slot), apply); @@ -12738,39 +12738,39 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool } } - DEBUG_LOG("Adding %u to stat nb %u",enchant_amount,enchant_spell_id); + DEBUG_LOG("Adding %u to stat nb %u", enchant_amount, enchant_spell_id); switch (enchant_spell_id) { case ITEM_MOD_MANA: - DEBUG_LOG("+ %u MANA",enchant_amount); + DEBUG_LOG("+ %u MANA", enchant_amount); HandleStatModifier(UNIT_MOD_MANA, BASE_VALUE, float(enchant_amount), apply); break; case ITEM_MOD_HEALTH: - DEBUG_LOG("+ %u HEALTH",enchant_amount); + DEBUG_LOG("+ %u HEALTH", enchant_amount); HandleStatModifier(UNIT_MOD_HEALTH, BASE_VALUE, float(enchant_amount), apply); break; case ITEM_MOD_AGILITY: - DEBUG_LOG("+ %u AGILITY",enchant_amount); + DEBUG_LOG("+ %u AGILITY", enchant_amount); HandleStatModifier(UNIT_MOD_STAT_AGILITY, TOTAL_VALUE, float(enchant_amount), apply); ApplyStatBuffMod(STAT_AGILITY, float(enchant_amount), apply); break; case ITEM_MOD_STRENGTH: - DEBUG_LOG("+ %u STRENGTH",enchant_amount); + DEBUG_LOG("+ %u STRENGTH", enchant_amount); HandleStatModifier(UNIT_MOD_STAT_STRENGTH, TOTAL_VALUE, float(enchant_amount), apply); ApplyStatBuffMod(STAT_STRENGTH, float(enchant_amount), apply); break; case ITEM_MOD_INTELLECT: - DEBUG_LOG("+ %u INTELLECT",enchant_amount); + DEBUG_LOG("+ %u INTELLECT", enchant_amount); HandleStatModifier(UNIT_MOD_STAT_INTELLECT, TOTAL_VALUE, float(enchant_amount), apply); ApplyStatBuffMod(STAT_INTELLECT, float(enchant_amount), apply); break; case ITEM_MOD_SPIRIT: - DEBUG_LOG("+ %u SPIRIT",enchant_amount); + DEBUG_LOG("+ %u SPIRIT", enchant_amount); HandleStatModifier(UNIT_MOD_STAT_SPIRIT, TOTAL_VALUE, float(enchant_amount), apply); ApplyStatBuffMod(STAT_SPIRIT, float(enchant_amount), apply); break; case ITEM_MOD_STAMINA: - DEBUG_LOG("+ %u STAMINA",enchant_amount); + DEBUG_LOG("+ %u STAMINA", enchant_amount); HandleStatModifier(UNIT_MOD_STAT_STAMINA, TOTAL_VALUE, float(enchant_amount), apply); ApplyStatBuffMod(STAT_STAMINA, float(enchant_amount), apply); break; @@ -12992,7 +12992,7 @@ void Player::SendNewItem(Item* item, uint32 count, bool received, bool created, return; // last check 2.0.10 - WorldPacket data(SMSG_ITEM_PUSH_RESULT, (8+4+4+4+1+4+4+4+4+4)); + WorldPacket data(SMSG_ITEM_PUSH_RESULT, (8 + 4 + 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4)); data << GetObjectGuid(); // player GUID data << uint32(received); // 0=looted, 1=from npc data << uint32(created); // 0=received, 1=created @@ -13236,7 +13236,7 @@ void Player::SendPreparedGossip(WorldObject* pSource) if (pSource->GetTypeId() == TYPEID_UNIT) { // in case no gossip flag and quest menu not empty, open quest menu (client expect gossip menu with this flag) - if (!((Creature*)pSource)->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty()) + if (!((Creature*)pSource)->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP) && !PlayerTalkClass->GetQuestMenu().Empty()) { SendPreparedQuest(pSource->GetObjectGuid()); return; @@ -13830,7 +13830,7 @@ bool Player::CanRewardQuest(Quest const* pQuest, bool msg) const bool Player::CanRewardQuest(Quest const* pQuest, uint32 reward, bool msg) const { // prevent receive reward with quest items in bank or for not completed quest - if (!CanRewardQuest(pQuest,msg)) + if (!CanRewardQuest(pQuest, msg)) return false; if (pQuest->GetRewChoiceItemsCount() > 0) @@ -13910,7 +13910,7 @@ void Player::AddQuest(Quest const* pQuest, Object* questGiver) uint32 limittime = pQuest->GetLimitTime(); // shared timed quest - if (questGiver && questGiver->GetTypeId()==TYPEID_PLAYER) + if (questGiver && questGiver->GetTypeId() == TYPEID_PLAYER) limittime = ((Player*)questGiver)->getQuestStatusMap()[quest_id].m_timer / IN_MILLISECONDS; AddTimedQuest(quest_id); @@ -13974,16 +13974,16 @@ void Player::AddQuest(Quest const* pQuest, Object* questGiver) AdjustQuestReqItemCount(pQuest, questStatusData); // Some spells applied at quest activation - SpellAreaForQuestMapBounds saBounds = sSpellMgr.GetSpellAreaForQuestMapBounds(quest_id,true); + SpellAreaForQuestMapBounds saBounds = sSpellMgr.GetSpellAreaForQuestMapBounds(quest_id, true); if (saBounds.first != saBounds.second) { uint32 zone, area; - GetZoneAndAreaId(zone,area); + GetZoneAndAreaId(zone, area); for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) - if (itr->second->autocast && itr->second->IsFitToRequirements(this,zone,area)) + if (itr->second->autocast && itr->second->IsFitToRequirements(this, zone, area)) if (!HasAura(itr->second->spellId, EFFECT_INDEX_0)) - CastSpell(this,itr->second->spellId,true); + CastSpell(this, itr->second->spellId, true); } UpdateForQuestWorldObjects(); @@ -14060,7 +14060,7 @@ void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, if (pQuest->GetRewItemsCount() > 0) { - for (uint32 i=0; i < pQuest->GetRewItemsCount(); ++i) + for (uint32 i = 0; i < pQuest->GetRewItemsCount(); ++i) { if (uint32 itemId = pQuest->RewItemId[i]) { @@ -14078,7 +14078,7 @@ void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, uint16 log_slot = FindQuestSlot(quest_id); if (log_slot < MAX_QUEST_LOG_SIZE) - SetQuestSlot(log_slot,0); + SetQuestSlot(log_slot, 0); QuestStatusData& q_status = mQuestStatus[quest_id]; @@ -14192,7 +14192,7 @@ void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver, SpellAreaForQuestMapBounds saEndBounds = sSpellMgr.GetSpellAreaForQuestEndMapBounds(quest_id); if (saEndBounds.first != saEndBounds.second) { - GetZoneAndAreaId(zone,area); + GetZoneAndAreaId(zone, area); for (SpellAreaForAreaMap::const_iterator itr = saEndBounds.first; itr != saEndBounds.second; ++itr) if (!itr->second->IsFitToRequirements(this, zone, area)) @@ -14571,8 +14571,8 @@ bool Player::SatisfyQuestDay(Quest const* qInfo, bool msg) const bool have_slot = false; for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { - uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx); - if (qInfo->GetQuestId()==id) + uint32 id = GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx); + if (qInfo->GetQuestId() == id) return false; if (!id) @@ -14669,7 +14669,7 @@ bool Player::TakeQuestSourceItem(uint32 quest_id, bool msg) // exist one case when destroy source quest item not possible: // non un-equippable item (equipped non-empty bag, for example) - InventoryResult res = CanUnequipItems(srcitem,count); + InventoryResult res = CanUnequipItems(srcitem, count); if (res != EQUIP_ERR_OK) { if (msg) @@ -14931,11 +14931,11 @@ void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid) for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { // skip GO activate objective or none - if (qInfo->ReqCreatureOrGOId[j] <=0) + if (qInfo->ReqCreatureOrGOId[j] <= 0) continue; // skip Cast at creature objective - if (qInfo->ReqSpell[j] !=0) + if (qInfo->ReqSpell[j] != 0) continue; uint32 reqkill = qInfo->ReqCreatureOrGOId[j]; @@ -15192,16 +15192,16 @@ bool Player::HasQuestForItem(uint32 itemid) const ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); // 'unique' item - if (pProto->MaxCount && (int32)GetItemCount(itemid,true) < pProto->MaxCount) + if (pProto->MaxCount && (int32)GetItemCount(itemid, true) < pProto->MaxCount) return true; // allows custom amount drop when not 0 if (qinfo->ReqSourceCount[j]) { - if (GetItemCount(itemid,true) < qinfo->ReqSourceCount[j]) + if (GetItemCount(itemid, true) < qinfo->ReqSourceCount[j]) return true; } - else if ((int32)GetItemCount(itemid,true) < pProto->Stackable) + else if ((int32)GetItemCount(itemid, true) < pProto->Stackable) return true; } } @@ -15226,7 +15226,7 @@ void Player::SendQuestReward(Quest const* pQuest, uint32 XP, Object* questGiver) { uint32 questid = pQuest->GetQuestId(); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_COMPLETE quest = %u", questid); - WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4+4+4+4+4)); + WorldPacket data(SMSG_QUESTGIVER_QUEST_COMPLETE, (4 + 4 + 4 + 4 + 4)); data << uint32(questid); if (getLevel() < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) @@ -15240,7 +15240,7 @@ void Player::SendQuestReward(Quest const* pQuest, uint32 XP, Object* questGiver) data << uint32(pQuest->GetRewOrReqMoney() + int32(pQuest->GetRewMoneyMaxLevel() * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY))); } - data << uint32(10*MaNGOS::Honor::hk_honor_at_level(getLevel(), pQuest->GetRewHonorAddition())); + data << uint32(10 * MaNGOS::Honor::hk_honor_at_level(getLevel(), pQuest->GetRewHonorAddition())); data << uint32(pQuest->GetBonusTalents()); // bonus talents data << uint32(0); // arena points GetSession()->SendPacket(&data); @@ -15250,7 +15250,7 @@ void Player::SendQuestFailed(uint32 quest_id, InventoryResult reason) { if (quest_id) { - WorldPacket data(SMSG_QUESTGIVER_QUEST_FAILED, 4+4); + WorldPacket data(SMSG_QUESTGIVER_QUEST_FAILED, 4 + 4); data << uint32(quest_id); data << uint32(reason); // failed reason (valid reasons: 4, 16, 50, 17, 74, other values show default message) GetSession()->SendPacket(&data); @@ -15299,7 +15299,7 @@ void Player::SendPushToPartyResponse(Player* pPlayer, uint32 msg) { if (pPlayer) { - WorldPacket data(MSG_QUEST_PUSH_RESULT, (8+1)); + WorldPacket data(MSG_QUEST_PUSH_RESULT, (8 + 1)); data << pPlayer->GetObjectGuid(); data << uint8(msg); // valid values: 0-8 GetSession()->SendPacket(&data); @@ -15316,7 +15316,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid // client expected gameobject template id in form (id|0x80000000) entry = (-entry) | 0x80000000; - WorldPacket data(SMSG_QUESTUPDATE_ADD_KILL, (4*4+8)); + WorldPacket data(SMSG_QUESTUPDATE_ADD_KILL, (4 * 4 + 8)); DEBUG_LOG("WORLD: Sent SMSG_QUESTUPDATE_ADD_KILL"); data << uint32(pQuest->GetQuestId()); data << uint32(entry); @@ -15409,7 +15409,7 @@ void Player::_LoadEquipmentSets(QueryResult* result) eqSet.state = EQUIPMENT_SET_UNCHANGED; for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i) - eqSet.Items[i] = fields[5+i].GetUInt32(); + eqSet.Items[i] = fields[5 + i].GetUInt32(); m_EquipmentSets[index] = eqSet; @@ -15533,17 +15533,17 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) SetGuidValue(OBJECT_FIELD_GUID, guid); // overwrite some data fields - SetByteValue(UNIT_FIELD_BYTES_0,0,fields[3].GetUInt8());// race - SetByteValue(UNIT_FIELD_BYTES_0,1,fields[4].GetUInt8());// class + SetByteValue(UNIT_FIELD_BYTES_0, 0, fields[3].GetUInt8()); // race + SetByteValue(UNIT_FIELD_BYTES_0, 1, fields[4].GetUInt8()); // class uint8 gender = fields[5].GetUInt8() & 0x01; // allowed only 1 bit values male/female cases (for fit drunk gender part) - SetByteValue(UNIT_FIELD_BYTES_0,2,gender); // gender + SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); // gender SetUInt32Value(UNIT_FIELD_LEVEL, fields[6].GetUInt8()); SetUInt32Value(PLAYER_XP, fields[7].GetUInt32()); _LoadIntoDataField(fields[60].GetString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE); - _LoadIntoDataField(fields[63].GetString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE*2); + _LoadIntoDataField(fields[63].GetString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE * 2); InitDisplayIds(); // model, scale and model data @@ -15607,7 +15607,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) // init saved position, and fix it later if problematic uint32 transGUID = fields[30].GetUInt32(); - Relocate(fields[12].GetFloat(),fields[13].GetFloat(),fields[14].GetFloat(),fields[16].GetFloat()); + Relocate(fields[12].GetFloat(), fields[13].GetFloat(), fields[14].GetFloat(), fields[16].GetFloat()); SetLocationMapId(fields[15].GetUInt32()); uint32 difficulty = fields[38].GetUInt32(); @@ -15677,7 +15677,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) currentBg->EventPlayerLoggedIn(this, GetObjectGuid()); currentBg->AddOrSetPlayerToCorrectBgGroup(this, GetObjectGuid(), m_bgData.bgTeam); - SetInviteForBattleGroundQueueType(bgQueueTypeId,currentBg->GetInstanceID()); + SetInviteForBattleGroundQueueType(bgQueueTypeId, currentBg->GetInstanceID()); } else { @@ -15716,7 +15716,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) if (transGUID != 0) { - m_movementInfo.SetTransportData(ObjectGuid(HIGHGUID_MO_TRANSPORT,transGUID), fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat(), 0, -1); + m_movementInfo.SetTransportData(ObjectGuid(HIGHGUID_MO_TRANSPORT, transGUID), fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat(), 0, -1); if (!MaNGOS::IsValidMapCoord( GetPositionX() + m_movementInfo.GetTransportPos()->x, GetPositionY() + m_movementInfo.GetTransportPos()->y, @@ -15807,16 +15807,16 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) // set value, including drunk invisibility detection // calculate sobering. after 15 minutes logged out, the player will be sober again float soberFactor; - if (time_diff > 15*MINUTE) + if (time_diff > 15 * MINUTE) soberFactor = 0; else - soberFactor = 1-time_diff/(15.0f*MINUTE); - uint16 newDrunkenValue = uint16(soberFactor* m_drunk); + soberFactor = 1 - time_diff / (15.0f * MINUTE); + uint16 newDrunkenValue = uint16(soberFactor * m_drunk); SetDrunkValue(newDrunkenValue); m_cinematic = fields[18].GetUInt32(); - m_Played_time[PLAYED_TIME_TOTAL]= fields[19].GetUInt32(); - m_Played_time[PLAYED_TIME_LEVEL]= fields[20].GetUInt32(); + m_Played_time[PLAYED_TIME_TOTAL] = fields[19].GetUInt32(); + m_Played_time[PLAYED_TIME_LEVEL] = fields[20].GetUInt32(); m_resetTalentsCost = fields[24].GetUInt32(); m_resetTalentsTime = time_t(fields[25].GetUInt64()); @@ -15834,7 +15834,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) m_stableSlots = fields[32].GetUInt32(); if (m_stableSlots > MAX_PET_STABLES) { - sLog.outError("Player can have not more %u stable slots, but have in DB %u",MAX_PET_STABLES,uint32(m_stableSlots)); + sLog.outError("Player can have not more %u stable slots, but have in DB %u", MAX_PET_STABLES, uint32(m_stableSlots)); m_stableSlots = MAX_PET_STABLES; } @@ -15846,14 +15846,14 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) UpdateHonorFields(); m_deathExpireTime = (time_t)fields[36].GetUInt64(); - if (m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP) - m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP-1; + if (m_deathExpireTime > now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP) + m_deathExpireTime = now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP - 1; std::string taxi_nodes = fields[37].GetCppString(); // clear channel spell data (if saved at channel spell casting) SetChannelObjectGuid(ObjectGuid()); - SetUInt32Value(UNIT_CHANNEL_SPELL,0); + SetUInt32Value(UNIT_CHANNEL_SPELL, 0); // clear charm/summon related fields SetCharm(NULL); @@ -15895,10 +15895,10 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) //speed collect rest bonus in offline, in logout, in tavern, city (section/in hour) float bubble1 = 0.125f; float bubble = fields[23].GetUInt32() > 0 - ? bubble1*sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) - : bubble0*sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_WILDERNESS); + ? bubble1 * sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) + : bubble0 * sWorld.getConfig(CONFIG_FLOAT_RATE_REST_OFFLINE_IN_WILDERNESS); - SetRestBonus(GetRestBonus()+ time_diff*((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)/72000)*bubble); + SetRestBonus(GetRestBonus() + time_diff * ((float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) / 72000)*bubble); } // load skills after InitStatsForLevel because it triggering aura apply also @@ -15974,14 +15974,14 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) if (!nodeEntry) // don't know taxi start node, to homebind { - sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.",GetGUIDLow()); + sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.", GetGUIDLow()); RelocateToHomebind(); } else // have start node, to it { - sLog.outError("Character %u have too short taxi destination list, teleport to original node.",GetGUIDLow()); + sLog.outError("Character %u have too short taxi destination list, teleport to original node.", GetGUIDLow()); SetLocationMapId(nodeEntry->map_id); - Relocate(nodeEntry->x, nodeEntry->y, nodeEntry->z,0.0f); + Relocate(nodeEntry->x, nodeEntry->y, nodeEntry->z, 0.0f); } //we can be relocated from taxi and still have an outdated Map pointer! @@ -16024,8 +16024,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder) SetHealth(savedhealth > GetMaxHealth() ? GetMaxHealth() : savedhealth); for (uint32 i = 0; i < MAX_POWERS; ++i) { - uint32 savedpower = fields[51+i].GetUInt32(); - SetPower(Powers(i),savedpower > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedpower); + uint32 savedpower = fields[51 + i].GetUInt32(); + SetPower(Powers(i), savedpower > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedpower); } DEBUG_FILTER_LOG(LOG_FILTER_PLAYER_STATS, "The value of player %s after load item and aura is: ", m_name.c_str()); @@ -16183,8 +16183,8 @@ void Player::_LoadAuras(QueryResult* result, uint32 timediff) for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) { - damage[i] = fields[i+5].GetInt32(); - periodicTime[i] = fields[i+8].GetUInt32(); + damage[i] = fields[i + 5].GetInt32(); + periodicTime[i] = fields[i + 8].GetUInt32(); } int32 maxduration = fields[11].GetInt32(); @@ -16194,16 +16194,16 @@ void Player::_LoadAuras(QueryResult* result, uint32 timediff) SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); if (!spellproto) { - sLog.outError("Unknown spell (spellid %u), ignore.",spellid); + sLog.outError("Unknown spell (spellid %u), ignore.", spellid); continue; } if (remaintime != -1 && !IsPositiveSpell(spellproto)) { - if (remaintime/IN_MILLISECONDS <= int32(timediff)) + if (remaintime / IN_MILLISECONDS <= int32(timediff)) continue; - remaintime -= timediff*IN_MILLISECONDS; + remaintime -= timediff * IN_MILLISECONDS; } // prevent wrong values of remaincharges @@ -16250,7 +16250,7 @@ void Player::_LoadAuras(QueryResult* result, uint32 timediff) } if (getClass() == CLASS_WARRIOR && !HasAuraType(SPELL_AURA_MOD_SHAPESHIFT)) - CastSpell(this,SPELL_ID_PASSIVE_BATTLE_STANCE,true); + CastSpell(this, SPELL_ID_PASSIVE_BATTLE_STANCE, true); } void Player::_LoadGlyphs(QueryResult* result) @@ -16349,7 +16349,7 @@ void Player::_LoadInventory(QueryResult* result, uint32 timediff) { CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_lowguid); - sLog.outError("Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(),item_id); + sLog.outError("Player::_LoadInventory: Player %s has an unknown item (id: #%u) in inventory, deleted.", GetName(), item_id); continue; } @@ -16357,7 +16357,7 @@ void Player::_LoadInventory(QueryResult* result, uint32 timediff) if (!item->LoadFromDB(item_lowguid, fields, GetObjectGuid())) { - sLog.outError("Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id); + sLog.outError("Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(), item_id); CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); item->SaveToDB(); // it also deletes item object ! @@ -16365,7 +16365,7 @@ void Player::_LoadInventory(QueryResult* result, uint32 timediff) } // not allow have in alive state item limited to another map/zone - if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone)) + if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(), zone)) { CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); @@ -16374,7 +16374,7 @@ void Player::_LoadInventory(QueryResult* result, uint32 timediff) } // "Conjured items disappear if you are logged out for more than 15 minutes" - if (timediff > 15*MINUTE && (item->GetProto()->Flags & ITEM_FLAG_CONJURED)) + if (timediff > 15 * MINUTE && (item->GetProto()->Flags & ITEM_FLAG_CONJURED)) { CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); item->FSetState(ITEM_REMOVED); @@ -16450,12 +16450,12 @@ void Player::_LoadInventory(QueryResult* result, uint32 timediff) item->GetContainer()->SetState(ITEM_UNCHANGED, this); // recharged mana gem - if (timediff > 15*MINUTE && proto->ItemLimitCategory ==ITEM_LIMIT_CATEGORY_MANA_GEM) + if (timediff > 15 * MINUTE && proto->ItemLimitCategory == ITEM_LIMIT_CATEGORY_MANA_GEM) item->RestoreCharges(); } else { - sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(),item_lowguid, item_id, bag_guid, slot); + sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by some reason, will send by mail.", GetName(), item_lowguid, item_id, bag_guid, slot); CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_lowguid); problematicItems.push_back(item); } @@ -16543,7 +16543,7 @@ void Player::_LoadMailedItems(QueryResult* result) if (!proto) { - sLog.outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID); + sLog.outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template, mail->messageID); CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid_low); continue; @@ -16653,7 +16653,7 @@ void Player::_LoadQuestStatus(QueryResult* result) else { questStatusData.m_status = QUEST_STATUS_NONE; - sLog.outError("Player %s have invalid quest %d status (%d), replaced by QUEST_STATUS_NONE(0).",GetName(),quest_id,qstatus); + sLog.outError("Player %s have invalid quest %d status (%d), replaced by QUEST_STATUS_NONE(0).", GetName(), quest_id, qstatus); } questStatusData.m_rewarded = (fields[2].GetUInt8() > 0); @@ -16743,7 +16743,7 @@ void Player::_LoadQuestStatus(QueryResult* result) void Player::_LoadDailyQuestStatus(QueryResult* result) { for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, 0); //QueryResult *result = CharacterDatabase.PQuery("SELECT quest FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow()); @@ -16755,7 +16755,7 @@ void Player::_LoadDailyQuestStatus(QueryResult* result) { if (quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query { - sLog.outError("Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`",GetGUIDLow()); + sLog.outError("Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`", GetGUIDLow()); break; } @@ -16767,7 +16767,7 @@ void Player::_LoadDailyQuestStatus(QueryResult* result) if (!pQuest) continue; - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, quest_id); ++quest_daily_idx; DEBUG_LOG("Daily quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); @@ -16882,7 +16882,7 @@ void Player::_LoadTalents(QueryResult* result) if (!talentInfo) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent_id: %u , this talent will be deleted from character_talent",GetGUIDLow(), talent_id); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent_id: %u , this talent will be deleted from character_talent", GetGUIDLow(), talent_id); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE talent_id = '%u'", talent_id); continue; } @@ -16891,7 +16891,7 @@ void Player::_LoadTalents(QueryResult* result) if (!talentTabInfo) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talentTabInfo: %u for talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), talentInfo->TalentTab, talentInfo->TalentID); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talentTabInfo: %u for talentID: %u , this talent will be deleted from character_talent", GetGUIDLow(), talentInfo->TalentTab, talentInfo->TalentID); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE talent_id = '%u'", talent_id); continue; } @@ -16899,7 +16899,7 @@ void Player::_LoadTalents(QueryResult* result) // prevent load talent for different class (cheating) if ((getClassMask() & talentTabInfo->ClassMask) == 0) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has talent with ClassMask: %u , but Player's ClassMask is: %u , talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), talentTabInfo->ClassMask, getClassMask() ,talentInfo->TalentID); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has talent with ClassMask: %u , but Player's ClassMask is: %u , talentID: %u , this talent will be deleted from character_talent", GetGUIDLow(), talentTabInfo->ClassMask, getClassMask() , talentInfo->TalentID); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE guid = '%u' AND talent_id = '%u'", GetGUIDLow(), talent_id); continue; } @@ -16908,7 +16908,7 @@ void Player::_LoadTalents(QueryResult* result) if (currentRank > MAX_TALENT_RANK || talentInfo->RankID[currentRank] == 0) { - sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent rank: %u , talentID: %u , this talent will be deleted from character_talent",GetGUIDLow(), currentRank, talentInfo->TalentID); + sLog.outError("Player::_LoadTalents:Player (GUID: %u) has invalid talent rank: %u , talentID: %u , this talent will be deleted from character_talent", GetGUIDLow(), currentRank, talentInfo->TalentID); CharacterDatabase.PExecute("DELETE FROM character_talent WHERE guid = '%u' AND talent_id = '%u'", GetGUIDLow(), talent_id); continue; } @@ -16930,7 +16930,7 @@ void Player::_LoadTalents(QueryResult* result) } if (m_activeSpec == spec) - addSpell(talentInfo->RankID[currentRank], true,false,false,false); + addSpell(talentInfo->RankID[currentRank], true, false, false, false); else { PlayerTalent talent; @@ -17005,7 +17005,7 @@ void Player::_LoadBoundInstances(QueryResult* result) continue; } - MapDifficulty const* mapDiff = GetMapDifficultyData(mapId,Difficulty(difficulty)); + MapDifficulty const* mapDiff = GetMapDifficultyData(mapId, Difficulty(difficulty)); if (!mapDiff) { sLog.outError("_LoadBoundInstances: player %s(%d) has bind to nonexistent difficulty %d instance for map %u", GetName(), GetGUIDLow(), difficulty, mapId); @@ -17034,7 +17034,7 @@ void Player::_LoadBoundInstances(QueryResult* result) InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, Difficulty difficulty) { // some instances only have one difficulty - MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty); + MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty); if (!mapDiff) return NULL; @@ -17278,7 +17278,7 @@ bool Player::_LoadHomeBind(QueryResult* result) MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId); // accept saved data only for valid position (and non instanceable), and accessable - if (MapManager::IsValidMapCoord(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ) && + if (MapManager::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ) && !bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion()) { ok = true; @@ -17470,7 +17470,7 @@ void Player::SaveToDB() uberInsert.addUInt32(GetUInt32Value(PLAYER_AMMO_ID)); - for (uint32 i = 0; i < KNOWN_TITLES_SIZE*2; ++i) //string + for (uint32 i = 0; i < KNOWN_TITLES_SIZE * 2; ++i) //string { ss << GetUInt32Value(PLAYER__FIELD_KNOWN_TITLES + i) << " "; } @@ -17715,7 +17715,7 @@ void Player::_SaveInventory() // update enchantment durations for (EnchantDurationList::const_iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) { - itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); + itr->item->SetEnchantmentDuration(itr->slot, itr->leftduration); } // if no changes @@ -17889,7 +17889,7 @@ void Player::_SaveQuestStatus() stmt.addUInt8(i->second.m_status); stmt.addUInt8(i->second.m_rewarded); stmt.addUInt8(i->second.m_explored); - stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS+ sWorld.GetGameTime())); + stmt.addUInt64(uint64(i->second.m_timer / IN_MILLISECONDS + sWorld.GetGameTime())); for (int k = 0; k < QUEST_OBJECTIVES_COUNT; ++k) stmt.addUInt32(i->second.m_creatureOrGOcount[k]); for (int k = 0; k < QUEST_ITEM_OBJECTIVES_COUNT; ++k) @@ -17937,8 +17937,8 @@ void Player::_SaveDailyQuestStatus() stmtDel.PExecute(GetGUIDLow()); for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) - stmtIns.PExecute(GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)); + if (GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)) + stmtIns.PExecute(GetGUIDLow(), GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)); m_DailyQuestChanged = false; } @@ -18087,7 +18087,7 @@ void Player::_SaveTalents() for (PlayerTalentMap::iterator itr = m_talents[i].begin(); itr != m_talents[i].end();) { if (itr->second.state == PLAYERSPELL_REMOVED || itr->second.state == PLAYERSPELL_CHANGED) - stmtDel.PExecute(GetGUIDLow(),itr->first, i); + stmtDel.PExecute(GetGUIDLow(), itr->first, i); // add only changed/new talents if (itr->second.state == PLAYERSPELL_NEW || itr->second.state == PLAYERSPELL_CHANGED) @@ -18151,18 +18151,18 @@ void Player::outDebugStatsValues() const if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG) || sLog.HasLogFilter(LOG_FILTER_PLAYER_STATS)) 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)); - sLog.outDebug("INTELLECT is: \t\t%f\t\tSPIRIT is: \t\t%f",GetStat(STAT_INTELLECT), GetStat(STAT_SPIRIT)); - sLog.outDebug("STAMINA is: \t\t%f",GetStat(STAT_STAMINA)); - sLog.outDebug("Armor is: \t\t%u\t\tBlock is: \t\t%f",GetArmor(), GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); - sLog.outDebug("HolyRes is: \t\t%u\t\tFireRes is: \t\t%u",GetResistance(SPELL_SCHOOL_HOLY), GetResistance(SPELL_SCHOOL_FIRE)); - sLog.outDebug("NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u",GetResistance(SPELL_SCHOOL_NATURE), GetResistance(SPELL_SCHOOL_FROST)); - sLog.outDebug("ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u",GetResistance(SPELL_SCHOOL_SHADOW), GetResistance(SPELL_SCHOOL_ARCANE)); - sLog.outDebug("MIN_DAMAGE is: \t\t%f\tMAX_DAMAGE is: \t\t%f",GetFloatValue(UNIT_FIELD_MINDAMAGE), GetFloatValue(UNIT_FIELD_MAXDAMAGE)); - sLog.outDebug("MIN_OFFHAND_DAMAGE is: \t%f\tMAX_OFFHAND_DAMAGE is: \t%f",GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE), GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)); - sLog.outDebug("MIN_RANGED_DAMAGE is: \t%f\tMAX_RANGED_DAMAGE is: \t%f",GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE), GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE)); - sLog.outDebug("ATTACK_TIME is: \t%u\t\tRANGE_ATTACK_TIME is: \t%u",GetAttackTime(BASE_ATTACK), GetAttackTime(RANGED_ATTACK)); + 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)); + sLog.outDebug("INTELLECT is: \t\t%f\t\tSPIRIT is: \t\t%f", GetStat(STAT_INTELLECT), GetStat(STAT_SPIRIT)); + sLog.outDebug("STAMINA is: \t\t%f", GetStat(STAT_STAMINA)); + sLog.outDebug("Armor is: \t\t%u\t\tBlock is: \t\t%f", GetArmor(), GetFloatValue(PLAYER_BLOCK_PERCENTAGE)); + sLog.outDebug("HolyRes is: \t\t%u\t\tFireRes is: \t\t%u", GetResistance(SPELL_SCHOOL_HOLY), GetResistance(SPELL_SCHOOL_FIRE)); + sLog.outDebug("NatureRes is: \t\t%u\t\tFrostRes is: \t\t%u", GetResistance(SPELL_SCHOOL_NATURE), GetResistance(SPELL_SCHOOL_FROST)); + sLog.outDebug("ShadowRes is: \t\t%u\t\tArcaneRes is: \t\t%u", GetResistance(SPELL_SCHOOL_SHADOW), GetResistance(SPELL_SCHOOL_ARCANE)); + sLog.outDebug("MIN_DAMAGE is: \t\t%f\tMAX_DAMAGE is: \t\t%f", GetFloatValue(UNIT_FIELD_MINDAMAGE), GetFloatValue(UNIT_FIELD_MAXDAMAGE)); + sLog.outDebug("MIN_OFFHAND_DAMAGE is: \t%f\tMAX_OFFHAND_DAMAGE is: \t%f", GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE), GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)); + sLog.outDebug("MIN_RANGED_DAMAGE is: \t%f\tMAX_RANGED_DAMAGE is: \t%f", GetFloatValue(UNIT_FIELD_MINRANGEDDAMAGE), GetFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE)); + sLog.outDebug("ATTACK_TIME is: \t%u\t\tRANGE_ATTACK_TIME is: \t%u", GetAttackTime(BASE_ATTACK), GetAttackTime(RANGED_ATTACK)); } /*********************************************************/ @@ -18217,18 +18217,18 @@ void Player::SendAttackSwingNotInRange() void Player::SavePositionInDB(ObjectGuid guid, uint32 mapid, float x, float y, float z, float o, uint32 zone) { std::ostringstream ss; - ss << "UPDATE characters SET position_x='"<= tokens.size()) return; @@ -18391,13 +18391,13 @@ void Player::UpdateAfkReport(time_t currTime) if (m_bgData.bgAfkReportedTimer <= currTime) { m_bgData.bgAfkReportedCount = 0; - m_bgData.bgAfkReportedTimer = currTime+5*MINUTE; + m_bgData.bgAfkReportedTimer = currTime + 5 * MINUTE; } } void Player::UpdateContestedPvP(uint32 diff) { - if (!m_contestedPvPTimer||isInCombat()) + if (!m_contestedPvPTimer || isInCombat()) return; if (m_contestedPvPTimer <= diff) { @@ -18419,7 +18419,7 @@ void Player::UpdatePvPFlag(time_t currTime) void Player::UpdateDuelFlag(time_t currTime) { - if (!duel || duel->startTimer == 0 ||currTime < duel->startTimer + 3) + if (!duel || duel->startTimer == 0 || currTime < duel->startTimer + 3) return; SetUInt32Value(PLAYER_DUEL_TEAM, 1); @@ -18444,7 +18444,7 @@ void Player::BuildPlayerChat(WorldPacket* data, uint8 msgtype, const std::string *data << ObjectGuid(GetObjectGuid()); *data << uint32(language); //language 2.1.0 ? *data << ObjectGuid(GetObjectGuid()); - *data << uint32(text.length()+1); + *data << uint32(text.length() + 1); *data << text; *data << uint8(GetChatTag()); } @@ -18453,21 +18453,21 @@ void Player::Say(const std::string& text, const uint32 language) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_SAY, text, language); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY),true); + SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY), true); } void Player::Yell(const std::string& text, const uint32 language) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_YELL, text, language); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL),true); + SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL), true); } void Player::TextEmote(const std::string& text) { WorldPacket data(SMSG_MESSAGECHAT, 200); BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL); - SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT)); + SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE), true, !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHAT)); } void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiver) @@ -18513,7 +18513,7 @@ void Player::PetSpellInitialize() CharmInfo* charmInfo = pet->GetCharmInfo(); - WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1); + WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1); data << pet->GetObjectGuid(); data << uint16(pet->GetCreatureInfo()->family); // creature family (required for pet talents) data << uint32(0); @@ -18536,7 +18536,7 @@ void Player::PetSpellInitialize() if (itr->second.state == PETSPELL_REMOVED) continue; - data << uint32(MAKE_UNIT_ACTION_BUTTON(itr->first,itr->second.active)); + data << uint32(MAKE_UNIT_ACTION_BUTTON(itr->first, itr->second.active)); ++addlist; } } @@ -18594,11 +18594,11 @@ void Player::PossessSpellInitialize() if (!charmInfo) { - sLog.outError("Player::PossessSpellInitialize(): charm (GUID: %u TypeId: %u) has no charminfo!", charm->GetGUIDLow(),charm->GetTypeId()); + sLog.outError("Player::PossessSpellInitialize(): charm (GUID: %u TypeId: %u) has no charminfo!", charm->GetGUIDLow(), charm->GetTypeId()); return; } - WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+1); + WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 1); data << charm->GetObjectGuid(); data << uint16(0); data << uint32(0); @@ -18622,7 +18622,7 @@ void Player::CharmSpellInitialize() CharmInfo* charmInfo = charm->GetCharmInfo(); if (!charmInfo) { - sLog.outError("Player::CharmSpellInitialize(): the player's charm (GUID: %u TypeId: %u) has no charminfo!", charm->GetGUIDLow(),charm->GetTypeId()); + sLog.outError("Player::CharmSpellInitialize(): the player's charm (GUID: %u TypeId: %u) has no charminfo!", charm->GetGUIDLow(), charm->GetTypeId()); return; } @@ -18642,7 +18642,7 @@ void Player::CharmSpellInitialize() } } - WorldPacket data(SMSG_PET_SPELLS, 8+2+4+4+4*MAX_UNIT_ACTION_BAR_INDEX+1+4*addlist+1); + WorldPacket data(SMSG_PET_SPELLS, 8 + 2 + 4 + 4 + 4 * MAX_UNIT_ACTION_BAR_INDEX + 1 + 4 * addlist + 1); data << charm->GetObjectGuid(); data << uint16(0); data << uint32(0); @@ -18681,17 +18681,17 @@ void Player::RemovePetActionBar() void Player::AddSpellMod(Aura* aura, bool apply) { Modifier const* mod = aura->GetModifier(); - uint16 Opcode= (mod->m_auraname == SPELL_AURA_ADD_FLAT_MODIFIER) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER; + uint16 Opcode = (mod->m_auraname == SPELL_AURA_ADD_FLAT_MODIFIER) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER; for (int eff = 0; eff < 96; ++eff) { uint64 _mask = 0; - uint32 _mask2= 0; + uint32 _mask2 = 0; if (eff < 64) _mask = uint64(1) << (eff - 0); else - _mask2= uint32(1) << (eff - 64); + _mask2 = uint32(1) << (eff - 64); if (aura->GetAuraSpellClassMask().IsFitToFamilyMask(_mask, _mask2)) { @@ -18702,7 +18702,7 @@ void Player::AddSpellMod(Aura* aura, bool apply) val += (*itr)->GetModifier()->m_amount; } val += apply ? mod->m_amount : -(mod->m_amount); - WorldPacket data(Opcode, (1+1+4)); + WorldPacket data(Opcode, (1 + 1 + 4)); data << uint8(eff); data << uint8(mod->m_miscvalue); data << int32(val); @@ -18743,14 +18743,14 @@ template T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& bas // special case (skip >10sec spell casts for instant cast setting) if (mod->m_miscvalue == SPELLMOD_CASTING_TIME - && basevalue >= T(10*IN_MILLISECONDS) && mod->m_amount <= -100) + && basevalue >= T(10 * IN_MILLISECONDS) && mod->m_amount <= -100) continue; totalpct += mod->m_amount; } } - float diff = (float)basevalue*(float)totalpct/100.0f + (float)totalflat; + float diff = (float)basevalue * (float)totalpct / 100.0f + (float)totalflat; basevalue = T((float)basevalue + diff); return T(diff); } @@ -18795,7 +18795,7 @@ void Player::RemovePetitionsAndSigns(ObjectGuid guid, uint32 type) delete result; - if (type==10) + if (type == 10) CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u'", lowguid); else CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE playerguid = '%u' AND type = '%u'", lowguid, type); @@ -18844,7 +18844,7 @@ void Player::SetRestBonus(float rest_bonus_new) if (rest_bonus_new < 0) rest_bonus_new = 0; - float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP)*1.5f/2.0f; + float rest_bonus_max = (float)GetUInt32Value(PLAYER_NEXT_LEVEL_XP) * 1.5f / 2.0f; if (rest_bonus_new > rest_bonus_max) m_rest_bonus = rest_bonus_max; @@ -18873,7 +18873,7 @@ void Player::HandleStealthedUnitsDetection() for (std::list::const_iterator i = stealthedUnits.begin(); i != stealthedUnits.end(); ++i) { - if ((*i)==this) + if ((*i) == this) continue; bool hasAtClient = HaveAtClient((*i)); @@ -18887,11 +18887,11 @@ void Player::HandleStealthedUnitsDetection() (*i)->SendCreateUpdateToPlayer(this); m_clientGUIDs.insert(i_guid); - DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is detected in stealth by player %u. Distance = %f",i_guid.GetString().c_str(),GetGUIDLow(),GetDistance(*i)); + DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is detected in stealth by player %u. Distance = %f", i_guid.GetString().c_str(), GetGUIDLow(), GetDistance(*i)); // target aura duration for caster show only if target exist at caster client // send data at target visibility change (adding to client) - if ((*i)!=this && (*i)->isType(TYPEMASK_UNIT)) + if ((*i) != this && (*i)->isType(TYPEMASK_UNIT)) SendAurasForTarget(*i); } } @@ -18962,13 +18962,13 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc if (Spell* spell = GetCurrentSpell(CURRENT_GENERIC_SPELL)) if (spell->m_spellInfo->Id != spellid) - InterruptSpell(CURRENT_GENERIC_SPELL,false); + InterruptSpell(CURRENT_GENERIC_SPELL, false); - InterruptSpell(CURRENT_AUTOREPEAT_SPELL,false); + InterruptSpell(CURRENT_AUTOREPEAT_SPELL, false); if (Spell* spell = GetCurrentSpell(CURRENT_CHANNELED_SPELL)) if (spell->m_spellInfo->Id != spellid) - InterruptSpell(CURRENT_CHANNELED_SPELL,true); + InterruptSpell(CURRENT_CHANNELED_SPELL, true); } uint32 sourcenode = nodes[0]; @@ -18987,10 +18987,10 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc if (node->x != 0.0f || node->y != 0.0f || node->z != 0.0f) { if (node->map_id != GetMapId() || - (node->x - GetPositionX())*(node->x - GetPositionX())+ - (node->y - GetPositionY())*(node->y - GetPositionY())+ - (node->z - GetPositionZ())*(node->z - GetPositionZ()) > - (2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)*(2*INTERACTION_DISTANCE)) + (node->x - GetPositionX()) * (node->x - GetPositionX()) + + (node->y - GetPositionY()) * (node->y - GetPositionY()) + + (node->z - GetPositionZ()) * (node->z - GetPositionZ()) > + (2 * INTERACTION_DISTANCE) * (2 * INTERACTION_DISTANCE) * (2 * INTERACTION_DISTANCE)) { WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); data << uint32(ERR_TAXITOOFARAWAY); @@ -19067,7 +19067,7 @@ bool Player::ActivateTaxiPathTo(std::vector const& nodes, Creature* npc uint32 money = GetMoney(); if (npc) - totalcost = (uint32)ceil(totalcost*GetReputationPriceDiscount(npc)); + totalcost = (uint32)ceil(totalcost * GetReputationPriceDiscount(npc)); if (money < totalcost) { @@ -19109,7 +19109,7 @@ bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 0*/) nodes[0] = entry->from; nodes[1] = entry->to; - return ActivateTaxiPathTo(nodes,NULL,spellid); + return ActivateTaxiPathTo(nodes, NULL, spellid); } void Player::ContinueTaxiFlight() @@ -19128,16 +19128,16 @@ void Player::ContinueTaxiFlight() TaxiPathNodeList const& nodeList = sTaxiPathNodesByPath[path]; - float distPrev = MAP_SIZE*MAP_SIZE; + float distPrev = MAP_SIZE * MAP_SIZE; float distNext = - (nodeList[0].x-GetPositionX())*(nodeList[0].x-GetPositionX())+ - (nodeList[0].y-GetPositionY())*(nodeList[0].y-GetPositionY())+ - (nodeList[0].z-GetPositionZ())*(nodeList[0].z-GetPositionZ()); + (nodeList[0].x - GetPositionX()) * (nodeList[0].x - GetPositionX()) + + (nodeList[0].y - GetPositionY()) * (nodeList[0].y - GetPositionY()) + + (nodeList[0].z - GetPositionZ()) * (nodeList[0].z - GetPositionZ()); for (uint32 i = 1; i < nodeList.size(); ++i) { TaxiPathNodeEntry const& node = nodeList[i]; - TaxiPathNodeEntry const& prevNode = nodeList[i-1]; + TaxiPathNodeEntry const& prevNode = nodeList[i - 1]; // skip nodes at another map if (node.mapid != GetMapId()) @@ -19146,14 +19146,14 @@ void Player::ContinueTaxiFlight() distPrev = distNext; distNext = - (node.x-GetPositionX())*(node.x-GetPositionX())+ - (node.y-GetPositionY())*(node.y-GetPositionY())+ - (node.z-GetPositionZ())*(node.z-GetPositionZ()); + (node.x - GetPositionX()) * (node.x - GetPositionX()) + + (node.y - GetPositionY()) * (node.y - GetPositionY()) + + (node.z - GetPositionZ()) * (node.z - GetPositionZ()); float distNodes = - (node.x-prevNode.x)*(node.x-prevNode.x)+ - (node.y-prevNode.y)*(node.y-prevNode.y)+ - (node.z-prevNode.z)*(node.z-prevNode.z); + (node.x - prevNode.x) * (node.x - prevNode.x) + + (node.y - prevNode.y) * (node.y - prevNode.y) + + (node.z - prevNode.z) * (node.z - prevNode.z); if (distNext + distPrev < distNodes) { @@ -19168,7 +19168,7 @@ void Player::ContinueTaxiFlight() void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) { // last check 2.0.10 - WorldPacket data(SMSG_SPELL_COOLDOWN, 8+1+m_spells.size()*8); + WorldPacket data(SMSG_SPELL_COOLDOWN, 8 + 1 + m_spells.size() * 8); data << GetObjectGuid(); data << uint8(0x0); // flags (0x1, 0x2) time_t curTime = time(NULL); @@ -19192,7 +19192,7 @@ void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs) { data << uint32(unSpellId); data << uint32(unTimeMs); // in m.secs - AddSpellCooldown(unSpellId, 0, curTime + unTimeMs/IN_MILLISECONDS); + AddSpellCooldown(unSpellId, 0, curTime + unTimeMs / IN_MILLISECONDS); } } GetSession()->SendPacket(&data); @@ -19205,8 +19205,8 @@ void Player::InitDataForForm(bool reapplyMods) SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(form); if (ssEntry && ssEntry->attackSpeed) { - SetAttackTime(BASE_ATTACK,ssEntry->attackSpeed); - SetAttackTime(OFF_ATTACK,ssEntry->attackSpeed); + SetAttackTime(BASE_ATTACK, ssEntry->attackSpeed); + SetAttackTime(OFF_ATTACK, ssEntry->attackSpeed); SetAttackTime(RANGED_ATTACK, BASE_ATTACK_TIME); } else @@ -19216,14 +19216,14 @@ void Player::InitDataForForm(bool reapplyMods) { case FORM_CAT: { - if (getPowerType()!=POWER_ENERGY) + if (getPowerType() != POWER_ENERGY) setPowerType(POWER_ENERGY); break; } case FORM_BEAR: case FORM_DIREBEAR: { - if (getPowerType()!=POWER_RAGE) + if (getPowerType() != POWER_RAGE) setPowerType(POWER_RAGE); break; } @@ -19268,7 +19268,7 @@ void Player::InitDisplayIds() SetNativeDisplayId(info->displayId_m); break; default: - sLog.outError("Invalid gender %u for player",gender); + sLog.outError("Invalid gender %u for player", gender); return; } } @@ -19324,7 +19324,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin uint32 vCount = vItems ? vItems->GetItemCount() : 0; uint32 tCount = tItems ? tItems->GetItemCount() : 0; - if (vendorslot >= vCount+tCount) + if (vendorslot >= vCount + tCount) { SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); return false; @@ -19482,7 +19482,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem, totalCount); - WorldPacket data(SMSG_BUY_ITEM, 8+4+4+4); + WorldPacket data(SMSG_BUY_ITEM, 8 + 4 + 4 + 4); data << pCreature->GetObjectGuid(); data << uint32(vendorslot + 1); // numbered from 1 at client data << uint32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); @@ -19522,7 +19522,7 @@ void Player::UpdateHomebindTime(uint32 time) if (m_HomebindTimer) // instance valid, but timer not reset { // hide reminder - WorldPacket data(SMSG_RAID_GROUP_ONLY, 4+4); + WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4); data << uint32(0); data << uint32(ERR_RAID_GROUP_NONE); // error used only when timer = 0 GetSession()->SendPacket(&data); @@ -19545,11 +19545,11 @@ void Player::UpdateHomebindTime(uint32 time) // instance is invalid, start homebind timer m_HomebindTimer = 60000; // send message to player - WorldPacket data(SMSG_RAID_GROUP_ONLY, 4+4); + WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4); data << uint32(m_HomebindTimer); data << uint32(ERR_RAID_GROUP_NONE); // error used only when timer = 0 GetSession()->SendPacket(&data); - DEBUG_LOG("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(),GetGUIDLow()); + DEBUG_LOG("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(), GetGUIDLow()); } } @@ -19615,8 +19615,8 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it { // use +MONTH as infinity mark for spell cooldown (will checked as MONTH/2 at save ans skipped) // but not allow ignore until reset or re-login - catrecTime = catrec > 0 ? curTime+infinityCooldownDelay : 0; - recTime = rec > 0 ? curTime+infinityCooldownDelay : catrecTime; + catrecTime = catrec > 0 ? curTime + infinityCooldownDelay : 0; + recTime = rec > 0 ? curTime + infinityCooldownDelay : catrecTime; } else { @@ -19640,8 +19640,8 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it if (rec == 0 && catrec == 0) return; - catrecTime = catrec ? curTime+catrec/IN_MILLISECONDS : 0; - recTime = rec ? curTime+rec/IN_MILLISECONDS : catrecTime; + catrecTime = catrec ? curTime + catrec / IN_MILLISECONDS : 0; + recTime = rec ? curTime + rec / IN_MILLISECONDS : catrecTime; } // self spell cooldown @@ -19679,7 +19679,7 @@ void Player::SendCooldownEvent(SpellEntry const* spellInfo, uint32 itemId, Spell AddSpellAndCategoryCooldowns(spellInfo, itemId, spell); // Send activate cooldown timer (possible 0) at client side - WorldPacket data(SMSG_COOLDOWN_EVENT, (4+8)); + WorldPacket data(SMSG_COOLDOWN_EVENT, (4 + 8)); data << uint32(spellInfo->Id); data << GetObjectGuid(); SendDirectMessage(&data); @@ -19699,11 +19699,11 @@ void Player::UpdatePotionCooldown(Spell* spell) for (int idx = 0; idx < 5; ++idx) if (proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE) if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId)) - SendCooldownEvent(spellInfo,m_lastPotionId); + SendCooldownEvent(spellInfo, m_lastPotionId); } // from spell cases (m_lastPotionId set in Spell::SendSpellCooldown) else - SendCooldownEvent(spell->m_spellInfo,m_lastPotionId,spell); + SendCooldownEvent(spell->m_spellInfo, m_lastPotionId, spell); m_lastPotionId = 0; } @@ -19729,7 +19729,7 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) Item* pItem2 = GetItemByPos(INVENTORY_SLOT_BAG_0, i); if (pItem2 && !pItem2->IsBroken() && pItem2->GetProto()->Socket[0].Color) { - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem2->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) @@ -19772,7 +19772,7 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) uint32 _cur_gem = curcount[Condition->Color[i] - 1]; // if have use them as count, else use from Condition - uint32 _cmp_gem = Condition->CompareColor[i] ? curcount[Condition->CompareColor[i] - 1]: Condition->Value[i]; + uint32 _cmp_gem = Condition->CompareColor[i] ? curcount[Condition->CompareColor[i] - 1] : Condition->Value[i]; switch (Condition->Comparator[i]) { @@ -19807,7 +19807,7 @@ void Player::CorrectMetaGemEnchants(uint8 exceptslot, bool apply) if (!pItem || !pItem->GetProto()->Socket[0].Color) continue; - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) @@ -19850,7 +19850,7 @@ void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) continue; //cycle all (gem)enchants - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) //if no enchant go to next enchant(slot) @@ -19863,7 +19863,7 @@ void Player::ToggleMetaGemsActive(uint8 exceptslot, bool apply) //only metagems to be (de)activated, so only enchants with condition uint32 condition = enchantEntry->EnchantmentCondition; if (condition) - ApplyEnchantment(pItem,EnchantmentSlot(enchant_slot), apply); + ApplyEnchantment(pItem, EnchantmentSlot(enchant_slot), apply); } } } @@ -20024,7 +20024,7 @@ bool Player::IsVisibleGloballyFor(Player* u) const return false; // Always can see self - if (u==this) + if (u == this) return true; // Visible units, always are visible for all players @@ -20063,9 +20063,9 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe { ObjectGuid t_guid = target->GetObjectGuid(); - if (target->GetTypeId()==TYPEID_UNIT) + if (target->GetTypeId() == TYPEID_UNIT) { - BeforeVisibilityDestroy((Creature*)target,this); + BeforeVisibilityDestroy((Creature*)target, this); // at remove from map (destroy) show kill animation (in different out of range/stealth case) target->DestroyForPlayer(this, !target->IsInWorld() && ((Creature*)target)->isDead()); @@ -20075,7 +20075,7 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe m_clientGUIDs.erase(t_guid); - DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s out of range for player %u. Distance = %f",t_guid.GetString().c_str(),GetGUIDLow(),GetDistance(target)); + DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s out of range for player %u. Distance = %f", t_guid.GetString().c_str(), GetGUIDLow(), GetDistance(target)); } } else @@ -20083,14 +20083,14 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* targe if (target->isVisibleForInState(this, viewPoint, false)) { target->SendCreateUpdateToPlayer(this); - if (target->GetTypeId()!=TYPEID_GAMEOBJECT||!((GameObject*)target)->IsTransport()) + if (target->GetTypeId() != TYPEID_GAMEOBJECT || !((GameObject*)target)->IsTransport()) m_clientGUIDs.insert(target->GetObjectGuid()); - DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "Object %u (Type: %u) is visible now for player %u. Distance = %f",target->GetGUIDLow(),target->GetTypeId(),GetGUIDLow(),GetDistance(target)); + DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "Object %u (Type: %u) is visible now for player %u. Distance = %f", target->GetGUIDLow(), target->GetTypeId(), GetGUIDLow(), GetDistance(target)); // target aura duration for caster show only if target exist at caster client // send data at target visibility change (adding to client) - if (target!=this && target->isType(TYPEMASK_UNIT)) + if (target != this && target->isType(TYPEMASK_UNIT)) SendAurasForTarget((Unit*)target); } } @@ -20114,9 +20114,9 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD { if (HaveAtClient(target)) { - if (!target->isVisibleForInState(this,viewPoint,true)) + if (!target->isVisibleForInState(this, viewPoint, true)) { - BeforeVisibilityDestroy(target,this); + BeforeVisibilityDestroy(target, this); ObjectGuid t_guid = target->GetObjectGuid(); @@ -20128,11 +20128,11 @@ void Player::UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateD } else { - if (target->isVisibleForInState(this,viewPoint,false)) + if (target->isVisibleForInState(this, viewPoint, false)) { visibleNow.insert(target); target->BuildCreateUpdateBlockForPlayer(&data, this); - UpdateVisibilityOf_helper(m_clientGUIDs,target); + UpdateVisibilityOf_helper(m_clientGUIDs, target); DEBUG_FILTER_LOG(LOG_FILTER_VISIBILITY_CHANGES, "%s is visible now for %s. Distance = %f", target->GetGuidStr().c_str(), GetGuidStr().c_str(), GetDistance(target)); } @@ -20171,7 +20171,7 @@ void Player::SendComboPoints() Unit* combotarget = ObjectAccessor::GetUnit(*this, m_comboTargetGuid); if (combotarget) { - WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size()+1); + WorldPacket data(SMSG_UPDATE_COMBO_POINTS, combotarget->GetPackGUID().size() + 1); data << combotarget->GetPackGUID(); data << uint8(m_comboPoints); GetSession()->SendPacket(&data); @@ -20227,7 +20227,7 @@ void Player::ClearComboPoints() SendComboPoints(); - if (Unit* target = ObjectAccessor::GetUnit(*this,m_comboTargetGuid)) + if (Unit* target = ObjectAccessor::GetUnit(*this, m_comboTargetGuid)) target->RemoveComboPointHolder(GetGUIDLow()); m_comboTargetGuid.Clear(); @@ -20251,7 +20251,7 @@ void Player::SendInitialPacketsBeforeAddToMap() GetSocial()->SendSocialList(); // Homebind - WorldPacket data(SMSG_BINDPOINTUPDATE, 5*4); + WorldPacket data(SMSG_BINDPOINTUPDATE, 5 * 4); data << m_homebindX << m_homebindY << m_homebindZ; data << (uint32) m_homebindMapId; data << (uint32) m_homebindAreaId; @@ -20263,7 +20263,7 @@ void Player::SendInitialPacketsBeforeAddToMap() SendTalentsInfoData(false); - data.Initialize(SMSG_INSTANCE_DIFFICULTY, 4+4); + data.Initialize(SMSG_INSTANCE_DIFFICULTY, 4 + 4); data << uint32(GetMap()->GetDifficulty()); data << uint32(0); GetSession()->SendPacket(&data); @@ -20307,8 +20307,8 @@ void Player::SendInitialPacketsAfterAddToMap() { // update zone uint32 newzone, newarea; - GetZoneAndAreaId(newzone,newarea); - UpdateZone(newzone,newarea); // also call SendInitWorldStates(); + GetZoneAndAreaId(newzone, newarea); + UpdateZone(newzone, newarea); // also call SendInitWorldStates(); ResetTimeSync(); SendTimeSync(); @@ -20328,7 +20328,7 @@ void Player::SendInitialPacketsAfterAddToMap() { Unit::AuraList const& auraList = GetAurasByType(*itr); if (!auraList.empty()) - auraList.front()->ApplyModifier(true,true); + auraList.front()->ApplyModifier(true, true); } if (HasAuraType(SPELL_AURA_MOD_STUN)) @@ -20340,7 +20340,7 @@ void Player::SendInitialPacketsAfterAddToMap() WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10); data2 << GetPackGUID(); data2 << (uint32)2; - SendMessageToSet(&data2,true); + SendMessageToSet(&data2, true); } SendAurasForTarget(this); @@ -20363,7 +20363,7 @@ void Player::SendUpdateToOutOfRangeGroupMembers() void Player::SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg) { - WorldPacket data(SMSG_TRANSFER_ABORTED, 4+2); + WorldPacket data(SMSG_TRANSFER_ABORTED, 4 + 2); data << uint32(mapid); data << uint8(reason); // transfer abort reason switch (reason) @@ -20390,7 +20390,7 @@ void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint3 else type = RAID_INSTANCE_WARNING_MIN_SOON; - WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4+4+4+4); + WorldPacket data(SMSG_RAID_INSTANCE_MESSAGE, 4 + 4 + 4 + 4); data << uint32(type); data << uint32(mapid); data << uint32(difficulty); // difficulty @@ -20433,14 +20433,14 @@ void Player::resetSpells() { // not need after this call if (HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) - RemoveAtLoginFlag(AT_LOGIN_RESET_SPELLS,true); + RemoveAtLoginFlag(AT_LOGIN_RESET_SPELLS, true); // make full copy of map (spells removed and marked as deleted at another spell remove // and we can't use original map for safe iterative with visit each spell at loop end PlayerSpellMap smap = GetSpellMap(); for (PlayerSpellMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter) - removeSpell(iter->first,false,false); // only iter->first can be accessed, object by iter->second can be deleted already + removeSpell(iter->first, false, false); // only iter->first can be accessed, object by iter->second can be deleted already learnDefaultSpells(); learnQuestRewardedSpells(); @@ -20449,11 +20449,11 @@ void Player::resetSpells() void Player::learnDefaultSpells() { // learn default race/class spells - PlayerInfo const* info = sObjectMgr.GetPlayerInfo(getRace(),getClass()); - for (PlayerCreateInfoSpells::const_iterator itr = info->spell.begin(); itr!=info->spell.end(); ++itr) + PlayerInfo const* info = sObjectMgr.GetPlayerInfo(getRace(), getClass()); + for (PlayerCreateInfoSpells::const_iterator itr = info->spell.begin(); itr != info->spell.end(); ++itr) { uint32 tspell = *itr; - DEBUG_LOG("PLAYER (Class: %u Race: %u): Adding initial spell, id = %u",uint32(getClass()),uint32(getRace()), tspell); + DEBUG_LOG("PLAYER (Class: %u Race: %u): Adding initial spell, id = %u", uint32(getClass()), uint32(getRace()), tspell); if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add addSpell(tspell, true, true, true, false); else // but send in normal spell in game learn case @@ -20475,7 +20475,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest) // check learned spells state bool found = false; - for (int i=0; i < MAX_EFFECT_INDEX; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i])) { @@ -20507,7 +20507,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest) // search other specialization for same prof for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) { - if (itr->second.state == PLAYERSPELL_REMOVED || itr->first==learned_0) + if (itr->second.state == PLAYERSPELL_REMOVED || itr->first == learned_0) continue; SpellEntry const* itrInfo = sSpellStore.LookupEntry(itr->first); @@ -20523,7 +20523,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest) continue; // now we have 2 specialization, learn possible only if found is lesser specialization rank - if (!sSpellMgr.IsHighRankOfSpell(learned_0,itr->first)) + if (!sSpellMgr.IsHighRankOfSpell(learned_0, itr->first)) return; } } @@ -20553,10 +20553,10 @@ void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value) { uint32 raceMask = getRaceMask(); uint32 classMask = getClassMask(); - for (uint32 j = 0; jskillId!=skill_id || pAbility->learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL) + if (!pAbility || pAbility->skillId != skill_id || pAbility->learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL) continue; // Check race if set if (pAbility->racemask && !(pAbility->racemask & raceMask)) @@ -20599,9 +20599,9 @@ void Player::SetDailyQuestStatus(uint32 quest_id) { for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) { - if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx)) + if (!GetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx)) { - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, quest_id); m_DailyQuestChanged = true; break; } @@ -20623,7 +20623,7 @@ void Player::SetMonthlyQuestStatus(uint32 quest_id) void Player::ResetDailyQuestStatus() { for (uint32 quest_daily_idx = 0; quest_daily_idx < PLAYER_MAX_DAILY_QUESTS; ++quest_daily_idx) - SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,0); + SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1 + quest_daily_idx, 0); // DB data deleted in caller m_DailyQuestChanged = false; @@ -20651,7 +20651,7 @@ void Player::ResetMonthlyQuestStatus() BattleGround* Player::GetBattleGround() const { - if (GetBattleGroundId()==0) + if (GetBattleGroundId() == 0) return NULL; return sBattleGroundMgr.GetBattleGround(GetBattleGroundId(), m_bgData.bgTypeID); @@ -20694,7 +20694,7 @@ float Player::GetReputationPriceDiscount(Creature const* pCreature) const if (rank <= REP_NEUTRAL) return 1.0f; - return 1.0f - 0.05f* (rank - REP_NEUTRAL); + return 1.0f - 0.05f * (rank - REP_NEUTRAL); } /** @@ -20712,7 +20712,7 @@ bool Player::IsSpellFitByClassAndRace(uint32 spell_id, uint32* pReqlevel /*= NUL uint32 classmask = getClassMask(); SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spell_id); - if (bounds.first==bounds.second) + if (bounds.first == bounds.second) return true; for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) @@ -20782,7 +20782,7 @@ bool Player::HasQuestForGO(int32 GOId) const for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { - if (qinfo->ReqCreatureOrGOId[j]>=0) //skip non GO case + if (qinfo->ReqCreatureOrGOId[j] >= 0) //skip non GO case continue; if ((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) @@ -20800,12 +20800,12 @@ void Player::UpdateForQuestWorldObjects() UpdateData udata; WorldPacket packet; - for (GuidSet::const_iterator itr=m_clientGUIDs.begin(); itr!=m_clientGUIDs.end(); ++itr) + for (GuidSet::const_iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) { if (itr->IsGameObject()) { if (GameObject* obj = GetMap()->GetGameObject(*itr)) - obj->BuildValuesUpdateBlockForPlayer(&udata,this); + obj->BuildValuesUpdateBlockForPlayer(&udata, this); } else if (itr->IsCreatureOrVehicle()) { @@ -20814,7 +20814,7 @@ void Player::UpdateForQuestWorldObjects() continue; // check if this unit requires quest specific flags - if (!obj->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK)) + if (!obj->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK)) continue; SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(obj->GetEntry()); @@ -20822,7 +20822,7 @@ void Player::UpdateForQuestWorldObjects() { if (_itr->second.questStart || _itr->second.questEnd) { - obj->BuildCreateUpdateBlockForPlayer(&udata,this); + obj->BuildCreateUpdateBlockForPlayer(&udata, this); break; } } @@ -20860,14 +20860,14 @@ void Player::SummonIfPossible(bool agree) GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ACCEPTED_SUMMONINGS, 1); - TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z,GetOrientation()); + TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z, GetOrientation()); } void Player::RemoveItemDurations(Item* item) { for (ItemDurationList::iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) { - if (*itr==item) + if (*itr == item) { m_itemDuration.erase(itr); break; @@ -20926,34 +20926,34 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons { case ITEM_CLASS_WEAPON: { - for (int i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) + for (int i = EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; break; } case ITEM_CLASS_ARMOR: { // tabard not have dependent spells - for (int i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) + for (int i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_MAINHAND; ++i) if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) - if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // shields can be equipped to offhand slot if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // ranged slot can have some armor subclasses if (Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - if (item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; break; } default: - sLog.outError("HasItemFitToSpellReqirements: Not handled spell requirement for item class %u",spellInfo->EquippedItemClass); + sLog.outError("HasItemFitToSpellReqirements: Not handled spell requirement for item class %u", spellInfo->EquippedItemClass); break; } @@ -20968,7 +20968,7 @@ bool Player::CanNoReagentCast(SpellEntry const* spellInfo) const // Check no reagent use mask uint64 noReagentMask_0_1 = GetUInt64Value(PLAYER_NO_REAGENT_COST_1); - uint32 noReagentMask_2 = GetUInt32Value(PLAYER_NO_REAGENT_COST_1+2); + uint32 noReagentMask_2 = GetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 2); if (spellInfo->IsFitToFamilyMask(noReagentMask_0_1, noReagentMask_2)) return true; @@ -20991,7 +20991,7 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem) } // skip if not item dependent or have alternative item - if (HasItemFitToSpellReqirements(spellInfo,pItem)) + if (HasItemFitToSpellReqirements(spellInfo, pItem)) { ++itr; continue; @@ -21005,7 +21005,7 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem) // currently casted spells can be dependent from item for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i) if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i))) - if (spell->getState()!=SPELL_STATE_DELAYED && !HasItemFitToSpellReqirements(spell->m_spellInfo,pItem)) + if (spell->getState() != SPELL_STATE_DELAYED && !HasItemFitToSpellReqirements(spell->m_spellInfo, pItem)) InterruptSpell(CurrentSpellTypes(i)); } @@ -21030,14 +21030,14 @@ uint32 Player::GetResurrectionSpellId() case 27239: spell_id = 27240; break; // rank 6 case 47883: spell_id = 47882; break; // rank 7 default: - sLog.outError("Unhandled spell %u: S.Resurrection",(*itr)->GetId()); + sLog.outError("Unhandled spell %u: S.Resurrection", (*itr)->GetId()); continue; } prio = 3; } // Twisting Nether // prio: 2 (max) - else if ((*itr)->GetId()==23701 && roll_chance_i(10)) + else if ((*itr)->GetId() == 23701 && roll_chance_i(10)) { prio = 2; spell_id = 23700; @@ -21046,7 +21046,7 @@ uint32 Player::GetResurrectionSpellId() // Reincarnation (passive spell) // prio: 1 // Glyph of Renewed Life remove reagent requiremnnt - if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasItemCount(17030,1) || HasAura(58059, EFFECT_INDEX_0))) + if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasItemCount(17030, 1) || HasAura(58059, EFFECT_INDEX_0))) spell_id = 21169; return spell_id; @@ -21059,7 +21059,7 @@ bool Player::isHonorOrXPTarget(Unit* pVictim) const uint32 k_grey = MaNGOS::XP::GetGrayLevel(getLevel()); // Victim level less gray level - if (v_level<=k_grey) + if (v_level <= k_grey) return false; if (pVictim->GetTypeId() == TYPEID_UNIT) @@ -21078,19 +21078,19 @@ void Player::RewardSinglePlayerAtKill(Unit* pVictim) uint32 xp = PvP ? 0 : MaNGOS::XP::Gain(this, pVictim); // honor can be in PvP and !PvP (racial leader) cases - RewardHonor(pVictim,1); + RewardHonor(pVictim, 1); // xp and reputation only in !PvP case if (!PvP) { - RewardReputation(pVictim,1); + RewardReputation(pVictim, 1); GiveXP(xp, pVictim); if (Pet* pet = GetPet()) pet->GivePetXP(xp); // normal creature (not pet/etc) can be only in !PvP case - if (pVictim->GetTypeId()==TYPEID_UNIT) + if (pVictim->GetTypeId() == TYPEID_UNIT) if (CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(pVictim->GetEntry())) KilledMonster(normalInfo, pVictim->GetObjectGuid()); } @@ -21113,7 +21113,7 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar continue; // member (alive or dead) or his corpse at req. distance // quest objectives updated only for alive group member or dead but with not released body - if (pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + if (pGroupGuy->isAlive() || !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) pGroupGuy->KilledMonsterCredit(creature_id, creature_guid); } } @@ -21136,7 +21136,7 @@ void Player::RewardPlayerAndGroupAtCast(WorldObject* pRewardSource, uint32 spell continue; // member (alive or dead) or his corpse at req. distance // quest objectives updated only for alive group member or dead but with not released body - if (pGroupGuy->isAlive()|| !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) + if (pGroupGuy->isAlive() || !pGroupGuy->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) pGroupGuy->CastedCreatureOrGO(pRewardSource->GetEntry(), pRewardSource->GetObjectGuid(), spellid, pGroupGuy == this); } } @@ -21146,7 +21146,7 @@ void Player::RewardPlayerAndGroupAtCast(WorldObject* pRewardSource, uint32 spell bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const { - if (pRewardSource->IsWithinDistInMap(this,sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE))) + if (pRewardSource->IsWithinDistInMap(this, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE))) return true; if (isAlive()) @@ -21156,12 +21156,12 @@ bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const if (!corpse) return false; - return pRewardSource->IsWithinDistInMap(corpse,sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE)); + return pRewardSource->IsWithinDistInMap(corpse, sWorld.getConfig(CONFIG_FLOAT_GROUP_XP_DISTANCE)); } uint32 Player::GetBaseWeaponSkillValue(WeaponAttackType attType) const { - Item* item = GetWeaponForAttack(attType,true,true); + Item* item = GetWeaponForAttack(attType, true, true); // unarmed only with base attack if (attType != BASE_ATTACK && !item) @@ -21186,7 +21186,7 @@ void Player::ResurectUsingRequestData() return; } - ResurrectPlayer(0.0f,false); + ResurrectPlayer(0.0f, false); if (GetMaxHealth() > m_resurrectHealth) SetHealth(m_resurrectHealth); @@ -21207,7 +21207,7 @@ void Player::ResurectUsingRequestData() void Player::SetClientControl(Unit* target, uint8 allowMove) { - WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1); + WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size() + 1); data << target->GetPackGUID(); data << uint8(allowMove); GetSession()->SendPacket(&data); @@ -21220,7 +21220,7 @@ void Player::UpdateZoneDependentAuras() for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) if (itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, 0)) if (!HasAura(itr->second->spellId, EFFECT_INDEX_0)) - CastSpell(this,itr->second->spellId,true); + CastSpell(this, itr->second->spellId, true); } void Player::UpdateAreaDependentAuras() @@ -21243,7 +21243,7 @@ void Player::UpdateAreaDependentAuras() for (SpellAreaForAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) if (itr->second->autocast && itr->second->IsFitToRequirements(this, m_zoneUpdateId, m_areaUpdateId)) if (!HasAura(itr->second->spellId, EFFECT_INDEX_0)) - CastSpell(this,itr->second->spellId,true); + CastSpell(this, itr->second->spellId, true); } struct UpdateZoneDependentPetsHelper @@ -21265,7 +21265,7 @@ struct UpdateZoneDependentPetsHelper void Player::UpdateZoneDependentPets() { // check pet (permanent pets ignored), minipet, guardians (including protector) - CallForAllControlledUnits(UpdateZoneDependentPetsHelper(this, m_zoneUpdateId, m_areaUpdateId), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_MINIPET); + CallForAllControlledUnits(UpdateZoneDependentPetsHelper(this, m_zoneUpdateId, m_areaUpdateId), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_MINIPET); } uint32 Player::GetCorpseReclaimDelay(bool pvp) const @@ -21278,7 +21278,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const time_t now = time(NULL); // 0..2 full period - uint32 count = (now < m_deathExpireTime) ? uint32((m_deathExpireTime - now)/DEATH_EXPIRE_STEP) : 0; + uint32 count = (now < m_deathExpireTime) ? uint32((m_deathExpireTime - now) / DEATH_EXPIRE_STEP) : 0; return copseReclaimDelay[count]; } @@ -21294,14 +21294,14 @@ void Player::UpdateCorpseReclaimDelay() if (now < m_deathExpireTime) { // full and partly periods 1..3 - uint32 count = uint32((m_deathExpireTime - now)/DEATH_EXPIRE_STEP +1); + uint32 count = uint32((m_deathExpireTime - now) / DEATH_EXPIRE_STEP + 1); if (count < MAX_DEATH_COUNT) - m_deathExpireTime = now+(count+1)*DEATH_EXPIRE_STEP; + m_deathExpireTime = now + (count + 1) * DEATH_EXPIRE_STEP; else - m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP; + m_deathExpireTime = now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP; } else - m_deathExpireTime = now+DEATH_EXPIRE_STEP; + m_deathExpireTime = now + DEATH_EXPIRE_STEP; } void Player::SendCorpseReclaimDelay(bool load) @@ -21316,33 +21316,33 @@ void Player::SendCorpseReclaimDelay(bool load) if (corpse->GetGhostTime() > m_deathExpireTime) return; - bool pvp = corpse->GetType()==CORPSE_RESURRECTABLE_PVP; + bool pvp = corpse->GetType() == CORPSE_RESURRECTABLE_PVP; uint32 count; if ((pvp && sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVP)) || (!pvp && sWorld.getConfig(CONFIG_BOOL_DEATH_CORPSE_RECLAIM_DELAY_PVE))) { - count = uint32(m_deathExpireTime-corpse->GetGhostTime())/DEATH_EXPIRE_STEP; - if (count>=MAX_DEATH_COUNT) - count = MAX_DEATH_COUNT-1; + count = uint32(m_deathExpireTime - corpse->GetGhostTime()) / DEATH_EXPIRE_STEP; + if (count >= MAX_DEATH_COUNT) + count = MAX_DEATH_COUNT - 1; } else - count=0; + count = 0; - time_t expected_time = corpse->GetGhostTime()+copseReclaimDelay[count]; + time_t expected_time = corpse->GetGhostTime() + copseReclaimDelay[count]; time_t now = time(NULL); if (now >= expected_time) return; - delay = uint32(expected_time-now); + delay = uint32(expected_time - now); } else - delay = GetCorpseReclaimDelay(corpse->GetType()==CORPSE_RESURRECTABLE_PVP); + delay = GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP); //! corpse reclaim delay 30 * 1000ms or longer at often deaths WorldPacket data(SMSG_CORPSE_RECLAIM_DELAY, 4); - data << uint32(delay*IN_MILLISECONDS); + data << uint32(delay * IN_MILLISECONDS); GetSession()->SendPacket(&data); } @@ -21368,7 +21368,7 @@ Player* Player::GetNextRandomRaidMember(float radius) if (nearMembers.empty()) return NULL; - uint32 randTarget = urand(0,nearMembers.size()-1); + uint32 randTarget = urand(0, nearMembers.size() - 1); return nearMembers[randTarget]; } @@ -21428,7 +21428,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z) GridMapLiquidStatus res = m->GetTerrain()->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status); if (!res) { - m_MirrorTimerFlags &= ~(UNDERWATER_INWATER|UNDERWATER_INLAVA|UNDERWATER_INSLIME|UNDERWATER_INDARKWATER); + m_MirrorTimerFlags &= ~(UNDERWATER_INWATER | UNDERWATER_INLAVA | UNDERWATER_INSLIME | UNDERWATER_INDARKWATER); // Small hack for enable breath in WMO /* if (IsInWater()) m_MirrorTimerFlags|=UNDERWATER_INWATER; */ @@ -21436,7 +21436,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z) } // All liquids type - check under water position - if (liquid_status.type&(MAP_LIQUID_TYPE_WATER|MAP_LIQUID_TYPE_OCEAN|MAP_LIQUID_TYPE_MAGMA|MAP_LIQUID_TYPE_SLIME)) + if (liquid_status.type & (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN | MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)) { if (res & LIQUID_MAP_UNDER_WATER) m_MirrorTimerFlags |= UNDERWATER_INWATER; @@ -21451,17 +21451,17 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z) m_MirrorTimerFlags &= ~UNDERWATER_INDARKWATER; // in lava check, anywhere in lava level - if (liquid_status.type&MAP_LIQUID_TYPE_MAGMA) + if (liquid_status.type & MAP_LIQUID_TYPE_MAGMA) { - if (res & (LIQUID_MAP_UNDER_WATER|LIQUID_MAP_IN_WATER|LIQUID_MAP_WATER_WALK)) + if (res & (LIQUID_MAP_UNDER_WATER | LIQUID_MAP_IN_WATER | LIQUID_MAP_WATER_WALK)) m_MirrorTimerFlags |= UNDERWATER_INLAVA; else m_MirrorTimerFlags &= ~UNDERWATER_INLAVA; } // in slime check, anywhere in slime level - if (liquid_status.type&MAP_LIQUID_TYPE_SLIME) + if (liquid_status.type & MAP_LIQUID_TYPE_SLIME) { - if (res & (LIQUID_MAP_UNDER_WATER|LIQUID_MAP_IN_WATER|LIQUID_MAP_WATER_WALK)) + if (res & (LIQUID_MAP_UNDER_WATER | LIQUID_MAP_IN_WATER | LIQUID_MAP_WATER_WALK)) m_MirrorTimerFlags |= UNDERWATER_INSLIME; else m_MirrorTimerFlags &= ~UNDERWATER_INSLIME; @@ -21470,7 +21470,7 @@ void Player::UpdateUnderwaterState(Map* m, float x, float y, float z) void Player::SetCanParry(bool value) { - if (m_canParry==value) + if (m_canParry == value) return; m_canParry = value; @@ -21479,7 +21479,7 @@ void Player::SetCanParry(bool value) void Player::SetCanBlock(bool value) { - if (m_canBlock==value) + if (m_canBlock == value) return; m_canBlock = value; @@ -21601,7 +21601,7 @@ void Player::ApplyGlyph(uint8 slot, bool apply) void Player::ApplyGlyphs(bool apply) { for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i) - ApplyGlyph(i,apply); + ApplyGlyph(i, apply); } bool Player::isTotalImmune() @@ -21753,21 +21753,21 @@ void Player::AutoStoreLoot(Loot& loot, bool broadcast, uint8 bag, uint8 slot) uint32 max_slot = loot.GetMaxSlotInLootFor(this); for (uint32 i = 0; i < max_slot; ++i) { - LootItem* lootItem = loot.LootItemInSlot(i,this); + LootItem* lootItem = loot.LootItemInSlot(i, this); ItemPosCountVec dest; - InventoryResult msg = CanStoreNewItem(bag,slot,dest,lootItem->itemid,lootItem->count); + InventoryResult msg = CanStoreNewItem(bag, slot, dest, lootItem->itemid, lootItem->count); if (msg != EQUIP_ERR_OK && slot != NULL_SLOT) - msg = CanStoreNewItem(bag, NULL_SLOT,dest,lootItem->itemid,lootItem->count); + msg = CanStoreNewItem(bag, NULL_SLOT, dest, lootItem->itemid, lootItem->count); if (msg != EQUIP_ERR_OK && bag != NULL_BAG) - msg = CanStoreNewItem(NULL_BAG, NULL_SLOT,dest,lootItem->itemid,lootItem->count); + msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, lootItem->itemid, lootItem->count); if (msg != EQUIP_ERR_OK) { SendEquipError(msg, NULL, NULL, lootItem->itemid); continue; } - Item* pItem = StoreNewItem(dest,lootItem->itemid,true,lootItem->randomPropertyId); + Item* pItem = StoreNewItem(dest, lootItem->itemid, true, lootItem->randomPropertyId); SendNewItem(pItem, lootItem->count, false, false, broadcast); } } @@ -21781,7 +21781,7 @@ Item* Player::ConvertItem(Item* item, uint32 newItemId) return NULL; // copy enchantments - for (uint8 j= PERM_ENCHANTMENT_SLOT; j<=TEMP_ENCHANTMENT_SLOT; ++j) + for (uint8 j = PERM_ENCHANTMENT_SLOT; j <= TEMP_ENCHANTMENT_SLOT; ++j) { if (item->GetEnchantmentId(EnchantmentSlot(j))) pNewItem->SetEnchantment(EnchantmentSlot(j), item->GetEnchantmentId(EnchantmentSlot(j)), @@ -21905,7 +21905,7 @@ void Player::_LoadSkills(QueryResult* result) } // set fixed skill ranges - switch (GetSkillRangeType(pSkill,false)) + switch (GetSkillRangeType(pSkill, false)) { case SKILL_RANGE_LANGUAGE: // 300..300 value = max = 300; @@ -21924,9 +21924,9 @@ void Player::_LoadSkills(QueryResult* result) continue; } - SetUInt32Value(PLAYER_SKILL_INDEX(count), MAKE_PAIR32(skill,0)); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(count),MAKE_SKILL_VALUE(value, max)); - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(count),0); + SetUInt32Value(PLAYER_SKILL_INDEX(count), MAKE_PAIR32(skill, 0)); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(count), MAKE_SKILL_VALUE(value, max)); + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(count), 0); mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(count, SKILL_UNCHANGED))); @@ -21947,17 +21947,17 @@ void Player::_LoadSkills(QueryResult* result) for (; count < PLAYER_MAX_SKILLS; ++count) { SetUInt32Value(PLAYER_SKILL_INDEX(count), 0); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(count),0); - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(count),0); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(count), 0); + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(count), 0); } // special settings - if (getClass()==CLASS_DEATH_KNIGHT) + if (getClass() == CLASS_DEATH_KNIGHT) { - uint32 base_level = std::min(getLevel(),sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL)); + uint32 base_level = std::min(getLevel(), sWorld.getConfig(CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL)); if (base_level < 1) base_level = 1; - uint32 base_skill = (base_level-1)*5; // 270 at starting level 55 + uint32 base_skill = (base_level - 1) * 5; // 270 at starting level 55 if (base_skill < 1) base_skill = 1; // skill mast be known and then > 0 in any case @@ -22004,11 +22004,11 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi ItemPrototype const* pProto = pItem->GetProto(); // proto based limitations - if (InventoryResult res = CanEquipUniqueItem(pProto,eslot,limit_count)) + if (InventoryResult res = CanEquipUniqueItem(pProto, eslot, limit_count)) return res; // check unique-equipped on gems - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + 3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); if (!enchant_id) @@ -22025,7 +22025,7 @@ InventoryResult Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limi uint32 gem_limit_count = !pItem->IsEquipped() && pGem->ItemLimitCategory ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1; - if (InventoryResult res = CanEquipUniqueItem(pGem, eslot,gem_limit_count)) + if (InventoryResult res = CanEquipUniqueItem(pGem, eslot, gem_limit_count)) return res; } @@ -22038,7 +22038,7 @@ InventoryResult Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 if (itemProto->Flags & ITEM_FLAG_UNIQUE_EQUIPPED) { // there is an equip limit on this item - if (HasItemOrGemWithIdEquipped(itemProto->ItemId,1,except_slot)) + if (HasItemOrGemWithIdEquipped(itemProto->ItemId, 1, except_slot)) return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; } @@ -22055,7 +22055,7 @@ InventoryResult Player::CanEquipUniqueItem(ItemPrototype const* itemProto, uint8 return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; // there is an equip limit on this item - if (HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory,limitEntry->maxCount-limit_count+1,except_slot)) + if (HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory, limitEntry->maxCount - limit_count + 1, except_slot)) return EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS; } @@ -22077,11 +22077,11 @@ void Player::HandleFall(MovementInfo const& movementInfo) //Safe fall, fall height reduction int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL); - float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f; + float damageperc = 0.018f * (z_diff - safe_fall) - 0.2426f; - if (damageperc >0) + if (damageperc > 0) { - uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getConfig(CONFIG_FLOAT_RATE_DAMAGE_FALL)); + uint32 damage = (uint32)(damageperc * GetMaxHealth() * sWorld.getConfig(CONFIG_FLOAT_RATE_DAMAGE_FALL)); float height = movementInfo.GetPos()->z; UpdateAllowedPositionZ(movementInfo.GetPos()->x, movementInfo.GetPos()->y, height); @@ -22094,14 +22094,14 @@ void Player::HandleFall(MovementInfo const& movementInfo) // Gust of Wind if (GetDummyAura(43621)) - damage = GetMaxHealth()/2; + damage = GetMaxHealth() / 2; uint32 original_health = GetHealth(); uint32 final_damage = EnvironmentalDamage(DAMAGE_FALL, damage); // recheck alive, might have died of EnvironmentalDamage, avoid cases when player die in fact like Spirit of Redemption case if (isAlive() && final_damage < original_health) - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, uint32(z_diff*100)); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, uint32(z_diff * 100)); } //Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction @@ -22112,7 +22112,7 @@ void Player::HandleFall(MovementInfo const& movementInfo) void Player::UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1/*=0*/, uint32 miscvalue2/*=0*/, Unit* unit/*=NULL*/, uint32 time/*=0*/) { - GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1,miscvalue2,unit,time); + GetAchievementMgr().UpdateAchievementCriteria(type, miscvalue1, miscvalue2, unit, time); } void Player::StartTimedAchievementCriteria(AchievementCriteriaTypes type, uint32 timedRequirementId, time_t startTime /*= 0*/) @@ -22271,7 +22271,7 @@ void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRa // find current max talent rank int32 curtalent_maxrank = 0; - for (int32 k = MAX_TALENT_RANK-1; k > -1; --k) + for (int32 k = MAX_TALENT_RANK - 1; k > -1; --k) { if (talentInfo->RankID[k] && pet->HasSpell(talentInfo->RankID[k])) { @@ -22367,7 +22367,7 @@ void Player::UpdateKnownCurrencies(uint32 itemId, bool apply) } } -void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode) +void Player::UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode) { if (m_lastFallTime >= minfo.GetFallTime() || m_lastFallZ <= minfo.GetPos()->z || opcode == MSG_MOVE_FALL_LAND) SetFallInformation(minfo.GetFallTime(), minfo.GetPos()->z); @@ -22406,7 +22406,7 @@ void Player::ResummonPetTemporaryUnSummonedIfAny() bool Player::canSeeSpellClickOn(Creature const* c) const { - if (!c->HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_SPELLCLICK)) + if (!c->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK)) return false; SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(c->GetEntry()); @@ -22601,7 +22601,7 @@ void Player::SendEquipmentSetList() data << uint32(count); // count placeholder for (EquipmentSets::iterator itr = m_EquipmentSets.begin(); itr != m_EquipmentSets.end(); ++itr) { - if (itr->second.state==EQUIPMENT_SET_DELETED) + if (itr->second.state == EQUIPMENT_SET_DELETED) continue; data.appendPackGUID(itr->second.Guid); data << uint32(itr->first); @@ -22824,7 +22824,7 @@ void Player::ActivateSpec(uint8 specNum) for (int r = 0; r < MAX_TALENT_RANK; ++r) if (talentInfo->RankID[r]) - removeSpell(talentInfo->RankID[r],!IsPassiveSpell(talentInfo->RankID[r]),false); + removeSpell(talentInfo->RankID[r], !IsPassiveSpell(talentInfo->RankID[r]), false); specIter = m_talents[m_activeSpec].begin(); } @@ -22884,9 +22884,9 @@ void Player::ActivateSpec(uint8 specNum) if (itr->second.uState != ACTIONBUTTON_DELETED) { // remove broken without any output (it can be not correct because talents not copied at spec creating) - if (!IsActionButtonDataValid(itr->first,itr->second.GetAction(),itr->second.GetType(), this, false)) + if (!IsActionButtonDataValid(itr->first, itr->second.GetAction(), itr->second.GetType(), this, false)) { - removeActionButton(m_activeSpec,itr->first); + removeActionButton(m_activeSpec, itr->first); itr = currentActionButtonList.begin(); continue; } @@ -22928,7 +22928,7 @@ void Player::UpdateSpecCount(uint8 count) if (itr->second.uState != ACTIONBUTTON_DELETED) { for (uint8 spec = curCount; spec < count; ++spec) - addActionButton(spec,itr->first,itr->second.GetAction(),itr->second.GetType()); + addActionButton(spec, itr->first, itr->second.GetAction(), itr->second.GetType()); } } } @@ -22940,7 +22940,7 @@ void Player::UpdateSpecCount(uint8 count) { // delete action buttons for removed spec for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button) - removeActionButton(spec,button); + removeActionButton(spec, button); } } @@ -22959,7 +22959,7 @@ void Player::RemoveAtLoginFlag(AtLoginFlags f, bool in_db_also /*= false*/) void Player::SendClearCooldown(uint32 spell_id, Unit* target) { - WorldPacket data(SMSG_CLEAR_COOLDOWN, 4+8); + WorldPacket data(SMSG_CLEAR_COOLDOWN, 4 + 8); data << uint32(spell_id); data << target->GetObjectGuid(); SendDirectMessage(&data); @@ -23048,7 +23048,7 @@ Object* Player::GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask) return GetItemByGuid(guid); break; case HIGHGUID_PLAYER: - if (GetObjectGuid()==guid) + if (GetObjectGuid() == guid) return this; if ((typemask & TYPEMASK_PLAYER) && IsInWorld()) return ObjectAccessor::FindPlayer(guid); diff --git a/src/game/Player.h b/src/game/Player.h index 447267e6f..bbc35f8e2 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -181,7 +181,7 @@ enum ActionButtonIndex #define MAX_ACTION_BUTTONS 144 //checked in 3.2.0 -typedef std::map ActionButtonList; +typedef std::map ActionButtonList; enum GlyphUpdateState { @@ -251,7 +251,7 @@ struct PlayerClassInfo struct PlayerLevelInfo { - PlayerLevelInfo() { for (int i=0; i < MAX_STATS; ++i) stats[i] = 0; } + PlayerLevelInfo() { for (int i = 0; i < MAX_STATS; ++i) stats[i] = 0; } uint8 stats[MAX_STATS]; }; @@ -273,7 +273,7 @@ typedef std::list PlayerCreateInfoActions; struct PlayerInfo { // existence checked by displayId != 0 // existence checked by displayId != 0 - PlayerInfo() : displayId_m(0),displayId_f(0),levelInfo(NULL) + PlayerInfo() : displayId_m(0), displayId_f(0), levelInfo(NULL) { } @@ -898,13 +898,13 @@ class MANGOS_DLL_SPEC PlayerTaxi bool IsTaximaskNodeKnown(uint32 nodeidx) const { uint8 field = uint8((nodeidx - 1) / 32); - uint32 submask = 1<<((nodeidx-1)%32); + uint32 submask = 1 << ((nodeidx - 1) % 32); return (m_taximask[field] & submask) == submask; } bool SetTaximaskNode(uint32 nodeidx) { uint8 field = uint8((nodeidx - 1) / 32); - uint32 submask = 1<<((nodeidx-1)%32); + uint32 submask = 1 << ((nodeidx - 1) % 32); if ((m_taximask[field] & submask) != submask) { m_taximask[field] |= submask; @@ -1111,7 +1111,7 @@ class MANGOS_DLL_SPEC Player : public Unit int GetAuctionAccessMode() const { return m_ExtraFlags & PLAYER_EXTRA_AUCTION_ENEMY ? -1 : (m_ExtraFlags & PLAYER_EXTRA_AUCTION_NEUTRAL ? 1 : 0); } void SetAuctionAccessMode(int state) { - m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY|PLAYER_EXTRA_AUCTION_NEUTRAL); + m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY | PLAYER_EXTRA_AUCTION_NEUTRAL); if (state < 0) m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY; @@ -1172,7 +1172,7 @@ class MANGOS_DLL_SPEC Player : public Unit Item* GetItemByPos(uint16 pos) const; Item* GetItemByPos(uint8 bag, uint8 slot) const; uint32 GetItemDisplayIdInSlot(uint8 bag, uint8 slot) const; - Item* GetWeaponForAttack(WeaponAttackType attackType) const { return GetWeaponForAttack(attackType,false,false); } + Item* GetWeaponForAttack(WeaponAttackType attackType) const { return GetWeaponForAttack(attackType, false, false); } Item* GetWeaponForAttack(WeaponAttackType attackType, bool nonbroken, bool useable) const; Item* GetShield(bool useable = false) const; static uint32 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot @@ -1207,7 +1207,7 @@ class MANGOS_DLL_SPEC Player : public Unit return _CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); } - InventoryResult CanStoreItems(Item** pItem,int count) const; + InventoryResult CanStoreItems(Item** pItem, int count) const; InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const; InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool direct_action = true) const; @@ -1220,7 +1220,7 @@ class MANGOS_DLL_SPEC Player : public Unit bool HasItemTotemCategory(uint32 TotemCategory) const; InventoryResult CanUseItem(ItemPrototype const* pItem) const; InventoryResult CanUseAmmo(uint32 item) const; - Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update,int32 randomPropertyId = 0); + Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0); Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update); Item* EquipNewItem(uint16 pos, uint32 item, bool update); Item* EquipItem(uint16 pos, Item* pItem, bool update); @@ -1268,7 +1268,7 @@ class MANGOS_DLL_SPEC Player : public Unit void TakeExtendedCost(uint32 extendedCostId, uint32 count); - uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; } + uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END - KEYRING_SLOT_START; } void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0) const; void SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param); void SendSellError(SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param); @@ -1297,13 +1297,13 @@ class MANGOS_DLL_SPEC Player : public Unit void TradeCancel(bool sendback); void UpdateEnchantTime(uint32 time); - void UpdateItemDuration(uint32 time, bool realtimeonly=false); + void UpdateItemDuration(uint32 time, bool realtimeonly = false); void AddEnchantmentDurations(Item* item); void RemoveEnchantmentDurations(Item* item); void RemoveAllEnchantments(EnchantmentSlot slot); - void AddEnchantmentDuration(Item* item,EnchantmentSlot slot,uint32 duration); - void ApplyEnchantment(Item* item,EnchantmentSlot slot,bool apply, bool apply_dur = true, bool ignore_condition = false); - void ApplyEnchantment(Item* item,bool apply); + void AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 duration); + void ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool apply_dur = true, bool ignore_condition = false); + void ApplyEnchantment(Item* item, bool apply); void SendEnchantmentDurations(); void BuildEnchantmentsInfoData(WorldPacket* data); void AddItemDurations(Item* item); @@ -1316,7 +1316,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetEquipGearScore(bool withBags = true, bool withBank = false); void ResetCachedGearScore() { m_cachedGS = 0; } - typedef std::vector GearScoreVec; + typedef std::vector < uint32/*item level*/ > GearScoreVec; /*********************************************************/ /*** GOSSIP SYSTEM ***/ @@ -1465,7 +1465,7 @@ class MANGOS_DLL_SPEC Player : public Unit static uint32 GetZoneIdFromDB(ObjectGuid guid); static uint32 GetLevelFromDB(ObjectGuid guid); - static bool LoadPositionFromDB(ObjectGuid guid, uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight); + static bool LoadPositionFromDB(ObjectGuid guid, uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight); /*********************************************************/ /*** SAVE SYSTEM ***/ @@ -1474,10 +1474,10 @@ class MANGOS_DLL_SPEC Player : public Unit void SaveToDB(); void SaveInventoryAndGoldToDB(); // fast save function for item/money cheating preventing void SaveGoldToDB(); - static void SetUInt32ValueInArray(Tokens& data,uint16 index, uint32 value); - static void SetFloatValueInArray(Tokens& data,uint16 index, float value); + static void SetUInt32ValueInArray(Tokens& data, uint16 index, uint32 value); + static void SetFloatValueInArray(Tokens& data, uint16 index, float value); static void Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); - static void SavePositionInDB(ObjectGuid guid, uint32 mapid, float x,float y,float z,float o,uint32 zone); + static void SavePositionInDB(ObjectGuid guid, uint32 mapid, float x, float y, float z, float o, uint32 zone); static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); static void DeleteOldCharacters(); @@ -1491,7 +1491,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SendTalentWipeConfirm(ObjectGuid guid); void RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker); void SendPetSkillWipeConfirm(); - void CalcRage(uint32 damage,bool attacker); + void CalcRage(uint32 damage, bool attacker); void RegenerateAll(uint32 diff = REGEN_TIME_FULL); void Regenerate(Powers power, uint32 diff); void RegenerateHealth(uint32 diff); @@ -1508,7 +1508,7 @@ class MANGOS_DLL_SPEC Player : public Unit // "At Gold Limit" if (GetMoney() >= MAX_MONEY_AMOUNT) - SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD,NULL,NULL); + SendEquipError(EQUIP_ERR_TOO_MUCH_GOLD, NULL, NULL); } void SetMoney(uint32 value) { @@ -1597,7 +1597,7 @@ class MANGOS_DLL_SPEC Player : public Unit void learnSpellHighRank(uint32 spellid); uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } - void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); } + void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1, points); } void UpdateFreeTalentPoints(bool resetIfNeed = true); bool resetTalents(bool no_cost = false, bool all_specs = false); uint32 resetTalentsCost() const; @@ -1642,7 +1642,7 @@ class MANGOS_DLL_SPEC Player : public Unit template T ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell const* spell = NULL); static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check - static uint32 const infinityCooldownDelayCheck = MONTH/2; + static uint32 const infinityCooldownDelayCheck = MONTH / 2; bool HasSpellCooldown(uint32 spell_id) const { SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); @@ -1698,8 +1698,8 @@ class MANGOS_DLL_SPEC Player : public Unit ActionButton const* GetActionButton(uint8 button); PvPInfo pvpInfo; - void UpdatePvP(bool state, bool ovrride=false); - void UpdateZone(uint32 newZone,uint32 newArea); + void UpdatePvP(bool state, bool ovrride = false); + void UpdateZone(uint32 newZone, uint32 newArea); void UpdateArea(uint32 newArea); uint32 GetCachedZoneId() const { return m_zoneUpdateId; } @@ -1728,7 +1728,7 @@ class MANGOS_DLL_SPEC Player : public Unit bool IsGroupVisibleFor(Player* p) const; bool IsInSameGroupWith(Player const* p) const; - bool IsInSameRaidWith(Player const* p) const { return p==this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); } + bool IsInSameRaidWith(Player const* p) const { return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); } void UninviteFromGroup(); static void RemoveFromGroup(Group* group, ObjectGuid guid); void RemoveFromGroup() { RemoveFromGroup(GetGroup(), GetObjectGuid()); } @@ -1839,7 +1839,7 @@ class MANGOS_DLL_SPEC Player : public Unit void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const; void DestroyForPlayer(Player* target, bool anim = false) const; - void SendLogXPGain(uint32 GivenXP,Unit* victim,uint32 RestXP); + void SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 RestXP); uint8 LastSwingErrorMsg() const { return m_swingErrorMsg; } void SwingErrorMsg(uint8 val) { m_swingErrorMsg = val; } @@ -1935,7 +1935,7 @@ class MANGOS_DLL_SPEC Player : public Unit bool IsAtGroupRewardDistance(WorldObject const* pRewardSource) const; void RewardSinglePlayerAtKill(Unit* pVictim); - void RewardPlayerAndGroupAtEvent(uint32 creature_id,WorldObject* pRewardSource); + void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewardSource); void RewardPlayerAndGroupAtCast(WorldObject* pRewardSource, uint32 spellid = 0); bool isHonorOrXPTarget(Unit* pVictim) const; @@ -1948,7 +1948,7 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateSkillsForLevel(); void UpdateSkillsToMaxSkillsForLevel(); // for .levelup - void ModifySkillBonus(uint32 skillid,int32 val, bool talent); + void ModifySkillBonus(uint32 skillid, int32 val, bool talent); /*********************************************************/ /*** PVP SYSTEM ***/ @@ -1967,7 +1967,7 @@ class MANGOS_DLL_SPEC Player : public Unit //End of PvP System - void SetDrunkValue(uint16 newDrunkValue, uint32 itemid=0); + void SetDrunkValue(uint16 newDrunkValue, uint32 itemid = 0); uint16 GetDrunkValue() const { return m_drunk; } static DrunkenState GetDrunkenstateByValue(uint16 value); @@ -2002,11 +2002,11 @@ class MANGOS_DLL_SPEC Player : public Unit void _ApplyWeaponDependentAuraCritMod(Item* item, WeaponAttackType attackType, Aura* aura, bool apply); void _ApplyWeaponDependentAuraDamageMod(Item* item, WeaponAttackType attackType, Aura* aura, bool apply); - void _ApplyItemMods(Item* item,uint8 slot,bool apply); + void _ApplyItemMods(Item* item, uint8 slot, bool apply); void _RemoveAllItemMods(); void _ApplyAllItemMods(); void _ApplyAllLevelScaleItemMods(bool apply); - void _ApplyItemBonuses(ItemPrototype const* proto,uint8 slot,bool apply, bool only_level_scale = false); + void _ApplyItemBonuses(ItemPrototype const* proto, uint8 slot, bool apply, bool only_level_scale = false); void _ApplyAmmoBonuses(); bool EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot); void ToggleMetaGemsActive(uint8 exceptslot, bool apply); @@ -2017,7 +2017,7 @@ class MANGOS_DLL_SPEC Player : public Unit void ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply, bool form_change = false); void UpdateEquipSpellsAtFormChange(); void CastItemCombatSpell(Unit* Target, WeaponAttackType attType); - void CastItemUseSpell(Item* item,SpellCastTargets const& targets,uint8 cast_count, uint32 glyphIndex); + void CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8 cast_count, uint32 glyphIndex); void ApplyItemOnStoreSpell(Item* item, bool apply); void DestroyItemWithOnStoreSpell(Item* item, uint32 spellId); @@ -2053,7 +2053,7 @@ class MANGOS_DLL_SPEC Player : public Unit bool InBattleGroundQueue() const { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE) return true; return false; @@ -2062,14 +2062,14 @@ class MANGOS_DLL_SPEC Player : public Unit BattleGroundQueueTypeId GetBattleGroundQueueTypeId(uint32 index) const { return m_bgBattleGroundQueueID[index].bgQueueTypeId; } uint32 GetBattleGroundQueueIndex(BattleGroundQueueTypeId bgQueueTypeId) const { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId) return i; return PLAYER_MAX_BATTLEGROUND_QUEUES; } bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId) return m_bgBattleGroundQueueID[i].invitedToInstance != 0; return false; @@ -2087,7 +2087,7 @@ class MANGOS_DLL_SPEC Player : public Unit } uint32 AddBattleGroundQueueId(BattleGroundQueueTypeId val) { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattleGroundQueueID[i].bgQueueTypeId == val) { @@ -2100,14 +2100,14 @@ class MANGOS_DLL_SPEC Player : public Unit } bool HasFreeBattleGroundQueueId() { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE) return true; return false; } void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val) { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { if (m_bgBattleGroundQueueID[i].bgQueueTypeId == val) { @@ -2119,13 +2119,13 @@ class MANGOS_DLL_SPEC Player : public Unit } void SetInviteForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId, uint32 instanceId) { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId) m_bgBattleGroundQueueID[i].invitedToInstance = instanceId; } bool IsInvitedForBattleGroundInstance(uint32 instanceId) const { - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId) return true; return false; @@ -2158,7 +2158,7 @@ class MANGOS_DLL_SPEC Player : public Unit /*** REST SYSTEM ***/ /*********************************************************/ - bool isRested() const { return GetRestTime() >= 10*IN_MILLISECONDS; } + bool isRested() const { return GetRestTime() >= 10 * IN_MILLISECONDS; } uint32 GetXPRestBonus(uint32 xp); uint32 GetRestTime() const { return m_restTime; } void SetRestTime(uint32 v) { m_restTime = v; } @@ -2181,7 +2181,7 @@ class MANGOS_DLL_SPEC Player : public Unit /*** VARIOUS SYSTEMS ***/ /*********************************************************/ bool HasMovementFlag(MovementFlags f) const; // for script access to m_movementInfo.HasMovementFlag - void UpdateFallInformationIfNeed(MovementInfo const& minfo,uint16 opcode); + void UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode); void SetFallInformation(uint32 time, float z) { m_lastFallTime = time; @@ -2237,7 +2237,7 @@ class MANGOS_DLL_SPEC Player : public Unit // currently visible objects at player client GuidSet m_clientGUIDs; - bool HaveAtClient(WorldObject const* u) { return u==this || m_clientGUIDs.find(u->GetObjectGuid())!=m_clientGUIDs.end(); } + bool HaveAtClient(WorldObject const* u) { return u == this || m_clientGUIDs.find(u->GetObjectGuid()) != m_clientGUIDs.end(); } bool IsVisibleInGridForPlayer(Player* pl) const; bool IsVisibleGloballyFor(Player* pl) const; @@ -2245,7 +2245,7 @@ class MANGOS_DLL_SPEC Player : public Unit void UpdateVisibilityOf(WorldObject const* viewPoint, WorldObject* target); template - void UpdateVisibilityOf(WorldObject const* viewPoint,T* target, UpdateData& data, std::set& visibleNow); + void UpdateVisibilityOf(WorldObject const* viewPoint, T* target, UpdateData& data, std::set& visibleNow); // Stealth detection system void HandleStealthedUnitsDetection(); @@ -2274,7 +2274,7 @@ class MANGOS_DLL_SPEC Player : public Unit /*** INSTANCE SYSTEM ***/ /*********************************************************/ - typedef UNORDERED_MAP< uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; + typedef UNORDERED_MAP < uint32 /*mapId*/, InstancePlayerBind > BoundInstancesMap; void UpdateHomebindTime(uint32 time); @@ -2341,7 +2341,7 @@ class MANGOS_DLL_SPEC Player : public Unit AchievementMgr const& GetAchievementMgr() const { return m_achievementMgr; } AchievementMgr& GetAchievementMgr() { return m_achievementMgr; } - void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1=0, uint32 miscvalue2=0, Unit* unit=NULL, uint32 time=0); + void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscvalue1 = 0, uint32 miscvalue2 = 0, Unit* unit = NULL, uint32 time = 0); void StartTimedAchievementCriteria(AchievementCriteriaTypes type, uint32 timedRequirementId, time_t startTime = 0); @@ -2667,7 +2667,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 m_cachedGS; }; -void AddItemsSetItem(Player* player,Item* item); -void RemoveItemsSetItem(Player* player,ItemPrototype const* proto); +void AddItemsSetItem(Player* player, Item* item); +void RemoveItemsSetItem(Player* player, ItemPrototype const* proto); #endif diff --git a/src/game/PlayerDump.cpp b/src/game/PlayerDump.cpp index 44b1076da..a66270ef9 100644 --- a/src/game/PlayerDump.cpp +++ b/src/game/PlayerDump.cpp @@ -87,33 +87,33 @@ std::string gettoknth(std::string& str, int n) if (!findtoknth(str, n, s, e)) return ""; - return str.substr(s, e-s); + return str.substr(s, e - s); } bool findnth(std::string& str, int n, std::string::size_type& s, std::string::size_type& e) { - s = str.find("VALUES ('")+9; + s = str.find("VALUES ('") + 9; if (s == std::string::npos) return false; do { - e = str.find("'",s); + e = str.find("'", s); if (e == std::string::npos) return false; } - while (str[e-1] == '\\'); + while (str[e - 1] == '\\'); for (int i = 1; i < n; ++i) { do { - s = e+4; - e = str.find("'",s); + s = e + 4; + e = str.find("'", s); if (e == std::string::npos) return false; } - while (str[e-1] == '\\'); + while (str[e - 1] == '\\'); } return true; } @@ -125,19 +125,19 @@ std::string gettablename(std::string& str) if (e == std::string::npos) return ""; - return str.substr(s, e-s); + return str.substr(s, e - s); } bool changenth(std::string& str, int n, const char* with, bool insert = false, bool nonzero = false) { std::string::size_type s, e; - if (!findnth(str,n,s,e)) + if (!findnth(str, n, s, e)) return false; - if (nonzero && str.substr(s,e-s) == "0") + 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); @@ -147,10 +147,10 @@ bool changenth(std::string& str, int n, const char* with, bool insert = false, b std::string getnth(std::string& str, int n) { std::string::size_type s, e; - if (!findnth(str,n,s,e)) + if (!findnth(str, n, s, e)) return ""; - return str.substr(s, e-s); + return str.substr(s, e - s); } bool changetoknth(std::string& str, int n, const char* with, bool insert = false, bool nonzero = false) @@ -158,10 +158,10 @@ 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; - if (nonzero && str.substr(s,e-s) == "0") + 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); @@ -211,7 +211,7 @@ std::string CreateDumpString(char const* tableName, QueryResult* result) return ""; std::ostringstream ss; - ss << "INSERT INTO "<< _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; + ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; Field* fields = result->Fetch(); for (uint32 i = 0; i < result->GetFieldCount(); ++i) { @@ -261,7 +261,7 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g return wherestr.str(); } -void StoreGUID(QueryResult* result,uint32 field,std::set& guids) +void StoreGUID(QueryResult* result, uint32 field, std::set& guids) { Field* fields = result->Fetch(); uint32 guid = fields[field].GetUInt32(); @@ -269,7 +269,7 @@ void StoreGUID(QueryResult* result,uint32 field,std::set& guids) guids.insert(guid); } -void StoreGUID(QueryResult* result,uint32 data,uint32 field, std::set& guids) +void StoreGUID(QueryResult* result, uint32 data, uint32 field, std::set& guids) { Field* fields = result->Fetch(); std::string dataStr = fields[data].GetCppString(); @@ -311,9 +311,9 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con 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); + wherestr = GenerateWhereStr(fieldname, guid); QueryResult* result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str()); if (!result) @@ -325,13 +325,13 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con switch (type) { case DTT_INVENTORY: - StoreGUID(result,3,items); break; // item guid collection (character_inventory.item) + StoreGUID(result, 3, items); break; // item guid collection (character_inventory.item) case DTT_PET: - StoreGUID(result,0,pets); break; // pet petnumber collection (character_pet.id) + StoreGUID(result, 0, pets); break; // pet petnumber collection (character_pet.id) case DTT_MAIL: - StoreGUID(result,0,mails); // mail id collection (mail.id) + StoreGUID(result, 0, mails); // mail id collection (mail.id) case DTT_MAIL_ITEM: - StoreGUID(result,1,items); break; // item guid collection (mail_items.item_guid) + StoreGUID(result, 1, items); break; // item guid collection (mail_items.item_guid) default: break; } @@ -360,7 +360,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid) std::string reqName; for (QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr) { - if (itr->substr(0,9)=="required_") + if (itr->substr(0, 9) == "required_") { reqName = *itr; break; @@ -370,7 +370,7 @@ std::string PlayerDumpWriter::GetDump(uint32 guid) if (!reqName.empty()) { // this will fail at wrong character DB version - dump += "UPDATE character_db_version SET "+reqName+" = 1 WHERE FALSE;\n\n"; + dump += "UPDATE character_db_version SET " + reqName + " = 1 WHERE FALSE;\n\n"; } else sLog.outError("Table 'character_db_version' not have revision guard field, revision guard query not added to pdump."); @@ -397,7 +397,7 @@ DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid) std::string dump = GetDump(guid); - fprintf(fout,"%s\n",dump.c_str()); + fprintf(fout, "%s\n", dump.c_str()); fclose(fout); return DUMP_SUCCESS; } @@ -440,7 +440,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!normalizePlayerName(name)) name = ""; - if (ObjectMgr::CheckPlayerName(name,true) == CHAR_NAME_SUCCESS) + if (ObjectMgr::CheckPlayerName(name, true) == CHAR_NAME_SUCCESS) { CharacterDatabase.escape_string(name); // for safe, we use name only for sql quearies anyway result = CharacterDatabase.PQuery("SELECT * FROM characters WHERE name = '%s'", name.c_str()); @@ -460,9 +460,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s snprintf(newpetid, 20, "%u", sObjectMgr.GeneratePetNumber()); snprintf(lastpetid, 20, "%s", ""); - std::map items; - std::map mails; - std::map eqsets; + std::map items; + std::map mails; + std::map eqsets; char buf[32000] = ""; typedef std::map PetIds; // old->new petid relation @@ -482,15 +482,15 @@ 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) + if (nw_pos == std::string::npos) continue; // skip NOTE - if (line.substr(nw_pos,15)=="IMPORTANT NOTE:") + if (line.substr(nw_pos, 15) == "IMPORTANT NOTE:") continue; // add required_ check - if (line.substr(nw_pos,41)=="UPDATE character_db_version SET required_") + if (line.substr(nw_pos, 41) == "UPDATE character_db_version SET required_") { if (!CharacterDatabase.Execute(line.c_str())) ROLLBACK(DUMP_FILE_BROKEN); @@ -597,10 +597,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update if (!changenth(line, 2, newguid)) // item_instance.owner_guid update 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())) + 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)) + 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); @@ -627,10 +627,10 @@ 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) + if (strlen(lastpetid) == 0) snprintf(lastpetid, 20, "%s", currpetid); - if (strcmp(lastpetid,currpetid)!=0) + if (strcmp(lastpetid, currpetid) != 0) { snprintf(newpetid, 20, "%d", sObjectMgr.GeneratePetNumber()); snprintf(lastpetid, 20, "%s", currpetid); @@ -710,12 +710,12 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s if (!changeGuid(line, 2, eqsets, sObjectMgr.m_EquipmentSetIds.GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); // character_equipmentsets.setguid for (int i = 0; i < 19; ++i) // character_equipmentsets.item0..item18 - if (!changeGuid(line, 6+i, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) + if (!changeGuid(line, 6 + i, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) ROLLBACK(DUMP_FILE_BROKEN); break; } default: - sLog.outError("Unknown dump table type: %u",type); + sLog.outError("Unknown dump table type: %u", type); break; } @@ -731,7 +731,7 @@ 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/PointMovementGenerator.cpp b/src/game/PointMovementGenerator.cpp index e6bbeb314..3424cef48 100644 --- a/src/game/PointMovementGenerator.cpp +++ b/src/game/PointMovementGenerator.cpp @@ -32,7 +32,7 @@ void PointMovementGenerator::Initialize(T& unit) if (!unit.IsStopped()) unit.StopMoving(); - unit.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); Movement::MoveSplineInit init(unit); init.MoveTo(i_x, i_y, i_z, m_generatePath); init.Launch(); @@ -41,7 +41,7 @@ void PointMovementGenerator::Initialize(T& unit) template void PointMovementGenerator::Finalize(T& unit) { - unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); if (unit.movespline->Finalized()) MovementInform(unit); @@ -50,7 +50,7 @@ void PointMovementGenerator::Finalize(T& unit) template void PointMovementGenerator::Interrupt(T& unit) { - unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); } template @@ -59,7 +59,7 @@ void PointMovementGenerator::Reset(T& unit) if (!unit.IsStopped()) unit.StopMoving(); - unit.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + unit.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); } template @@ -112,7 +112,7 @@ template bool PointMovementGenerator::Update(Creature&, const uint32& void AssistanceMovementGenerator::Finalize(Unit& unit) { - unit.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + unit.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); ((Creature*)&unit)->SetNoCallAssistance(false); ((Creature*)&unit)->CallAssistance(); @@ -133,7 +133,7 @@ void EffectMovementGenerator::Finalize(Unit& unit) if (((Creature&)unit).AI() && unit.movespline->Finalized()) ((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)) + if (unit.isAlive() && !unit.hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING)) { if (Unit* victim = unit.getVictim()) unit.GetMotionMaster()->MoveChase(victim); diff --git a/src/game/PointMovementGenerator.h b/src/game/PointMovementGenerator.h index d56dff6ba..6bc9baa42 100644 --- a/src/game/PointMovementGenerator.h +++ b/src/game/PointMovementGenerator.h @@ -41,10 +41,10 @@ class MANGOS_DLL_SPEC PointMovementGenerator MovementGeneratorType GetMovementGeneratorType() const { return POINT_MOTION_TYPE; } - bool GetDestination(float& x, float& y, float& z) const { x=i_x; y=i_y; z=i_z; return true; } + bool GetDestination(float& x, float& y, float& z) const { x = i_x; y = i_y; z = i_z; return true; } private: uint32 id; - float i_x,i_y,i_z; + float i_x, i_y, i_z; bool m_generatePath; }; diff --git a/src/game/PoolManager.cpp b/src/game/PoolManager.cpp index 187b20195..3dd3e471c 100644 --- a/src/game/PoolManager.cpp +++ b/src/game/PoolManager.cpp @@ -151,7 +151,7 @@ bool PoolGroup::CheckPool() const if (EqualChanced.size() == 0) { float chance = 0; - for (uint32 i=0; i::CheckPool() const template void PoolGroup::CheckEventLinkAndReport(int16 event_id, std::map const& creature2event, std::map const& go2event) const { - for (uint32 i=0; i < EqualChanced.size(); ++i) + for (uint32 i = 0; i < EqualChanced.size(); ++i) EqualChanced[i].CheckEventLinkAndReport(poolId, event_id, creature2event, go2event); - for (uint32 i=0; i(poolId, event_id, creature2event, go2event); } template void PoolGroup::SetExcludeObject(uint32 guid, bool state) { - for (uint32 i=0; i < EqualChanced.size(); ++i) + for (uint32 i = 0; i < EqualChanced.size(); ++i) { if (EqualChanced[i].guid == guid) { @@ -182,7 +182,7 @@ void PoolGroup::SetExcludeObject(uint32 guid, bool state) } } - for (uint32 i=0; i::RollOne(SpawnedPoolData& spawns, uint32 triggerFrom) if (!EqualChanced.empty()) { - int32 index = irand(0, EqualChanced.size()-1); + int32 index = irand(0, EqualChanced.size() - 1); // Triggering object is marked as spawned at this time and can be also rolled (respawn case) // so this need explicit check for this case if (!EqualChanced[index].exclude && (EqualChanced[index].guid == triggerFrom || !spawns.IsSpawnedObject(EqualChanced[index].guid))) @@ -237,7 +237,7 @@ void PoolGroup::DespawnObject(MapPersistentState& mapState, uint32 guid) if (!guid || EqualChanced[i].guid == guid) { Despawn1Object(mapState, EqualChanced[i].guid); - mapState.GetSpawnedPoolData().RemoveSpawn(EqualChanced[i].guid,poolId); + mapState.GetSpawnedPoolData().RemoveSpawn(EqualChanced[i].guid, poolId); } } } @@ -251,7 +251,7 @@ void PoolGroup::DespawnObject(MapPersistentState& mapState, uint32 guid) if (!guid || ExplicitlyChanced[i].guid == guid) { Despawn1Object(mapState, ExplicitlyChanced[i].guid); - mapState.GetSpawnedPoolData().RemoveSpawn(ExplicitlyChanced[i].guid,poolId); + mapState.GetSpawnedPoolData().RemoveSpawn(ExplicitlyChanced[i].guid, poolId); } } } @@ -344,7 +344,7 @@ void PoolGroup::SpawnObject(MapPersistentState& mapState, uint32 limit, uint3 // This will try to spawn the rest of pool, not guaranteed for (int i = 0; i < count; ++i) { - PoolObject* obj = RollOne(spawns,triggerFrom); + PoolObject* obj = RollOne(spawns, triggerFrom); if (!obj) continue; if (obj->guid == lastDespawned) @@ -359,7 +359,7 @@ void PoolGroup::SpawnObject(MapPersistentState& mapState, uint32 limit, uint3 continue; } - spawns.AddSpawn(obj->guid,poolId); + spawns.AddSpawn(obj->guid, poolId); Spawn1Object(mapState, obj, instantly); if (triggerFrom) @@ -653,7 +653,7 @@ void PoolManager::LoadFromDB() } if (pool_id > max_pool_id) { - sLog.outErrorDb("`pool_creature` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.",pool_id); + sLog.outErrorDb("`pool_creature` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.", pool_id); continue; } if (chance < 0 || chance > 100) @@ -716,7 +716,7 @@ void PoolManager::LoadFromDB() } if (pool_id > max_pool_id) { - sLog.outErrorDb("`pool_creature_template` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.",pool_id); + sLog.outErrorDb("`pool_creature_template` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.", pool_id); continue; } if (chance < 0 || chance > 100) @@ -802,7 +802,7 @@ void PoolManager::LoadFromDB() } if (pool_id > max_pool_id) { - sLog.outErrorDb("`pool_gameobject` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.",pool_id); + sLog.outErrorDb("`pool_gameobject` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.", pool_id); continue; } if (chance < 0 || chance > 100) @@ -875,7 +875,7 @@ void PoolManager::LoadFromDB() } if (pool_id > max_pool_id) { - sLog.outErrorDb("`pool_gameobject_template` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.",pool_id); + sLog.outErrorDb("`pool_gameobject_template` pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.", pool_id); continue; } if (chance < 0 || chance > 100) @@ -945,17 +945,17 @@ void PoolManager::LoadFromDB() if (mother_pool_id > max_pool_id) { - sLog.outErrorDb("`pool_pool` mother_pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.",mother_pool_id); + sLog.outErrorDb("`pool_pool` mother_pool id (%i) is out of range compared to max pool id in `pool_template`, skipped.", mother_pool_id); continue; } if (child_pool_id > max_pool_id) { - sLog.outErrorDb("`pool_pool` included pool_id (%i) is out of range compared to max pool id in `pool_template`, skipped.",child_pool_id); + sLog.outErrorDb("`pool_pool` included pool_id (%i) is out of range compared to max pool id in `pool_template`, skipped.", child_pool_id); continue; } if (mother_pool_id == child_pool_id) { - sLog.outErrorDb("`pool_pool` pool_id (%i) includes itself, dead-lock detected, skipped.",child_pool_id); + sLog.outErrorDb("`pool_pool` pool_id (%i) includes itself, dead-lock detected, skipped.", child_pool_id); continue; } if (chance < 0 || chance > 100) @@ -982,7 +982,7 @@ void PoolManager::LoadFromDB() while (result->NextRow()); // Now check for circular reference - for (uint16 i=0; i checkedPools; for (SearchMap::iterator poolItr = mPoolSearchMap.find(i); poolItr != mPoolSearchMap.end(); poolItr = mPoolSearchMap.find(poolItr->second)) @@ -1003,8 +1003,8 @@ void PoolManager::LoadFromDB() if (checkedPools.find(poolItr->second) != checkedPools.end()) { std::ostringstream ss; - ss<< "The pool(s) "; - for (std::set::const_iterator itr=checkedPools.begin(); itr!=checkedPools.end(); ++itr) + ss << "The pool(s) "; + for (std::set::const_iterator itr = checkedPools.begin(); itr != checkedPools.end(); ++itr) ss << *itr << " "; ss << "create(s) a circular reference, which can cause the server to freeze.\nRemoving the last link between mother pool " << poolItr->first << " and child pool " << poolItr->second; diff --git a/src/game/PoolManager.h b/src/game/PoolManager.h index e705e143f..145bf1c5d 100644 --- a/src/game/PoolManager.h +++ b/src/game/PoolManager.h @@ -63,7 +63,7 @@ class Pool // for Pool of Pool }; typedef std::set SpawnedPoolObjects; -typedef std::map SpawnedPoolPools; +typedef std::map SpawnedPoolPools; class SpawnedPoolData { @@ -108,7 +108,7 @@ class PoolGroup bool CheckPool() const; void CheckEventLinkAndReport(int16 event_id, std::map const& creature2event, std::map const& go2event) const; PoolObject* RollOne(SpawnedPoolData& spawns, uint32 triggerFrom); - void DespawnObject(MapPersistentState& mapState, uint32 guid=0); + void DespawnObject(MapPersistentState& mapState, uint32 guid = 0); void Despawn1Object(MapPersistentState& mapState, uint32 guid); void SpawnObject(MapPersistentState& mapState, uint32 limit, uint32 triggerFrom, bool instantly); void SetExcludeObject(uint32 guid, bool state); diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index ea28cdcfa..690eafc3c 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -39,7 +39,7 @@ void WorldSession::SendNameQueryOpcode(Player* p) if (!p) return; // guess size - WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+10)); + WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 1 + 1 + 1 + 1 + 10)); data << p->GetPackGUID(); // player guid data << uint8(0); // added in 3.1; if > 1, then end of packet data << p->GetName(); // played name @@ -102,7 +102,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult* result, uint32 pClass = fields[4].GetUInt8(); } // guess size - WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10)); + WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 1 + 1 + 1 + 1 + 1 + 10)); data << ObjectGuid(HIGHGUID_PLAYER, lowguid).WriteAsPacked(); data << uint8(0); // added in 3.1; if > 1, then end of packet data << name; @@ -115,7 +115,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult* result, uint32 if (sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) && fields[5].GetCppString() != "") { data << uint8(1); // is declined - for (int i = 5; i < MAX_DECLINED_NAME_CASES+5; ++i) + for (int i = 5; i < MAX_DECLINED_NAME_CASES + 5; ++i) data << fields[i].GetCppString(); } else @@ -298,7 +298,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recv_data*/) } } - WorldPacket data(MSG_CORPSE_QUERY, 1+(6*4)); + WorldPacket data(MSG_CORPSE_QUERY, 1 + (6 * 4)); data << uint8(1); // corpse found data << int32(mapid); data << float(x); @@ -347,8 +347,8 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recv_data) std::string Text_0[MAX_GOSSIP_TEXT_OPTIONS], Text_1[MAX_GOSSIP_TEXT_OPTIONS]; for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { - Text_0[i]=pGossip->Options[i].Text_0; - Text_1[i]=pGossip->Options[i].Text_1; + Text_0[i] = pGossip->Options[i].Text_0; + Text_1[i] = pGossip->Options[i].Text_1; } int loc_idx = GetSessionDbLocaleIndex(); @@ -438,7 +438,7 @@ void WorldSession::HandleCorpseMapPositionQueryOpcode(WorldPacket& recv_data) uint32 unk; recv_data >> unk; - WorldPacket data(SMSG_CORPSE_TRANSPORT_QUERY, 4+4+4+4); + WorldPacket data(SMSG_CORPSE_TRANSPORT_QUERY, 4 + 4 + 4 + 4); data << float(0); data << float(0); data << float(0); @@ -450,7 +450,7 @@ void WorldSession::HandleQueryQuestsCompletedOpcode(WorldPacket& /*recv_data */) { uint32 count = 0; - WorldPacket data(SMSG_ALL_QUESTS_COMPLETED, 4+4*count); + WorldPacket data(SMSG_ALL_QUESTS_COMPLETED, 4 + 4 * count); data << uint32(count); for (QuestStatusMap::const_iterator itr = _player->getQuestStatusMap().begin(); itr != _player->getQuestStatusMap().end(); ++itr) @@ -476,7 +476,7 @@ void WorldSession::HandleQuestPOIQueryOpcode(WorldPacket& recv_data) return; } - WorldPacket data(SMSG_QUEST_POI_QUERY_RESPONSE, 4+(4+4)*count); + WorldPacket data(SMSG_QUEST_POI_QUERY_RESPONSE, 4 + (4 + 4)*count); data << uint32(count); // count for (uint32 i = 0; i < count; ++i) @@ -489,7 +489,7 @@ void WorldSession::HandleQuestPOIQueryOpcode(WorldPacket& recv_data) uint16 questSlot = _player->FindQuestSlot(questId); if (questSlot != MAX_QUEST_LOG_SIZE) - questOk =_player->GetQuestSlotQuestId(questSlot) == questId; + questOk = _player->GetQuestSlotQuestId(questSlot) == questId; if (questOk) { @@ -536,7 +536,7 @@ void WorldSession::HandleQuestPOIQueryOpcode(WorldPacket& recv_data) void WorldSession::SendQueryTimeResponse() { - WorldPacket data(SMSG_QUERY_TIME_RESPONSE, 4+4); + WorldPacket data(SMSG_QUERY_TIME_RESPONSE, 4 + 4); data << uint32(time(NULL)); data << uint32(sWorld.GetNextDailyQuestsResetTime() - time(NULL)); SendPacket(&data); diff --git a/src/game/QuestDef.cpp b/src/game/QuestDef.cpp index 52d381aba..55df2075f 100644 --- a/src/game/QuestDef.cpp +++ b/src/game/QuestDef.cpp @@ -63,49 +63,49 @@ Quest::Quest(Field* questRecord) CompletedText = questRecord[37].GetCppString(); for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ObjectiveText[i] = questRecord[38+i].GetCppString(); + ObjectiveText[i] = questRecord[38 + i].GetCppString(); for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) - ReqItemId[i] = questRecord[42+i].GetUInt32(); + ReqItemId[i] = questRecord[42 + i].GetUInt32(); for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) - ReqItemCount[i] = questRecord[48+i].GetUInt32(); + ReqItemCount[i] = questRecord[48 + i].GetUInt32(); for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - ReqSourceId[i] = questRecord[54+i].GetUInt32(); + ReqSourceId[i] = questRecord[54 + i].GetUInt32(); for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i) - ReqSourceCount[i] = questRecord[58+i].GetUInt32(); + ReqSourceCount[i] = questRecord[58 + i].GetUInt32(); for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ReqCreatureOrGOId[i] = questRecord[62+i].GetInt32(); + ReqCreatureOrGOId[i] = questRecord[62 + i].GetInt32(); for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ReqCreatureOrGOCount[i] = questRecord[66+i].GetUInt32(); + ReqCreatureOrGOCount[i] = questRecord[66 + i].GetUInt32(); for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ReqSpell[i] = questRecord[70+i].GetUInt32(); + ReqSpell[i] = questRecord[70 + i].GetUInt32(); for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) - RewChoiceItemId[i] = questRecord[74+i].GetUInt32(); + RewChoiceItemId[i] = questRecord[74 + i].GetUInt32(); for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) - RewChoiceItemCount[i] = questRecord[80+i].GetUInt32(); + RewChoiceItemCount[i] = questRecord[80 + i].GetUInt32(); for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) - RewItemId[i] = questRecord[86+i].GetUInt32(); + RewItemId[i] = questRecord[86 + i].GetUInt32(); for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) - RewItemCount[i] = questRecord[90+i].GetUInt32(); + RewItemCount[i] = questRecord[90 + i].GetUInt32(); for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - RewRepFaction[i] = questRecord[94+i].GetUInt32(); + RewRepFaction[i] = questRecord[94 + i].GetUInt32(); for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - RewRepValueId[i] = questRecord[99+i].GetInt32(); + RewRepValueId[i] = questRecord[99 + i].GetInt32(); for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i) - RewRepValue[i] = questRecord[104+i].GetInt32(); + RewRepValue[i] = questRecord[104 + i].GetInt32(); RewHonorAddition = questRecord[109].GetUInt32(); RewHonorMultiplier = questRecord[110].GetFloat(); @@ -121,19 +121,19 @@ Quest::Quest(Field* questRecord) PointOpt = questRecord[120].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - DetailsEmote[i] = questRecord[121+i].GetUInt32(); + DetailsEmote[i] = questRecord[121 + i].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - DetailsEmoteDelay[i] = questRecord[125+i].GetUInt32(); + DetailsEmoteDelay[i] = questRecord[125 + i].GetUInt32(); IncompleteEmote = questRecord[129].GetUInt32(); CompleteEmote = questRecord[130].GetUInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmote[i] = questRecord[131+i].GetInt32(); + OfferRewardEmote[i] = questRecord[131 + i].GetInt32(); for (int i = 0; i < QUEST_EMOTE_COUNT; ++i) - OfferRewardEmoteDelay[i] = questRecord[135+i].GetInt32(); + OfferRewardEmoteDelay[i] = questRecord[135 + i].GetInt32(); QuestStartScript = questRecord[139].GetUInt32(); QuestCompleteScript = questRecord[140].GetUInt32(); @@ -145,25 +145,25 @@ Quest::Quest(Field* questRecord) m_rewitemscount = 0; m_rewchoiceitemscount = 0; - for (int i=0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i) { if (ReqItemId[i]) ++m_reqitemscount; } - for (int i=0; i < QUEST_OBJECTIVES_COUNT; ++i) + for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) { if (ReqCreatureOrGOId[i]) ++m_reqCreatureOrGOcount; } - for (int i=0; i < QUEST_REWARDS_COUNT; ++i) + for (int i = 0; i < QUEST_REWARDS_COUNT; ++i) { if (RewItemId[i]) ++m_rewitemscount; } - for (int i=0; i < QUEST_REWARD_CHOICES_COUNT; ++i) + for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i) { if (RewChoiceItemId[i]) ++m_rewchoiceitemscount; @@ -184,14 +184,14 @@ uint32 Quest::XPValue(Player* pPlayer) const if (QuestLevel != -1) baseLevel = QuestLevel; - if (((baseLevel - playerLevel) + 10)*2 > 10) + if (((baseLevel - playerLevel) + 10) * 2 > 10) { baseLevel = playerLevel; if (QuestLevel != -1) baseLevel = QuestLevel; - if (((baseLevel - playerLevel) + 10)*2 <= 10) + if (((baseLevel - playerLevel) + 10) * 2 <= 10) { if (QuestLevel == -1) baseLevel = playerLevel; @@ -210,14 +210,14 @@ uint32 Quest::XPValue(Player* pPlayer) const if (QuestLevel != -1) baseLevel = QuestLevel; - if (((baseLevel - playerLevel) + 10)*2 >= 1) + if (((baseLevel - playerLevel) + 10) * 2 >= 1) { baseLevel = playerLevel; if (QuestLevel != -1) baseLevel = QuestLevel; - if (((baseLevel - playerLevel) + 10)*2 <= 10) + if (((baseLevel - playerLevel) + 10) * 2 <= 10) { if (QuestLevel == -1) baseLevel = playerLevel; @@ -259,7 +259,7 @@ uint32 Quest::XPValue(Player* pPlayer) const int32 Quest::GetRewOrReqMoney() const { - if (RewOrReqMoney <=0) + if (RewOrReqMoney <= 0) return RewOrReqMoney; return int32(RewOrReqMoney * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); @@ -283,7 +283,7 @@ uint32 Quest::CalculateRewardHonor(uint32 level) const if (GetRewHonorAddition() > 0 || GetRewHonorMultiplier() > 0.0f) { // values stored from 0.. for 1... - TeamContributionPoints const* tc = sTeamContributionPoints.LookupEntry(level-1); + TeamContributionPoints const* tc = sTeamContributionPoints.LookupEntry(level - 1); if (!tc) return 0; uint32 i_honor = uint32(tc->Value * GetRewHonorMultiplier() * 0.1f); diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h index 0698329a0..f7e2929eb 100644 --- a/src/game/QuestDef.h +++ b/src/game/QuestDef.h @@ -383,7 +383,7 @@ enum QuestUpdateState struct QuestStatusData { QuestStatusData() - : m_status(QUEST_STATUS_NONE),m_rewarded(false), + : m_status(QUEST_STATUS_NONE), m_rewarded(false), m_explored(false), m_timer(0), uState(QUEST_NEW) { memset(m_itemcount, 0, QUEST_ITEM_OBJECTIVES_COUNT * sizeof(uint32)); diff --git a/src/game/QuestHandler.cpp b/src/game/QuestHandler.cpp index a6819bc3c..feba9cf98 100644 --- a/src/game/QuestHandler.cpp +++ b/src/game/QuestHandler.cpp @@ -138,7 +138,7 @@ void WorldSession::HandleQuestgiverAcceptQuestOpcode(WorldPacket& recv_data) if (qInfo) { // prevent cheating - if (!GetPlayer()->CanTakeQuest(qInfo,true)) + if (!GetPlayer()->CanTakeQuest(qInfo, true)) { _player->PlayerTalkClass->CloseGossip(); _player->ClearDividerGuid(); @@ -221,7 +221,7 @@ void WorldSession::HandleQuestQueryOpcode(WorldPacket& recv_data) { uint32 quest; recv_data >> quest; - DEBUG_LOG("WORLD: Received CMSG_QUEST_QUERY quest = %u",quest); + DEBUG_LOG("WORLD: Received CMSG_QUEST_QUERY quest = %u", quest); Quest const* pQuest = sObjectMgr.GetQuestTemplate(quest); if (pQuest) @@ -282,7 +282,7 @@ void WorldSession::HandleQuestgiverRequestRewardOpcode(WorldPacket& recv_data) DEBUG_LOG("WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD - for %s to %s, quest = %u", _player->GetGuidStr().c_str(), guid.GetString().c_str(), quest); Object* pObject = _player->GetObjectByTypeMask(guid, TYPEMASK_CREATURE_OR_GAMEOBJECT); - if (!pObject||!pObject->HasInvolvedQuest(quest)) + if (!pObject || !pObject->HasInvolvedQuest(quest)) return; if (_player->CanCompleteQuest(quest)) @@ -312,7 +312,7 @@ void WorldSession::HandleQuestLogSwapQuest(WorldPacket& recv_data) DEBUG_LOG("WORLD: Received CMSG_QUESTLOG_SWAP_QUEST slot 1 = %u, slot 2 = %u", slot1, slot2); - GetPlayer()->SwapQuestSlot(slot1,slot2); + GetPlayer()->SwapQuestSlot(slot1, slot2); } void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data) @@ -413,7 +413,7 @@ void WorldSession::HandleQuestgiverCompleteQuest(WorldPacket& recv_data) else { if (pQuest->GetReqItemsCount()) // some items required - _player->PlayerTalkClass->SendQuestGiverRequestItems(pQuest, guid, _player->CanRewardQuest(pQuest,false), false); + _player->PlayerTalkClass->SendQuestGiverRequestItems(pQuest, guid, _player->CanRewardQuest(pQuest, false), false); else // no items required _player->PlayerTalkClass->SendQuestGiverOfferReward(pQuest, guid, true); } @@ -492,7 +492,7 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket) if (Player* pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid())) { - WorldPacket data(MSG_QUEST_PUSH_RESULT, (8+1)); + WorldPacket data(MSG_QUEST_PUSH_RESULT, (8 + 1)); data << ObjectGuid(guid); data << uint8(msg); // valid values: 0-8 pPlayer->GetSession()->SendPacket(&data); diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index fe94a1b4e..e718fcc9d 100644 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -41,12 +41,12 @@ RandomMovementGenerator::RandomMovementGenerator(const Creature& creat template<> void RandomMovementGenerator::_setRandomLocation(Creature& creature) { - const float angle = rand_norm_f() * (M_PI_F*2.0f); + const float angle = rand_norm_f() * (M_PI_F * 2.0f); const float range = rand_norm_f() * i_radius; float destX = i_x + range * cos(angle); float destY = i_y + range * sin(angle); - float destZ = i_z + frand(-1,1) * i_verticalZ; + float destZ = i_z + frand(-1, 1) * i_verticalZ; creature.UpdateAllowedPositionZ(destX, destY, destZ); creature.addUnitState(UNIT_STAT_ROAMING_MOVE); @@ -68,7 +68,7 @@ void RandomMovementGenerator::Initialize(Creature& creature) if (!creature.isAlive()) return; - creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); _setRandomLocation(creature); } @@ -81,14 +81,14 @@ void RandomMovementGenerator::Reset(Creature& creature) template<> void RandomMovementGenerator::Interrupt(Creature& creature) { - creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.SetWalk(false); } template<> void RandomMovementGenerator::Finalize(Creature& creature) { - creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.SetWalk(false); } diff --git a/src/game/ReactorAI.cpp b/src/game/ReactorAI.cpp index 91d00d7ee..8aaf48e88 100644 --- a/src/game/ReactorAI.cpp +++ b/src/game/ReactorAI.cpp @@ -45,7 +45,7 @@ ReactorAI::AttackStart(Unit* p) if (!p) return; - if (m_creature->Attack(p,true)) + if (m_creature->Attack(p, true)) { DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "Tag unit GUID: %u (TypeId: %u) as a victim", p->GetGUIDLow(), p->GetTypeId()); i_victimGuid = p->GetObjectGuid(); diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp index a97a42f1d..fd5f176ae 100644 --- a/src/game/ReputationMgr.cpp +++ b/src/game/ReputationMgr.cpp @@ -27,7 +27,7 @@ const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 300 ReputationRank ReputationMgr::ReputationToRank(int32 standing) { int32 limit = Reputation_Cap + 1; - for (int i = MAX_REPUTATION_RANK-1; i >= MIN_REPUTATION_RANK; --i) + for (int i = MAX_REPUTATION_RANK - 1; i >= MIN_REPUTATION_RANK; --i) { limit -= PointsInRank[i]; if (standing >= limit) @@ -42,7 +42,7 @@ int32 ReputationMgr::GetReputation(uint32 faction_id) const if (!factionEntry) { - sLog.outError("ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.",m_player->GetName(), faction_id); + sLog.outError("ReputationMgr::GetReputation: Can't get reputation of %s for unknown faction (faction id) #%u.", m_player->GetName(), faction_id); return 0; } @@ -86,7 +86,7 @@ ReputationRank ReputationMgr::GetBaseRank(FactionEntry const* factionEntry) cons return ReputationToRank(reputation); } -void ReputationMgr::ApplyForceReaction(uint32 faction_id,ReputationRank rank,bool apply) +void ReputationMgr::ApplyForceReaction(uint32 faction_id, ReputationRank rank, bool apply) { if (apply) m_forcedReactions[faction_id] = rank; @@ -110,7 +110,7 @@ uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) con void ReputationMgr::SendForceReactions() { WorldPacket data; - data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+m_forcedReactions.size()*(4+4)); + data.Initialize(SMSG_SET_FORCED_REACTIONS, 4 + m_forcedReactions.size() * (4 + 4)); data << uint32(m_forcedReactions.size()); for (ForcedReactions::const_iterator itr = m_forcedReactions.begin(); itr != m_forcedReactions.end(); ++itr) { @@ -155,7 +155,7 @@ void ReputationMgr::SendState(FactionState const* faction) void ReputationMgr::SendInitialReputations() { - WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4+128*5)); + WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4 + 128 * 5)); data << uint32(0x00000080); RepListID a = 0; @@ -224,7 +224,7 @@ void ReputationMgr::Initialize() if (newFaction.Flags & FACTION_FLAG_VISIBLE) ++m_visibleFactionCount; - UpdateRankCounters(REP_HOSTILE,GetBaseRank(factionEntry)); + UpdateRankCounters(REP_HOSTILE, GetBaseRank(factionEntry)); m_factions[newFaction.ReputationListID] = newFaction; } @@ -325,16 +325,16 @@ bool ReputationMgr::SetOneFactionReputation(FactionEntry const* factionEntry, in SetVisible(&itr->second); if (new_rank <= REP_HOSTILE) - SetAtWar(&itr->second,true); + SetAtWar(&itr->second, true); UpdateRankCounters(old_rank, new_rank); m_player->ReputationChanged(factionEntry); m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS, factionEntry->ID); m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION, factionEntry->ID); - m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION,factionEntry->ID); - m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION,factionEntry->ID); - m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION,factionEntry->ID); + m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_EXALTED_REPUTATION, factionEntry->ID); + m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REVERED_REPUTATION, factionEntry->ID); + m_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GAIN_HONORED_REPUTATION, factionEntry->ID); return true; } @@ -365,7 +365,7 @@ void ReputationMgr::SetVisible(FactionEntry const* factionEntry) void ReputationMgr::SetVisible(FactionState* faction) { // always invisible or hidden faction can't be make visible - if (faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) + if (faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN)) return; // already set @@ -388,10 +388,10 @@ void ReputationMgr::SetAtWar(RepListID repListID, bool on) return; // always invisible or hidden faction can't change war state - if (itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) + if (itr->second.Flags & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN)) return; - SetAtWar(&itr->second,on); + SetAtWar(&itr->second, on); } void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) @@ -419,13 +419,13 @@ void ReputationMgr::SetInactive(RepListID repListID, bool on) if (itr == m_factions.end()) return; - SetInactive(&itr->second,on); + SetInactive(&itr->second, on); } void ReputationMgr::SetInactive(FactionState* faction, bool inactive) { // always invisible or hidden faction can't be inactive - if (inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE))) + if (inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED | FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE))) return; // already set @@ -466,7 +466,7 @@ void ReputationMgr::LoadFromDB(QueryResult* result) int32 BaseRep = GetBaseReputation(factionEntry); ReputationRank old_rank = ReputationToRank(BaseRep); ReputationRank new_rank = ReputationToRank(BaseRep + faction->Standing); - UpdateRankCounters(old_rank,new_rank); + UpdateRankCounters(old_rank, new_rank); uint32 dbFactionFlags = fields[2].GetUInt32(); @@ -474,15 +474,15 @@ void ReputationMgr::LoadFromDB(QueryResult* result) SetVisible(faction); // have internal checks for forced invisibility if (dbFactionFlags & FACTION_FLAG_INACTIVE) - SetInactive(faction,true); // have internal checks for visibility requirement + SetInactive(faction, true); // have internal checks for visibility requirement if (dbFactionFlags & FACTION_FLAG_AT_WAR) // DB at war - SetAtWar(faction,true); // have internal checks for FACTION_FLAG_PEACE_FORCED + SetAtWar(faction, true); // have internal checks for FACTION_FLAG_PEACE_FORCED else // DB not at war { // allow remove if visible (and then not FACTION_FLAG_INVISIBLE_FORCED or FACTION_FLAG_HIDDEN) if (faction->Flags & FACTION_FLAG_VISIBLE) - SetAtWar(faction,false); // have internal checks for FACTION_FLAG_PEACE_FORCED + SetAtWar(faction, false); // have internal checks for FACTION_FLAG_PEACE_FORCED } // set atWar for hostile diff --git a/src/game/ReputationMgr.h b/src/game/ReputationMgr.h index f50db6fde..b5d2e35e3 100644 --- a/src/game/ReputationMgr.h +++ b/src/game/ReputationMgr.h @@ -47,10 +47,10 @@ struct FactionState bool needSave; }; -typedef std::map FactionStateList; -typedef std::pair FactionStateListPair; +typedef std::map FactionStateList; +typedef std::pair FactionStateListPair; -typedef std::map ForcedReactions; +typedef std::map ForcedReactions; class Player; class QueryResult; @@ -117,7 +117,7 @@ class ReputationMgr void SetAtWar(RepListID repListID, bool on); void SetInactive(RepListID repListID, bool on); - void ApplyForceReaction(uint32 faction_id,ReputationRank rank,bool apply); + void ApplyForceReaction(uint32 faction_id, ReputationRank rank, bool apply); public: // senders void SendInitialReputations(); @@ -138,10 +138,10 @@ class ReputationMgr Player* m_player; FactionStateList m_factions; ForcedReactions m_forcedReactions; - uint8 m_visibleFactionCount :8; - uint8 m_honoredFactionCount :8; - uint8 m_reveredFactionCount :8; - uint8 m_exaltedFactionCount :8; + uint8 m_visibleFactionCount : 8; + uint8 m_honoredFactionCount : 8; + uint8 m_reveredFactionCount : 8; + uint8 m_exaltedFactionCount : 8; }; #endif diff --git a/src/game/SQLStorages.cpp b/src/game/SQLStorages.cpp index 8ed6d82cb..c234e7547 100644 --- a/src/game/SQLStorages.cpp +++ b/src/game/SQLStorages.cpp @@ -18,38 +18,38 @@ #include "SQLStorages.h" -const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiis"; -const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiii"; -const char CreatureDataAddonInfofmt[]="iiibbiis"; -const char CreatureModelfmt[]="iffbii"; -const char CreatureInfoAddonInfofmt[]="iiibbiis"; -const char GameObjectInfoAddonInfofmt[]="iffff"; -const char EquipmentInfofmt[]="iiii"; -const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis"; -const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"; -const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii"; -const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii"; -const char PageTextfmt[]="isi"; -const char InstanceTemplatesrcfmt[]="iiiis"; -const char InstanceTemplatedstfmt[]="iiiii"; -const char WorldTemplatesrcfmt[]="is"; -const char WorldTemplatedstfmt[]="ii"; -const char ConditionsSrcFmt[]="iiii"; -const char ConditionsDstFmt[]="iiii"; -const char SpellTemplatesrcfmt[]="iiiiiiiiiix"; +const char CreatureInfosrcfmt[] = "iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiis"; +const char CreatureInfodstfmt[] = "iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiii"; +const char CreatureDataAddonInfofmt[] = "iiibbiis"; +const char CreatureModelfmt[] = "iffbii"; +const char CreatureInfoAddonInfofmt[] = "iiibbiis"; +const char GameObjectInfoAddonInfofmt[] = "iffff"; +const char EquipmentInfofmt[] = "iiii"; +const char GameObjectInfosrcfmt[] = "iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiis"; +const char GameObjectInfodstfmt[] = "iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"; +const char ItemPrototypesrcfmt[] = "iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii"; +const char ItemPrototypedstfmt[] = "iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii"; +const char PageTextfmt[] = "isi"; +const char InstanceTemplatesrcfmt[] = "iiiis"; +const char InstanceTemplatedstfmt[] = "iiiii"; +const char WorldTemplatesrcfmt[] = "is"; +const char WorldTemplatedstfmt[] = "ii"; +const char ConditionsSrcFmt[] = "iiii"; +const char ConditionsDstFmt[] = "iiii"; +const char SpellTemplatesrcfmt[] = "iiiiiiiiiix"; // 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 185 -const char SpellTemplatedstfmt[]="ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiixxxxixxxxxxFxxxxxxxxxxxxxxxxxxxxxxixxxxxFFFxxxxxxixxxxxixxixxxxxFFFxxxxxxixxxxxixxFFFxxxxxxxxxxxxxppppppppppppppppppppppppppppppppxxxxxxxxxxxFFFxxxxxx"; +const char SpellTemplatedstfmt[] = "ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiixxxxixxxxxxFxxxxxxxxxxxxxxxxxxxxxxixxxxxFFFxxxxxxixxxxxixxixxxxxFFFxxxxxxixxxxxixxFFFxxxxxxxxxxxxxppppppppppppppppppppppppppppppppxxxxxxxxxxxFFFxxxxxx"; // Id proc DurationIndex Effect0 tarA0 effectAura0 triggerSpell0 SpellName[16] Rank[16] -SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template"); -SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); -SQLStorage sCreatureModelStorage(CreatureModelfmt,"modelid","creature_model_info"); -SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon"); -SQLStorage sGameObjectDataAddonStorage(GameObjectInfoAddonInfofmt,"guid","gameobject_addon"); -SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template"); -SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template"); -SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template"); -SQLStorage sPageTextStore(PageTextfmt,"entry","page_text"); -SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map","instance_template"); -SQLStorage sWorldTemplate(WorldTemplatesrcfmt, WorldTemplatedstfmt, "map","world_template"); +SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry", "creature_template"); +SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt, "guid", "creature_addon"); +SQLStorage sCreatureModelStorage(CreatureModelfmt, "modelid", "creature_model_info"); +SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt, "entry", "creature_template_addon"); +SQLStorage sGameObjectDataAddonStorage(GameObjectInfoAddonInfofmt, "guid", "gameobject_addon"); +SQLStorage sEquipmentStorage(EquipmentInfofmt, "entry", "creature_equip_template"); +SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry", "gameobject_template"); +SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry", "item_template"); +SQLStorage sPageTextStore(PageTextfmt, "entry", "page_text"); +SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map", "instance_template"); +SQLStorage sWorldTemplate(WorldTemplatesrcfmt, WorldTemplatedstfmt, "map", "world_template"); SQLStorage sConditionStorage(ConditionsSrcFmt, ConditionsDstFmt, "condition_entry", "conditions"); SQLStorage sSpellTemplate(SpellTemplatesrcfmt, SpellTemplatedstfmt, "id", "spell_template"); diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index 63143c50e..535fbad9e 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -197,7 +197,7 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename) if (tmp.data_flags) // Check flags { - if (tmp.data_flags & ~(SCRIPT_FLAG_COMMAND_ADDITIONAL*2 - 1)) + if (tmp.data_flags & ~(SCRIPT_FLAG_COMMAND_ADDITIONAL * 2 - 1)) { sLog.outErrorDb("Table `%s` has invalid data_flags %u in command %u for script id %u, skipping.", tablename, tmp.data_flags, tmp.command, tmp.id); continue; @@ -1050,7 +1050,7 @@ void ScriptAction::HandleScriptStep() } // Use one random - textId = m_script->textId[urand(0, i-1)]; + textId = m_script->textId[urand(0, i - 1)]; } switch (m_script->talk.chatType) @@ -1277,10 +1277,10 @@ void ScriptAction::HandleScriptStep() break; } - if (pGo->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || - pGo->GetGoType()==GAMEOBJECT_TYPE_DOOR || - pGo->GetGoType()==GAMEOBJECT_TYPE_BUTTON || - pGo->GetGoType()==GAMEOBJECT_TYPE_TRAP) + if (pGo->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE || + pGo->GetGoType() == GAMEOBJECT_TYPE_DOOR || + pGo->GetGoType() == GAMEOBJECT_TYPE_BUTTON || + pGo->GetGoType() == GAMEOBJECT_TYPE_TRAP) { sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u can not be used with gameobject of type %u (guid: %u, buddyEntry: %u).", m_table, m_script->id, m_script->command, uint32(pGo->GetGoType()), m_script->respawnGo.goGuid, m_script->buddyEntry); break; @@ -1307,7 +1307,7 @@ void ScriptAction::HandleScriptStep() float z = m_script->z; float o = m_script->o; - Creature* pCreature = pSource->SummonCreature(m_script->summonCreature.creatureEntry, x, y, z, o, m_script->summonCreature.despawnDelay ? TEMPSUMMON_TIMED_OR_DEAD_DESPAWN : TEMPSUMMON_DEAD_DESPAWN, m_script->summonCreature.despawnDelay, (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) ? true: false); + Creature* pCreature = pSource->SummonCreature(m_script->summonCreature.creatureEntry, x, y, z, o, m_script->summonCreature.despawnDelay ? TEMPSUMMON_TIMED_OR_DEAD_DESPAWN : TEMPSUMMON_DEAD_DESPAWN, m_script->summonCreature.despawnDelay, (m_script->data_flags & SCRIPT_FLAG_COMMAND_ADDITIONAL) ? true : false); if (!pCreature) { sLog.outError(" DB-SCRIPTS: Process table `%s` id %u, command %u failed for creature (entry: %u).", m_table, m_script->id, m_script->command, m_script->summonCreature.creatureEntry); @@ -2037,7 +2037,7 @@ ScriptLoadResult ScriptMgr::LoadScriptLibrary(const char* libName) } // let check used mangosd revision for build library (unsafe use with different revision because changes in inline functions, define and etc) - char const* (MANGOS_IMPORT* pGetMangosRevStr)(); + char const* (MANGOS_IMPORT * pGetMangosRevStr)(); GET_SCRIPT_HOOK_PTR(pGetMangosRevStr, "GetMangosRevStr"); diff --git a/src/game/ScriptMgr.h b/src/game/ScriptMgr.h index bad545720..9ecffb818 100644 --- a/src/game/ScriptMgr.h +++ b/src/game/ScriptMgr.h @@ -384,8 +384,8 @@ class ScriptAction Player* GetPlayerTargetOrSourceAndLog(WorldObject* pSource, WorldObject* pTarget); }; -typedef std::multimap ScriptMap; -typedef std::map ScriptMapMap; +typedef std::multimap < uint32 /*delay*/, ScriptInfo > ScriptMap; +typedef std::map < uint32 /*id*/, ScriptMap > ScriptMapMap; typedef std::pair ScriptMapMapName; extern ScriptMapMapName sQuestEndScripts; diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index ccf154a49..a1421a0ac 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -126,8 +126,8 @@ enum ReputationRank enum MoneyConstants { COPPER = 1, - SILVER = COPPER*100, - GOLD = SILVER*100 + SILVER = COPPER * 100, + GOLD = SILVER * 100 }; enum Stats @@ -640,7 +640,7 @@ enum SpellEffects SPELL_EFFECT_DUAL_WIELD = 40, SPELL_EFFECT_JUMP = 41, SPELL_EFFECT_JUMP2 = 42, - SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER= 43, + SPELL_EFFECT_TELEPORT_UNITS_FACE_CASTER = 43, SPELL_EFFECT_SKILL_STEP = 44, SPELL_EFFECT_ADD_HONOR = 45, SPELL_EFFECT_SPAWN = 46, @@ -1242,7 +1242,7 @@ enum Targets TARGET_AREAEFFECT_PARTY = 37, TARGET_SCRIPT = 38, TARGET_SELF_FISHING = 39, - TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT= 40, + TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT = 40, TARGET_TOTEM_EARTH = 41, TARGET_TOTEM_WATER = 42, TARGET_TOTEM_AIR = 43, @@ -1905,7 +1905,7 @@ enum Anim ANIM_FLY = 0x87, ANIM_EMOTE_WORK_NO_SHEATHE = 0x88, ANIM_EMOTE_STUN_NO_SHEATHE = 0x89, - ANIM_EMOTE_USE_STANDING_NO_SHEATHE= 0x8A, + ANIM_EMOTE_USE_STANDING_NO_SHEATHE = 0x8A, ANIM_SPELL_SLEEP_DOWN = 0x8B, ANIM_SPELL_KNEEL_START = 0x8C, ANIM_SPELL_KNEEL_LOOP = 0x8D, @@ -2054,9 +2054,9 @@ enum CreatureType CREATURE_TYPE_GAS_CLOUD = 13 }; -uint32 const CREATURE_TYPEMASK_DEMON_OR_UNDEAD = (1 << (CREATURE_TYPE_DEMON-1)) | (1 << (CREATURE_TYPE_UNDEAD-1)); -uint32 const CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD = (1 << (CREATURE_TYPE_HUMANOID-1)) | (1 << (CREATURE_TYPE_UNDEAD-1)); -uint32 const CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL = (1 << (CREATURE_TYPE_MECHANICAL-1)) | (1 << (CREATURE_TYPE_ELEMENTAL-1)); +uint32 const CREATURE_TYPEMASK_DEMON_OR_UNDEAD = (1 << (CREATURE_TYPE_DEMON - 1)) | (1 << (CREATURE_TYPE_UNDEAD - 1)); +uint32 const CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD = (1 << (CREATURE_TYPE_HUMANOID - 1)) | (1 << (CREATURE_TYPE_UNDEAD - 1)); +uint32 const CREATURE_TYPEMASK_MECHANICAL_OR_ELEMENTAL = (1 << (CREATURE_TYPE_MECHANICAL - 1)) | (1 << (CREATURE_TYPE_ELEMENTAL - 1)); // CreatureFamily.dbc enum CreatureFamily diff --git a/src/game/SkillDiscovery.cpp b/src/game/SkillDiscovery.cpp index ef2e6fb3b..d00c1c04b 100644 --- a/src/game/SkillDiscovery.cpp +++ b/src/game/SkillDiscovery.cpp @@ -92,7 +92,7 @@ void LoadSkillDiscoveryTable() { if (reportedReqSpells.find(reqSkillOrSpell) == reportedReqSpells.end()) { - sLog.outErrorDb("Spell (ID: %u) have nonexistent spell (ID: %i) in `reqSpell` field in `skill_discovery_template` table",spellId,reqSkillOrSpell); + sLog.outErrorDb("Spell (ID: %u) have nonexistent spell (ID: %i) in `reqSpell` field in `skill_discovery_template` table", spellId, reqSkillOrSpell); reportedReqSpells.insert(reqSkillOrSpell); } continue; @@ -107,7 +107,7 @@ void LoadSkillDiscoveryTable() { sLog.outErrorDb("Spell (ID: %u) not have MECHANIC_DISCOVERY (28) value in Mechanic field in spell.dbc" " and not 100%% chance random discovery ability but listed for spellId %u (and maybe more) in `skill_discovery_template` table", - reqSkillOrSpell,spellId); + reqSkillOrSpell, spellId); reportedReqSpells.insert(reqSkillOrSpell); } continue; @@ -119,9 +119,9 @@ void LoadSkillDiscoveryTable() { SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(spellId); - if (bounds.first==bounds.second) + if (bounds.first == bounds.second) { - sLog.outErrorDb("Spell (ID: %u) not listed in `SkillLineAbility.dbc` but listed with `reqSpell`=0 in `skill_discovery_template` table",spellId); + sLog.outErrorDb("Spell (ID: %u) not listed in `SkillLineAbility.dbc` but listed with `reqSpell`=0 in `skill_discovery_template` table", spellId); continue; } @@ -130,7 +130,7 @@ void LoadSkillDiscoveryTable() } else { - sLog.outErrorDb("Spell (ID: %u) have negative value in `reqSpell` field in `skill_discovery_template` table",spellId); + sLog.outErrorDb("Spell (ID: %u) have negative value in `reqSpell` field in `skill_discovery_template` table", spellId); continue; } @@ -143,7 +143,7 @@ void LoadSkillDiscoveryTable() sLog.outString(); sLog.outString(">> Loaded %u skill discovery definitions", count); if (!ssNonDiscoverableEntries.str().empty()) - sLog.outErrorDb("Some items can't be successfully discovered: have in chance field value < 0.000001 in `skill_discovery_template` DB table . List:\n%s",ssNonDiscoverableEntries.str().c_str()); + sLog.outErrorDb("Some items can't be successfully discovered: have in chance field value < 0.000001 in `skill_discovery_template` DB table . List:\n%s", ssNonDiscoverableEntries.str().c_str()); // report about empty data for explicit discovery spells for (uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id) @@ -156,8 +156,8 @@ void LoadSkillDiscoveryTable() if (!IsExplicitDiscoverySpell(spellEntry)) continue; - if (SkillDiscoveryStore.find(spell_id)==SkillDiscoveryStore.end()) - sLog.outErrorDb("Spell (ID: %u) is 100%% chance random discovery ability but not have data in `skill_discovery_template` table",spell_id); + if (SkillDiscoveryStore.find(spell_id) == SkillDiscoveryStore.end()) + sLog.outErrorDb("Spell (ID: %u) is 100%% chance random discovery ability but not have data in `skill_discovery_template` table", spell_id); } } diff --git a/src/game/SkillExtraItems.cpp b/src/game/SkillExtraItems.cpp index b9c78a97a..732ebaae4 100644 --- a/src/game/SkillExtraItems.cpp +++ b/src/game/SkillExtraItems.cpp @@ -47,7 +47,7 @@ struct SkillExtraItemEntry }; // map to store the extra item creation info, the key is the spellId of the creation spell, the mapped value is the assigned SkillExtraItemEntry -typedef std::map SkillExtraItemMap; +typedef std::map SkillExtraItemMap; SkillExtraItemMap SkillExtraItemStore; @@ -81,7 +81,7 @@ void LoadSkillExtraItemTable() uint32 requiredSpecialization = fields[1].GetUInt32(); if (!sSpellStore.LookupEntry(requiredSpecialization)) { - sLog.outError("Skill specialization %u have nonexistent required specialization spell id %u in `skill_extra_item_template`!", spellId,requiredSpecialization); + sLog.outError("Skill specialization %u have nonexistent required specialization spell id %u in `skill_extra_item_template`!", spellId, requiredSpecialization); continue; } @@ -125,7 +125,7 @@ bool canCreateExtraItems(Player* player, uint32 spellId, float& additionalChance { // get the info for the specified spell SkillExtraItemMap::const_iterator ret = SkillExtraItemStore.find(spellId); - if (ret==SkillExtraItemStore.end()) + if (ret == SkillExtraItemStore.end()) return false; SkillExtraItemEntry const* specEntry = &ret->second; diff --git a/src/game/SkillHandler.cpp b/src/game/SkillHandler.cpp index 8feb29d9c..fbf7fb9e0 100644 --- a/src/game/SkillHandler.cpp +++ b/src/game/SkillHandler.cpp @@ -72,7 +72,7 @@ void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket& recv_data) if (!(_player->resetTalents())) { - WorldPacket data(MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent + WorldPacket data(MSG_TALENT_WIPE_CONFIRM, 8 + 4); //you have not any talent data << uint64(0); data << uint32(0); SendPacket(&data); diff --git a/src/game/SocialMgr.cpp b/src/game/SocialMgr.cpp index 100cb6b9a..93ccc6cc9 100644 --- a/src/game/SocialMgr.cpp +++ b/src/game/SocialMgr.cpp @@ -110,7 +110,7 @@ void PlayerSocial::SetFriendNote(ObjectGuid friend_guid, std::string note) if (itr == m_playerSocialMap.end()) // not exist return; - utf8truncate(note,48); // DB and client size limitation + utf8truncate(note, 48); // DB and client size limitation std::string safe_note = note; CharacterDatabase.escape_string(safe_note); @@ -126,7 +126,7 @@ void PlayerSocial::SendSocialList() uint32 size = m_playerSocialMap.size(); - WorldPacket data(SMSG_CONTACT_LIST, (4+4+size*25)); // just can guess size + WorldPacket data(SMSG_CONTACT_LIST, (4 + 4 + size * 25)); // just can guess size data << uint32(7); // unk flag (0x1, 0x2, 0x4), 0x7 if it include ignore list data << uint32(size); // friends count @@ -309,7 +309,7 @@ PlayerSocial* SocialMgr::LoadFromDB(QueryResult* result, ObjectGuid guid) std::string note = ""; // used to speed up check below. Using GetNumberOfSocialsWithFlag will cause unneeded iteration - uint32 friendCounter=0, ignoreCounter=0; + uint32 friendCounter = 0, ignoreCounter = 0; do { diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index d97cdf21b..a955a8133 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -807,7 +807,7 @@ void Spell::prepareDataForTriggerSystem() m_negativeEffectMask = 0x0; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (!IsPositiveEffect(m_spellInfo, SpellEffectIndex(i))) - m_negativeEffectMask |= (1<speed * 1000.0f); // Calculate minimum incoming time - if (m_delayMoment == 0 || m_delayMoment>target.timeDelay) + if (m_delayMoment == 0 || m_delayMoment > target.timeDelay) m_delayMoment = target.timeDelay; } else @@ -1024,13 +1024,13 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) // mark effects that were already handled in Spell::HandleDelayedSpellLaunch on spell launch as processed for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) if (IsEffectHandledOnDelayedSpellLaunch(m_spellInfo, SpellEffectIndex(i))) - mask &= ~(1<damage; } - if (missInfo==SPELL_MISS_NONE) // In case spell hit target, do all effect on that target + if (missInfo == SPELL_MISS_NONE) // In case spell hit target, do all effect on that target DoSpellHitOnUnit(unit, mask); else if (missInfo == SPELL_MISS_REFLECT) // In case spell reflect from target, do all effect on caster (if hit) { @@ -1135,7 +1135,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) { uint32 count = 0; Unit::SpellAuraHolderMap const& auras = unitTarget->GetSpellAuraHolderMap(); - for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE && itr->second->GetCasterGuid() == caster->GetObjectGuid()) @@ -1284,7 +1284,7 @@ void Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) } // Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add - m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo,m_triggeredByAuraSpell); + m_diminishGroup = GetDiminishingReturnsGroupForSpell(m_spellInfo, m_triggeredByAuraSpell); m_diminishLevel = unit->GetDiminishing(m_diminishGroup); // Increase Diminishing on unit, current informations for actually casts will use values above if ((GetDiminishingReturnsGroupType(m_diminishGroup) == DRTYPE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) || @@ -1904,7 +1904,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& //Now to get us a random target that's in the initial range of the spell uint32 t = 0; UnitList::iterator itr = tempTargetUnitMap.begin(); - while (itr!= tempTargetUnitMap.end() && (*itr)->IsWithinDist(m_caster, radius)) + while (itr != tempTargetUnitMap.end() && (*itr)->IsWithinDist(m_caster, radius)) ++t, ++itr; if (!t) @@ -2058,7 +2058,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& while (t && next != tempTargetUnitMap.end()) { - if (!prev->IsWithinDist(*next,CHAIN_SPELL_JUMP_RADIUS)) + if (!prev->IsWithinDist(*next, CHAIN_SPELL_JUMP_RADIUS)) break; if (!prev->IsWithinLOSInMap(*next)) @@ -2302,7 +2302,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& else FillRaidOrPartyManaPriorityTargets(targetUnitMap, m_caster, m_caster, radius, 10, true, false, true); } - else if (m_spellInfo->Id==52759) // Ancestral Awakening (special target selection) + else if (m_spellInfo->Id == 52759) // Ancestral Awakening (special target selection) FillRaidOrPartyHealthPriorityTargets(targetUnitMap, m_caster, m_caster, radius, 1, true, false, true); else FillRaidOrPartyTargets(targetUnitMap, m_caster, m_caster, radius, true, true, IsPositiveSpell(m_spellInfo->Id)); @@ -2354,7 +2354,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& if (m_spellInfo->Id == 48743) { // checked in Spell::CheckCast - if (m_caster->GetTypeId()==TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) if (Unit* target = m_caster->GetMap()->GetPet(((Player*)m_caster)->GetSelectionGuid())) targetUnitMap.push_back(target); } @@ -2378,7 +2378,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& Unit* target = m_targets.getUnitTarget(); if (!target) target = m_caster; - uint32 count = CalculateDamage(EFFECT_INDEX_2,m_caster); // stored in dummy effect, affected by mods + uint32 count = CalculateDamage(EFFECT_INDEX_2, m_caster); // stored in dummy effect, affected by mods FillRaidOrPartyHealthPriorityTargets(targetUnitMap, m_caster, target, radius, count, true, false, true); } @@ -2493,7 +2493,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& break; case TARGET_ALL_ENEMY_IN_AREA_CHANNELED: // targets the ground, not the units in the area - if (m_spellInfo->Effect[effIndex]!=SPELL_EFFECT_PERSISTENT_AREA_AURA) + if (m_spellInfo->Effect[effIndex] != SPELL_EFFECT_PERSISTENT_AREA_AURA) FillAreaTargets(targetUnitMap, radius, PUSH_DEST_CENTER, SPELL_TARGETS_AOE_DAMAGE); break; case TARGET_MINION: @@ -2707,7 +2707,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& // explicit cast data from client or server-side cast // some spell at client send caster - if (m_targets.getUnitTarget() && m_targets.getUnitTarget()!=m_caster) + if (m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster) pTarget = m_targets.getUnitTarget(); else if (m_caster->getVictim()) pTarget = m_caster->getVictim(); @@ -2803,8 +2803,8 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& case TARGET_POINT_AT_WEST: angle += M_PI_F / 2; break; case TARGET_POINT_AT_NE: angle -= M_PI_F / 4; break; case TARGET_POINT_AT_NW: angle += M_PI_F / 4; break; - case TARGET_POINT_AT_SE: angle -= 3*M_PI_F / 4; break; - case TARGET_POINT_AT_SW: angle += 3*M_PI_F / 4; break; + case TARGET_POINT_AT_SE: angle -= 3 * M_PI_F / 4; break; + case TARGET_POINT_AT_SW: angle += 3 * M_PI_F / 4; break; } float x, y; @@ -2820,7 +2820,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& SpellRangeEntry const* rEntry = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex); float minRange = GetSpellMinRange(rEntry); float maxRange = GetSpellMaxRange(rEntry); - float dist = minRange+ rand_norm_f()*(maxRange-minRange); + float dist = minRange + rand_norm_f() * (maxRange - minRange); float _target_x, _target_y, _target_z; m_caster->GetClosePoint(_target_x, _target_y, _target_z, m_caster->GetObjectBoundingRadius(), dist); @@ -2901,7 +2901,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& targetUnitMap.push_back(m_caster); break; case SPELL_EFFECT_SUMMON_PLAYER: - if (m_caster->GetTypeId()==TYPEID_PLAYER && ((Player*)m_caster)->GetSelectionGuid()) + if (m_caster->GetTypeId() == TYPEID_PLAYER && ((Player*)m_caster)->GetSelectionGuid()) if (Player* target = sObjectMgr.GetPlayer(((Player*)m_caster)->GetSelectionGuid())) targetUnitMap.push_back(target); break; @@ -3003,7 +3003,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& // remove random units from the map while (targetUnitMap.size() > unMaxTargets - removed_utarget) { - uint32 poz = urand(0, targetUnitMap.size()-1); + uint32 poz = urand(0, targetUnitMap.size() - 1); for (UnitList::iterator itr = targetUnitMap.begin(); itr != targetUnitMap.end(); ++itr, --poz) { if (!*itr) continue; @@ -3040,7 +3040,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& // remove random units from the map while (tempTargetGOList.size() > unMaxTargets - removed_utarget) { - uint32 poz = urand(0, tempTargetGOList.size()-1); + uint32 poz = urand(0, tempTargetGOList.size() - 1); for (std::list::iterator itr = tempTargetGOList.begin(); itr != tempTargetGOList.end(); ++itr, --poz) { if (!*itr) continue; @@ -3290,7 +3290,7 @@ void Spell::cast(bool skipCheck) case SPELLFAMILY_WARRIOR: { // Shield Slam - if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000020000000000)) && m_spellInfo->Category==1209) + if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000020000000000)) && m_spellInfo->Category == 1209) { if (m_caster->HasAura(58375)) // Glyph of Blocking AddTriggeredSpell(58374); // Glyph of Blocking @@ -3330,7 +3330,7 @@ void Spell::cast(bool skipCheck) case 25331: AddTriggeredSpell(25329); break;// Holy Nova, rank 7 case 48077: AddTriggeredSpell(48075); break;// Holy Nova, rank 8 case 48078: AddTriggeredSpell(48076); break;// Holy Nova, rank 9 - default:break; + default: break; } break; } @@ -3418,7 +3418,7 @@ void Spell::cast(bool skipCheck) else if (m_spellInfo->Id == 58875) AddPrecastSpell(58876); // Totem of Wrath - else if (m_spellInfo->Effect[EFFECT_INDEX_0]==SPELL_EFFECT_APPLY_AREA_AURA_RAID && m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) + else if (m_spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_APPLY_AREA_AURA_RAID && m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) // only for main totem spell cast AddTriggeredSpell(30708); // Totem of Wrath break; @@ -3885,7 +3885,7 @@ void Spell::SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 ca if (result == SPELL_CAST_OK) return; - WorldPacket data(SMSG_CAST_FAILED, (4+1+1)); + WorldPacket data(SMSG_CAST_FAILED, (4 + 1 + 1)); data << uint8(cast_count); // single cast or multi 2.3 (0/1) data << uint32(spellInfo->Id); data << uint8(result); // problem @@ -3979,7 +3979,7 @@ void Spell::SendSpellStart() if (m_spellInfo->runeCostID) castFlags |= CAST_FLAG_UNKNOWN19; - WorldPacket data(SMSG_SPELL_START, (8+8+4+4+2)); + WorldPacket data(SMSG_SPELL_START, (8 + 8 + 4 + 4 + 2)); if (m_CastItem) data << m_CastItem->GetPackGUID(); else @@ -4236,7 +4236,7 @@ void Spell::SendLogExecute() { Unit* target = m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster; - WorldPacket data(SMSG_SPELLLOGEXECUTE, (8+4+4+4+4+8)); + WorldPacket data(SMSG_SPELLLOGEXECUTE, (8 + 4 + 4 + 4 + 4 + 8)); if (m_caster->GetTypeId() == TYPEID_PLAYER) data << m_caster->GetPackGUID(); @@ -4342,14 +4342,14 @@ void Spell::SendLogExecute() void Spell::SendInterrupted(uint8 result) { - WorldPacket data(SMSG_SPELL_FAILURE, (8+4+1)); + WorldPacket data(SMSG_SPELL_FAILURE, (8 + 4 + 1)); data << m_caster->GetPackGUID(); data << uint8(m_cast_count); data << uint32(m_spellInfo->Id); data << uint8(result); m_caster->SendMessageToSet(&data, true); - data.Initialize(SMSG_SPELL_FAILED_OTHER, (8+4)); + data.Initialize(SMSG_SPELL_FAILED_OTHER, (8 + 4)); data << m_caster->GetPackGUID(); data << uint8(m_cast_count); data << uint32(m_spellInfo->Id); @@ -4406,7 +4406,7 @@ void Spell::SendChannelUpdate(uint32 time) m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); } - WorldPacket data(MSG_CHANNEL_UPDATE, 8+4); + WorldPacket data(MSG_CHANNEL_UPDATE, 8 + 4); data << m_caster->GetPackGUID(); data << uint32(time); m_caster->SendMessageToSet(&data, true); @@ -4444,7 +4444,7 @@ void Spell::SendChannelStart(uint32 duration) } } - WorldPacket data(MSG_CHANNEL_START, (8+4+4)); + WorldPacket data(MSG_CHANNEL_START, (8 + 4 + 4)); data << m_caster->GetPackGUID(); data << uint32(m_spellInfo->Id); data << uint32(duration); @@ -4465,7 +4465,7 @@ void Spell::SendResurrectRequest(Player* target) const char* sentName = m_caster->GetTypeId() == TYPEID_PLAYER ? "" : m_caster->GetNameForLocaleIdx(target->GetSession()->GetSessionDbLocaleIndex()); - WorldPacket data(SMSG_RESURRECT_REQUEST, (8+4+strlen(sentName)+1+1+1)); + WorldPacket data(SMSG_RESURRECT_REQUEST, (8 + 4 + strlen(sentName) + 1 + 1 + 1)); data << m_caster->GetObjectGuid(); data << uint32(strlen(sentName) + 1); @@ -4742,7 +4742,7 @@ void Spell::HandleThreatSpells() uint8 effectMask = 0; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (m_spellInfo->Effect[i]) - effectMask |= (1<Id, threat, positive ? "assisting" : "harming", uint32(m_UniqueTargetInfo.size())); } -void Spell::HandleEffects(Unit* pUnitTarget,Item* pItemTarget,GameObject* pGOTarget,SpellEffectIndex i, float DamageMultiplier) +void Spell::HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, SpellEffectIndex i, float DamageMultiplier) { unitTarget = pUnitTarget; itemTarget = pItemTarget; @@ -4856,7 +4856,7 @@ void Spell::CastPreCastSpells(Unit* target) SpellCastResult Spell::CheckCast(bool strict) { // check cooldowns to prevent cheating (ignore passive spells, that client side visual only) - if (m_caster->GetTypeId()==TYPEID_PLAYER && !m_spellInfo->HasAttribute(SPELL_ATTR_PASSIVE) && + if (m_caster->GetTypeId() == TYPEID_PLAYER && !m_spellInfo->HasAttribute(SPELL_ATTR_PASSIVE) && ((Player*)m_caster)->HasSpellCooldown(m_spellInfo->Id)) { if (m_triggeredByAuraSpell) @@ -5177,13 +5177,13 @@ SpellCastResult Spell::CheckCast(bool strict) uint32 zone, area; m_caster->GetZoneAndAreaId(zone, area); - SpellCastResult locRes= sSpellMgr.GetSpellAllowedInLocationError(m_spellInfo, m_caster->GetMapId(), zone, area, - m_caster->GetCharmerOrOwnerPlayerOrPlayerItself()); + SpellCastResult locRes = sSpellMgr.GetSpellAllowedInLocationError(m_spellInfo, m_caster->GetMapId(), zone, area, + m_caster->GetCharmerOrOwnerPlayerOrPlayerItself()); if (locRes != SPELL_CAST_OK) return locRes; // not let players cast spells at mount (and let do it to creatures) - if (m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell && + if (m_caster->IsMounted() && m_caster->GetTypeId() == TYPEID_PLAYER && !m_IsTriggeredSpell && !IsPassiveSpell(m_spellInfo) && !m_spellInfo->HasAttribute(SPELL_ATTR_CASTABLE_WHILE_MOUNTED)) { if (m_caster->IsTaxiFlying()) @@ -5325,7 +5325,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES) { - m_targets.setDestination(creatureScriptTarget->GetPositionX(),creatureScriptTarget->GetPositionY(),creatureScriptTarget->GetPositionZ()); + m_targets.setDestination(creatureScriptTarget->GetPositionX(), creatureScriptTarget->GetPositionY(), creatureScriptTarget->GetPositionZ()); if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->Effect[j] != SPELL_EFFECT_PERSISTENT_AREA_AURA) AddUnitTarget(creatureScriptTarget, SpellEffectIndex(j)); @@ -5344,7 +5344,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES || m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES) { - m_targets.setDestination(goScriptTarget->GetPositionX(),goScriptTarget->GetPositionY(),goScriptTarget->GetPositionZ()); + m_targets.setDestination(goScriptTarget->GetPositionX(), goScriptTarget->GetPositionY(), goScriptTarget->GetPositionZ()); if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->Effect[j] != SPELL_EFFECT_PERSISTENT_AREA_AURA) AddGOTarget(goScriptTarget, SpellEffectIndex(j)); @@ -5423,7 +5423,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; float dist = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); - if (!target->IsWithinDistInMap(m_caster,dist)) + if (!target->IsWithinDistInMap(m_caster, dist)) return SPELL_FAILED_OUT_OF_RANGE; // will set in target selection code @@ -5460,7 +5460,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!m_targets.getUnitTarget()) return SPELL_FAILED_BAD_IMPLICIT_TARGETS; - if (m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth()*0.2) + if (m_targets.getUnitTarget()->GetHealth() > m_targets.getUnitTarget()->GetMaxHealth() * 0.2) return SPELL_FAILED_BAD_TARGETS; } break; @@ -5629,7 +5629,7 @@ SpellCastResult Spell::CheckCast(bool strict) int32 skillValue = ((Player*)m_caster)->GetSkillValue(skill); int32 TargetLevel = m_targets.getUnitTarget()->getLevel(); - int32 ReqValue = (skillValue < 100 ? (TargetLevel-10) * 10 : TargetLevel * 5); + int32 ReqValue = (skillValue < 100 ? (TargetLevel - 10) * 10 : TargetLevel * 5); if (ReqValue > skillValue) return SPELL_FAILED_LOW_CASTLEVEL; @@ -5804,7 +5804,7 @@ SpellCastResult Spell::CheckCast(bool strict) return SPELL_FAILED_BAD_TARGETS; break; } - default:break; + default: break; } } @@ -5853,7 +5853,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_targets.getUnitTarget()->GetCharmerGuid()) return SPELL_FAILED_CHARMED; - if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget())) + if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i), m_targets.getUnitTarget())) return SPELL_FAILED_HIGHLEVEL; break; @@ -5878,7 +5878,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (m_targets.getUnitTarget()->GetCharmerGuid()) return SPELL_FAILED_CHARMED; - if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i),m_targets.getUnitTarget())) + if (int32(m_targets.getUnitTarget()->getLevel()) > CalculateDamage(SpellEffectIndex(i), m_targets.getUnitTarget())) return SPELL_FAILED_HIGHLEVEL; break; @@ -6023,7 +6023,7 @@ SpellCastResult Spell::CheckPetCast(Unit* target) if (m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo)) return SPELL_FAILED_AFFECTING_COMBAT; - if (m_caster->GetTypeId()==TYPEID_UNIT && (((Creature*)m_caster)->IsPet() || m_caster->isCharmed())) + if (m_caster->GetTypeId() == TYPEID_UNIT && (((Creature*)m_caster)->IsPet() || m_caster->isCharmed())) { //dead owner (pets still alive when owners ressed?) if (m_caster->GetCharmerOrOwner() && !m_caster->GetCharmerOrOwner()->isAlive()) @@ -6108,7 +6108,7 @@ SpellCastResult Spell::CheckCasterAuras() const if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_SCHOOL_IMMUNITY) school_immune |= uint32(m_spellInfo->EffectMiscValue[i]); else if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY) - mechanic_immune |= 1 << uint32(m_spellInfo->EffectMiscValue[i]-1); + mechanic_immune |= 1 << uint32(m_spellInfo->EffectMiscValue[i] - 1); else if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MECHANIC_IMMUNITY_MASK) mechanic_immune |= uint32(m_spellInfo->EffectMiscValue[i]); else if (m_spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DISPEL_IMMUNITY) @@ -6187,7 +6187,7 @@ SpellCastResult Spell::CheckCasterAuras() const if ((GetSpellSchoolMask(pEntry) & school_immune) && !pEntry->HasAttribute(SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE)) continue; - if ((1<<(pEntry->Dispel)) & dispel_immune) + if ((1 << (pEntry->Dispel)) & dispel_immune) continue; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) @@ -6403,7 +6403,7 @@ uint32 Spell::CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spel modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COST, powerCost, spell); if (spellInfo->HasAttribute(SPELL_ATTR_LEVEL_DAMAGE_CALCULATION)) - powerCost = int32(powerCost/ (1.117f * spellInfo->spellLevel / caster->getLevel() -0.1327f)); + powerCost = int32(powerCost / (1.117f * spellInfo->spellLevel / caster->getLevel() - 0.1327f)); // PCT mod from user auras by school powerCost = int32(powerCost * (1.0f + caster->GetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + school))); @@ -6597,7 +6597,7 @@ SpellCastResult Spell::CheckItems() if (m_spellInfo->RequiresSpellFocus) { GameObject* ok = NULL; - MaNGOS::GameObjectFocusCheck go_check(m_caster,m_spellInfo->RequiresSpellFocus); + MaNGOS::GameObjectFocusCheck go_check(m_caster, m_spellInfo->RequiresSpellFocus); MaNGOS::GameObjectSearcher checker(ok, go_check); Cell::VisitGridObjects(m_caster, checker, m_caster->GetMap()->GetVisibilityDistance()); @@ -6664,7 +6664,7 @@ SpellCastResult Spell::CheckItems() // Check items for TotemCategory (items presence in inventory) uint32 TotemCategory = MAX_SPELL_TOTEM_CATEGORIES; - for (int i= 0; i < MAX_SPELL_TOTEM_CATEGORIES; ++i) + for (int i = 0; i < MAX_SPELL_TOTEM_CATEGORIES; ++i) { if (m_spellInfo->TotemCategory[i] != 0) { @@ -6818,7 +6818,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_CANT_BE_PROSPECTED; // Check for enough skill in jewelcrafting uint32 item_prospectingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; - if (item_prospectingskilllevel >p_caster->GetSkillValue(SKILL_JEWELCRAFTING)) + if (item_prospectingskilllevel > p_caster->GetSkillValue(SKILL_JEWELCRAFTING)) return SPELL_FAILED_LOW_CASTLEVEL; // make sure the player has the required ores in inventory if (int32(m_targets.getItemTarget()->GetCount()) < CalculateDamage(SpellEffectIndex(i), m_caster)) @@ -6841,7 +6841,7 @@ SpellCastResult Spell::CheckItems() return SPELL_FAILED_CANT_BE_MILLED; // Check for enough skill in inscription uint32 item_millingskilllevel = m_targets.getItemTarget()->GetProto()->RequiredSkillRank; - if (item_millingskilllevel >p_caster->GetSkillValue(SKILL_INSCRIPTION)) + if (item_millingskilllevel > p_caster->GetSkillValue(SKILL_INSCRIPTION)) return SPELL_FAILED_LOW_CASTLEVEL; // make sure the player has the required herbs in inventory if (int32(m_targets.getItemTarget()->GetCount()) < CalculateDamage(SpellEffectIndex(i), m_caster)) @@ -6858,7 +6858,7 @@ SpellCastResult Spell::CheckItems() if (m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_TARGET_NOT_PLAYER; if (m_attackType != RANGED_ATTACK) break; - Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(m_attackType,true,false); + Item* pItem = ((Player*)m_caster)->GetWeaponForAttack(m_attackType, true, false); if (!pItem) return SPELL_FAILED_EQUIPPED_ITEM; @@ -6917,7 +6917,7 @@ SpellCastResult Spell::CheckItems() } break; } - default:break; + default: break; } } @@ -6959,7 +6959,7 @@ void Spell::Delayed() DETAIL_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell %u partially interrupted for (%d) ms at damage", m_spellInfo->Id, delaytime); - WorldPacket data(SMSG_SPELL_DELAYED, 8+4); + WorldPacket data(SMSG_SPELL_DELAYED, 8 + 4); data << m_caster->GetPackGUID(); data << uint32(delaytime); @@ -7338,7 +7338,7 @@ SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, Ski { // check key item (many fit cases can be) case LOCK_KEY_ITEM: - if (lockInfo->Index[j] && m_CastItem && m_CastItem->GetEntry()==lockInfo->Index[j]) + if (lockInfo->Index[j] && m_CastItem && m_CastItem->GetEntry() == lockInfo->Index[j]) return SPELL_CAST_OK; reqKey = true; break; @@ -7361,7 +7361,7 @@ SpellCastResult Spell::CanOpenLock(SpellEffectIndex effIndex, uint32 lockId, Ski reqSkillValue = lockInfo->Skill[j]; // castitem check: rogue using skeleton keys. the skill values should not be added in this case. - skillValue = m_CastItem || m_caster->GetTypeId()!= TYPEID_PLAYER ? + skillValue = m_CastItem || m_caster->GetTypeId() != TYPEID_PLAYER ? 0 : ((Player*)m_caster)->GetSkillValue(skillId); skillValue += spellSkillBonus; @@ -7412,7 +7412,7 @@ void Spell::FillRaidOrPartyTargets(UnitList& targetUnitMap, Unit* member, Unit* Player* Target = itr->getSource(); // IsHostileTo check duel and controlled by enemy - if (Target && (raid || subgroup==Target->GetSubGroup()) + if (Target && (raid || subgroup == Target->GetSubGroup()) && !m_caster->IsHostileTo(Target)) { if ((Target == center || center->IsWithinDistInMap(Target, radius)) && @@ -7525,7 +7525,7 @@ void Spell::SelectMountByAreaAndSkill(Unit* target, SpellEntry const* parentSpel uint32 zone, area; target->GetZoneAndAreaId(zone, area); - SpellCastResult locRes= sSpellMgr.GetSpellAllowedInLocationError(pSpell, target->GetMapId(), zone, area, target->GetCharmerOrOwnerPlayerOrPlayerItself()); + SpellCastResult locRes = sSpellMgr.GetSpellAllowedInLocationError(pSpell, target->GetMapId(), zone, area, target->GetCharmerOrOwnerPlayerOrPlayerItself()); if (locRes != SPELL_CAST_OK || !((Player*)target)->CanStartFlyInArea(target->GetMapId(), zone, area)) target->CastSpell(target, spellId150, true, NULL, NULL, ObjectGuid(), parentSpell); else if (spellIdSpecial > 0) @@ -7566,7 +7566,7 @@ void Spell::SelectMountByAreaAndSkill(Unit* target, SpellEntry const* parentSpel void Spell::ClearCastItem() { - if (m_CastItem==m_targets.getItemTarget()) + if (m_CastItem == m_targets.getItemTarget()) m_targets.setItemTarget(NULL); m_CastItem = NULL; diff --git a/src/game/Spell.h b/src/game/Spell.h index 703fe0d33..8584e91d8 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -110,7 +110,7 @@ class SpellCastTargets void read(ByteBuffer& data, Unit* caster); void write(ByteBuffer& data) const; - SpellCastTargetsReader ReadForCaster(Unit* caster) { return SpellCastTargetsReader(*this,caster); } + SpellCastTargetsReader ReadForCaster(Unit* caster) { return SpellCastTargetsReader(*this, caster); } SpellCastTargets& operator=(const SpellCastTargets& target) { @@ -202,7 +202,7 @@ inline ByteBuffer& operator<< (ByteBuffer& buf, SpellCastTargets const& targets) inline ByteBuffer& operator>> (ByteBuffer& buf, SpellCastTargetsReader const& targets) { - targets.targets.read(buf,targets.caster); + targets.targets.read(buf, targets.caster); return buf; } @@ -423,7 +423,7 @@ class Spell void SendResurrectRequest(Player* target); void SendPlaySpellVisual(uint32 SpellID); - void HandleEffects(Unit* pUnitTarget,Item* pItemTarget,GameObject* pGOTarget,SpellEffectIndex i, float DamageMultiplier = 1.0); + void HandleEffects(Unit* pUnitTarget, Item* pItemTarget, GameObject* pGOTarget, SpellEffectIndex i, float DamageMultiplier = 1.0); void HandleThreatSpells(); //void HandleAddAura(Unit* Target); @@ -580,10 +580,10 @@ class Spell uint64 timeDelay; uint32 HitInfo; uint32 damage; - SpellMissInfo missCondition:8; - SpellMissInfo reflectResult:8; - uint8 effectMask:8; - bool processed:1; + SpellMissInfo missCondition: 8; + SpellMissInfo reflectResult: 8; + uint8 effectMask: 8; + bool processed: 1; }; uint8 m_needAliveTargetMask; // Mask req. alive targets @@ -591,8 +591,8 @@ class Spell { ObjectGuid targetGUID; uint64 timeDelay; - uint8 effectMask:8; - bool processed:1; + uint8 effectMask: 8; + bool processed: 1; }; struct ItemTargetInfo @@ -696,7 +696,7 @@ namespace MaNGOS if (!i_originalCaster) return; - for (PlayerMapType::iterator itr=m.begin(); itr != m.end(); ++itr) + for (PlayerMapType::iterator itr = m.begin(); itr != m.end(); ++itr) { Player* pPlayer = itr->getSource(); if (!pPlayer->isAlive() || pPlayer->IsTaxiFlying()) @@ -705,7 +705,7 @@ namespace MaNGOS if (i_originalCaster->IsFriendlyTo(pPlayer)) continue; - if (pPlayer->IsWithinDist3d(i_spell.m_targets.m_destX, i_spell.m_targets.m_destY, i_spell.m_targets.m_destZ,i_radius)) + if (pPlayer->IsWithinDist3d(i_spell.m_targets.m_destX, i_spell.m_targets.m_destY, i_spell.m_targets.m_destZ, i_radius)) i_data.push_back(pPlayer); } } @@ -814,7 +814,7 @@ namespace MaNGOS break; case SPELL_TARGETS_AOE_DAMAGE: { - if (itr->getSource()->GetTypeId()==TYPEID_UNIT && ((Creature*)itr->getSource())->IsTotem()) + if (itr->getSource()->GetTypeId() == TYPEID_UNIT && ((Creature*)itr->getSource())->IsTotem()) continue; if (i_playerControlled) @@ -838,23 +838,23 @@ namespace MaNGOS switch (i_push_type) { case PUSH_IN_FRONT: - if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, 2*M_PI_F/3)) + if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, 2 * M_PI_F / 3)) i_data->push_back(itr->getSource()); break; case PUSH_IN_FRONT_90: - if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, M_PI_F/2)) + if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, M_PI_F / 2)) i_data->push_back(itr->getSource()); break; case PUSH_IN_FRONT_30: - if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, M_PI_F/6)) + if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, M_PI_F / 6)) i_data->push_back(itr->getSource()); break; case PUSH_IN_FRONT_15: - if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, M_PI_F/12)) + if (i_castingObject->isInFront((Unit*)(itr->getSource()), i_radius, M_PI_F / 12)) i_data->push_back(itr->getSource()); break; case PUSH_IN_BACK: - if (i_castingObject->isInBack((Unit*)(itr->getSource()), i_radius, 2*M_PI_F/3)) + if (i_castingObject->isInBack((Unit*)(itr->getSource()), i_radius, 2 * M_PI_F / 3)) i_data->push_back(itr->getSource()); break; case PUSH_SELF_CENTER: diff --git a/src/game/SpellAuraDefines.h b/src/game/SpellAuraDefines.h index 2071944b5..20cb86318 100644 --- a/src/game/SpellAuraDefines.h +++ b/src/game/SpellAuraDefines.h @@ -220,7 +220,7 @@ enum AuraType SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT = 182, SPELL_AURA_MOD_CRITICAL_THREAT = 183, SPELL_AURA_MOD_ATTACKER_MELEE_HIT_CHANCE = 184, - SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE= 185, + SPELL_AURA_MOD_ATTACKER_RANGED_HIT_CHANCE = 185, SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE = 186, SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_CHANCE = 187, SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_CHANCE = 188, diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index e032f4ba3..eeea832a6 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -49,7 +49,7 @@ #define NULL_AURA_SLOT 0xFF -pAuraHandler AuraHandler[TOTAL_AURAS]= +pAuraHandler AuraHandler[TOTAL_AURAS] = { &Aura::HandleNULL, // 0 SPELL_AURA_NONE &Aura::HandleBindSight, // 1 SPELL_AURA_BIND_SIGHT @@ -407,7 +407,7 @@ Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBas if (pEnchant->spellid[t] != spellproto->Id) continue; - damage = uint32((item_rand_suffix->prefix[k]*castItem->GetItemSuffixFactor()) / 10000); + damage = uint32((item_rand_suffix->prefix[k] * castItem->GetItemSuffixFactor()) / 10000); break; } } @@ -508,7 +508,7 @@ 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() @@ -592,7 +592,7 @@ void AreaAura::Update(uint32 diff) for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->getSource(); - if (Target && Target->isAlive() && Target->GetSubGroup()==subgroup && caster->IsFriendlyTo(Target)) + if (Target && Target->isAlive() && Target->GetSubGroup() == subgroup && caster->IsFriendlyTo(Target)) { if (caster->IsWithinDistInMap(Target, m_radius)) targets.push_back(Target); @@ -739,7 +739,7 @@ void AreaAura::Update(uint32 diff) { (*tIter)->AddAuraToModList(aur); holder->SetInUse(true); - aur->ApplyModifier(true,true); + aur->ApplyModifier(true, true); holder->SetInUse(false); } else @@ -884,7 +884,7 @@ bool Aura::CanProcFrom(SpellEntry const* spell, uint32 procFlag, uint32 EventPro if (EventProcEx == PROC_EX_NONE) { // 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) + if (((procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) && active) || procEx == PROC_EX_CAST_END) return true; else return false; @@ -892,7 +892,7 @@ bool Aura::CanProcFrom(SpellEntry const* spell, uint32 procFlag, uint32 EventPro else // Passive spells hits here only if resist/reflect/immune/evade { // 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) + if ((EventProcEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT) & procEx) && !active) return false; } } @@ -987,7 +987,7 @@ void Aura::ReapplyAffectedPassiveAuras() ReapplyAffectedPassiveAuras(GetTarget(), true); // re-apply talents/passives/area auras applied to pet/totems (it affected by player spellmods) - GetTarget()->CallForAllControlledUnits(ReapplyAffectedPassiveAurasHelper(this), CONTROLLED_PET|CONTROLLED_TOTEMS); + GetTarget()->CallForAllControlledUnits(ReapplyAffectedPassiveAurasHelper(this), CONTROLLED_PET | CONTROLLED_TOTEMS); // re-apply talents/passives/area auras applied to group members (it affected by player spellmods) if (Group* group = ((Player*)GetTarget())->GetGroup()) @@ -1240,7 +1240,7 @@ void Aura::TriggerSpell() // case 25152: break; case 25371: // Consume { - int32 bpDamage = triggerTarget->GetMaxHealth()*10/100; + int32 bpDamage = triggerTarget->GetMaxHealth() * 10 / 100; triggerTarget->CastCustomSpell(triggerTarget, 25373, &bpDamage, NULL, NULL, true, NULL, this, casterGUID); return; } @@ -1266,7 +1266,7 @@ void Aura::TriggerSpell() // case 27747: break; case 27808: // Frost Blast { - int32 bpDamage = triggerTarget->GetMaxHealth()*26/100; + int32 bpDamage = triggerTarget->GetMaxHealth() * 26 / 100; triggerTarget->CastCustomSpell(triggerTarget, 29879, &bpDamage, NULL, NULL, true, NULL, this, casterGUID); return; } @@ -1361,7 +1361,7 @@ void Aura::TriggerSpell() if (!caster) return; // move loot to player inventory and despawn target - if (caster->GetTypeId() ==TYPEID_PLAYER && + if (caster->GetTypeId() == TYPEID_PLAYER && triggerTarget->GetTypeId() == TYPEID_UNIT && ((Creature*)triggerTarget)->GetCreatureInfo()->type == CREATURE_TYPE_GAS_CLOUD) { @@ -1395,7 +1395,7 @@ void Aura::TriggerSpell() // case 31326: break; case 31347: // Doom { - target->CastSpell(target,31350,true); + target->CastSpell(target, 31350, true); target->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return; } @@ -1807,7 +1807,7 @@ void Aura::TriggerSpell() if (lRage > 100) // rage stored as rage*10 lRage = 100; target->ModifyPower(POWER_RAGE, -lRage); - int32 FRTriggerBasePoints = int32(lRage*LifePerRage/10); + int32 FRTriggerBasePoints = int32(lRage * LifePerRage / 10); target->CastCustomSpell(target, 22845, &FRTriggerBasePoints, NULL, NULL, true, NULL, this); return; } @@ -2017,7 +2017,7 @@ void Aura::TriggerSpell() if (Unit* caster = GetCaster()) { if (triggerTarget->GetTypeId() != TYPEID_UNIT || !sScriptMgr.OnEffectDummy(caster, GetId(), GetEffIndex(), (Creature*)triggerTarget)) - 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()); } } } @@ -2067,7 +2067,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 7057: // Haunting Spirits // expected to tick with 30 sec period (tick part see in Aura::PeriodicTick) m_isPeriodic = true; - m_modifier.periodictime = 30*IN_MILLISECONDS; + m_modifier.periodictime = 30 * IN_MILLISECONDS; m_periodicTimer = m_modifier.periodictime; return; case 10255: // Stoned @@ -2367,15 +2367,15 @@ void Aura::HandleAuraDummy(bool apply, bool Real) for (Unit::AuraList::const_iterator itr = modifierAuras.begin(); itr != modifierAuras.end(); ++itr) { // Unrelenting Assault - if ((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARRIOR && (*itr)->GetSpellProto()->SpellIconID == 2775) + if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARRIOR && (*itr)->GetSpellProto()->SpellIconID == 2775) { switch ((*itr)->GetSpellProto()->Id) { case 46859: // Unrelenting Assault, rank 1 - target->CastSpell(target,64849,true,NULL,(*itr)); + target->CastSpell(target, 64849, true, NULL, (*itr)); break; case 46860: // Unrelenting Assault, rank 2 - target->CastSpell(target,64850,true,NULL,(*itr)); + target->CastSpell(target, 64850, true, NULL, (*itr)); break; default: break; @@ -2616,7 +2616,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 45934: // Dark Fiend { // Kill target if dispelled - if (m_removeMode==AURA_REMOVE_BY_DISPEL) + if (m_removeMode == AURA_REMOVE_BY_DISPEL) target->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return; } @@ -2658,7 +2658,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) 51443 // bug }; - target->CastSpell(target, spell_list[urand(0,6)], true); + target->CastSpell(target, spell_list[urand(0, 6)], true); target->HandleEmote(EMOTE_STATE_NONE); target->clearUnitState(UNIT_STAT_STUNNED); @@ -2746,7 +2746,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_MAGE && (GetSpellProto()->SpellFamilyFlags & UI64LIT(0x2000000000000))) { if (m_removeMode == AURA_REMOVE_BY_EXPIRE || m_removeMode == AURA_REMOVE_BY_DISPEL) - target->CastSpell(target,m_modifier.m_amount,true,NULL,this); + target->CastSpell(target, m_modifier.m_amount, true, NULL, this); return; } @@ -3051,7 +3051,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) } // Predatory Strikes - if (target->GetTypeId()==TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563) + if (target->GetTypeId() == TYPEID_PLAYER && GetSpellProto()->SpellIconID == 1563) { ((Player*)target)->UpdateAttackPowerAndDamage(); return; @@ -3067,7 +3067,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) case 48395: spell_id = 50171; break; //Rank 2 case 48396: spell_id = 50172; break; //Rank 3 default: - sLog.outError("HandleAuraDummy: Not handled rank of IMF (Spell: %u)",GetId()); + sLog.outError("HandleAuraDummy: Not handled rank of IMF (Spell: %u)", GetId()); return; } @@ -3233,9 +3233,9 @@ void Aura::HandleAuraWaterWalk(bool apply, bool Real) WorldPacket data; if (apply) - data.Initialize(SMSG_MOVE_WATER_WALK, 8+4); + data.Initialize(SMSG_MOVE_WATER_WALK, 8 + 4); else - data.Initialize(SMSG_MOVE_LAND_WALK, 8+4); + data.Initialize(SMSG_MOVE_LAND_WALK, 8 + 4); data << GetTarget()->GetPackGUID(); data << uint32(0); GetTarget()->SendMessageToSet(&data, true); @@ -3249,9 +3249,9 @@ void Aura::HandleAuraFeatherFall(bool apply, bool Real) Unit* target = GetTarget(); WorldPacket data; if (apply) - data.Initialize(SMSG_MOVE_FEATHER_FALL, 8+4); + data.Initialize(SMSG_MOVE_FEATHER_FALL, 8 + 4); else - data.Initialize(SMSG_MOVE_NORMAL_FALL, 8+4); + data.Initialize(SMSG_MOVE_NORMAL_FALL, 8 + 4); data << target->GetPackGUID(); data << uint32(0); target->SendMessageToSet(&data, true); @@ -3269,9 +3269,9 @@ void Aura::HandleAuraHover(bool apply, bool Real) WorldPacket data; if (apply) - data.Initialize(SMSG_MOVE_SET_HOVER, 8+4); + data.Initialize(SMSG_MOVE_SET_HOVER, 8 + 4); else - data.Initialize(SMSG_MOVE_UNSET_HOVER, 8+4); + data.Initialize(SMSG_MOVE_UNSET_HOVER, 8 + 4); data << GetTarget()->GetPackGUID(); data << uint32(0); GetTarget()->SendMessageToSet(&data, true); @@ -3280,7 +3280,7 @@ void Aura::HandleAuraHover(bool apply, bool Real) void Aura::HandleWaterBreathing(bool /*apply*/, bool /*Real*/) { // update timers in client - if (GetTarget()->GetTypeId()==TYPEID_PLAYER) + if (GetTarget()->GetTypeId() == TYPEID_PLAYER) ((Player*)GetTarget())->UpdateMirrorTimers(); } @@ -3352,7 +3352,7 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real) if ((aurMechMask & MECHANIC_NOT_REMOVED_BY_SHAPESHIFT) || // some Daze spells have these parameters instead of MECHANIC_DAZE (skip snare spells) (aurSpellInfo->SpellIconID == 15 && aurSpellInfo->Dispel == 0 && - (aurMechMask & (1 << (MECHANIC_SNARE-1))) == 0)) + (aurMechMask & (1 << (MECHANIC_SNARE - 1))) == 0)) { ++iter; continue; @@ -3771,8 +3771,8 @@ void Aura::HandleAuraTransform(bool apply, bool Real) ((Creature*)target)->LoadEquipment(ci->equipmentId, true); // Dragonmaw Illusion (set mount model also) - if (GetId()==42016 && target->GetMountID() && !target->GetAurasByType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED).empty()) - target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314); + if (GetId() == 42016 && target->GetMountID() && !target->GetAurasByType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED).empty()) + target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 16314); } // update active transform spell only not set or not overwriting negative by positive case @@ -3785,7 +3785,7 @@ void Aura::HandleAuraTransform(bool apply, bool Real) // for players, start regeneration after 1s (in polymorph fast regeneration case) // only if caster is Player (after patch 2.4.2) if (GetCasterGuid().IsPlayer()) - ((Player*)target)->setRegenTimer(1*IN_MILLISECONDS); + ((Player*)target)->setRegenTimer(1 * IN_MILLISECONDS); //dismount polymorphed target (after patch 2.4.2) if (target->IsMounted()) @@ -3866,10 +3866,10 @@ void Aura::HandleAuraModSkill(bool apply, bool /*Real*/) if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; - uint32 prot=GetSpellProto()->EffectMiscValue[m_effIndex]; + uint32 prot = GetSpellProto()->EffectMiscValue[m_effIndex]; int32 points = GetModifier()->m_amount; - ((Player*)GetTarget())->ModifySkillBonus(prot, (apply ? points: -points), m_modifier.m_auraname == SPELL_AURA_MOD_SKILL_TALENT); + ((Player*)GetTarget())->ModifySkillBonus(prot, (apply ? points : -points), m_modifier.m_auraname == SPELL_AURA_MOD_SKILL_TALENT); if (prot == SKILL_DEFENSE) ((Player*)GetTarget())->UpdateDefenseBonusesMod(); } @@ -3910,9 +3910,9 @@ void Aura::HandleChannelDeathItem(bool apply, bool Real) InventoryResult msg = ((Player*)caster)->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellInfo->EffectItemType[m_effIndex], count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) { - count-=noSpaceForCount; + count -= noSpaceForCount; ((Player*)caster)->SendEquipError(msg, NULL, NULL, spellInfo->EffectItemType[m_effIndex]); - if (count==0) + if (count == 0) return; } @@ -3957,35 +3957,35 @@ void Aura::HandleFarSight(bool apply, bool /*Real*/) void Aura::HandleAuraTrackCreatures(bool apply, bool /*Real*/) { - if (GetTarget()->GetTypeId()!=TYPEID_PLAYER) + if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (apply) 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)); + GetTarget()->RemoveFlag(PLAYER_TRACK_CREATURES, uint32(1) << (m_modifier.m_miscvalue - 1)); } void Aura::HandleAuraTrackResources(bool apply, bool /*Real*/) { - if (GetTarget()->GetTypeId()!=TYPEID_PLAYER) + if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (apply) 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)); + GetTarget()->RemoveFlag(PLAYER_TRACK_RESOURCES, uint32(1) << (m_modifier.m_miscvalue - 1)); } void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/) { - if (GetTarget()->GetTypeId()!=TYPEID_PLAYER) + if (GetTarget()->GetTypeId() != TYPEID_PLAYER) return; if (apply) @@ -4177,7 +4177,7 @@ void Aura::HandleAuraModPetTalentsPoints(bool /*Apply*/, bool Real) return; // Recalculate pet talent points - if (Pet* pet=GetTarget()->GetPet()) + if (Pet* pet = GetTarget()->GetPet()) pet->InitTalentForLevel(); } @@ -4224,12 +4224,12 @@ void Aura::HandleModCharm(bool apply, bool Real) if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) { // creature with pet number expected have class set - if (target->GetByteValue(UNIT_FIELD_BYTES_0, 1)==0) + if (target->GetByteValue(UNIT_FIELD_BYTES_0, 1) == 0) { - if (cinfo->unit_class==0) - sLog.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.",cinfo->Entry); + if (cinfo->unit_class == 0) + sLog.outErrorDb("Creature (Entry: %u) have unit_class = 0 but used in charmed spell, that will be result client crash.", cinfo->Entry); else - sLog.outError("Creature (Entry: %u) have unit_class = %u but at charming have class 0!!! that will be result client crash.",cinfo->Entry,cinfo->unit_class); + sLog.outError("Creature (Entry: %u) have unit_class = %u but at charming have class 0!!! that will be result client crash.", cinfo->Entry, cinfo->unit_class); target->SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_MAGE); } @@ -4417,7 +4417,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) if (pObj->Create(target->GetMap()->GenerateLocalLowGuid(HIGHGUID_GAMEOBJECT), 185584, target->GetMap(), target->GetPhaseMask(), target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), target->GetOrientation())) { - pObj->SetRespawnTime(GetAuraDuration()/IN_MILLISECONDS); + pObj->SetRespawnTime(GetAuraDuration() / IN_MILLISECONDS); pObj->SetSpellId(GetId()); target->AddGameObject(pObj); target->GetMap()->Add(pObj); @@ -4463,7 +4463,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) if (target->getVictim() && target->isAlive()) target->SetTargetGuid(target->getVictim()->GetObjectGuid()); - WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8+4); + WorldPacket data(SMSG_FORCE_MOVE_UNROOT, 8 + 4); data << target->GetPackGUID(); data << uint32(0); target->SendMessageToSet(&data, true); @@ -4473,7 +4473,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000100000000000)) { Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId()!=TYPEID_PLAYER) + if (!caster || caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; @@ -4487,7 +4487,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) case 49011: spell_id = 49009; break; case 49012: spell_id = 49010; break; default: - sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?",GetId()); + sLog.outError("Spell selection called for unexpected original spell %u, new spell for this spell family?", GetId()); return; } @@ -4496,7 +4496,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) if (!spellInfo) return; - caster->CastSpell(target,spellInfo,true,NULL,this); + caster->CastSpell(target, spellInfo, true, NULL, this); return; } } @@ -4516,18 +4516,18 @@ void Aura::HandleModStealth(bool apply, bool Real) { target->SetStandFlags(UNIT_STAND_FLAGS_CREEP); - if (target->GetTypeId()==TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER) target->SetByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_STEALTH); // apply only if not in GM invisibility (and overwrite invisibility state) - if (target->GetVisibility()!=VISIBILITY_OFF) + if (target->GetVisibility() != VISIBILITY_OFF) { target->SetVisibility(VISIBILITY_GROUP_NO_DETECT); target->SetVisibility(VISIBILITY_GROUP_STEALTH); } // apply full stealth period bonuses only at first stealth aura in stack - if (target->GetAurasByType(SPELL_AURA_MOD_STEALTH).size()<=1) + if (target->GetAurasByType(SPELL_AURA_MOD_STEALTH).size() <= 1) { Unit::AuraList const& mDummyAuras = target->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) @@ -4537,7 +4537,7 @@ void Aura::HandleModStealth(bool apply, bool Real) { target->RemoveAurasDueToSpell(31666); int32 bp = (*i)->GetModifier()->m_amount; - target->CastCustomSpell(target,31665,&bp,NULL,NULL,true); + target->CastCustomSpell(target, 31665, &bp, NULL, NULL, true); } // Overkill else if ((*i)->GetId() == 58426 && GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000400000)) @@ -4554,11 +4554,11 @@ void Aura::HandleModStealth(bool apply, bool Real) if (Real && !target->HasAuraType(SPELL_AURA_MOD_STEALTH)) { // if no GM invisibility - if (target->GetVisibility()!=VISIBILITY_OFF) + if (target->GetVisibility() != VISIBILITY_OFF) { target->RemoveStandFlags(UNIT_STAND_FLAGS_CREEP); - if (target->GetTypeId()==TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER) target->RemoveByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_STEALTH); // restore invisibility if any @@ -4583,7 +4583,7 @@ void Aura::HandleModStealth(bool apply, bool Real) { if (SpellAuraHolder* holder = target->GetSpellAuraHolder(58427)) { - holder->SetAuraMaxDuration(20*IN_MILLISECONDS); + holder->SetAuraMaxDuration(20 * IN_MILLISECONDS); holder->RefreshHolder(); } } @@ -4602,7 +4602,7 @@ void Aura::HandleInvisibility(bool apply, bool Real) target->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); - if (Real && target->GetTypeId()==TYPEID_PLAYER) + if (Real && target->GetTypeId() == TYPEID_PLAYER) { // apply glow vision target->SetByteFlag(PLAYER_FIELD_BYTES2, 3, PLAYER_FIELD_BYTE2_INVISIBILITY_GLOW); @@ -4662,7 +4662,7 @@ void Aura::HandleInvisibilityDetect(bool apply, bool Real) for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) target->m_detectInvisibilityMask |= (1 << (*itr)->GetModifier()->m_miscvalue); } - if (Real && target->GetTypeId()==TYPEID_PLAYER) + if (Real && target->GetTypeId() == TYPEID_PLAYER) ((Player*)target)->GetCamera().UpdateVisibilityForOwner(); } @@ -4811,8 +4811,8 @@ void Aura::HandleModThreat(bool apply, bool Real) 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<m_threatModifier[x], float(m_modifier.m_amount), apply); } @@ -4930,12 +4930,12 @@ void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real) target->SendMessageToSet(&data, true); //Players on flying mounts must be immune to polymorph - if (target->GetTypeId()==TYPEID_PLAYER) - target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,MECHANIC_POLYMORPH,apply); + if (target->GetTypeId() == TYPEID_PLAYER) + target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, MECHANIC_POLYMORPH, apply); // Dragonmaw Illusion (overwrite mount model, mounted aura already applied) if (apply && target->HasAura(42016, EFFECT_INDEX_0) && target->GetMountID()) - target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID,16314); + target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 16314); // Festive Holiday Mount if (apply && GetSpellProto()->SpellIconID != 1794 && target->HasAura(62061)) @@ -5035,16 +5035,16 @@ void Aura::HandleModMechanicImmunity(bool apply, bool /*Real*/) if (apply && GetSpellProto()->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) { - uint32 mechanic = 1 << (misc-1); + uint32 mechanic = 1 << (misc - 1); // immune movement impairment and loss of control (spell data have special structure for mark this case) if (IsSpellRemoveAllMovementAndControlLossEffects(GetSpellProto())) - mechanic=IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; + mechanic = IMMUNE_TO_MOVEMENT_IMPAIRMENT_AND_LOSS_CONTROL_MASK; target->RemoveAurasAtMechanicImmunity(mechanic, GetId()); } - target->ApplySpellImmune(GetId(),IMMUNITY_MECHANIC,misc,apply); + target->ApplySpellImmune(GetId(), IMMUNITY_MECHANIC, misc, apply); // Bestial Wrath if (GetSpellProto()->SpellFamilyName == SPELLFAMILY_HUNTER && GetSpellProto()->SpellIconID == 1680) @@ -5077,7 +5077,7 @@ 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 } @@ -5233,7 +5233,7 @@ void Aura::HandlePeriodicTriggerSpell(bool apply, bool /*Real*/) return; case 42783: // Wrath of the Astrom... if (m_removeMode == AURA_REMOVE_BY_EXPIRE && GetEffIndex() + 1 < MAX_EFFECT_INDEX) - target->CastSpell(target, GetSpellProto()->CalculateSimpleValue(SpellEffectIndex(GetEffIndex()+1)), true); + target->CastSpell(target, GetSpellProto()->CalculateSimpleValue(SpellEffectIndex(GetEffIndex() + 1)), true); return; case 46221: // Animal Blood @@ -5291,7 +5291,7 @@ void Aura::HandlePeriodicEnergize(bool apply, bool Real) { // Glyph of Innervate if (caster->HasAura(54832)) - caster->CastSpell(caster,54833,true,NULL,this); + caster->CastSpell(caster, 54833, true, NULL, this); m_modifier.m_amount = int32(caster->GetCreateMana() * GetBasePoints() / (100 * GetAuraMaxTicks())); } @@ -5475,11 +5475,11 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) // $0.2*(($MWB+$mwb)/2+$AP/14*$MWS) bonus per tick float ap = caster->GetTotalAttackPowerValue(BASE_ATTACK); int32 mws = caster->GetAttackTime(BASE_ATTACK); - float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK,MINDAMAGE); - float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK,MAXDAMAGE); - m_modifier.m_amount+=int32(((mwb_min+mwb_max)/2+ap*mws/14000)*0.2f); + float mwb_min = caster->GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE); + float mwb_max = caster->GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE); + m_modifier.m_amount += int32(((mwb_min + mwb_max) / 2 + ap * mws / 14000) * 0.2f); // If used while target is above 75% health, Rend does 35% more damage - if (spellProto->CalculateSimpleValue(EFFECT_INDEX_1) !=0 && + if (spellProto->CalculateSimpleValue(EFFECT_INDEX_1) != 0 && target->GetHealth() > target->GetMaxHealth() * spellProto->CalculateSimpleValue(EFFECT_INDEX_1) / 100) m_modifier.m_amount += m_modifier.m_amount * spellProto->CalculateSimpleValue(EFFECT_INDEX_2) / 100; } @@ -5500,7 +5500,7 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) Unit::AuraList const& dummyAuras = caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) { - if ((*itr)->GetId()==34241) + if ((*itr)->GetId() == 34241) { m_modifier.m_amount += cp * (*itr)->GetModifier()->m_amount; break; @@ -5633,7 +5633,7 @@ void Aura::HandleAuraModResistanceExclusive(bool apply, bool /*Real*/) { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; x++) { - if (m_modifier.m_miscvalue & int32(1<HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_VALUE, float(m_modifier.m_amount), apply); if (GetTarget()->GetTypeId() == TYPEID_PLAYER) @@ -5646,7 +5646,7 @@ void Aura::HandleAuraModResistance(bool apply, bool /*Real*/) { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; x++) { - if (m_modifier.m_miscvalue & int32(1<HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), TOTAL_VALUE, float(m_modifier.m_amount), apply); if (GetTarget()->GetTypeId() == TYPEID_PLAYER || ((Creature*)GetTarget())->IsPet()) @@ -5668,7 +5668,7 @@ void Aura::HandleAuraModBaseResistancePCT(bool apply, bool /*Real*/) { for (int8 x = SPELL_SCHOOL_NORMAL; x < MAX_SPELL_SCHOOL; x++) { - if (m_modifier.m_miscvalue & int32(1<HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + x), BASE_PCT, float(m_modifier.m_amount), apply); } } @@ -5680,7 +5680,7 @@ void Aura::HandleModResistancePercent(bool apply, bool /*Real*/) for (int8 i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) { - if (m_modifier.m_miscvalue & int32(1<HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_PCT, float(m_modifier.m_amount), apply); if (target->GetTypeId() == TYPEID_PLAYER || ((Creature*)target)->IsPet()) @@ -5704,7 +5704,7 @@ void Aura::HandleModBaseResistance(bool apply, bool /*Real*/) else { for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; i++) - if (m_modifier.m_miscvalue & (1<HandleStatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), TOTAL_VALUE, float(m_modifier.m_amount), apply); } } @@ -5717,7 +5717,7 @@ void Aura::HandleAuraModStat(bool apply, bool /*Real*/) { if (m_modifier.m_miscvalue < -2 || m_modifier.m_miscvalue > 4) { - sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ",GetId(),GetEffIndex(),m_modifier.m_miscvalue); + sLog.outError("WARNING: Spell %u effect %u have unsupported misc value (%i) for SPELL_AURA_MOD_STAT ", GetId(), GetEffIndex(), m_modifier.m_miscvalue); return; } @@ -6004,7 +6004,7 @@ void Aura::HandleAuraModIncreaseMaxHealth(bool apply, bool /*Real*/) if (oldhealth > 0) { uint32 newhealth = uint32(ceil((double)target->GetMaxHealth() * healthPercentage)); - if (newhealth==0) + if (newhealth == 0) newhealth = 1; target->SetHealth(newhealth); @@ -6021,13 +6021,13 @@ void Aura::HandleAuraModIncreaseEnergy(bool apply, bool Real) UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + powerType); // Special case with temporary increase max/current power (percent) - if (GetId()==64904) // Hymn of Hope + if (GetId() == 64904) // Hymn of Hope { if (Real) { uint32 val = target->GetPower(powerType); target->HandleStatModifier(unitMod, TOTAL_PCT, float(m_modifier.m_amount), apply); - target->SetPower(powerType, apply ? val*(100+m_modifier.m_amount)/100 : val*100/(100+m_modifier.m_amount)); + target->SetPower(powerType, apply ? val * (100 + m_modifier.m_amount) / 100 : val * 100 / (100 + m_modifier.m_amount)); } return; } @@ -6124,7 +6124,7 @@ void Aura::HandleAuraModCritPercent(bool apply, bool Real) if (Real) { for (int i = 0; i < MAX_ATTACK; ++i) - if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i),true,false)) + if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) ((Player*)target)->_ApplyWeaponDependentAuraCritMod(pItem, WeaponAttackType(i), this, apply); } @@ -6168,7 +6168,7 @@ void Aura::HandleModSpellHitChance(bool apply, bool /*Real*/) } else { - GetTarget()->m_modSpellHitChance += apply ? m_modifier.m_amount: (-m_modifier.m_amount); + GetTarget()->m_modSpellHitChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); } } @@ -6184,7 +6184,7 @@ void Aura::HandleModSpellCritChance(bool apply, bool Real) } else { - GetTarget()->m_baseSpellCritChance += apply ? m_modifier.m_amount:(-m_modifier.m_amount); + GetTarget()->m_baseSpellCritChance += apply ? m_modifier.m_amount : (-m_modifier.m_amount); } } @@ -6198,7 +6198,7 @@ void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) return; for (int school = SPELL_SCHOOL_NORMAL; school < MAX_SPELL_SCHOOL; ++school) - if (m_modifier.m_miscvalue & (1<UpdateSpellCritChance(school); } @@ -6208,7 +6208,7 @@ void Aura::HandleModSpellCritChanceShool(bool /*apply*/, bool Real) void Aura::HandleModCastingSpeed(bool apply, bool /*Real*/) { - GetTarget()->ApplyCastTimePercentMod(float(m_modifier.m_amount),apply); + GetTarget()->ApplyCastTimePercentMod(float(m_modifier.m_amount), apply); } void Aura::HandleModMeleeRangedSpeedPct(bool apply, bool /*Real*/) @@ -6230,7 +6230,7 @@ void Aura::HandleModCombatSpeedPct(bool apply, bool /*Real*/) void Aura::HandleModAttackSpeed(bool apply, bool /*Real*/) { - GetTarget()->ApplyAttackTimePercentMod(BASE_ATTACK,float(m_modifier.m_amount),apply); + GetTarget()->ApplyAttackTimePercentMod(BASE_ATTACK, float(m_modifier.m_amount), apply); } void Aura::HandleModMeleeSpeedPct(bool apply, bool /*Real*/) @@ -6263,7 +6263,7 @@ void Aura::HandleAuraModAttackPower(bool apply, bool /*Real*/) void Aura::HandleAuraModRangedAttackPower(bool apply, bool /*Real*/) { - if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS)!=0) + if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS) != 0) return; GetTarget()->HandleStatModifier(UNIT_MOD_ATTACK_POWER_RANGED, TOTAL_VALUE, float(m_modifier.m_amount), apply); @@ -6277,7 +6277,7 @@ void Aura::HandleAuraModAttackPowerPercent(bool apply, bool /*Real*/) void Aura::HandleAuraModRangedAttackPowerPercent(bool apply, bool /*Real*/) { - if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS)!=0) + if ((GetTarget()->getClassMask() & CLASSMASK_WAND_USERS) != 0) return; //UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = multiplier - 1 @@ -6327,7 +6327,7 @@ void Aura::HandleModDamageDone(bool apply, bool Real) if (Real && target->GetTypeId() == TYPEID_PLAYER) { for (int i = 0; i < MAX_ATTACK; ++i) - if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i),true,false)) + if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); } @@ -6384,7 +6384,7 @@ void Aura::HandleModDamageDone(bool apply, bool Real) { for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { - if ((m_modifier.m_miscvalue & (1<ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, m_modifier.m_amount, apply); } } @@ -6392,7 +6392,7 @@ void Aura::HandleModDamageDone(bool apply, bool Real) { for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) { - if ((m_modifier.m_miscvalue & (1<ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + i, m_modifier.m_amount, apply); } } @@ -6411,7 +6411,7 @@ void Aura::HandleModDamagePercentDone(bool apply, bool Real) if (Real && target->GetTypeId() == TYPEID_PLAYER) { for (int i = 0; i < MAX_ATTACK; ++i) - if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i),true,false)) + if (Item* pItem = ((Player*)target)->GetWeaponForAttack(WeaponAttackType(i), true, false)) ((Player*)target)->_ApplyWeaponDependentAuraDamageMod(pItem, WeaponAttackType(i), this, apply); } @@ -6439,7 +6439,7 @@ 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 @@ -6459,7 +6459,7 @@ void Aura::HandleModDamagePercentDone(bool apply, bool Real) // Send info to client if (target->GetTypeId() == TYPEID_PLAYER) for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, m_modifier.m_amount/100.0f, apply); + target->ApplyModSignedFloatValue(PLAYER_FIELD_MOD_DAMAGE_DONE_PCT + i, m_modifier.m_amount / 100.0f, apply); } void Aura::HandleModOffhandDamagePercent(bool apply, bool Real) @@ -6483,9 +6483,9 @@ void Aura::HandleModPowerCostPCT(bool apply, bool Real) if (!Real) return; - float amount = m_modifier.m_amount/100.0f; + float amount = m_modifier.m_amount / 100.0f; for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) - if (m_modifier.m_miscvalue & (1<ApplyModSignedFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER + i, amount, apply); } @@ -6496,7 +6496,7 @@ void Aura::HandleModPowerCost(bool apply, bool Real) return; for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) - if (m_modifier.m_miscvalue & (1<ApplyModInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + i, m_modifier.m_amount, apply); } @@ -6514,8 +6514,8 @@ void Aura::HandleNoReagentUseAura(bool /*Apply*/, bool Real) for (Unit::AuraList::const_iterator i = noReagent.begin(); i != noReagent.end(); ++i) mask |= (*i)->GetAuraSpellClassMask(); - target->SetUInt64Value(PLAYER_NO_REAGENT_COST_1+0, mask.Flags); - target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1+2, mask.Flags2); + target->SetUInt64Value(PLAYER_NO_REAGENT_COST_1 + 0, mask.Flags); + target->SetUInt32Value(PLAYER_NO_REAGENT_COST_1 + 2, mask.Flags2); } /*********************************************************/ @@ -6623,7 +6623,7 @@ void Aura::HandleShapeshiftBoosts(bool apply) for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { if (itr->second.state == PLAYERSPELL_REMOVED) continue; - if (itr->first==spellId1 || itr->first==spellId2) continue; + if (itr->first == spellId1 || itr->first == spellId2) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (!spellInfo || !IsNeedCastSpellAtFormApply(spellInfo, form)) continue; @@ -6635,7 +6635,7 @@ void Aura::HandleShapeshiftBoosts(bool apply) { SpellEntry const* spellInfo = itr->second->GetSpellProto(); if (itr->second->IsPassive() && spellInfo->HasAttribute(SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) - && (spellInfo->StancesNot & (1<<(form-1)))) + && (spellInfo->StancesNot & (1 << (form - 1)))) { target->RemoveAurasDueToSpell(itr->second->GetId()); itr = tAuras.begin(); @@ -6664,7 +6664,7 @@ void Aura::HandleShapeshiftBoosts(bool apply) if (((Player*)target)->HasSpell(17007)) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(24932); - if (spellInfo && spellInfo->Stances & (1<<(form-1))) + if (spellInfo && spellInfo->Stances & (1 << (form - 1))) target->CastSpell(target, 24932, true, NULL, this); } @@ -6695,17 +6695,17 @@ void Aura::HandleShapeshiftBoosts(bool apply) Unit::AuraList const& dummyAuras = target->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = dummyAuras.begin(); i != dummyAuras.end(); ++i) { - if ((*i)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_DRUID && + if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && (*i)->GetSpellProto()->SpellIconID == 2855) { uint32 spell_id = 0; switch ((*i)->GetId()) { - case 48384:spell_id=50170; break; //Rank 1 - case 48395:spell_id=50171; break; //Rank 2 - case 48396:spell_id=50172; break; //Rank 3 + case 48384: spell_id = 50170; break; //Rank 1 + case 48395: spell_id = 50171; break; //Rank 2 + case 48396: spell_id = 50172; break; //Rank 3 default: - sLog.outError("Aura::HandleShapeshiftBoosts: Not handled rank of IMF (Spell: %u)",(*i)->GetId()); + sLog.outError("Aura::HandleShapeshiftBoosts: Not handled rank of IMF (Spell: %u)", (*i)->GetId()); break; } @@ -6751,11 +6751,11 @@ void Aura::HandleShapeshiftBoosts(bool apply) for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { if (itr->second.state == PLAYERSPELL_REMOVED) continue; - if (itr->first==spellId1 || itr->first==spellId2) continue; + if (itr->first == spellId1 || itr->first == spellId2) continue; SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (!spellInfo || !IsPassiveSpell(spellInfo)) continue; - if (spellInfo->HasAttribute(SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && (spellInfo->StancesNot & (1<<(form-1)))) + if (spellInfo->HasAttribute(SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) && (spellInfo->StancesNot & (1 << (form - 1)))) target->CastSpell(target, itr->first, true, NULL, this); } } @@ -6898,7 +6898,7 @@ void Aura::HandleModTargetResistance(bool apply, bool Real) target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_PHYSICAL_RESISTANCE, m_modifier.m_amount, apply); // show as spell penetration only full spell penetration bonuses (all resistances except armor and holy - if (target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL)==SPELL_SCHOOL_MASK_SPELL) + if (target->GetTypeId() == TYPEID_PLAYER && (m_modifier.m_miscvalue & SPELL_SCHOOL_MASK_SPELL) == SPELL_SCHOOL_MASK_SPELL) target->ApplyModInt32Value(PLAYER_FIELD_MOD_TARGET_RESISTANCE, m_modifier.m_amount, apply); } @@ -6926,7 +6926,7 @@ void Aura::HandleAuraRetainComboPoints(bool apply, bool Real) // combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler // 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())) + if (Unit* unit = ObjectAccessor::GetUnit(*GetTarget(), target->GetComboTargetGuid())) target->AddComboPoints(unit, -m_modifier.m_amount); } @@ -6937,7 +6937,7 @@ void Aura::HandleModUnattackable(bool Apply, bool Real) GetTarget()->CombatStop(); GetTarget()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_IMMUNE_OR_LOST_SELECTION); } - GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE,Apply); + GetTarget()->ApplyModFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE, Apply); } void Aura::HandleSpiritOfRedemption(bool apply, bool Real) @@ -6951,7 +6951,7 @@ void Aura::HandleSpiritOfRedemption(bool apply, bool Real) // prepare spirit state if (apply) { - if (target->GetTypeId()==TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER) { // disable breath/etc timers ((Player*)target)->StopMirrorTimers(); @@ -6982,7 +6982,7 @@ void Aura::HandleSchoolAbsorb(bool apply, bool Real) if (apply) { // prevent double apply bonuses - if (target->GetTypeId()!=TYPEID_PLAYER || !((Player*)target)->GetSession()->PlayerLoading()) + if (target->GetTypeId() != TYPEID_PLAYER || !((Player*)target)->GetSession()->PlayerLoading()) { float DoneActualBenefit = 0.0f; switch (spellProto->SpellFamilyName) @@ -7003,7 +7003,7 @@ void Aura::HandleSchoolAbsorb(bool apply, bool Real) for (Unit::AuraList::const_iterator itr = borrowedTime.begin(); itr != borrowedTime.end(); ++itr) { SpellEntry const* i_spell = (*itr)->GetSpellProto(); - if (i_spell->SpellFamilyName==SPELLFAMILY_PRIEST && i_spell->SpellIconID == 2899 && i_spell->EffectMiscValue[(*itr)->GetEffIndex()] == 24) + if (i_spell->SpellFamilyName == SPELLFAMILY_PRIEST && i_spell->SpellIconID == 2899 && i_spell->EffectMiscValue[(*itr)->GetEffIndex()] == 24) { DoneActualBenefit += DoneActualBenefit * (*itr)->GetModifier()->m_amount / 100; break; @@ -7186,7 +7186,7 @@ void Aura::PeriodicTick() if (m_modifier.m_auraname == SPELL_AURA_PERIODIC_DAMAGE) pdamage = amount; else - pdamage = uint32(target->GetMaxHealth()*amount/100); + pdamage = uint32(target->GetMaxHealth() * amount / 100); // SpellDamageBonus for magic spells if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE || spellProto->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) @@ -7209,11 +7209,11 @@ void Aura::PeriodicTick() } // Curse of Agony damage-per-tick calculation - if (spellProto->SpellFamilyName==SPELLFAMILY_WARLOCK && (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400)) && spellProto->SpellIconID==544) + if (spellProto->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellProto->SpellFamilyFlags & UI64LIT(0x0000000000000400)) && spellProto->SpellIconID == 544) { // 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 @@ -7239,7 +7239,7 @@ void Aura::PeriodicTick() target->CalculateDamageAbsorbAndResist(pCaster, GetSpellSchoolMask(spellProto), DOT, pdamage, &absorb, &resist, !GetSpellProto()->HasAttribute(SPELL_ATTR_EX2_CANT_REFLECTED)); DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s attacked %s for %u dmg inflicted by %u abs is %u", - GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId(),absorb); + GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId(), absorb); pCaster->DealDamageMods(target, pdamage, &absorb); @@ -7255,7 +7255,7 @@ 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); @@ -7297,8 +7297,8 @@ void Aura::PeriodicTick() if (target->IsImmunedToDamage(GetSpellSchoolMask(spellProto))) return; - uint32 absorb=0; - uint32 resist=0; + uint32 absorb = 0; + uint32 resist = 0; CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL); uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0; @@ -7331,7 +7331,7 @@ void Aura::PeriodicTick() target->CalculateDamageAbsorbAndResist(pCaster, GetSpellSchoolMask(spellProto), DOT, pdamage, &absorb, &resist, !spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_REFLECTED)); DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s health leech of %s for %u dmg inflicted by %u abs is %u", - GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId(),absorb); + GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId(), absorb); pCaster->DealDamageMods(target, pdamage, &absorb); @@ -7344,9 +7344,9 @@ void Aura::PeriodicTick() uint32 procVictim = PROC_FLAG_ON_TAKE_PERIODIC;// | PROC_FLAG_TAKEN_HARMFUL_SPELL_HIT; uint32 procEx = isCrit ? PROC_EX_CRITICAL_HIT : PROC_EX_NORMAL_HIT; - pdamage = (pdamage <= absorb + resist) ? 0 : (pdamage-absorb-resist); + 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); @@ -7389,7 +7389,7 @@ void Aura::PeriodicTick() uint32 pdamage; - if (m_modifier.m_auraname==SPELL_AURA_OBS_MOD_HEALTH) + if (m_modifier.m_auraname == SPELL_AURA_OBS_MOD_HEALTH) pdamage = uint32(target->GetMaxHealth() * amount / 100); else { @@ -7400,12 +7400,12 @@ void Aura::PeriodicTick() { int32 ticks = GetAuraMaxTicks(); int32 remainingTicks = ticks - GetAuraTicks(); - int32 addition = int32(amount)*ticks*(-6+2*remainingTicks)/100; + int32 addition = int32(amount) * ticks * (-6 + 2 * remainingTicks) / 100; if (GetAuraTicks() != 1) // Item - Druid T10 Restoration 2P Bonus if (Aura* aura = pCaster->GetAura(70658, EFFECT_INDEX_0)) - addition += abs(int32((addition * aura->GetModifier()->m_amount) / ((ticks-1)* 100))); + addition += abs(int32((addition * aura->GetModifier()->m_amount) / ((ticks - 1) * 100))); pdamage = int32(pdamage) + addition; } @@ -7444,7 +7444,7 @@ void Aura::PeriodicTick() if (target != pCaster && spellProto->SpellVisual[0] == 163) { uint32 dmg = spellProto->manaPerSecond; - if (pCaster->GetHealth() <= dmg && pCaster->GetTypeId()==TYPEID_PLAYER) + if (pCaster->GetHealth() <= dmg && pCaster->GetTypeId() == TYPEID_PLAYER) { pCaster->RemoveAurasDueToSpell(GetId()); @@ -7611,7 +7611,7 @@ void Aura::PeriodicTick() SpellPeriodicAuraLogInfo pInfo(this, pdamage, 0, 0, 0, 0.0f); target->SendPeriodicAuraLog(&pInfo); - int32 gain = target->ModifyPower(power,pdamage); + int32 gain = target->ModifyPower(power, pdamage); if (Unit* pCaster = GetCaster()) target->getHostileRefManager().threatAssist(pCaster, float(gain) * 0.5f * sSpellMgr.GetSpellThreatMultiplier(spellProto), spellProto); @@ -7687,7 +7687,7 @@ 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); @@ -7788,7 +7788,7 @@ void Aura::PeriodicDummyTick() } case 7057: // Haunting Spirits if (roll_chance_i(33)) - target->CastSpell(target,m_modifier.m_amount,true,NULL,this); + target->CastSpell(target, m_modifier.m_amount, true, NULL, this); return; // // Panda // case 19230: break; @@ -8004,7 +8004,7 @@ void Aura::PeriodicDummyTick() target->CastSpell(target, 53521, true, NULL, this); return; case 55592: // Clean - switch (urand(0,2)) + switch (urand(0, 2)) { case 0: target->CastSpell(target, 55731, true); break; case 1: target->CastSpell(target, 55738, true); break; @@ -8050,9 +8050,9 @@ void Aura::PeriodicDummyTick() case 68876: // Wailing Souls { // Sweep around - float newAngle = target->GetOrientation() + (spell->Id == 68875 ? 0.09f : 2*M_PI_F - 0.09f); - if (newAngle > 2*M_PI_F) - newAngle -= 2*M_PI_F; + float newAngle = target->GetOrientation() + (spell->Id == 68875 ? 0.09f : 2 * M_PI_F - 0.09f); + if (newAngle > 2 * M_PI_F) + newAngle -= 2 * M_PI_F; target->SetFacingTo(newAngle); @@ -8066,7 +8066,7 @@ void Aura::PeriodicDummyTick() } // Drink (item drink spells) - if (GetEffIndex() > EFFECT_INDEX_0 && spell->EffectApplyAuraName[GetEffIndex()-1] == SPELL_AURA_MOD_POWER_REGEN) + if (GetEffIndex() > EFFECT_INDEX_0 && spell->EffectApplyAuraName[GetEffIndex() - 1] == SPELL_AURA_MOD_POWER_REGEN) { if (target->GetTypeId() != TYPEID_PLAYER) return; @@ -8125,7 +8125,7 @@ void Aura::PeriodicDummyTick() int32 points = target->CalculateSpellDamage(target, spell, EFFECT_INDEX_1); int32 regen = target->GetMaxHealth() * (mod * points / 10) / 1000; target->CastCustomSpell(target, 22845, ®en, NULL, NULL, true, NULL, this); - target->SetPower(POWER_RAGE, rage-mod); + target->SetPower(POWER_RAGE, rage - mod); return; } // Force of Nature @@ -8160,7 +8160,7 @@ void Aura::PeriodicDummyTick() return; Spell::UnitList::const_iterator itr = targets.begin(); - std::advance(itr, rand()%targets.size()); + std::advance(itr, rand() % targets.size()); Unit* victim = *itr; target->CastSpell(victim, 57840, true); @@ -8232,7 +8232,7 @@ void Aura::PeriodicDummyTick() { slow->ApplyModifier(false, true); Modifier* mod = slow->GetModifier(); - mod->m_amount+= m_modifier.m_amount; + mod->m_amount += m_modifier.m_amount; if (mod->m_amount > 0) mod->m_amount = 0; slow->ApplyModifier(true, true); } @@ -8295,7 +8295,7 @@ void Aura::HandleManaShield(bool apply, bool Real) return; // prevent double apply bonuses - if (apply && (GetTarget()->GetTypeId()!=TYPEID_PLAYER || !((Player*)GetTarget())->GetSession()->PlayerLoading())) + if (apply && (GetTarget()->GetTypeId() != TYPEID_PLAYER || !((Player*)GetTarget())->GetSession()->PlayerLoading())) { if (Unit* caster = GetCaster()) { @@ -8746,7 +8746,7 @@ void SpellAuraHolder::_AddSpellAuraHolder() if (m_spellProto->HasAttribute(SPELL_ATTR_DISABLED_WHILE_ACTIVE)) { Item* castItem = m_castItemGuid ? ((Player*)caster)->GetItemByGuid(m_castItemGuid) : NULL; - ((Player*)caster)->AddSpellAndCategoryCooldowns(m_spellProto,castItem ? castItem->GetEntry() : 0, NULL,true); + ((Player*)caster)->AddSpellAndCategoryCooldowns(m_spellProto, castItem ? castItem->GetEntry() : 0, NULL, true); } } @@ -8812,7 +8812,7 @@ void SpellAuraHolder::_AddSpellAuraHolder() m_target->ModifyAuraState(AURA_STATE_ENRAGE, true); // Bleeding aura state - if (GetAllSpellMechanicMask(m_spellProto) & (1 << (MECHANIC_BLEED-1))) + if (GetAllSpellMechanicMask(m_spellProto) & (1 << (MECHANIC_BLEED - 1))) m_target->ModifyAuraState(AURA_STATE_BLEEDING, true); } } @@ -8821,7 +8821,7 @@ void SpellAuraHolder::_RemoveSpellAuraHolder() { // Remove all triggered by aura spells vs unlimited duration // except same aura replace case - if (m_removeMode!=AURA_REMOVE_BY_STACK) + if (m_removeMode != AURA_REMOVE_BY_STACK) CleanupTriggeredSpells(); Unit* caster = GetCaster(); @@ -8872,14 +8872,14 @@ void SpellAuraHolder::_RemoveSpellAuraHolder() m_target->ModifyAuraState(AURA_STATE_ENRAGE, false); // Bleeding aura state - if (GetAllSpellMechanicMask(m_spellProto) & (1 << (MECHANIC_BLEED-1))) + if (GetAllSpellMechanicMask(m_spellProto) & (1 << (MECHANIC_BLEED - 1))) { bool found = false; Unit::SpellAuraHolderMap const& holders = m_target->GetSpellAuraHolderMap(); for (Unit::SpellAuraHolderMap::const_iterator itr = holders.begin(); itr != holders.end(); ++itr) { - if (GetAllSpellMechanicMask(itr->second->GetSpellProto()) & (1 << (MECHANIC_BLEED-1))) + if (GetAllSpellMechanicMask(itr->second->GetSpellProto()) & (1 << (MECHANIC_BLEED - 1))) { found = true; break; @@ -8998,7 +8998,7 @@ bool SpellAuraHolder::ModStackAmount(int32 num) int32 stackAmount = m_stackAmount + num; if (stackAmount > (int32)protoStackAmount) stackAmount = protoStackAmount; - else if (stackAmount <=0) // Last aura from stack removed + else if (stackAmount <= 0) // Last aura from stack removed { m_stackAmount = 0; return true; // need remove aura @@ -9115,7 +9115,7 @@ void SpellAuraHolder::BuildUpdatePacket(WorldPacket& data) const data << uint8(auraFlags); data << uint8(GetAuraLevel()); - uint32 stackCount = m_procCharges ? m_procCharges*m_stackAmount : m_stackAmount; + uint32 stackCount = m_procCharges ? m_procCharges * m_stackAmount : m_stackAmount; data << uint8(stackCount <= 255 ? stackCount : 255); if (!(auraFlags & AFLAG_NOT_CASTER)) @@ -9412,7 +9412,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) if (Aura* glyph = caster->GetAura(55672, EFFECT_INDEX_0)) { Aura* shield = GetAuraByEffectIndex(EFFECT_INDEX_0); - int32 heal = (glyph->GetModifier()->m_amount * shield->GetModifier()->m_amount)/100; + int32 heal = (glyph->GetModifier()->m_amount * shield->GetModifier()->m_amount) / 100; caster->CastCustomSpell(m_target, 56160, &heal, NULL, NULL, true, 0, shield); } return; @@ -9425,14 +9425,14 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) { if (apply) { - int chance =0; + int chance = 0; Unit::AuraList const& dummyAuras = m_target->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) { SpellEntry const* dummyEntry = (*itr)->GetSpellProto(); // Body and Soul (talent ranks) if (dummyEntry->SpellFamilyName == SPELLFAMILY_PRIEST && dummyEntry->SpellIconID == 2218 && - dummyEntry->SpellVisual[0]==0) + dummyEntry->SpellVisual[0] == 0) { chance = (*itr)->GetSpellProto()->CalculateSimpleValue(EFFECT_INDEX_1); break; @@ -9459,7 +9459,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) case SPELLFAMILY_DRUID: { // Barkskin - if (GetId()==22812 && m_target->HasAura(63057)) // Glyph of Barkskin + if (GetId() == 22812 && m_target->HasAura(63057)) // Glyph of Barkskin spellId1 = 63058; // Glyph - Barkskin 01 else if (!apply && GetId() == 5229) // Enrage (Druid Bear) spellId1 = 51185; // King of the Jungle (Enrage damage aura) @@ -9562,7 +9562,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) spellId1 = 61848; // triggered spell have same category as main spell and cooldown - if (apply && m_target->GetTypeId()==TYPEID_PLAYER) + if (apply && m_target->GetTypeId() == TYPEID_PLAYER) ((Player*)m_target)->RemoveSpellCooldown(61848); } else @@ -9613,7 +9613,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) return; // Sanctified Retribution and Swift Retribution (they share one aura), but not Retribution Aura (already gets modded) - if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000008))==0) + if ((GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000000008)) == 0) spellId1 = 63531; // placeholder for talent spell mods // Improved Concentration Aura (auras bonus) spellId2 = 63510; // placeholder for talent spell mods @@ -9633,7 +9633,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) case 48266: // Blood Presence { // else part one per 3 pair - if (GetId()==48263 || GetId()==48265) // Frost Presence or Unholy Presence + if (GetId() == 48263 || GetId() == 48265) // Frost Presence or Unholy Presence { // Improved Blood Presence int32 heal_pct = 0; @@ -9660,7 +9660,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) else spellId1 = 63611; // Improved Blood Presence, trigger for heal - if (GetId()==48263 || GetId()==48266) // Frost Presence or Blood Presence + if (GetId() == 48263 || GetId() == 48266) // Frost Presence or Blood Presence { // Improved Unholy Presence int32 power_pct = 0; @@ -9684,7 +9684,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) else spellId1 = 49772; // Unholy Presence move speed - if (GetId()==48265 || GetId()==48266) // Unholy Presence or Blood Presence + if (GetId() == 48265 || GetId() == 48266) // Unholy Presence or Blood Presence { // Improved Frost Presence int32 stamina_pct = 0; @@ -9711,7 +9711,7 @@ void SpellAuraHolder::HandleSpellSpecificBoosts(bool apply) else spellId1 = 61261; // Frost Presence, stamina - if (GetId()==48265) // Unholy Presence + if (GetId() == 48265) // Unholy Presence { // Improved Unholy Presence, special case for own presence int32 power_pct = 0; @@ -9865,7 +9865,7 @@ void SpellAuraHolder::Update(uint32 diff) { Powers powertype = Powers(GetSpellProto()->powerType); int32 manaPerSecond = GetSpellProto()->manaPerSecond + GetSpellProto()->manaPerSecondPerLevel * caster->getLevel(); - m_timeCla = 1*IN_MILLISECONDS; + m_timeCla = 1 * IN_MILLISECONDS; if (manaPerSecond) { @@ -9949,7 +9949,7 @@ bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const return true; for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) - if (m_auras[i] && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] -1)) & mechanicMask)) + if (m_auras[i] && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] - 1)) & mechanicMask)) return true; return false; } diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 96f4d7ccc..787b4430e 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -176,15 +176,15 @@ class MANGOS_DLL_SPEC SpellAuraHolder int32 m_duration; // Current time int32 m_timeCla; // Timer for power per sec calculation - AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason - DiminishingGroup m_AuraDRGroup:8; // Diminishing + AuraRemoveMode m_removeMode: 8; // Store info for know remove aura reason + DiminishingGroup m_AuraDRGroup: 8; // Diminishing - bool m_permanent:1; - bool m_isPassive:1; - bool m_isDeathPersist:1; - bool m_isRemovedOnShapeLost:1; - bool m_isSingleTarget:1; // true if it's a single target spell and registered at caster - can change at spell steal for example - bool m_deleted:1; + bool m_permanent: 1; + bool m_isPassive: 1; + bool m_isDeathPersist: 1; + bool m_isRemovedOnShapeLost: 1; + bool m_isSingleTarget: 1; // true if it's a single target spell and registered at caster - can change at spell steal for example + bool m_deleted: 1; uint32 m_in_use; // > 0 while in SpellAuraHolder::ApplyModifiers call/SpellAuraHolder::Update/etc }; @@ -475,14 +475,14 @@ class MANGOS_DLL_SPEC Aura int32 m_periodicTimer; // Timer for periodic auras uint32 m_periodicTick; // Tick count pass (including current if use in tick code) from aura apply, used for some tick count dependent aura effects - AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason + AuraRemoveMode m_removeMode: 8; // Store info for know remove aura reason - SpellEffectIndex m_effIndex :8; // Aura effect index in spell + SpellEffectIndex m_effIndex : 8; // Aura effect index in spell - bool m_positive:1; - bool m_isPeriodic:1; - bool m_isAreaAura:1; - bool m_isPersistent:1; + bool m_positive: 1; + bool m_isPeriodic: 1; + bool m_isAreaAura: 1; + bool m_isPersistent: 1; uint32 m_in_use; // > 0 while in Aura::ApplyModifier call/Aura::Update/etc diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index a05afc0fd..011c762e2 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -58,7 +58,7 @@ #include "GridNotifiersImpl.h" #include "CellImpl.h" -pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= +pEffect SpellEffects[TOTAL_SPELL_EFFECTS] = { &Spell::EffectNULL, // 0 &Spell::EffectInstaKill, // 1 SPELL_EFFECT_INSTAKILL @@ -274,7 +274,7 @@ void Spell::EffectInstaKill(SpellEffectIndex /*eff_idx*/) WorldObject* caster = GetCastingObject(); // we need the original casting object - WorldPacket data(SMSG_SPELLINSTAKILLLOG, (8+8+4)); + WorldPacket data(SMSG_SPELLINSTAKILLLOG, (8 + 8 + 4)); data << (caster && caster->GetTypeId() != TYPEID_GAMEOBJECT ? m_caster->GetObjectGuid() : ObjectGuid()); // Caster GUID data << unitTarget->GetObjectGuid(); // Victim GUID data << uint32(m_spellInfo->Id); @@ -327,7 +327,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) { uint32 count = 0; for (TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - if (ihit->effectMask & (1<effectMask & (1 << effect_idx)) ++count; damage /= count; // divide to all targets @@ -345,7 +345,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) case 20253: case 61491: { - damage+= uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.12f); + damage += uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.12f); break; } // percent max target health @@ -405,7 +405,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) damage = uint32(damage * (m_caster->GetTotalAttackPowerValue(BASE_ATTACK)) / 100); } // Shield Slam - else if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000020000000000)) && m_spellInfo->Category==1209) + else if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000020000000000)) && m_spellInfo->Category == 1209) damage += int32(m_caster->GetShieldBlockValue()); // Victory Rush else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x10000000000)) @@ -415,32 +415,32 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) } // Revenge ${$m1+$AP*0.310} to ${$M1+$AP*0.310} else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000400)) - damage+= uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.310f); + damage += uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.310f); // Heroic Throw ${$m1+$AP*.50} else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000100000000)) - damage+= uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f); + damage += uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f); // Shattering Throw ${$m1+$AP*.50} else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0040000000000000)) - damage+= uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f); + damage += uint32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f); // Shockwave ${$m3/100*$AP} else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000800000000000)) { int32 pct = m_caster->CalculateSpellDamage(unitTarget, m_spellInfo, EFFECT_INDEX_2); if (pct > 0) - damage+= int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * pct / 100); + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * pct / 100); break; } // Thunder Clap else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000000080)) { - damage+=int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 12 / 100); + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 12 / 100); } break; } case SPELLFAMILY_WARLOCK: { // Incinerate Rank 1 & 2 - if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x00004000000000)) && m_spellInfo->SpellIconID==2128) + if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x00004000000000)) && m_spellInfo->SpellIconID == 2128) { // Incinerate does more dmg (dmg*0.25) if the target have Immolate debuff. // Check aura state for speed but aura state set not only for Immolate spell @@ -453,7 +453,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && ((*i)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x00000000000004))) { - damage += damage/4; + damage += damage / 4; break; } } @@ -468,7 +468,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) case 47897: m_caster->CastSpell(unitTarget, 47960, true); break; case 61290: m_caster->CastSpell(unitTarget, 61291, true); break; default: - sLog.outError("Spell::EffectDummy: Unhandeled Shadowflame spell rank %u",m_spellInfo->Id); + sLog.outError("Spell::EffectDummy: Unhandeled Shadowflame spell rank %u", m_spellInfo->Id); break; } } @@ -481,7 +481,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) uint32 counter = 0; Unit::AuraList const& dotAuras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for (Unit::AuraList::const_iterator itr = dotAuras.begin(); itr!=dotAuras.end(); ++itr) + for (Unit::AuraList::const_iterator itr = dotAuras.begin(); itr != dotAuras.end(); ++itr) if ((*itr)->GetCasterGuid() == owner->GetObjectGuid()) ++counter; @@ -554,7 +554,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) case SPELLFAMILY_DRUID: { // Ferocious Bite - if (m_caster->GetTypeId()==TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x000800000)) && m_spellInfo->SpellVisual[0]==6587) + if (m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x000800000)) && m_spellInfo->SpellVisual[0] == 6587) { // converts up to 30 points of energy into ($f1+$AP/410) additional damage float ap = m_caster->GetTotalAttackPowerValue(BASE_ATTACK); @@ -563,7 +563,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) uint32 energy = m_caster->GetPower(POWER_ENERGY); uint32 used_energy = energy > 30 ? 30 : energy; damage += int32(used_energy * multiple); - m_caster->SetPower(POWER_ENERGY,energy-used_energy); + m_caster->SetPower(POWER_ENERGY, energy - used_energy); } // Rake else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000001000) && m_spellInfo->Effect[EFFECT_INDEX_2] == SPELL_EFFECT_ADD_COMBO_POINTS) @@ -574,14 +574,14 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) // Swipe else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0010000000000000)) { - damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK)*0.08f); + damage += int32(m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.08f); } break; } case SPELLFAMILY_ROGUE: { // Envenom - if (m_caster->GetTypeId()==TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x800000000))) + if (m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x800000000))) { // consume from stack dozes not more that have combo-points if (uint32 combo = ((Player*)m_caster)->GetComboPoints()) @@ -589,9 +589,9 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) Aura* poison = 0; // Lookup for Deadly poison (only attacker applied) Unit::AuraList const& auras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for (Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - if ((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_ROGUE && + if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_ROGUE && ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x10000)) && (*itr)->GetCasterGuid() == m_caster->GetObjectGuid()) { @@ -610,7 +610,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) // Master Poisoner Unit::AuraList const& auraList = ((Player*)m_caster)->GetAurasByType(SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL); - for (Unit::AuraList::const_iterator iter = auraList.begin(); iter!=auraList.end(); ++iter) + for (Unit::AuraList::const_iterator iter = auraList.begin(); iter != auraList.end(); ++iter) { if ((*iter)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_ROGUE && (*iter)->GetSpellProto()->SpellIconID == 1960) { @@ -630,11 +630,11 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) } // Eviscerate and Envenom Bonus Damage (item set effect) if (m_caster->GetDummyAura(37169)) - damage += ((Player*)m_caster)->GetComboPoints()*40; + damage += ((Player*)m_caster)->GetComboPoints() * 40; } } // Eviscerate - else if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x00020000)) && m_caster->GetTypeId()==TYPEID_PLAYER) + else if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x00020000)) && m_caster->GetTypeId() == TYPEID_PLAYER) { if (uint32 combo = ((Player*)m_caster)->GetComboPoints()) { @@ -643,7 +643,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) // Eviscerate and Envenom Bonus Damage (item set effect) if (m_caster->GetDummyAura(37169)) - damage += combo*40; + damage += combo * 40; } } break; @@ -659,8 +659,8 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) // Steady Shot else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x100000000)) { - int32 base = irand((int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE),(int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE)); - damage += int32(float(base)/m_caster->GetAttackTime(RANGED_ATTACK)*2800 + m_caster->GetTotalAttackPowerValue(RANGED_ATTACK)*0.1f); + int32 base = irand((int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MINDAMAGE), (int32)m_caster->GetWeaponDamageRange(RANGED_ATTACK, MAXDAMAGE)); + damage += int32(float(base) / m_caster->GetAttackTime(RANGED_ATTACK) * 2800 + m_caster->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.1f); } break; } @@ -676,7 +676,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) damage += int32(ap * 0.2f) + int32(holy * 32 / 100); } // Judgement of Vengeance/Corruption ${1+0.22*$SPH+0.14*$AP} + 10% for each application of Holy Vengeance/Blood Corruption on the target - else if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x800000000)) && m_spellInfo->SpellIconID==2292) + else if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x800000000)) && m_spellInfo->SpellIconID == 2292) { uint32 debuf_id; switch (m_spellInfo->Id) @@ -690,13 +690,13 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) int32 holy = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)); if (holy < 0) holy = 0; - damage+=int32(ap * 0.14f) + int32(holy * 22 / 100); + damage += int32(ap * 0.14f) + int32(holy * 22 / 100); // Get stack of Holy Vengeance on the target added by caster uint32 stacks = 0; Unit::AuraList const& auras = unitTarget->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for (Unit::AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { - if (((*itr)->GetId() == debuf_id) && (*itr)->GetCasterGuid()==m_caster->GetObjectGuid()) + if (((*itr)->GetId() == debuf_id) && (*itr)->GetCasterGuid() == m_caster->GetObjectGuid()) { stacks = (*itr)->GetStackAmount(); break; @@ -704,7 +704,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) } // + 10% for each application of Holy Vengeance on the target if (stacks) - damage += damage * stacks * 10 /100; + damage += damage * stacks * 10 / 100; } // Avenger's Shield ($m1+0.07*$SPH+0.07*$AP) - ranged sdb for future else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000004000)) @@ -735,7 +735,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx) // Shield of Righteousness else if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0010000000000000)) { - damage+=int32(m_caster->GetShieldBlockValue()); + damage += int32(m_caster->GetShieldBlockValue()); } // Judgement else if (m_spellInfo->Id == 54158) @@ -769,7 +769,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) if (!unitTarget) return; - uint32 spell_id = (unitTarget->getGender() == GENDER_MALE) ? 10651: 10653; + uint32 spell_id = (unitTarget->getGender() == GENDER_MALE) ? 10651 : 10653; m_caster->CastSpell(unitTarget, spell_id, true); return; @@ -789,7 +789,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; uint32 spell_id = 0; - switch (urand(1,5)) + switch (urand(1, 5)) { case 1: spell_id = 8064; break; // Sleepy case 2: spell_id = 8065; break; // Invigorate @@ -806,7 +806,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; uint32 spell_id = 0; - switch (urand(1,2)) + switch (urand(1, 2)) { // Flip Out - ninja case 1: spell_id = (m_caster->getGender() == GENDER_MALE ? 8219 : 8220); break; @@ -814,7 +814,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case 2: spell_id = (m_caster->getGender() == GENDER_MALE ? 8221 : 8222); break; } - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 9976: // Polly Eats the E.C.A.C. @@ -854,7 +854,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) else // normal root spell_id = 13099; - m_caster->CastSpell(unitTarget,spell_id,true,NULL); + m_caster->CastSpell(unitTarget, spell_id, true, NULL); return; } case 13567: // Dummy Trigger @@ -869,7 +869,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) m_caster->CastCustomSpell(unitTarget, 26470, &damage, NULL, NULL, true); break; default: - sLog.outError("EffectDummy: Non-handled case for spell 13567 for triggered aura %u",m_triggeredByAuraSpell->Id); + sLog.outError("EffectDummy: Non-handled case for spell 13567 for triggered aura %u", m_triggeredByAuraSpell->Id); break; } return; @@ -927,7 +927,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) { case 1: spell_id = 16595; break; case 2: spell_id = 16593; break; - default:spell_id = 16591; break; + default: spell_id = 16591; break; } m_caster->CastSpell(m_caster, spell_id, true, NULL); @@ -950,7 +950,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } case 17271: // Test Fetid Skull { - if (!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) + if (!itemTarget && m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = roll_chance_i(50) @@ -1008,7 +1008,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) DEBUG_LOG("Gameobject, create custom in SpellEffects.cpp EffectDummy"); // Expect created without owner, but with level from _template - pGameObj->SetRespawnTime(MINUTE/2); + pGameObj->SetRespawnTime(MINUTE / 2); pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, pGameObj->GetGOInfo()->trap.level); pGameObj->SetSpellId(m_spellInfo->Id); @@ -1060,7 +1060,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; } - pGameObj->SetRespawnTime(creatureTarget->GetRespawnTime()-time(NULL)); + pGameObj->SetRespawnTime(creatureTarget->GetRespawnTime() - time(NULL)); pGameObj->SetOwnerGuid(m_caster->GetObjectGuid()); pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); pGameObj->SetSpellId(m_spellInfo->Id); @@ -1148,7 +1148,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) { uint32 spell_id = 0; - switch (urand(1,4)) + switch (urand(1, 4)) { case 1: spell_id = 24924; break; // Larger and Orange case 2: spell_id = 24925; break; // Skeleton @@ -1229,13 +1229,13 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) ? 29277 // Summon Purified Helboar Meat : 29278; // Summon Toxic Helboar Meat - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 29858: // Soulshatter { if (unitTarget && unitTarget->GetTypeId() == TYPEID_UNIT && unitTarget->IsHostileTo(m_caster)) - m_caster->CastSpell(unitTarget,32835,true); + m_caster->CastSpell(unitTarget, 32835, true); return; } @@ -1282,12 +1282,12 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } case 33060: // Make a Wish { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; - switch (urand(1,5)) + switch (urand(1, 5)) { case 1: spell_id = 33053; break; // Mr Pinchy's Blessing case 2: spell_id = 33057; break; // Summon Mighty Mr. Pinchy @@ -1383,7 +1383,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; uint32 spell_id = 0; - switch (urand(1,4)) + switch (urand(1, 4)) { case 1: spell_id = 40957; break; // Blade's Edge Terrace Demon Boss Summon 1 case 2: spell_id = 40959; break; // Blade's Edge Terrace Demon Boss Summon 2 @@ -1481,7 +1481,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Cast Siphon Soul channeling spell if (!possibleTargets.empty()) - m_caster->CastSpell(possibleTargets[urand(0, possibleTargets.size()-1)], 43501, false); + m_caster->CastSpell(possibleTargets[urand(0, possibleTargets.size() - 1)], 43501, false); return; } @@ -1579,7 +1579,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } case 45449: // Arcane Prisoner Rescue { - uint32 spellId=0; + uint32 spellId = 0; switch (rand() % 2) { case 0: spellId = 45446; break; // Summon Arcane Prisoner - Male @@ -1615,7 +1615,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) if (pGo && !pGo->isSpawned()) { - pGo->SetRespawnTime(MINUTE/2); + pGo->SetRespawnTime(MINUTE / 2); pGo->Refresh(); } @@ -1631,7 +1631,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) { if (!(*iter)->isSpawned()) { - (*iter)->SetRespawnTime(MINUTE/2); + (*iter)->SetRespawnTime(MINUTE / 2); (*iter)->Refresh(); } } @@ -1761,7 +1761,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) if (pGo && !pGo->isSpawned()) { - pGo->SetRespawnTime(MINUTE/2); + pGo->SetRespawnTime(MINUTE / 2); pGo->Refresh(); } @@ -2155,7 +2155,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) else { // ...drop banana, orange or papaya - switch (urand(0,2)) + switch (urand(0, 2)) { case 0: unitTarget->CastSpell(m_caster, 51836, true); break; case 1: unitTarget->CastSpell(m_caster, 51837, true); break; @@ -2187,10 +2187,10 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) Creature* pTargetDummy = NULL; float fRange = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); - MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, 28523, true, false, fRange*2); + MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster, 28523, true, false, fRange * 2); MaNGOS::CreatureLastSearcher searcher(pTargetDummy, u_check); - Cell::VisitGridObjects(m_caster, searcher, fRange*2); + Cell::VisitGridObjects(m_caster, searcher, fRange * 2); if (pTargetDummy) { @@ -2287,7 +2287,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) { if (!(*iter)->isSpawned()) { - (*iter)->SetRespawnTime(MINUTE/2); + (*iter)->SetRespawnTime(MINUTE / 2); (*iter)->Refresh(); } } @@ -2439,7 +2439,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case 55818: // Hurl Boulder { // unclear how many summon min/max random, best guess below - uint32 random = urand(3,5); + uint32 random = urand(3, 5); for (uint32 i = 0; i < random; ++i) m_caster->CastSpell(m_caster, 55528, true); @@ -2472,14 +2472,14 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; uint32 spell_id = 0; - switch (urand(1,3)) + switch (urand(1, 3)) { case 1: spell_id = 59645; break; case 2: spell_id = 59831; break; case 3: spell_id = 59843; break; } - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 60932: // Disengage (one from creature versions) @@ -2487,7 +2487,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) if (!unitTarget) return; - m_caster->CastSpell(unitTarget,60934,true,NULL); + m_caster->CastSpell(unitTarget, 60934, true, NULL); return; } case 62105: // To'kini's Blowgun @@ -2509,7 +2509,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } case 64385: // Spinning (from Unusual Compass) { - m_caster->SetFacingTo(frand(0, M_PI_F*2)); + m_caster->SetFacingTo(frand(0, M_PI_F * 2)); return; } case 64981: // Summon Random Vanquished Tentacle @@ -2641,7 +2641,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) { case 11958: // Cold Snap { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; // immediately finishes the cooldown on Frost spells @@ -2701,7 +2701,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Conjure Mana Gem if (eff_idx == EFFECT_INDEX_1 && m_spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_ITEM) { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; // checked in create item check, avoid unexpected @@ -2739,10 +2739,10 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) uint32 rage_modified = rage; if (Aura* aura = m_caster->GetDummyAura(58367)) - rage_modified += aura->GetModifier()->m_amount*10; + rage_modified += aura->GetModifier()->m_amount * 10; - int32 basePoints0 = damage+int32(rage_modified * m_spellInfo->DmgMultiplier[eff_idx] + - m_caster->GetTotalAttackPowerValue(BASE_ATTACK)*0.2f); + int32 basePoints0 = damage + int32(rage_modified * m_spellInfo->DmgMultiplier[eff_idx] + + m_caster->GetTotalAttackPowerValue(BASE_ATTACK) * 0.2f); m_caster->CastCustomSpell(unitTarget, 20647, &basePoints0, NULL, NULL, true, 0); @@ -2756,7 +2756,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) if ((*itr)->GetSpellProto()->SpellIconID == 1989) { // saved rage top stored in next affect - uint32 lastrage = (*itr)->GetSpellProto()->CalculateSimpleValue(EFFECT_INDEX_1)*10; + uint32 lastrage = (*itr)->GetSpellProto()->CalculateSimpleValue(EFFECT_INDEX_1) * 10; if (lastrage < rage) rage -= lastrage; break; @@ -2764,7 +2764,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } } - m_caster->SetPower(POWER_RAGE,m_caster->GetPower(POWER_RAGE)-rage); + m_caster->SetPower(POWER_RAGE, m_caster->GetPower(POWER_RAGE) - rage); return; } // Slam @@ -2774,13 +2774,13 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) return; // dummy cast itself ignored by client in logs - m_caster->CastCustomSpell(unitTarget,50782,&damage,NULL,NULL,true); + m_caster->CastCustomSpell(unitTarget, 50782, &damage, NULL, NULL, true); return; } // Concussion Blow if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) { - m_damage+= uint32(damage * m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); + m_damage += uint32(damage * m_caster->GetTotalAttackPowerValue(BASE_ATTACK) / 100); return; } @@ -2797,7 +2797,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Last Stand case 12975: { - int32 healthModSpellBasePoints0 = int32(m_caster->GetMaxHealth()*0.3); + int32 healthModSpellBasePoints0 = int32(m_caster->GetMaxHealth() * 0.3); m_caster->CastCustomSpell(m_caster, 12976, &healthModSpellBasePoints0, NULL, NULL, true, NULL); return; } @@ -2826,8 +2826,8 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Improved Life Tap mod Unit::AuraList const& auraDummy = m_caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = auraDummy.begin(); itr != auraDummy.end(); ++itr) - if ((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (*itr)->GetSpellProto()->SpellIconID == 208) - mana = ((*itr)->GetModifier()->m_amount + 100)* mana / 100; + if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (*itr)->GetSpellProto()->SpellIconID == 208) + mana = ((*itr)->GetModifier()->m_amount + 100) * mana / 100; m_caster->CastCustomSpell(unitTarget, 31818, &mana, NULL, NULL, true); @@ -2836,8 +2836,8 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) Unit::AuraList const& mod = m_caster->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER); for (Unit::AuraList::const_iterator itr = mod.begin(); itr != mod.end(); ++itr) { - if ((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_WARLOCK && (*itr)->GetSpellProto()->SpellIconID == 1982) - manaFeedVal+= (*itr)->GetModifier()->m_amount; + if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && (*itr)->GetSpellProto()->SpellIconID == 1982) + manaFeedVal += (*itr)->GetModifier()->m_amount; } if (manaFeedVal > 0) { @@ -2910,7 +2910,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case 53197: m_caster->CastSpell(unitTarget, 53194, true); return; case 53198: m_caster->CastSpell(unitTarget, 53195, true); return; default: - sLog.outError("Spell::EffectDummy: Unhandeled Starfall spell rank %u",m_spellInfo->Id); + sLog.outError("Spell::EffectDummy: Unhandeled Starfall spell rank %u", m_spellInfo->Id); return; } } @@ -2942,7 +2942,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) for (int s = 0; s < 3; ++s) { - if (pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) + if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) continue; SpellEntry const* combatEntry = sSpellStore.LookupEntry(pEnchant->spellid[s]); @@ -2957,7 +2957,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } case 14185: // Preparation { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; //immediately finishes the cooldown on certain Rogue abilities @@ -2967,7 +2967,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (spellInfo->SpellFamilyFlags & UI64LIT(0x0000024000000860))) - ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first,true); + ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first, true); else ++itr; } @@ -3001,7 +3001,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) Unit::AuraList const& decSpeedList = unitTarget->GetAurasByType(SPELL_AURA_MOD_DECREASE_SPEED); for (Unit::AuraList::const_iterator iter = decSpeedList.begin(); iter != decSpeedList.end(); ++iter) { - if ((*iter)->GetSpellProto()->SpellIconID==15 && (*iter)->GetSpellProto()->Dispel==0) + if ((*iter)->GetSpellProto()->SpellIconID == 15 && (*iter)->GetSpellProto()->Dispel == 0) { found = true; break; @@ -3009,7 +3009,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } if (found) - m_damage+= damage; + m_damage += damage; return; } @@ -3023,19 +3023,19 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case 57635: spellid = 57636; break; // one from creature cases case 61507: spellid = 61508; break; // one from creature cases default: - sLog.outError("Spell %u not handled propertly in EffectDummy(Disengage)",m_spellInfo->Id); + sLog.outError("Spell %u not handled propertly in EffectDummy(Disengage)", m_spellInfo->Id); return; } if (!target || !target->isAlive()) return; - m_caster->CastSpell(target,spellid,true,NULL); + m_caster->CastSpell(target, spellid, true, NULL); } switch (m_spellInfo->Id) { case 23989: // Readiness talent { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; //immediately finishes the cooldown for hunter abilities @@ -3045,7 +3045,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first); if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->Id != 23989 && GetSpellRecoveryTime(spellInfo) > 0) - ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first,true); + ((Player*)m_caster)->RemoveSpellCooldown((itr++)->first, true); else ++itr; } @@ -3053,7 +3053,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) } case 37506: // Scatter Shot { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; // break Auto Shot and autohit @@ -3106,7 +3106,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case 48824: hurt = 48822; heal = 48820; break; case 48825: hurt = 48823; heal = 48821; break; default: - sLog.outError("Spell::EffectDummy: Spell %u not handled in HS",m_spellInfo->Id); + sLog.outError("Spell::EffectDummy: Spell %u not handled in HS", m_spellInfo->Id); return; } @@ -3154,7 +3154,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // non-standard cast requirement check if (!friendTarget || friendTarget->getAttackers().empty()) { - ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true); + ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id, true); SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT); return; } @@ -3162,13 +3162,13 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Righteous Defense (step 2) (in old version 31980 dummy effect) // Clear targets for eff 1 for (TargetList::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - ihit->effectMask &= ~(1<<1); + ihit->effectMask &= ~(1 << 1); // not empty (checked), copy Unit::AttackerSet attackers = friendTarget->getAttackers(); // selected from list 3 - for (uint32 i = 0; i < std::min(size_t(3),attackers.size()); ++i) + for (uint32 i = 0; i < std::min(size_t(3), attackers.size()); ++i) { Unit::AttackerSet::iterator aItr = attackers.begin(); std::advance(aItr, rand() % attackers.size()); @@ -3203,7 +3203,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) case SPELLFAMILY_SHAMAN: { // Cleansing Totem - if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) && m_spellInfo->SpellIconID==1673) + if ((m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000004000000)) && m_spellInfo->SpellIconID == 1673) { if (unitTarget) m_caster->CastSpell(unitTarget, 52025, true); @@ -3241,7 +3241,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Mana Spring Totem if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000000004000)) { - if (!unitTarget || unitTarget->getPowerType()!=POWER_MANA) + if (!unitTarget || unitTarget->getPowerType() != POWER_MANA) return; m_caster->CastCustomSpell(unitTarget, 52032, &damage, 0, 0, true, 0, 0, m_originalCasterGUID); return; @@ -3257,7 +3257,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // found spelldamage coefficients of 0.381% per 0.1 speed and 15.244 per 4.0 speed // but own calculation say 0.385 gives at most one point difference to published values int32 spellDamage = m_caster->SpellBaseDamageBonusDone(GetSpellSchoolMask(m_spellInfo)); - float weaponSpeed = (1.0f/IN_MILLISECONDS) * m_CastItem->GetProto()->Delay; + float weaponSpeed = (1.0f / IN_MILLISECONDS) * m_CastItem->GetProto()->Delay; int32 totalDamage = int32((damage + 3.85f * spellDamage) * 0.01 * weaponSpeed); m_caster->CastCustomSpell(unitTarget, 10444, &totalDamage, NULL, NULL, true, m_CastItem); @@ -3271,7 +3271,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Glyph of Mana Tide if (Unit* owner = m_caster->GetOwner()) if (Aura* dummy = owner->GetDummyAura(55441)) - damage+=dummy->GetModifier()->m_amount; + damage += dummy->GetModifier()->m_amount; // Regenerate 6% of Total Mana Every 3 secs int32 EffectBasePoints0 = unitTarget->GetMaxPower(POWER_MANA) * damage / 100; m_caster->CastCustomSpell(unitTarget, 39609, &EffectBasePoints0, NULL, NULL, true, NULL, NULL, m_originalCasterGUID); @@ -3280,7 +3280,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) // Lava Lash if (m_spellInfo->IsFitToFamilyMask(UI64LIT(0x0000000000000000), 0x00000004)) { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Item* item = ((Player*)m_caster)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); if (item) @@ -3289,7 +3289,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) Unit::AuraList const& auraDummy = m_caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator itr = auraDummy.begin(); itr != auraDummy.end(); ++itr) { - if ((*itr)->GetSpellProto()->SpellFamilyName==SPELLFAMILY_SHAMAN && + if ((*itr)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && ((*itr)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000000200000)) && (*itr)->GetCastItemGuid() == item->GetObjectGuid()) { @@ -3362,7 +3362,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) { uint32 count = 0; Unit::SpellAuraHolderMap const& auras = unitTarget->GetSpellAuraHolderMap(); - for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE && itr->second->GetCasterGuid() == m_caster->GetObjectGuid()) @@ -3451,12 +3451,12 @@ void Spell::EffectTriggerSpellWithValue(SpellEffectIndex eff_idx) if (!spellInfo) { - sLog.outError("EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); + sLog.outError("EffectTriggerSpellWithValue of spell %u: triggering unknown spell id %i", m_spellInfo->Id, triggered_spell_id); return; } int32 bp = damage; - m_caster->CastCustomSpell(unitTarget,triggered_spell_id,&bp,&bp,&bp,true,NULL,NULL,m_originalCasterGUID); + m_caster->CastCustomSpell(unitTarget, triggered_spell_id, &bp, &bp, &bp, true, NULL, NULL, m_originalCasterGUID); } void Spell::EffectTriggerRitualOfSummoning(SpellEffectIndex eff_idx) @@ -3466,13 +3466,13 @@ void Spell::EffectTriggerRitualOfSummoning(SpellEffectIndex eff_idx) if (!spellInfo) { - sLog.outError("EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", m_spellInfo->Id,triggered_spell_id); + sLog.outError("EffectTriggerRitualOfSummoning of spell %u: triggering unknown spell id %i", m_spellInfo->Id, triggered_spell_id); return; } finish(); - m_caster->CastSpell(unitTarget,spellInfo,false); + m_caster->CastSpell(unitTarget, spellInfo, false); } void Spell::EffectClearQuest(SpellEffectIndex eff_idx) @@ -3532,7 +3532,7 @@ void Spell::EffectTriggerSpell(SpellEffectIndex effIndex) if (!unitTarget) { if (gameObjTarget || itemTarget) - sLog.outError("Spell::EffectTriggerSpell (Spell: %u): Unsupported non-unit case!",m_spellInfo->Id); + sLog.outError("Spell::EffectTriggerSpell (Spell: %u): Unsupported non-unit case!", m_spellInfo->Id); return; } @@ -3639,7 +3639,7 @@ void Spell::EffectTriggerSpell(SpellEffectIndex effIndex) Unit* caster = m_caster; // some triggered spells require specific equipment - if (spellInfo->EquippedItemClass >=0 && m_caster->GetTypeId()==TYPEID_PLAYER) + if (spellInfo->EquippedItemClass >= 0 && m_caster->GetTypeId() == TYPEID_PLAYER) { // main hand weapon required if (spellInfo->HasAttribute(SPELL_ATTR_EX3_MAIN_HAND)) @@ -3676,7 +3676,7 @@ void Spell::EffectTriggerSpell(SpellEffectIndex effIndex) caster = IsSpellWithCasterSourceTargetsOnly(spellInfo) ? unitTarget : m_caster; } - caster->CastSpell(unitTarget,spellInfo,true,NULL,NULL,m_originalCasterGUID); + caster->CastSpell(unitTarget, spellInfo, true, NULL, NULL, m_originalCasterGUID); } void Spell::EffectTriggerMissileSpell(SpellEffectIndex effect_idx) @@ -3689,7 +3689,7 @@ void Spell::EffectTriggerMissileSpell(SpellEffectIndex effect_idx) if (!spellInfo) { sLog.outError("EffectTriggerMissileSpell of spell %u (eff: %u): triggering unknown spell id %u", - m_spellInfo->Id,effect_idx,triggered_spell_id); + m_spellInfo->Id, effect_idx, triggered_spell_id); return; } @@ -3705,7 +3705,7 @@ void Spell::EffectJump(SpellEffectIndex eff_idx) return; // Init dest coordinates - float x,y,z,o; + float x, y, z, o; if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) { x = m_targets.m_destX; @@ -3717,7 +3717,7 @@ void Spell::EffectJump(SpellEffectIndex eff_idx) // explicit cast data from client or server-side cast // some spell at client send caster Unit* pTarget = NULL; - if (m_targets.getUnitTarget() && m_targets.getUnitTarget()!=m_caster) + if (m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster) pTarget = m_targets.getUnitTarget(); else if (unitTarget->getVictim()) pTarget = m_caster->getVictim(); @@ -3731,12 +3731,12 @@ void Spell::EffectJump(SpellEffectIndex eff_idx) } else if (unitTarget) { - unitTarget->GetContactPoint(m_caster,x,y,z,CONTACT_DISTANCE); + unitTarget->GetContactPoint(m_caster, x, y, z, CONTACT_DISTANCE); o = m_caster->GetOrientation(); } else if (gameObjTarget) { - gameObjTarget->GetContactPoint(m_caster,x,y,z,CONTACT_DISTANCE); + gameObjTarget->GetContactPoint(m_caster, x, y, z, CONTACT_DISTANCE); o = m_caster->GetOrientation(); } else @@ -3766,7 +3766,7 @@ void Spell::EffectTeleportUnits(SpellEffectIndex eff_idx) if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; - ((Player*)unitTarget)->TeleportToHomebind(unitTarget==m_caster ? TELE_TO_SPELL : 0); + ((Player*)unitTarget)->TeleportToHomebind(unitTarget == m_caster ? TELE_TO_SPELL : 0); return; } case TARGET_AREAEFFECT_INSTANT: // in all cases first TARGET_TABLE_X_Y_Z_COORDINATES @@ -3779,10 +3779,10 @@ void Spell::EffectTeleportUnits(SpellEffectIndex eff_idx) return; } - if (st->target_mapId==unitTarget->GetMapId()) - unitTarget->NearTeleportTo(st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster); - else if (unitTarget->GetTypeId()==TYPEID_PLAYER) - ((Player*)unitTarget)->TeleportTo(st->target_mapId,st->target_X,st->target_Y,st->target_Z,st->target_Orientation,unitTarget==m_caster ? TELE_TO_SPELL : 0); + if (st->target_mapId == unitTarget->GetMapId()) + unitTarget->NearTeleportTo(st->target_X, st->target_Y, st->target_Z, st->target_Orientation, unitTarget == m_caster); + else if (unitTarget->GetTypeId() == TYPEID_PLAYER) + ((Player*)unitTarget)->TeleportTo(st->target_mapId, st->target_X, st->target_Y, st->target_Z, st->target_Orientation, unitTarget == m_caster ? TELE_TO_SPELL : 0); break; } case TARGET_EFFECT_SELECT: @@ -3803,7 +3803,7 @@ void Spell::EffectTeleportUnits(SpellEffectIndex eff_idx) // explicit cast data from client or server-side cast // some spell at client send caster - if (m_targets.getUnitTarget() && m_targets.getUnitTarget()!=unitTarget) + if (m_targets.getUnitTarget() && m_targets.getUnitTarget() != unitTarget) pTarget = m_targets.getUnitTarget(); else if (unitTarget->getVictim()) pTarget = unitTarget->getVictim(); @@ -3815,7 +3815,7 @@ void Spell::EffectTeleportUnits(SpellEffectIndex eff_idx) float y = m_targets.m_destY; float z = m_targets.m_destZ; float orientation = pTarget ? pTarget->GetOrientation() : unitTarget->GetOrientation(); - unitTarget->NearTeleportTo(x,y,z,orientation,unitTarget==m_caster); + unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster); return; } default: @@ -3832,7 +3832,7 @@ void Spell::EffectTeleportUnits(SpellEffectIndex eff_idx) float z = m_targets.m_destZ; float orientation = unitTarget->GetOrientation(); // Teleport - unitTarget->NearTeleportTo(x,y,z,orientation,unitTarget==m_caster); + unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster); return; } } @@ -3993,8 +3993,8 @@ void Spell::EffectPowerDrain(SpellEffectIndex eff_idx) uint32 curPower = unitTarget->GetPower(drain_power); //add spell damage bonus - damage = m_caster->SpellDamageBonusDone(unitTarget,m_spellInfo,uint32(damage),SPELL_DIRECT_DAMAGE); - damage = unitTarget->SpellDamageBonusTaken(m_caster, m_spellInfo, uint32(damage),SPELL_DIRECT_DAMAGE); + damage = m_caster->SpellDamageBonusDone(unitTarget, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE); + damage = unitTarget->SpellDamageBonusTaken(m_caster, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE); // resilience reduce mana draining effect at spell crit damage reduction (added in 2.4) uint32 power = damage; @@ -4007,13 +4007,13 @@ void Spell::EffectPowerDrain(SpellEffectIndex eff_idx) else new_damage = power; - unitTarget->ModifyPower(drain_power,-new_damage); + unitTarget->ModifyPower(drain_power, -new_damage); // Don`t restore from self drain if (drain_power == POWER_MANA && m_caster != unitTarget) { float manaMultiplier = m_spellInfo->EffectMultipleValue[eff_idx]; - if (manaMultiplier==0) + if (manaMultiplier == 0) manaMultiplier = 1; if (Player* modOwner = m_caster->GetSpellModOwner()) @@ -4047,7 +4047,7 @@ void Spell::EffectPowerBurn(SpellEffectIndex eff_idx) return; if (!unitTarget->isAlive()) return; - if (unitTarget->getPowerType()!=powertype) + if (unitTarget->getPowerType() != powertype) return; if (damage < 0) return; @@ -4108,14 +4108,14 @@ void Spell::EffectHeal(SpellEffectIndex /*eff_idx*/) Unit::AuraList const& mDummyAuras = m_caster->GetAurasByType(SPELL_AURA_DUMMY); for (Unit::AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) if ((*i)->GetId() == 45062) - damageAmount+=(*i)->GetModifier()->m_amount; + damageAmount += (*i)->GetModifier()->m_amount; if (damageAmount) m_caster->RemoveAurasDueToSpell(45062); addhealth += damageAmount; } // Death Pact (percent heal) - else if (m_spellInfo->Id==48743) + else if (m_spellInfo->Id == 48743) addhealth = addhealth * unitTarget->GetMaxHealth() / 100; // Swiftmend - consumes Regrowth or Rejuvenation else if (m_spellInfo->TargetAuraState == AURA_STATE_SWIFTMEND && unitTarget->HasAuraState(AURA_STATE_SWIFTMEND)) @@ -4173,7 +4173,7 @@ void Spell::EffectHeal(SpellEffectIndex /*eff_idx*/) Aura* riptide = unitTarget->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_SHAMAN, UI64LIT(0x0), 0x00000010, caster->GetObjectGuid()); if (riptide) { - addhealth += addhealth/4; + addhealth += addhealth / 4; unitTarget->RemoveAurasDueToSpell(riptide->GetId()); } } @@ -4250,7 +4250,7 @@ void Spell::EffectHealthLeech(SpellEffectIndex eff_idx) if (Player* modOwner = m_caster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MULTIPLE_VALUE, multiplier); - int32 heal = int32(damage*multiplier); + int32 heal = int32(damage * multiplier); if (m_caster->isAlive()) { heal = m_caster->SpellHealingBonusTaken(m_caster, m_spellInfo, heal, HEAL); @@ -4297,16 +4297,16 @@ void Spell::DoCreateItem(SpellEffectIndex eff_idx, uint32 itemtype) num_to_add = pProto->GetMaxStackSize(); // init items_count to 1, since 1 item will be created regardless of specialization - int items_count=1; + int items_count = 1; // the chance to create additional items - float additionalCreateChance=0.0f; + float additionalCreateChance = 0.0f; // the maximum number of created additional items - uint8 additionalMaxNum=0; + uint8 additionalMaxNum = 0; // get the chance and maximum number for creating extra items if (canCreateExtraItems(player, m_spellInfo->Id, additionalCreateChance, additionalMaxNum)) { // roll with this chance till we roll not to create or we create the max num - while (roll_chance_f(additionalCreateChance) && items_count<=additionalMaxNum) + while (roll_chance_f(additionalCreateChance) && items_count <= additionalMaxNum) ++items_count; } @@ -4361,12 +4361,12 @@ void Spell::DoCreateItem(SpellEffectIndex eff_idx, uint32 itemtype) void Spell::EffectCreateItem(SpellEffectIndex eff_idx) { - DoCreateItem(eff_idx,m_spellInfo->EffectItemType[eff_idx]); + DoCreateItem(eff_idx, m_spellInfo->EffectItemType[eff_idx]); } void Spell::EffectCreateItem2(SpellEffectIndex eff_idx) { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player* player = (Player*)m_caster; @@ -4396,7 +4396,7 @@ void Spell::EffectCreateItem2(SpellEffectIndex eff_idx) void Spell::EffectCreateRandomItem(SpellEffectIndex /*eff_idx*/) { - if (m_caster->GetTypeId()!=TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player* player = (Player*)m_caster; @@ -4526,8 +4526,8 @@ void Spell::EffectEnergize(SpellEffectIndex eff_idx) if (!elixirs.empty()) { // cast random elixir on target - uint32 rand_spell = urand(0,elixirs.size()-1); - m_caster->CastSpell(unitTarget,elixirs[rand_spell],true,m_CastItem); + uint32 rand_spell = urand(0, elixirs.size() - 1); + m_caster->CastSpell(unitTarget, elixirs[rand_spell], true, m_CastItem); } } } @@ -4809,7 +4809,7 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx) } else // Get a point near the caster { - m_caster->GetClosePoint(itr->x, itr->y, itr->z, 0.0f, radius, frand(0.0f, 2*M_PI_F)); + m_caster->GetClosePoint(itr->x, itr->y, itr->z, 0.0f, radius, frand(0.0f, 2 * M_PI_F)); if (m_caster->GetMap()->GetObjectHitPos(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, itr->x, itr->y, itr->z, itr->x, itr->y, itr->z, 0.5f)) m_caster->UpdateAllowedPositionZ(itr->x, itr->y, itr->z); } @@ -5145,7 +5145,7 @@ bool Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc) // FIXME: Setup near to finish point because GetObjectBoundingRadius set in Create but some Create calls can be dependent from proper position // if totem have creature_template_addon.auras with persistent point for example or script call - float angle = slot < MAX_TOTEM_SLOT ? M_PI_F/MAX_TOTEM_SLOT - (slot*2*M_PI_F/MAX_TOTEM_SLOT) : 0; + float angle = slot < MAX_TOTEM_SLOT ? M_PI_F / MAX_TOTEM_SLOT - (slot * 2 * M_PI_F / MAX_TOTEM_SLOT) : 0; CreatureCreatePos pos(m_caster, m_caster->GetOrientation(), 2.0f, angle); @@ -5167,7 +5167,7 @@ bool Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc) pTotem->SetSummonPoint(pos); if (slot < MAX_TOTEM_SLOT) - m_caster->_AddTotem(TotemSlot(slot),pTotem); + m_caster->_AddTotem(TotemSlot(slot), pTotem); //pTotem->SetName(""); // generated by client pTotem->SetOwner(m_caster); @@ -5285,7 +5285,7 @@ bool Spell::DoSummonPet(SpellEffectIndex eff_idx) uint32 level = m_caster->getLevel(); // TODO Engineering Pets have also caster-level? (if they exist) Pet* spawnCreature = new Pet(SUMMON_PET); - if (m_caster->GetTypeId()==TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster, pet_entry)) + if (m_caster->GetTypeId() == TYPEID_PLAYER && spawnCreature->LoadPetFromDB((Player*)m_caster, pet_entry)) { // Summon in dest location if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) @@ -5375,7 +5375,7 @@ void Spell::EffectLearnSpell(SpellEffectIndex eff_idx) Player* player = (Player*)unitTarget; - uint32 spellToLearn = ((m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) || (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN_PET)) ? damage : m_spellInfo->EffectTriggerSpell[eff_idx]; + uint32 spellToLearn = ((m_spellInfo->Id == SPELL_ID_GENERIC_LEARN) || (m_spellInfo->Id == SPELL_ID_GENERIC_LEARN_PET)) ? damage : m_spellInfo->EffectTriggerSpell[eff_idx]; player->learnSpell(spellToLearn, false); DEBUG_LOG("Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow()); @@ -5387,7 +5387,7 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) return; // Fill possible dispel list - std::list > dispel_list; + std::list > dispel_list; // Create dispel mask by dispel type uint32 dispel_type = m_spellInfo->EffectMiscValue[eff_idx]; @@ -5396,7 +5396,7 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { SpellAuraHolder* holder = itr->second; - if ((1<GetSpellProto()->Dispel) & dispelMask) + if ((1 << holder->GetSpellProto()->Dispel) & dispelMask) { if (holder->GetSpellProto()->Dispel == DISPEL_MAGIC) { @@ -5416,13 +5416,13 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) if (unitTarget->HasAura(50536)) continue; - dispel_list.push_back(std::pair(holder, holder->GetStackAmount())); + dispel_list.push_back(std::pair(holder, holder->GetStackAmount())); } } // Ok if exist some buffs for dispel try dispel it if (!dispel_list.empty()) { - std::list > success_list;// (spell_id,casterGuid) + std::list > success_list; // (spell_id,casterGuid) std::list < uint32 > fail_list; // spell_id // some spells have effect value = 0 and all from its by meaning expect 1 @@ -5430,11 +5430,11 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) damage = 1; // Dispel N = damage buffs (or while exist buffs for dispel) - for (int32 count=0; count < damage && !dispel_list.empty(); ++count) + for (int32 count = 0; count < damage && !dispel_list.empty(); ++count) { // Random select buff for dispel - std::list >::iterator dispel_itr = dispel_list.begin(); - std::advance(dispel_itr,urand(0, dispel_list.size()-1)); + std::list >::iterator dispel_itr = dispel_list.begin(); + std::advance(dispel_itr, urand(0, dispel_list.size() - 1)); SpellAuraHolder* holder = dispel_itr->first; @@ -5460,7 +5460,7 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) else { bool foundDispelled = false; - for (std::list >::iterator success_iter = success_list.begin(); success_iter != success_list.end(); ++success_iter) + for (std::list >::iterator success_iter = success_list.begin(); success_iter != success_list.end(); ++success_iter) { if (success_iter->first->GetId() == holder->GetId() && success_iter->first->GetCasterGuid() == holder->GetCasterGuid()) { @@ -5470,20 +5470,20 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) } } if (!foundDispelled) - success_list.push_back(std::pair(holder, 1)); + success_list.push_back(std::pair(holder, 1)); } } // Send success log and really remove auras if (!success_list.empty()) { int32 count = success_list.size(); - WorldPacket data(SMSG_SPELLDISPELLOG, 8+8+4+1+4+count*5); + WorldPacket data(SMSG_SPELLDISPELLOG, 8 + 8 + 4 + 1 + 4 + count * 5); data << unitTarget->GetPackGUID(); // Victim GUID data << m_caster->GetPackGUID(); // Caster GUID data << uint32(m_spellInfo->Id); // Dispel spell id data << uint8(0); // not used data << uint32(count); // count - for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) + for (std::list >::iterator j = success_list.begin(); j != success_list.end(); ++j) { SpellAuraHolder* dispelledHolder = j->first; data << uint32(dispelledHolder->GetId()); // Spell Id @@ -5504,7 +5504,7 @@ void Spell::EffectDispel(SpellEffectIndex eff_idx) if (!fail_list.empty()) { // Failed to dispel - WorldPacket data(SMSG_DISPEL_FAILED, 8+8+4+4*fail_list.size()); + WorldPacket data(SMSG_DISPEL_FAILED, 8 + 8 + 4 + 4 * fail_list.size()); data << m_caster->GetObjectGuid(); // Caster GUID data << unitTarget->GetObjectGuid(); // Victim GUID data << uint32(m_spellInfo->Id); // Dispel spell id @@ -5562,7 +5562,7 @@ void Spell::EffectPickPocket(SpellEffectIndex /*eff_idx*/) { // Stealing successful //DEBUG_LOG("Sending loot from pickpocket"); - ((Player*)m_caster)->SendLoot(unitTarget->GetObjectGuid(),LOOT_PICKPOCKETING); + ((Player*)m_caster)->SendLoot(unitTarget->GetObjectGuid(), LOOT_PICKPOCKETING); } else { @@ -5607,7 +5607,7 @@ void Spell::EffectTeleUnitsFaceCaster(SpellEffectIndex eff_idx) float fx, fy, fz; m_caster->GetClosePoint(fx, fy, fz, unitTarget->GetObjectBoundingRadius(), dis); - unitTarget->NearTeleportTo(fx, fy, fz, -m_caster->GetOrientation(), unitTarget==m_caster); + unitTarget->NearTeleportTo(fx, fy, fz, -m_caster->GetOrientation(), unitTarget == m_caster); } void Spell::EffectLearnSkill(SpellEffectIndex eff_idx) @@ -5632,7 +5632,7 @@ void Spell::EffectAddHonor(SpellEffectIndex /*eff_idx*/) if (m_CastItem) { ((Player*)unitTarget)->RewardHonor(NULL, 1, float(damage / 10)); - DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(),((Player*)unitTarget)->GetGUIDLow()); + DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage / 10, m_CastItem->GetEntry(), ((Player*)unitTarget)->GetGUIDLow()); return; } @@ -5688,7 +5688,7 @@ void Spell::EffectEnchantItemPerm(SpellEffectIndex eff_idx) if (targetProto->IsVellum() && m_spellInfo->EffectItemType[eff_idx]) { unitTarget = m_caster; - DoCreateItem(eff_idx,m_spellInfo->EffectItemType[eff_idx]); + DoCreateItem(eff_idx, m_spellInfo->EffectItemType[eff_idx]); // Vellum target case: Target becomes additional reagent, new scroll item created instead in Spell::EffectEnchantItemPerm() // cannot already delete in TakeReagents() unfortunately p_caster->DestroyItemCount(targetProto->ItemId, 1, true); @@ -5699,21 +5699,21 @@ void Spell::EffectEnchantItemPerm(SpellEffectIndex eff_idx) if (!(m_CastItem && m_CastItem->GetProto()->Flags & ITEM_FLAG_ENCHANT_SCROLL)) p_caster->UpdateCraftSkill(m_spellInfo->Id); - if (item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) + if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(),p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1,itemTarget->GetEntry(), - item_owner->GetName(),item_owner->GetSession()->GetAccountId()); + sLog.outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", + p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + itemTarget->GetProto()->Name1, itemTarget->GetEntry(), + item_owner->GetName(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped - item_owner->ApplyEnchantment(itemTarget,PERM_ENCHANTMENT_SLOT,false); + item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, false); itemTarget->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchant_id, 0, 0); // add new enchanting if equipped - item_owner->ApplyEnchantment(itemTarget,PERM_ENCHANTMENT_SLOT,true); + item_owner->ApplyEnchantment(itemTarget, PERM_ENCHANTMENT_SLOT, true); } void Spell::EffectEnchantItemPrismatic(SpellEffectIndex eff_idx) @@ -5738,7 +5738,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffectIndex eff_idx) bool add_socket = false; for (int i = 0; i < 3; ++i) { - if (pEnchant->type[i]==ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET) + if (pEnchant->type[i] == ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET) { add_socket = true; break; @@ -5747,7 +5747,7 @@ void Spell::EffectEnchantItemPrismatic(SpellEffectIndex eff_idx) if (!add_socket) { sLog.outError("Spell::EffectEnchantItemPrismatic: attempt apply enchant spell %u with SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC (%u) but without ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET (%u), not suppoted yet.", - m_spellInfo->Id,SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC,ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET); + m_spellInfo->Id, SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC, ITEM_ENCHANTMENT_TYPE_PRISMATIC_SOCKET); return; } } @@ -5757,21 +5757,21 @@ void Spell::EffectEnchantItemPrismatic(SpellEffectIndex eff_idx) if (!item_owner) return; - if (item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) + if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", - p_caster->GetName(),p_caster->GetSession()->GetAccountId(), - itemTarget->GetProto()->Name1,itemTarget->GetEntry(), - item_owner->GetName(),item_owner->GetSession()->GetAccountId()); + sLog.outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", + p_caster->GetName(), p_caster->GetSession()->GetAccountId(), + itemTarget->GetProto()->Name1, itemTarget->GetEntry(), + item_owner->GetName(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped - item_owner->ApplyEnchantment(itemTarget,PRISMATIC_ENCHANTMENT_SLOT,false); + item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, false); itemTarget->SetEnchantment(PRISMATIC_ENCHANTMENT_SLOT, enchant_id, 0, 0); // add new enchanting if equipped - item_owner->ApplyEnchantment(itemTarget,PRISMATIC_ENCHANTMENT_SLOT,true); + item_owner->ApplyEnchantment(itemTarget, PRISMATIC_ENCHANTMENT_SLOT, true); } void Spell::EffectEnchantItemTmp(SpellEffectIndex eff_idx) @@ -5804,7 +5804,7 @@ void Spell::EffectEnchantItemTmp(SpellEffectIndex eff_idx) case 10: spell_id = 36758; break; // 14% case 11: spell_id = 36760; break; // 20% default: - sLog.outError("Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW",damage); + sLog.outError("Spell::EffectEnchantItemTmp: Damage %u not handled in S'RW", damage); return; } @@ -5829,14 +5829,14 @@ void Spell::EffectEnchantItemTmp(SpellEffectIndex eff_idx) if (!enchant_id) { - sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id",m_spellInfo->Id,eff_idx); + sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have 0 as enchanting id", m_spellInfo->Id, eff_idx); return; } SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); if (!pEnchant) { - sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have nonexistent enchanting id %u ",m_spellInfo->Id,eff_idx,enchant_id); + sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have nonexistent enchanting id %u ", m_spellInfo->Id, eff_idx, enchant_id); return; } @@ -5874,16 +5874,16 @@ void Spell::EffectEnchantItemTmp(SpellEffectIndex eff_idx) if (!item_owner) return; - if (item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) + if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", + sLog.outCommand(p_caster->GetSession()->GetAccountId(), "GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(), p_caster->GetSession()->GetAccountId(), itemTarget->GetProto()->Name1, itemTarget->GetEntry(), item_owner->GetName(), item_owner->GetSession()->GetAccountId()); } // remove old enchanting before applying new if equipped - item_owner->ApplyEnchantment(itemTarget,TEMP_ENCHANTMENT_SLOT, false); + item_owner->ApplyEnchantment(itemTarget, TEMP_ENCHANTMENT_SLOT, false); itemTarget->SetEnchantment(TEMP_ENCHANTMENT_SLOT, enchant_id, duration * 1000, 0); @@ -5974,7 +5974,7 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx) if (OldSummon->isDead()) return; - OldSummon->GetMap()->Remove((Creature*)OldSummon,false); + OldSummon->GetMap()->Remove((Creature*)OldSummon, false); float px, py, pz; m_caster->GetClosePoint(px, py, pz, OldSummon->GetObjectBoundingRadius()); @@ -6126,7 +6126,7 @@ void Spell::EffectTaunt(SpellEffectIndex /*eff_idx*/) // for spell as marked "non effective at already attacking target" if (unitTarget->GetTypeId() != TYPEID_PLAYER) { - if (unitTarget->getVictim()==m_caster) + if (unitTarget->getVictim() == m_caster) { SendCastResult(SPELL_FAILED_DONT_REPORT); return; @@ -6135,7 +6135,7 @@ void Spell::EffectTaunt(SpellEffectIndex /*eff_idx*/) // Also use this effect to set the taunter's threat to the taunted creature's highest value if (unitTarget->CanHaveThreatList() && unitTarget->getThreatManager().getCurrentVictim()) - unitTarget->getThreatManager().addThreat(m_caster,unitTarget->getThreatManager().getCurrentVictim()->getThreat()); + unitTarget->getThreatManager().addThreat(m_caster, unitTarget->getThreatManager().getCurrentVictim()->getThreat()); } void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) @@ -6185,7 +6185,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) { uint32 count = 0; for (TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) - if (ihit->effectMask & (1<effectMask & (1 << eff_idx)) ++count; totalDamagePercentMod /= float(count); // divide to all targets @@ -6229,7 +6229,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) else { Unit::SpellAuraHolderMap const& auras = unitTarget->GetSpellAuraHolderMap(); - for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (itr->second->GetSpellProto()->Dispel == DISPEL_POISON) { @@ -6243,23 +6243,23 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) totalDamagePercentMod *= 1.2f; // 120% if poisoned } // Fan of Knives - else if (m_caster->GetTypeId()==TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0004000000000000))) + else if (m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0004000000000000))) { - Item* weapon = ((Player*)m_caster)->GetWeaponForAttack(m_attackType,true,true); + Item* weapon = ((Player*)m_caster)->GetWeaponForAttack(m_attackType, true, true); if (weapon && weapon->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) totalDamagePercentMod *= 1.5f; // 150% to daggers } // Ghostly Strike else if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->Id == 14278) { - Item* weapon = ((Player*)m_caster)->GetWeaponForAttack(m_attackType,true,true); + Item* weapon = ((Player*)m_caster)->GetWeaponForAttack(m_attackType, true, true); if (weapon && weapon->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) totalDamagePercentMod *= 1.44f; // 144% to daggers } // Hemorrhage else if (m_caster->GetTypeId() == TYPEID_PLAYER && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x2000000))) { - Item* weapon = ((Player*)m_caster)->GetWeaponForAttack(m_attackType,true,true); + Item* weapon = ((Player*)m_caster)->GetWeaponForAttack(m_attackType, true, true); if (weapon && weapon->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) totalDamagePercentMod *= 1.45f; // 145% to daggers } @@ -6317,7 +6317,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) { uint32 count = 0; Unit::SpellAuraHolderMap const& auras = unitTarget->GetSpellAuraHolderMap(); - for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE && itr->second->GetCasterGuid() == m_caster->GetObjectGuid()) @@ -6384,7 +6384,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) weaponDamagePercentMod *= float(CalculateDamage(SpellEffectIndex(j), unitTarget)) / 100.0f; // applied only to prev.effects fixed damage - fixed_bonus = int32(fixed_bonus*weaponDamagePercentMod); + fixed_bonus = int32(fixed_bonus * weaponDamagePercentMod); break; default: break; // not weapon damage effect, just skip @@ -6393,7 +6393,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) // apply weaponDamagePercentMod to spell bonus also if (spellBonusNeedWeaponDamagePercentMod) - spell_bonus = int32(spell_bonus*weaponDamagePercentMod); + spell_bonus = int32(spell_bonus * weaponDamagePercentMod); // non-weapon damage int32 bonus = spell_bonus + fixed_bonus; @@ -6411,28 +6411,28 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) } float weapon_total_pct = m_caster->GetModifierValue(unitMod, TOTAL_PCT); - bonus = int32(bonus*weapon_total_pct); + bonus = int32(bonus * weapon_total_pct); } // + weapon damage with applied weapon% dmg to base weapon damage in call - bonus += int32(m_caster->CalculateDamage(m_attackType, normalized)*weaponDamagePercentMod); + bonus += int32(m_caster->CalculateDamage(m_attackType, normalized) * weaponDamagePercentMod); // total damage - bonus = int32(bonus*totalDamagePercentMod); + bonus = int32(bonus * totalDamagePercentMod); // prevent negative damage - m_damage+= uint32(bonus > 0 ? bonus : 0); + m_damage += uint32(bonus > 0 ? bonus : 0); // Hemorrhage - if (m_spellInfo->SpellFamilyName==SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x2000000))) + if (m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x2000000))) { - if (m_caster->GetTypeId()==TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) ((Player*)m_caster)->AddComboPoints(unitTarget, 1); } // Mangle (Cat): CP else if (m_spellInfo->IsFitToFamily(SPELLFAMILY_DRUID, UI64LIT(0x0000040000000000))) { - if (m_caster->GetTypeId()==TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) ((Player*)m_caster)->AddComboPoints(unitTarget, 1); } @@ -6447,7 +6447,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) if (pItem->GetProto()->InventoryType == INVTYPE_THROWN) { - if (pItem->GetMaxStackCount()==1) + if (pItem->GetMaxStackCount() == 1) { // decrease durability for non-stackable throw weapon ((Player*)m_caster)->DurabilityPointLossForEquipSlot(EQUIPMENT_SLOT_RANGED); @@ -6505,7 +6505,7 @@ void Spell::EffectInterruptCast(SpellEffectIndex /*eff_idx*/) if ((curSpellInfo->InterruptFlags & SPELL_INTERRUPT_FLAG_INTERRUPT) && curSpellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE) { unitTarget->ProhibitSpellSchool(GetSpellSchoolMask(curSpellInfo), GetSpellDuration(m_spellInfo)); - unitTarget->InterruptSpell(CurrentSpellTypes(i),false); + unitTarget->InterruptSpell(CurrentSpellTypes(i), false); } } } @@ -6540,7 +6540,7 @@ void Spell::EffectSummonObjectWild(SpellEffectIndex eff_idx) return; } - pGameObj->SetRespawnTime(m_duration > 0 ? m_duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(m_duration > 0 ? m_duration / IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); // Wild object not have owner and check clickable by players @@ -6558,7 +6558,7 @@ void Spell::EffectSummonObjectWild(SpellEffectIndex eff_idx) { case 489: //WS { - if (bg && bg->GetTypeID()==BATTLEGROUND_WS && bg->GetStatus() == STATUS_IN_PROGRESS) + if (bg && bg->GetTypeID() == BATTLEGROUND_WS && bg->GetStatus() == STATUS_IN_PROGRESS) { Team team = pl->GetTeam() == ALLIANCE ? HORDE : ALLIANCE; @@ -6568,7 +6568,7 @@ void Spell::EffectSummonObjectWild(SpellEffectIndex eff_idx) } case 566: //EY { - if (bg && bg->GetTypeID()==BATTLEGROUND_EY && bg->GetStatus() == STATUS_IN_PROGRESS) + if (bg && bg->GetTypeID() == BATTLEGROUND_EY && bg->GetStatus() == STATUS_IN_PROGRESS) { ((BattleGroundEY*)bg)->SetDroppedFlagGuid(pGameObj->GetObjectGuid()); } @@ -6597,7 +6597,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) { case 8856: // Bending Shinbone { - if (!itemTarget && m_caster->GetTypeId()!=TYPEID_PLAYER) + if (!itemTarget && m_caster->GetTypeId() != TYPEID_PLAYER) return; uint32 spell_id = 0; @@ -6607,7 +6607,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) default: spell_id = 8855; break; } - m_caster->CastSpell(m_caster,spell_id,true,NULL); + m_caster->CastSpell(m_caster, spell_id, true, NULL); return; } case 17512: // Piccolo of the Flaming Fire @@ -6820,7 +6820,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) return; } - unitTarget->CastSpell(unitTarget,spellid,false); + unitTarget->CastSpell(unitTarget, spellid, false); return; } case 26004: // Mistletoe @@ -6851,7 +6851,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) return; // cast - unitTarget->CastSpell(unitTarget, spells[urand(0,3)], true); + unitTarget->CastSpell(unitTarget, spells[urand(0, 3)], true); return; } case 26465: // Mercurial Shield - need remove one 26464 Mercurial Shield aura @@ -6884,8 +6884,8 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) float angle = unitTarget->GetOrientation(); for (uint8 i = 0; i < 4; ++i) { - unitTarget->GetNearPoint(unitTarget, x, y, z, unitTarget->GetObjectBoundingRadius(), 5.0f, angle + i*M_PI_F/2); - unitTarget->SummonCreature(16119, x, y, z, angle, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10*MINUTE*IN_MILLISECONDS); + unitTarget->GetNearPoint(unitTarget, x, y, z, unitTarget->GetObjectBoundingRadius(), 5.0f, angle + i * M_PI_F / 2); + unitTarget->SummonCreature(16119, x, y, z, angle, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10 * MINUTE * IN_MILLISECONDS); } return; } @@ -6956,7 +6956,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) creature_id = 17039; if (WorldObject* pSource = GetAffectiveCasterObject()) - pSource->SummonCreature(creature_id, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120*IN_MILLISECONDS); + pSource->SummonCreature(creature_id, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 120 * IN_MILLISECONDS); return; } case 29830: // Mirren's Drinking Hat @@ -6976,7 +6976,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) } if (item) - DoCreateItem(eff_idx,item); + DoCreateItem(eff_idx, item); break; } @@ -6986,7 +6986,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) return; // Removes snares and roots. - unitTarget->RemoveAurasAtMechanicImmunity(IMMUNE_TO_ROOT_AND_SNARE_MASK,30918,true); + unitTarget->RemoveAurasAtMechanicImmunity(IMMUNE_TO_ROOT_AND_SNARE_MASK, 30918, true); break; } case 32301: // Ping Shirrak @@ -7006,7 +7006,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) float x, y, z; for (uint8 i = 0; i < 4; ++i) { - m_caster->GetNearPoint(m_caster, x, y, z, 0, 5.0f, M_PI_F*.5f*i + M_PI_F*.25f); + m_caster->GetNearPoint(m_caster, x, y, z, 0, 5.0f, M_PI_F * .5f * i + M_PI_F * .25f); m_caster->SummonCreature(21002, x, y, z, 0, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 30000); } return; @@ -7244,8 +7244,8 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) 45683 // Polymorph }; - m_caster->CastSpell(m_caster, spellPlayer[urand(0,4)], true); - unitTarget->CastSpell(unitTarget, spellTarget[urand(0,4)], true); + m_caster->CastSpell(m_caster, spellPlayer[urand(0, 4)], true); + unitTarget->CastSpell(unitTarget, spellTarget[urand(0, 4)], true); return; } @@ -7931,7 +7931,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) 62688, // Summon Wave - 10 Mob }; - m_caster->CastSpell(m_caster, randSpells[urand(0, countof(randSpells)-1)], true); + m_caster->CastSpell(m_caster, randSpells[urand(0, countof(randSpells) - 1)], true); return; } case 62688: // Summon Wave - 10 Mob @@ -8154,21 +8154,21 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) switch (m_spellInfo->Id) { case 6201: - itemtype=itypes[0][rank]; break; // Minor Healthstone + itemtype = itypes[0][rank]; break; // Minor Healthstone case 6202: - itemtype=itypes[1][rank]; break; // Lesser Healthstone + itemtype = itypes[1][rank]; break; // Lesser Healthstone case 5699: - itemtype=itypes[2][rank]; break; // Healthstone + itemtype = itypes[2][rank]; break; // Healthstone case 11729: - itemtype=itypes[3][rank]; break; // Greater Healthstone + itemtype = itypes[3][rank]; break; // Greater Healthstone case 11730: - itemtype=itypes[4][rank]; break; // Major Healthstone + itemtype = itypes[4][rank]; break; // Major Healthstone case 27230: - itemtype=itypes[5][rank]; break; // Master Healthstone + itemtype = itypes[5][rank]; break; // Master Healthstone case 47871: - itemtype=itypes[6][rank]; break; // Demonic Healthstone + itemtype = itypes[6][rank]; break; // Demonic Healthstone case 47878: - itemtype=itypes[7][rank]; break; // Fel Healthstone + itemtype = itypes[7][rank]; break; // Fel Healthstone default: return; } @@ -8381,7 +8381,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) case 57774: spellId1 = 20185; break; // Judgement of Light case 53408: spellId1 = 20186; break; // Judgement of Wisdom default: - sLog.outError("Unsupported Judgement (seal trigger) spell (Id: %u) in Spell::EffectScriptEffect",m_spellInfo->Id); + sLog.outError("Unsupported Judgement (seal trigger) spell (Id: %u) in Spell::EffectScriptEffect", m_spellInfo->Id); return; } @@ -8453,7 +8453,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx) if (unitTarget->HasAura(spellid + i, EFFECT_INDEX_0)) return; - unitTarget->CastSpell(unitTarget, spellid+urand(0, 4), true); + unitTarget->CastSpell(unitTarget, spellid + urand(0, 4), true); break; } case 28720: // Nightmare Vine @@ -8587,9 +8587,9 @@ void Spell::EffectDuel(SpellEffectIndex eff_idx) } pGameObj->SetUInt32Value(GAMEOBJECT_FACTION, m_caster->getFaction()); - pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()+1); + pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() + 1); - pGameObj->SetRespawnTime(m_duration > 0 ? m_duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(m_duration > 0 ? m_duration / IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); m_caster->AddGameObject(pGameObj); @@ -8639,7 +8639,7 @@ void Spell::EffectStuck(SpellEffectIndex /*eff_idx*/) return; // homebind location is loaded always - pTarget->TeleportToHomebind(unitTarget==m_caster ? TELE_TO_SPELL : 0); + pTarget->TeleportToHomebind(unitTarget == m_caster ? TELE_TO_SPELL : 0); // Stuck spell trigger Hearthstone cooldown SpellEntry const* spellInfo = sSpellStore.LookupEntry(8690); @@ -8661,12 +8661,12 @@ void Spell::EffectSummonPlayer(SpellEffectIndex /*eff_idx*/) float x, y, z; m_caster->GetClosePoint(x, y, z, unitTarget->GetObjectBoundingRadius()); - ((Player*)unitTarget)->SetSummonPoint(m_caster->GetMapId(),x,y,z); + ((Player*)unitTarget)->SetSummonPoint(m_caster->GetMapId(), x, y, z); - WorldPacket data(SMSG_SUMMON_REQUEST, 8+4+4); + WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); data << m_caster->GetObjectGuid(); // summoner guid data << uint32(m_caster->GetZoneId()); // summoner zone - data << uint32(MAX_PLAYER_SUMMON_DELAY*IN_MILLISECONDS); // auto decline after msecs + data << uint32(MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); // auto decline after msecs ((Player*)unitTarget)->GetSession()->SendPacket(&data); } @@ -8760,7 +8760,7 @@ void Spell::EffectEnchantHeldItem(SpellEffectIndex eff_idx) return; // Apply the temporary enchantment - item->SetEnchantment(slot, enchant_id, duration*IN_MILLISECONDS, 0); + item->SetEnchantment(slot, enchant_id, duration * IN_MILLISECONDS, 0); item_owner->ApplyEnchantment(item, slot, true); } } @@ -8776,7 +8776,7 @@ void Spell::EffectDisEnchant(SpellEffectIndex /*eff_idx*/) p_caster->UpdateCraftSkill(m_spellInfo->Id); - ((Player*)m_caster)->SendLoot(itemTarget->GetObjectGuid(),LOOT_DISENCHANTING); + ((Player*)m_caster)->SendLoot(itemTarget->GetObjectGuid(), LOOT_DISENCHANTING); // item will be removed at disenchanting end } @@ -8819,7 +8819,7 @@ void Spell::EffectFeedPet(SpellEffectIndex eff_idx) return; uint32 count = 1; - _player->DestroyItemCount(foodItem,count,true); + _player->DestroyItemCount(foodItem, count, true); // TODO: fix crash when a spell has two effects, both pointed at the same item target m_caster->CastCustomSpell(pet, m_spellInfo->EffectTriggerSpell[eff_idx], &benefit, NULL, NULL, true); @@ -8833,7 +8833,7 @@ void Spell::EffectDismissPet(SpellEffectIndex /*eff_idx*/) Pet* pet = m_caster->GetPet(); // not let dismiss dead pet - if (!pet||!pet->isAlive()) + if (!pet || !pet->isAlive()) return; pet->Unsummon(PET_SAVE_NOT_IN_SLOT, m_caster); @@ -8883,7 +8883,7 @@ void Spell::EffectSummonObject(SpellEffectIndex eff_idx) } pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel()); - pGameObj->SetRespawnTime(m_duration > 0 ? m_duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(m_duration > 0 ? m_duration / IN_MILLISECONDS : 0); pGameObj->SetSpellId(m_spellInfo->Id); m_caster->AddGameObject(pGameObj); @@ -8917,9 +8917,9 @@ void Spell::EffectResurrect(SpellEffectIndex /*eff_idx*/) uint32 failSpellId = 0; switch (m_spellInfo->Id) { - case 8342: failChance=67; failSpellId = 8338; break; - case 22999: failChance=50; failSpellId = 23055; break; - case 54732: failChance=33; failSpellId = 0; break; + case 8342: failChance = 67; failSpellId = 8338; break; + case 22999: failChance = 50; failSpellId = 23055; break; + case 54732: failChance = 33; failSpellId = 0; break; } if (roll_chance_i(failChance)) @@ -8984,7 +8984,7 @@ void Spell::EffectLeapForward(SpellEffectIndex eff_idx) float ox, oy, oz; unitTarget->GetPosition(ox, oy, oz); - if (unitTarget->GetMap()->GetObjectHitPos(ox,oy,oz+0.5f, fx,fy,oz+0.5f,fx,fy,fz, -0.5f)) + if (unitTarget->GetMap()->GetObjectHitPos(ox, oy, oz + 0.5f, fx, fy, oz + 0.5f, fx, fy, fz, -0.5f)) unitTarget->UpdateAllowedPositionZ(fx, fy, fz); unitTarget->NearTeleportTo(fx, fy, fz, unitTarget->GetOrientation(), unitTarget == m_caster); @@ -8996,7 +8996,7 @@ void Spell::EffectLeapBack(SpellEffectIndex eff_idx) if (unitTarget->IsTaxiFlying()) return; - m_caster->KnockBackFrom(unitTarget, float(m_spellInfo->EffectMiscValue[eff_idx])/10, float(damage)/10); + m_caster->KnockBackFrom(unitTarget, float(m_spellInfo->EffectMiscValue[eff_idx]) / 10, float(damage) / 10); } void Spell::EffectReputation(SpellEffectIndex eff_idx) @@ -9068,9 +9068,9 @@ void Spell::EffectSelfResurrect(SpellEffectIndex eff_idx) // percent case else { - health = uint32(damage/100.0f*unitTarget->GetMaxHealth()); + health = uint32(damage / 100.0f * unitTarget->GetMaxHealth()); if (unitTarget->GetMaxPower(POWER_MANA) > 0) - mana = uint32(damage/100.0f*unitTarget->GetMaxPower(POWER_MANA)); + mana = uint32(damage / 100.0f * unitTarget->GetMaxPower(POWER_MANA)); } Player* plr = ((Player*)unitTarget); @@ -9096,10 +9096,10 @@ void Spell::EffectSkinning(SpellEffectIndex /*eff_idx*/) uint32 skill = creature->GetCreatureInfo()->GetRequiredLootSkill(); - ((Player*)m_caster)->SendLoot(creature->GetObjectGuid(),LOOT_SKINNING); + ((Player*)m_caster)->SendLoot(creature->GetObjectGuid(), LOOT_SKINNING); creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); - int32 reqValue = targetLevel < 10 ? 0 : targetLevel < 20 ? (targetLevel-10)*10 : targetLevel*5; + int32 reqValue = targetLevel < 10 ? 0 : targetLevel < 20 ? (targetLevel - 10) * 10 : targetLevel * 5; int32 skillValue = ((Player*)m_caster)->GetPureSkillValue(skill); @@ -9158,7 +9158,7 @@ void Spell::EffectKnockBack(SpellEffectIndex eff_idx) if (!unitTarget) return; - unitTarget->KnockBackFrom(m_caster, float(m_spellInfo->EffectMiscValue[eff_idx])/10, float(damage)/10); + unitTarget->KnockBackFrom(m_caster, float(m_spellInfo->EffectMiscValue[eff_idx]) / 10, float(damage) / 10); } void Spell::EffectSendTaxi(SpellEffectIndex eff_idx) @@ -9166,7 +9166,7 @@ void Spell::EffectSendTaxi(SpellEffectIndex eff_idx) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - ((Player*)unitTarget)->ActivateTaxiPathTo(m_spellInfo->EffectMiscValue[eff_idx],m_spellInfo->Id); + ((Player*)unitTarget)->ActivateTaxiPathTo(m_spellInfo->EffectMiscValue[eff_idx], m_spellInfo->Id); } void Spell::EffectPlayerPull(SpellEffectIndex eff_idx) @@ -9178,7 +9178,7 @@ void Spell::EffectPlayerPull(SpellEffectIndex eff_idx) if (damage && dist > damage) dist = float(damage); - unitTarget->KnockBackFrom(m_caster, -dist, float(m_spellInfo->EffectMiscValue[eff_idx])/10); + unitTarget->KnockBackFrom(m_caster, -dist, float(m_spellInfo->EffectMiscValue[eff_idx]) / 10); } void Spell::EffectDispelMechanic(SpellEffectIndex eff_idx) @@ -9222,7 +9222,7 @@ void Spell::EffectSummonDeadPet(SpellEffectIndex /*eff_idx*/) pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); pet->SetDeathState(ALIVE); pet->clearUnitState(UNIT_STAT_ALL_STATE); - pet->SetHealth(uint32(pet->GetMaxHealth()*(float(damage)/100))); + pet->SetHealth(uint32(pet->GetMaxHealth() * (float(damage) / 100))); pet->AIM_Initialize(); @@ -9239,10 +9239,10 @@ void Spell::EffectSummonAllTotems(SpellEffectIndex eff_idx) int32 amount_buttons = m_spellInfo->EffectMiscValueB[eff_idx]; for (int32 slot = 0; slot < amount_buttons; ++slot) - if (ActionButton const* actionButton = ((Player*)m_caster)->GetActionButton(start_button+slot)) - if (actionButton->GetType()==ACTION_BUTTON_SPELL) + if (ActionButton const* actionButton = ((Player*)m_caster)->GetActionButton(start_button + slot)) + if (actionButton->GetType() == ACTION_BUTTON_SPELL) if (uint32 spell_id = actionButton->GetAction()) - m_caster->CastSpell(unitTarget,spell_id,true); + m_caster->CastSpell(unitTarget, spell_id, true); } void Spell::EffectDestroyAllTotems(SpellEffectIndex /*eff_idx*/) @@ -9313,7 +9313,7 @@ void Spell::EffectDurabilityDamagePCT(SpellEffectIndex eff_idx) // Possibly its mean -1 all player equipped items and -2 all items if (slot < 0) { - ((Player*)unitTarget)->DurabilityLossAll(double(damage)/100.0f, (slot < -1)); + ((Player*)unitTarget)->DurabilityLossAll(double(damage) / 100.0f, (slot < -1)); return; } @@ -9325,7 +9325,7 @@ void Spell::EffectDurabilityDamagePCT(SpellEffectIndex eff_idx) return; if (Item* item = ((Player*)unitTarget)->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) - ((Player*)unitTarget)->DurabilityLoss(item, double(damage)/100.0f); + ((Player*)unitTarget)->DurabilityLoss(item, double(damage) / 100.0f); } void Spell::EffectModifyThreatPercent(SpellEffectIndex /*eff_idx*/) @@ -9344,7 +9344,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx) if (!goinfo) { - sLog.outErrorDb("Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast",name_id, m_spellInfo->Id); + sLog.outErrorDb("Gameobject (Entry: %u) not exist and not created at spell (ID: %u) cast", name_id, m_spellInfo->Id); return; } @@ -9357,7 +9357,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx) fz = m_targets.m_destZ; } //FIXME: this can be better check for most objects but still hack - else if (m_spellInfo->EffectRadiusIndex[eff_idx] && m_spellInfo->speed==0) + else if (m_spellInfo->EffectRadiusIndex[eff_idx] && m_spellInfo->speed == 0) { float dis = GetSpellRadius(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[eff_idx])); m_caster->GetClosePoint(fx, fy, fz, DEFAULT_WORLD_OBJECT_SIZE, dis); @@ -9373,7 +9373,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx) if (goinfo->type == GAMEOBJECT_TYPE_FISHINGNODE) { // calculate angle variation for roughly equal dimensions of target area - float max_angle = (max_dis - min_dis)/(max_dis + m_caster->GetObjectBoundingRadius()); + float max_angle = (max_dis - min_dis) / (max_dis + m_caster->GetObjectBoundingRadius()); float angle_offset = max_angle * (rand_norm_f() - 0.5f); m_caster->GetNearPoint2D(fx, fy, dis, m_caster->GetOrientation() + angle_offset); @@ -9436,7 +9436,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx) case 3: lastSec = 17; break; } - duration = duration - lastSec*IN_MILLISECONDS + FISHING_BOBBER_READY_TIME*IN_MILLISECONDS; + duration = duration - lastSec * IN_MILLISECONDS + FISHING_BOBBER_READY_TIME * IN_MILLISECONDS; break; } case GAMEOBJECT_TYPE_SUMMONING_RITUAL: @@ -9454,7 +9454,7 @@ void Spell::EffectTransmitted(SpellEffectIndex eff_idx) break; } - pGameObj->SetRespawnTime(duration > 0 ? duration/IN_MILLISECONDS : 0); + pGameObj->SetRespawnTime(duration > 0 ? duration / IN_MILLISECONDS : 0); pGameObj->SetOwnerGuid(m_caster->GetObjectGuid()); @@ -9544,7 +9544,7 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) { DEBUG_LOG("Effect: StealBeneficialBuff"); - if (!unitTarget || unitTarget==m_caster) // can't steal from self + if (!unitTarget || unitTarget == m_caster) // can't steal from self return; typedef std::vector StealList; @@ -9555,7 +9555,7 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { SpellAuraHolder* holder = itr->second; - if (holder && (1<GetSpellProto()->Dispel) & dispelMask) + if (holder && (1 << holder->GetSpellProto()->Dispel) & dispelMask) { // Need check for passive? this if (holder->IsPositive() && !holder->IsPassive() && !holder->GetSpellProto()->HasAttribute(SPELL_ATTR_EX4_NOT_STEALABLE)) @@ -9569,13 +9569,13 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) SuccessList success_list; int32 list_size = steal_list.size(); // Dispell N = damage buffs (or while exist buffs for dispel) - for (int32 count=0; count < damage && list_size > 0; ++count) + for (int32 count = 0; count < damage && list_size > 0; ++count) { // Random select buff for dispel - SpellAuraHolder* holder = steal_list[urand(0, list_size-1)]; + SpellAuraHolder* holder = steal_list[urand(0, list_size - 1)]; // Not use chance for steal // TODO possible need do it - success_list.push_back(SuccessList::value_type(holder->GetId(),holder->GetCasterGuid())); + success_list.push_back(SuccessList::value_type(holder->GetId(), holder->GetCasterGuid())); // Remove buff from list for prevent doubles for (StealList::iterator j = steal_list.begin(); j != steal_list.end();) @@ -9594,7 +9594,7 @@ void Spell::EffectStealBeneficialBuff(SpellEffectIndex eff_idx) if (!success_list.empty()) { int32 count = success_list.size(); - WorldPacket data(SMSG_SPELLSTEALLOG, 8+8+4+1+4+count*5); + WorldPacket data(SMSG_SPELLSTEALLOG, 8 + 8 + 4 + 1 + 4 + count * 5); data << unitTarget->GetPackGUID(); // Victim GUID data << m_caster->GetPackGUID(); // Caster GUID data << uint32(m_spellInfo->Id); // Dispell spell id @@ -9719,7 +9719,7 @@ void Spell::EffectActivateSpec(SpellEffectIndex /*eff_idx*/) if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - uint32 spec = damage-1; + uint32 spec = damage - 1; ((Player*)unitTarget)->ActivateSpec(spec); } @@ -9756,10 +9756,10 @@ void Spell::EffectBind(SpellEffectIndex eff_idx) area_id = player->GetAreaId(); } - player->SetHomebindToLocation(loc,area_id); + player->SetHomebindToLocation(loc, area_id); // binding - WorldPacket data(SMSG_BINDPOINTUPDATE, (4+4+4+4+4)); + WorldPacket data(SMSG_BINDPOINTUPDATE, (4 + 4 + 4 + 4 + 4)); data << float(loc.coord_x); data << float(loc.coord_y); data << float(loc.coord_z); @@ -9774,7 +9774,7 @@ void Spell::EffectBind(SpellEffectIndex eff_idx) DEBUG_LOG("New Home AreaId is %u", area_id); // zone update - data.Initialize(SMSG_PLAYERBOUND, 8+4); + data.Initialize(SMSG_PLAYERBOUND, 8 + 4); data << player->GetObjectGuid(); data << uint32(area_id); player->SendDirectMessage(&data); diff --git a/src/game/SpellHandler.cpp b/src/game/SpellHandler.cpp index 56dd52d13..021d0eb5d 100644 --- a/src/game/SpellHandler.cpp +++ b/src/game/SpellHandler.cpp @@ -113,7 +113,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) pUser->InArena()) { recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail - pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH,pItem,NULL); + pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, pItem, NULL); return; } @@ -126,7 +126,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) if (IsNonCombatSpell(spellInfo)) { recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail - pUser->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT,pItem,NULL); + pUser->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT, pItem, NULL); return; } } @@ -136,7 +136,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) if (pItem->IsPotion() && pUser->GetLastPotionId()) { recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail - pUser->SendEquipError(EQUIP_ERR_OBJECT_IS_BUSY,pItem,NULL); + pUser->SendEquipError(EQUIP_ERR_OBJECT_IS_BUSY, pItem, NULL); return; } } @@ -168,10 +168,10 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) // for implicit area/coord target spells if (IsPointEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_0])) || IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_0]))) - Spell::SendCastResult(_player,spellInfo,cast_count,SPELL_FAILED_NO_VALID_TARGETS); + Spell::SendCastResult(_player, spellInfo, cast_count, SPELL_FAILED_NO_VALID_TARGETS); // for explicit target spells else - Spell::SendCastResult(_player,spellInfo,cast_count,SPELL_FAILED_BAD_TARGETS); + Spell::SendCastResult(_player, spellInfo, cast_count, SPELL_FAILED_BAD_TARGETS); } return; } @@ -180,7 +180,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) if (!sScriptMgr.OnItemUse(pUser, pItem, targets)) { // no script or script not process request by self - pUser->CastItemUseSpell(pItem,targets,cast_count,glyphIndex); + pUser->CastItemUseSpell(pItem, targets, cast_count, glyphIndex); } } @@ -192,13 +192,13 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket) void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) { - DETAIL_LOG("WORLD: CMSG_OPEN_ITEM packet, data length = %i",(uint32)recvPacket.size()); + DETAIL_LOG("WORLD: CMSG_OPEN_ITEM packet, data length = %i", (uint32)recvPacket.size()); uint8 bagIndex, slot; recvPacket >> bagIndex >> slot; - DETAIL_LOG("bagIndex: %u, slot: %u",bagIndex,slot); + DETAIL_LOG("bagIndex: %u, slot: %u", bagIndex, slot); Player* pUser = _player; @@ -269,7 +269,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket) stmt.PExecute(pItem->GetGUIDLow()); } else - pUser->SendLoot(pItem->GetObjectGuid(),LOOT_CORPSE); + pUser->SendLoot(pItem->GetObjectGuid(), LOOT_CORPSE); } void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recv_data) @@ -327,7 +327,7 @@ void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket) if (!go) return; - if (!go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) + if (!go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)) return; _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, go->GetEntry()); @@ -343,7 +343,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) // ignore for remote control state (for player case) Unit* mover = _player->GetMover(); - if (mover != _player && mover->GetTypeId()==TYPEID_PLAYER) + if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER) { recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet return; @@ -361,7 +361,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket) return; } - if (mover->GetTypeId()==TYPEID_PLAYER) + if (mover->GetTypeId() == TYPEID_PLAYER) { // not have spell in spellbook or spell passive and not casted by client if (!((Player*)mover)->HasActiveSpell(spellId) || IsPassiveSpell(spellInfo)) @@ -429,15 +429,15 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket) // ignore for remote control state (for player case) Unit* mover = _player->GetMover(); - if (mover != _player && mover->GetTypeId()==TYPEID_PLAYER) + if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER) return; //FIXME: hack, ignore unexpected client cancel Deadly Throw cast - if (spellId==26679) + if (spellId == 26679) return; if (mover->IsNonMeleeSpellCasted(false)) - mover->InterruptNonMeleeSpells(false,spellId); + mover->InterruptNonMeleeSpells(false, spellId); } void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) @@ -484,7 +484,7 @@ void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket) if (IsChanneledSpell(spellInfo)) { if (Spell* curSpell = _player->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - if (curSpell->m_spellInfo->Id==spellId) + if (curSpell->m_spellInfo->Id == spellId) _player->InterruptSpell(CURRENT_CHANNELED_SPELL); return; } @@ -561,7 +561,7 @@ void WorldSession::HandleCancelChanneling(WorldPacket& recv_data) // ignore for remote control state (for player case) Unit* mover = _player->GetMover(); - if (mover != _player && mover->GetTypeId()==TYPEID_PLAYER) + if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER) return; mover->InterruptSpell(CURRENT_CHANNELED_SPELL); diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 025f04e2f..f792227e8 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -107,7 +107,7 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell) return 0; // spell targeted to non-trading trade slot item instant at trade success apply - if (spell->GetCaster()->GetTypeId()==TYPEID_PLAYER) + if (spell->GetCaster()->GetTypeId() == TYPEID_PLAYER) if (TradeData* my_trade = ((Player*)(spell->GetCaster()))->GetTradeData()) if (Item* nonTrade = my_trade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED)) if (nonTrade == spell->m_targets.getItemTarget()) @@ -541,7 +541,7 @@ SpellSpecific GetSpellSpecific(uint32 spellId) } // target not allow have more one spell specific from same caster -bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2) +bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1, SpellSpecific spellSpec2) { switch (spellSpec1) { @@ -554,14 +554,14 @@ bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1,SpellS case SPELL_JUDGEMENT: case SPELL_HAND: case SPELL_UA_IMMOLATE: - return spellSpec1==spellSpec2; + return spellSpec1 == spellSpec2; default: return false; } } // target not allow have more one ranks from spell from spell specific per target -bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2) +bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1, SpellSpecific spellSpec2) { switch (spellSpec1) { @@ -570,14 +570,14 @@ bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1,Spell case SPELL_CURSE: case SPELL_ASPECT: case SPELL_HAND: - return spellSpec1==spellSpec2; + return spellSpec1 == spellSpec2; default: return false; } } // target not allow have more one spell specific per target from any caster -bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2) +bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1, SpellSpecific spellSpec2) { switch (spellSpec1) { @@ -589,27 +589,27 @@ bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1,SpellSpecific s case SPELL_MAGE_POLYMORPH: case SPELL_PRESENCE: case SPELL_WELL_FED: - return spellSpec1==spellSpec2; + return spellSpec1 == spellSpec2; case SPELL_BATTLE_ELIXIR: - return spellSpec2==SPELL_BATTLE_ELIXIR - || spellSpec2==SPELL_FLASK_ELIXIR; + return spellSpec2 == SPELL_BATTLE_ELIXIR + || spellSpec2 == SPELL_FLASK_ELIXIR; case SPELL_GUARDIAN_ELIXIR: - return spellSpec2==SPELL_GUARDIAN_ELIXIR - || spellSpec2==SPELL_FLASK_ELIXIR; + return spellSpec2 == SPELL_GUARDIAN_ELIXIR + || spellSpec2 == SPELL_FLASK_ELIXIR; case SPELL_FLASK_ELIXIR: - return spellSpec2==SPELL_BATTLE_ELIXIR - || spellSpec2==SPELL_GUARDIAN_ELIXIR - || spellSpec2==SPELL_FLASK_ELIXIR; + return spellSpec2 == SPELL_BATTLE_ELIXIR + || spellSpec2 == SPELL_GUARDIAN_ELIXIR + || spellSpec2 == SPELL_FLASK_ELIXIR; case SPELL_FOOD: - return spellSpec2==SPELL_FOOD - || spellSpec2==SPELL_FOOD_AND_DRINK; + return spellSpec2 == SPELL_FOOD + || spellSpec2 == SPELL_FOOD_AND_DRINK; case SPELL_DRINK: - return spellSpec2==SPELL_DRINK - || spellSpec2==SPELL_FOOD_AND_DRINK; + return spellSpec2 == SPELL_DRINK + || spellSpec2 == SPELL_FOOD_AND_DRINK; case SPELL_FOOD_AND_DRINK: - return spellSpec2==SPELL_FOOD - || spellSpec2==SPELL_DRINK - || spellSpec2==SPELL_FOOD_AND_DRINK; + return spellSpec2 == SPELL_FOOD + || spellSpec2 == SPELL_DRINK + || spellSpec2 == SPELL_FOOD_AND_DRINK; default: return false; } @@ -892,7 +892,7 @@ bool IsPositiveEffect(SpellEntry const* spellproto, SpellEffectIndex effIndex) } // non-positive targets - if (!IsPositiveTarget(spellproto->EffectImplicitTargetA[effIndex],spellproto->EffectImplicitTargetB[effIndex])) + if (!IsPositiveTarget(spellproto->EffectImplicitTargetA[effIndex], spellproto->EffectImplicitTargetB[effIndex])) return false; // AttributesEx check @@ -940,7 +940,7 @@ bool IsSingleTargetSpell(SpellEntry const* spellInfo) // single target triggered spell. // Not real client side single target spell, but it' not triggered until prev. aura expired. // This is allow store it in single target spells list for caster for spell proc checking - if (spellInfo->Id==38324) // Regeneration (triggered by 38299 (HoTs on Heals)) + if (spellInfo->Id == 38324) // Regeneration (triggered by 38299 (HoTs on Heals)) return true; return false; @@ -1056,35 +1056,35 @@ void SpellMgr::LoadSpellTargetPositions() MapEntry const* mapEntry = sMapStore.LookupEntry(st.target_mapId); if (!mapEntry) { - sLog.outErrorDb("Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Spell_ID,st.target_mapId); + sLog.outErrorDb("Spell (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.", Spell_ID, st.target_mapId); continue; } - if (st.target_X==0 && st.target_Y==0 && st.target_Z==0) + if (st.target_X == 0 && st.target_Y == 0 && st.target_Z == 0) { - sLog.outErrorDb("Spell (ID:%u) target coordinates not provided.",Spell_ID); + sLog.outErrorDb("Spell (ID:%u) target coordinates not provided.", Spell_ID); continue; } SpellEntry const* spellInfo = sSpellStore.LookupEntry(Spell_ID); if (!spellInfo) { - sLog.outErrorDb("Spell (ID:%u) listed in `spell_target_position` does not exist.",Spell_ID); + sLog.outErrorDb("Spell (ID:%u) listed in `spell_target_position` does not exist.", Spell_ID); continue; } bool found = false; for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { - if (spellInfo->EffectImplicitTargetA[i]==TARGET_TABLE_X_Y_Z_COORDINATES || spellInfo->EffectImplicitTargetB[i]==TARGET_TABLE_X_Y_Z_COORDINATES) + if (spellInfo->EffectImplicitTargetA[i] == TARGET_TABLE_X_Y_Z_COORDINATES || spellInfo->EffectImplicitTargetB[i] == TARGET_TABLE_X_Y_Z_COORDINATES) { // additional requirements - if (spellInfo->Effect[i]==SPELL_EFFECT_BIND && spellInfo->EffectMiscValue[i]) + if (spellInfo->Effect[i] == SPELL_EFFECT_BIND && spellInfo->EffectMiscValue[i]) { uint32 zone_id = sTerrainMgr.GetAreaId(st.target_mapId, st.target_X, st.target_Y, st.target_Z); if (int32(zone_id) != spellInfo->EffectMiscValue[i]) { - sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` expected point to zone %u bit point to zone %u.",Spell_ID, spellInfo->EffectMiscValue[i], zone_id); + sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` expected point to zone %u bit point to zone %u.", Spell_ID, spellInfo->EffectMiscValue[i], zone_id); break; } } @@ -1095,7 +1095,7 @@ void SpellMgr::LoadSpellTargetPositions() } if (!found) { - sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_TABLE_X_Y_Z_COORDINATES (17).",Spell_ID); + sLog.outErrorDb("Spell (Id: %u) listed in `spell_target_position` does not have target TARGET_TABLE_X_Y_Z_COORDINATES (17).", Spell_ID); continue; } @@ -1233,12 +1233,12 @@ struct DoSpellProcEvent if (spe.procFlags == 0) { - if (spell->procFlags==0) + if (spell->procFlags == 0) sLog.outErrorDb("Spell %u listed in `spell_proc_event` probally not triggered spell (no proc flags)", spell->Id); } else { - if (spell->procFlags==spe.procFlags) + if (spell->procFlags == spe.procFlags) sLog.outErrorDb("Spell %u listed in `spell_proc_event` has exactly same proc flags as in spell.dbc, field value redundant", spell->Id); else isCustom = true; @@ -1253,7 +1253,7 @@ struct DoSpellProcEvent } else { - if (spell->procChance==spe.customChance) + if (spell->procChance == spe.customChance) sLog.outErrorDb("Spell %u listed in `spell_proc_event` has exactly same custom chance as in spell.dbc, field value redundant", spell->Id); else isCustom = true; @@ -1327,8 +1327,8 @@ void SpellMgr::LoadSpellProcEvents() for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { spe.spellFamilyMask[i] = ClassFamilyMask( - (uint64)fields[i+3].GetUInt32() | ((uint64)fields[i+6].GetUInt32()<<32), - fields[i+9].GetUInt32()); + (uint64)fields[i + 3].GetUInt32() | ((uint64)fields[i + 6].GetUInt32() << 32), + fields[i + 9].GetUInt32()); } spe.procFlags = fields[12].GetUInt32(); spe.procEx = fields[13].GetUInt32(); @@ -1410,7 +1410,7 @@ void SpellMgr::LoadSpellProcItemEnchant() // also add to high ranks DoSpellProcItemEnchant worker(mSpellProcItemEnchantMap, ppmRate); - doForHighRanks(entry,worker); + doForHighRanks(entry, worker); ++count; } @@ -1669,7 +1669,7 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr return false; // No extra req, so can trigger for (damage/healing present) and cast end/hit/crit - if (procExtra & (PROC_EX_CAST_END|PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) + if (procExtra & (PROC_EX_CAST_END | PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) return true; } else // all spells hits here only if resist/reflect/immune/evade @@ -1833,13 +1833,13 @@ void SpellMgr::LoadSpellThreats() sLog.outString(">> Loaded %u spell threat entries", rankHelper.worker.count); } -bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const* spellInfo_1,uint32 spellId_2) const +bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const* spellInfo_1, uint32 spellId_2) const { SpellEntry const* spellInfo_2 = sSpellStore.LookupEntry(spellId_2); if (!spellInfo_1 || !spellInfo_2) return false; if (spellInfo_1->Id == spellId_2) return false; - return GetFirstSpellInChain(spellInfo_1->Id)==GetFirstSpellInChain(spellId_2); + return GetFirstSpellInChain(spellInfo_1->Id) == GetFirstSpellInChain(spellId_2); } bool SpellMgr::canStackSpellRanksInSpellBook(SpellEntry const* spellInfo) const @@ -1861,7 +1861,7 @@ bool SpellMgr::canStackSpellRanksInSpellBook(SpellEntry const* spellInfo) const { case SPELLFAMILY_PALADIN: // Paladin aura Spell - if (spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AREA_AURA_RAID) + if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AREA_AURA_RAID) return false; // Seal of Righteousness, 2 version of same rank if ((spellInfo->SpellFamilyFlags & UI64LIT(0x0000000008000000)) && spellInfo->SpellIconID == 25) @@ -1869,13 +1869,13 @@ bool SpellMgr::canStackSpellRanksInSpellBook(SpellEntry const* spellInfo) const break; case SPELLFAMILY_DRUID: // Druid form Spell - if (spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AURA && + if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT) return false; break; case SPELLFAMILY_ROGUE: // Rogue Stealth - if (spellInfo->Effect[i]==SPELL_EFFECT_APPLY_AURA && + if (spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && spellInfo->EffectApplyAuraName[i] == SPELL_AURA_MOD_SHAPESHIFT) return false; break; @@ -1896,7 +1896,7 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons return false; // Resurrection sickness - if ((spellInfo_1->Id == SPELL_ID_PASSIVE_RESURRECTION_SICKNESS) != (spellInfo_2->Id==SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) + if ((spellInfo_1->Id == SPELL_ID_PASSIVE_RESURRECTION_SICKNESS) != (spellInfo_2->Id == SPELL_ID_PASSIVE_RESURRECTION_SICKNESS)) return false; // Allow stack passive and not passive spells @@ -2044,11 +2044,11 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons case SPELLFAMILY_PALADIN: { // Unstable Currents and other -> *Sanctity Aura (multi-family check) - if (spellInfo_2->SpellIconID==502 && spellInfo_1->SpellIconID==502 && spellInfo_1->SpellVisual[0]==969) + if (spellInfo_2->SpellIconID == 502 && spellInfo_1->SpellIconID == 502 && spellInfo_1->SpellVisual[0] == 969) return false; // *Band of Eternal Champion and Seal of Command(multi-family check) - if (spellId_1 == 35081 && spellInfo_2->SpellIconID==561 && spellInfo_2->SpellVisual[0]==7992) + if (spellId_1 == 35081 && spellInfo_2->SpellIconID == 561 && spellInfo_2->SpellVisual[0] == 7992) return false; // Blessing of Sanctuary (multi-family check, some from 16 spell icon spells) @@ -2361,18 +2361,18 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) cons return false; // *Sanctity Aura -> Unstable Currents and other (multi-family check) - if (spellInfo_1->SpellIconID==502 && spellInfo_2->SpellFamilyName == SPELLFAMILY_GENERIC && spellInfo_2->SpellIconID==502 && spellInfo_2->SpellVisual[0]==969) + if (spellInfo_1->SpellIconID == 502 && spellInfo_2->SpellFamilyName == SPELLFAMILY_GENERIC && spellInfo_2->SpellIconID == 502 && spellInfo_2->SpellVisual[0] == 969) return false; // *Seal of Command and Band of Eternal Champion (multi-family check) - if (spellInfo_1->SpellIconID==561 && spellInfo_1->SpellVisual[0]==7992 && spellId_2 == 35081) + if (spellInfo_1->SpellIconID == 561 && spellInfo_1->SpellVisual[0] == 7992 && spellId_2 == 35081) return false; break; case SPELLFAMILY_SHAMAN: if (spellInfo_2->SpellFamilyName == SPELLFAMILY_SHAMAN) { // Windfury weapon - if (spellInfo_1->SpellIconID==220 && spellInfo_2->SpellIconID==220 && + if (spellInfo_1->SpellIconID == 220 && spellInfo_2->SpellIconID == 220 && !spellInfo_1->IsFitToFamilyMask(spellInfo_2->SpellFamilyFlags)) return false; @@ -2539,7 +2539,7 @@ uint32 SpellMgr::GetProfessionSpellMinLevel(uint32 spellId) bool SpellMgr::IsPrimaryProfessionFirstRankSpell(uint32 spellId) const { - return IsPrimaryProfessionSpell(spellId) && GetSpellRank(spellId)==1; + return IsPrimaryProfessionSpell(spellId) && GetSpellRank(spellId) == 1; } bool SpellMgr::IsSkillBonusSpell(uint32 spellId) const @@ -2606,7 +2606,7 @@ SpellEntry const* SpellMgr::SelectAuraRankForLevel(SpellEntry const* spellInfo, return NULL; } -typedef UNORDERED_MAP AbilitySpellPrevMap; +typedef UNORDERED_MAP AbilitySpellPrevMap; static void LoadSpellChains_AbilityHelper(SpellChainMap& chainMap, AbilitySpellPrevMap const& prevRanks, uint32 spell_id, uint32 prev_id, uint32 deep = 30) { @@ -2625,7 +2625,7 @@ static void LoadSpellChains_AbilityHelper(SpellChainMap& chainMap, AbilitySpellP SpellChainNode node; node.prev = prev_id; node.first = prev_chain_itr->second.first; - node.rank = prev_chain_itr->second.rank+1; + node.rank = prev_chain_itr->second.rank + 1; node.req = 0; chainMap[spell_id] = node; return; @@ -2658,7 +2658,7 @@ static void LoadSpellChains_AbilityHelper(SpellChainMap& chainMap, AbilitySpellP } // prev rank listed, so process it first - LoadSpellChains_AbilityHelper(chainMap, prevRanks, prev_id, prev_itr->second, deep-1); + LoadSpellChains_AbilityHelper(chainMap, prevRanks, prev_id, prev_itr->second, deep - 1); // prev rank must be listed now prev_chain_itr = chainMap.find(prev_id); @@ -2668,7 +2668,7 @@ static void LoadSpellChains_AbilityHelper(SpellChainMap& chainMap, AbilitySpellP SpellChainNode node; node.prev = prev_id; node.first = prev_chain_itr->second.first; - node.rank = prev_chain_itr->second.rank+1; + node.rank = prev_chain_itr->second.rank + 1; node.req = 0; chainMap[spell_id] = node; } @@ -2702,9 +2702,9 @@ void SpellMgr::LoadSpellChains() } SpellChainNode node; - node.prev = (j > 0) ? talentInfo->RankID[j-1] : 0; + node.prev = (j > 0) ? talentInfo->RankID[j - 1] : 0; node.first = talentInfo->RankID[0]; - node.rank = j+1; + node.rank = j + 1; node.req = 0; mSpellChains[spell_id] = node; @@ -2766,7 +2766,7 @@ void SpellMgr::LoadSpellChains() SpellChainNode node; node.prev = spell_id; node.first = prev_chain_itr->second.first; - node.rank = prev_chain_itr->second.rank+1; + node.rank = prev_chain_itr->second.rank + 1; node.req = 0; mSpellChains[forward_id] = node; @@ -2820,7 +2820,7 @@ void SpellMgr::LoadSpellChains() if (!sSpellStore.LookupEntry(spell_id)) { - sLog.outErrorDb("Spell %u listed in `spell_chain` does not exist",spell_id); + sLog.outErrorDb("Spell %u listed in `spell_chain` does not exist", spell_id); continue; } @@ -2830,21 +2830,21 @@ void SpellMgr::LoadSpellChains() if (chain_itr->second.rank != node.rank) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected rank %u by DBC data.", - spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.rank); + spell_id, node.prev, node.first, node.rank, node.req, chain_itr->second.rank); continue; } if (chain_itr->second.prev != node.prev) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected prev %u by DBC data.", - spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.prev); + spell_id, node.prev, node.first, node.rank, node.req, chain_itr->second.prev); continue; } if (chain_itr->second.first != node.first) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` expected first %u by DBC data.", - spell_id,node.prev,node.first,node.rank,node.req,chain_itr->second.first); + spell_id, node.prev, node.first, node.rank, node.req, chain_itr->second.first); continue; } @@ -2858,21 +2858,21 @@ void SpellMgr::LoadSpellChains() // in other case redundant sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) already added (talent or spell ability with forward) and non need in `spell_chain`", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } if (node.prev != 0 && !sSpellStore.LookupEntry(node.prev)) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has nonexistent previous rank spell.", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } if (!sSpellStore.LookupEntry(node.first)) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing first rank spell.", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } @@ -2882,40 +2882,40 @@ void SpellMgr::LoadSpellChains() (node.rank <= 1) != (node.prev == 0)) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not compatible chain data.", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } - if (node.req!=0 && !sSpellStore.LookupEntry(node.req)) + if (node.req != 0 && !sSpellStore.LookupEntry(node.req)) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not existing required spell.", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } // talents not required data in spell chain for work, but must be checked if present for integrity if (TalentSpellPos const* pos = GetTalentSpellPos(spell_id)) { - if (node.rank!=pos->rank+1) + if (node.rank != pos->rank + 1) { sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong rank.", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } if (TalentEntry const* talentEntry = sTalentStore.LookupEntry(pos->talent_id)) { - if (node.first!=talentEntry->RankID[0]) + if (node.first != talentEntry->RankID[0]) { sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong first rank spell.", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } - if (node.rank > 1 && node.prev != talentEntry->RankID[node.rank-1-1]) + if (node.rank > 1 && node.prev != talentEntry->RankID[node.rank - 1 - 1]) { sLog.outErrorDb("Talent %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has wrong prev rank spell.", - spell_id,node.prev,node.first,node.rank,node.req); + spell_id, node.prev, node.first, node.rank, node.req); continue; } @@ -2973,19 +2973,19 @@ void SpellMgr::LoadSpellChains() if (i_prev == mSpellChains.end()) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found previous rank spell in table.", - i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); + i->first, i->second.prev, i->second.first, i->second.rank, i->second.req); } else if (i_prev->second.first != i->second.first) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different first spell in chain compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).", - i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, - i_prev->second.prev,i_prev->second.first,i_prev->second.rank,i_prev->second.req); + i->first, i->second.prev, i->second.first, i->second.rank, i->second.req, + i_prev->second.prev, i_prev->second.first, i_prev->second.rank, i_prev->second.req); } - else if (i_prev->second.rank+1 != i->second.rank) + else if (i_prev->second.rank + 1 != i->second.rank) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has different rank compared to previous rank spell (prev: %u, first: %u, rank: %d, req: %u).", - i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, - i_prev->second.prev,i_prev->second.first,i_prev->second.rank,i_prev->second.req); + i->first, i->second.prev, i->second.first, i->second.rank, i->second.req, + i_prev->second.prev, i_prev->second.first, i_prev->second.rank, i_prev->second.req); } } @@ -2995,19 +2995,19 @@ void SpellMgr::LoadSpellChains() if (i_req == mSpellChains.end()) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has not found required rank spell in table.", - i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); + i->first, i->second.prev, i->second.first, i->second.rank, i->second.req); } else if (i_req->second.first == i->second.first) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell from same spell chain (prev: %u, first: %u, rank: %d, req: %u).", - i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, - i_req->second.prev,i_req->second.first,i_req->second.rank,i_req->second.req); + i->first, i->second.prev, i->second.first, i->second.rank, i->second.req, + i_req->second.prev, i_req->second.first, i_req->second.rank, i_req->second.req); } else if (i_req->second.req) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has required rank spell with required spell (prev: %u, first: %u, rank: %d, req: %u).", - i->first,i->second.prev,i->second.first,i->second.rank,i->second.req, - i_req->second.prev,i_req->second.first,i_req->second.rank,i_req->second.req); + i->first, i->second.prev, i->second.first, i->second.rank, i->second.req, + i_req->second.prev, i_req->second.first, i_req->second.rank, i_req->second.req); } } } @@ -3019,10 +3019,10 @@ void SpellMgr::LoadSpellChains() SpellChainNode const& node = i->second; if (node.prev) - mSpellChainsNext.insert(SpellChainMapNext::value_type(node.prev,spell_id)); + mSpellChainsNext.insert(SpellChainMapNext::value_type(node.prev, spell_id)); if (node.req) - mSpellChainsNext.insert(SpellChainMapNext::value_type(node.req,spell_id)); + mSpellChainsNext.insert(SpellChainMapNext::value_type(node.req, spell_id)); } // check single rank redundant cases (single rank talents/spell abilities not added by default so this can be only custom cases) @@ -3035,12 +3035,12 @@ void SpellMgr::LoadSpellChains() if (mSpellChainsNext.find(i->first) == mSpellChainsNext.end()) { sLog.outErrorDb("Spell %u (prev: %u, first: %u, rank: %d, req: %u) listed in `spell_chain` has single rank data, so redundant.", - i->first,i->second.prev,i->second.first,i->second.rank,i->second.req); + i->first, i->second.prev, i->second.first, i->second.rank, i->second.req); } } sLog.outString(); - sLog.outString(">> Loaded %u spell chain records (%u from DBC data with %u req field updates, and %u loaded from table)", dbc_count+new_count, dbc_count, req_count, new_count); + sLog.outString(">> Loaded %u spell chain records (%u from DBC data with %u req field updates, and %u loaded from table)", dbc_count + new_count, dbc_count, req_count, new_count); } void SpellMgr::LoadSpellLearnSkills() @@ -3112,27 +3112,27 @@ void SpellMgr::LoadSpellLearnSpells() SpellLearnSpellNode node; node.spell = fields[1].GetUInt32(); node.active = fields[2].GetBool(); - node.autoLearned= false; + node.autoLearned = false; if (!sSpellStore.LookupEntry(spell_id)) { - sLog.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",spell_id); + sLog.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist", spell_id); continue; } if (!sSpellStore.LookupEntry(node.spell)) { - sLog.outErrorDb("Spell %u listed in `spell_learn_spell` learning nonexistent spell %u",spell_id,node.spell); + sLog.outErrorDb("Spell %u listed in `spell_learn_spell` learning nonexistent spell %u", spell_id, node.spell); continue; } if (GetTalentSpellCost(node.spell)) { - sLog.outErrorDb("Spell %u listed in `spell_learn_spell` attempt learning talent spell %u, skipped",spell_id,node.spell); + sLog.outErrorDb("Spell %u listed in `spell_learn_spell` attempt learning talent spell %u, skipped", spell_id, node.spell); continue; } - mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell_id,node)); + mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell_id, node)); ++count; } @@ -3151,7 +3151,7 @@ void SpellMgr::LoadSpellLearnSpells() for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { - if (entry->Effect[i]==SPELL_EFFECT_LEARN_SPELL) + if (entry->Effect[i] == SPELL_EFFECT_LEARN_SPELL) { SpellLearnSpellNode dbc_node; dbc_node.spell = entry->EffectTriggerSpell[i]; @@ -3164,7 +3164,7 @@ void SpellMgr::LoadSpellLearnSpells() // talent or passive spells or skill-step spells auto-casted and not need dependent learning, // pet teaching spells don't must be dependent learning (casted) // other required explicit dependent learning - dbc_node.autoLearned = entry->EffectImplicitTargetA[i]==TARGET_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(entry) || IsSpellHaveEffect(entry,SPELL_EFFECT_SKILL_STEP); + dbc_node.autoLearned = entry->EffectImplicitTargetA[i] == TARGET_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(entry) || IsSpellHaveEffect(entry, SPELL_EFFECT_SKILL_STEP); SpellLearnSpellMapBounds db_node_bounds = GetSpellLearnSpellMapBounds(spell); @@ -3174,7 +3174,7 @@ void SpellMgr::LoadSpellLearnSpells() if (itr->second.spell == dbc_node.spell) { sLog.outErrorDb("Spell %u auto-learn spell %u in spell.dbc then the record in `spell_learn_spell` is redundant, please fix DB.", - spell,dbc_node.spell); + spell, dbc_node.spell); found = true; break; } @@ -3182,7 +3182,7 @@ void SpellMgr::LoadSpellLearnSpells() if (!found) // add new spell-spell pair if not found { - mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell,dbc_node)); + mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell, dbc_node)); ++dbc_count; } } @@ -3227,7 +3227,7 @@ void SpellMgr::LoadSpellScriptTarget() if (!spellProto) { - sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not exist.",spellId,targetEntry); + sLog.outErrorDb("Table `spell_script_target`: spellId %u listed for TargetEntry %u does not exist.", spellId, targetEntry); continue; } @@ -3259,7 +3259,7 @@ void SpellMgr::LoadSpellScriptTarget() if (type >= MAX_SPELL_TARGET_TYPE) { - sLog.outErrorDb("Table `spell_script_target`: target type %u for TargetEntry %u is incorrect.",type,targetEntry); + sLog.outErrorDb("Table `spell_script_target`: target type %u for TargetEntry %u is incorrect.", type, targetEntry); continue; } @@ -3273,7 +3273,7 @@ void SpellMgr::LoadSpellScriptTarget() if (!sGOStorage.LookupEntry(targetEntry)) { - sLog.outErrorDb("Table `spell_script_target`: gameobject template entry %u does not exist.",targetEntry); + sLog.outErrorDb("Table `spell_script_target`: gameobject template entry %u does not exist.", targetEntry); continue; } break; @@ -3281,7 +3281,7 @@ void SpellMgr::LoadSpellScriptTarget() default: if (!targetEntry) { - sLog.outErrorDb("Table `spell_script_target`: target entry == 0 for not GO target type (%u).",type); + sLog.outErrorDb("Table `spell_script_target`: target entry == 0 for not GO target type (%u).", type); continue; } if (const CreatureInfo* cInfo = sCreatureStorage.LookupEntry(targetEntry)) @@ -3294,13 +3294,13 @@ void SpellMgr::LoadSpellScriptTarget() } else { - sLog.outErrorDb("Table `spell_script_target`: creature template entry %u does not exist.",targetEntry); + sLog.outErrorDb("Table `spell_script_target`: creature template entry %u does not exist.", targetEntry); continue; } break; } - mSpellScriptTarget.insert(SpellScriptTarget::value_type(spellId,SpellTargetEntry(SpellTargetType(type),targetEntry))); + mSpellScriptTarget.insert(SpellScriptTarget::value_type(spellId, SpellTargetEntry(SpellTargetType(type), targetEntry))); ++count; } @@ -3376,7 +3376,7 @@ void SpellMgr::LoadSpellPetAuras() continue; } - SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find((spell<<8) + eff); + SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find((spell << 8) + eff); if (itr != mSpellPetAuraMap.end()) { itr->second.AddAura(pet, aura); @@ -3406,7 +3406,7 @@ void SpellMgr::LoadSpellPetAuras() } PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[eff] == TARGET_PET, spellInfo->CalculateSimpleValue(eff)); - mSpellPetAuraMap[(spell<<8) + eff] = pa; + mSpellPetAuraMap[(spell << 8) + eff] = pa; } ++count; @@ -3436,8 +3436,8 @@ void SpellMgr::LoadPetLevelupSpellMap() if (!skillLine) continue; - if (skillLine->skillId!=creatureFamily->skillLine[0] && - (!creatureFamily->skillLine[1] || skillLine->skillId!=creatureFamily->skillLine[1])) + if (skillLine->skillId != creatureFamily->skillLine[0] && + (!creatureFamily->skillLine[1] || skillLine->skillId != creatureFamily->skillLine[1])) continue; if (skillLine->learnOnGetSkill != ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL) @@ -3451,7 +3451,7 @@ void SpellMgr::LoadPetLevelupSpellMap() if (spellSet.empty()) ++family_count; - spellSet.insert(PetLevelupSpellSet::value_type(spell->spellLevel,spell->Id)); + spellSet.insert(PetLevelupSpellSet::value_type(spell->spellLevel, spell->Id)); count++; } } @@ -3510,7 +3510,7 @@ bool SpellMgr::LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefault void SpellMgr::LoadPetDefaultSpells() { - MANGOS_ASSERT(MAX_CREATURE_SPELL_DATA_SLOT==CREATURE_MAX_SPELLS); + MANGOS_ASSERT(MAX_CREATURE_SPELL_DATA_SLOT == CREATURE_MAX_SPELLS); mPetDefaultSpellsMap.clear(); @@ -3552,7 +3552,7 @@ void SpellMgr::LoadPetDefaultSpells() for (int k = 0; k < MAX_EFFECT_INDEX; ++k) { - if (spellEntry->Effect[k]==SPELL_EFFECT_SUMMON || spellEntry->Effect[k]==SPELL_EFFECT_SUMMON_PET) + if (spellEntry->Effect[k] == SPELL_EFFECT_SUMMON || spellEntry->Effect[k] == SPELL_EFFECT_SUMMON_PET) { uint32 creature_id = spellEntry->EffectMiscValue[k]; CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(creature_id); @@ -3614,9 +3614,9 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) if (msg) { if (pl) - ChatHandler(pl).PSendSysMessage("Craft spell %u not have create item entry.",spellInfo->Id); + ChatHandler(pl).PSendSysMessage("Craft spell %u not have create item entry.", spellInfo->Id); else - sLog.outErrorDb("Craft spell %u not have create item entry.",spellInfo->Id); + sLog.outErrorDb("Craft spell %u not have create item entry.", spellInfo->Id); } return false; } @@ -3628,9 +3628,9 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) if (msg) { if (pl) - ChatHandler(pl).PSendSysMessage("Craft spell %u create item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->EffectItemType[i]); + ChatHandler(pl).PSendSysMessage("Craft spell %u create item (Entry: %u) but item does not exist in item_template.", spellInfo->Id, spellInfo->EffectItemType[i]); else - sLog.outErrorDb("Craft spell %u create item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->EffectItemType[i]); + sLog.outErrorDb("Craft spell %u create item (Entry: %u) but item does not exist in item_template.", spellInfo->Id, spellInfo->EffectItemType[i]); } return false; } @@ -3641,14 +3641,14 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) case SPELL_EFFECT_LEARN_SPELL: { SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(spellInfo->EffectTriggerSpell[i]); - if (!IsSpellValid(spellInfo2,pl,msg)) + if (!IsSpellValid(spellInfo2, pl, msg)) { if (msg) { if (pl) - ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[i]); + ChatHandler(pl).PSendSysMessage("Spell %u learn to broken spell %u, and then...", spellInfo->Id, spellInfo->EffectTriggerSpell[i]); else - sLog.outErrorDb("Spell %u learn to invalid spell %u, and then...",spellInfo->Id,spellInfo->EffectTriggerSpell[i]); + sLog.outErrorDb("Spell %u learn to invalid spell %u, and then...", spellInfo->Id, spellInfo->EffectTriggerSpell[i]); } return false; } @@ -3666,9 +3666,9 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) if (msg) { if (pl) - ChatHandler(pl).PSendSysMessage("Craft spell %u requires reagent item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->Reagent[j]); + ChatHandler(pl).PSendSysMessage("Craft spell %u requires reagent item (Entry: %u) but item does not exist in item_template.", spellInfo->Id, spellInfo->Reagent[j]); else - sLog.outErrorDb("Craft spell %u requires reagent item (Entry: %u) but item does not exist in item_template.",spellInfo->Id,spellInfo->Reagent[j]); + sLog.outErrorDb("Craft spell %u requires reagent item (Entry: %u) but item does not exist in item_template.", spellInfo->Id, spellInfo->Reagent[j]); } return false; } @@ -3747,7 +3747,7 @@ void SpellMgr::LoadSpellAreas() continue; // duplicate by requirements - ok =false; + ok = false; break; } @@ -3761,13 +3761,13 @@ void SpellMgr::LoadSpellAreas() if (spellArea.areaId && !GetAreaEntryByAreaID(spellArea.areaId)) { - sLog.outErrorDb("Spell %u listed in `spell_area` have wrong area (%u) requirement", spell,spellArea.areaId); + sLog.outErrorDb("Spell %u listed in `spell_area` have wrong area (%u) requirement", spell, spellArea.areaId); continue; } if (spellArea.questStart && !sObjectMgr.GetQuestTemplate(spellArea.questStart)) { - sLog.outErrorDb("Spell %u listed in `spell_area` have wrong start quest (%u) requirement", spell,spellArea.questStart); + sLog.outErrorDb("Spell %u listed in `spell_area` have wrong start quest (%u) requirement", spell, spellArea.questStart); continue; } @@ -3775,13 +3775,13 @@ void SpellMgr::LoadSpellAreas() { if (!sObjectMgr.GetQuestTemplate(spellArea.questEnd)) { - sLog.outErrorDb("Spell %u listed in `spell_area` have wrong end quest (%u) requirement", spell,spellArea.questEnd); + sLog.outErrorDb("Spell %u listed in `spell_area` have wrong end quest (%u) requirement", spell, spellArea.questEnd); continue; } - if (spellArea.questEnd==spellArea.questStart && !spellArea.questStartCanActive) + if (spellArea.questEnd == spellArea.questStart && !spellArea.questStartCanActive) { - sLog.outErrorDb("Spell %u listed in `spell_area` have quest (%u) requirement for start and end in same time", spell,spellArea.questEnd); + sLog.outErrorDb("Spell %u listed in `spell_area` have quest (%u) requirement for start and end in same time", spell, spellArea.questEnd); continue; } } @@ -3791,7 +3791,7 @@ void SpellMgr::LoadSpellAreas() SpellEntry const* spellInfo = sSpellStore.LookupEntry(abs(spellArea.auraSpell)); if (!spellInfo) { - sLog.outErrorDb("Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell,abs(spellArea.auraSpell)); + sLog.outErrorDb("Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell, abs(spellArea.auraSpell)); continue; } @@ -3802,11 +3802,11 @@ void SpellMgr::LoadSpellAreas() case SPELL_AURA_GHOST: break; default: - sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell requirement (%u) without dummy/phase/ghost aura in effect 0", spell,abs(spellArea.auraSpell)); + sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell requirement (%u) without dummy/phase/ghost aura in effect 0", spell, abs(spellArea.auraSpell)); continue; } - if (uint32(abs(spellArea.auraSpell))==spellArea.spellId) + if (uint32(abs(spellArea.auraSpell)) == spellArea.spellId) { sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell, abs(spellArea.auraSpell)); continue; @@ -3828,7 +3828,7 @@ void SpellMgr::LoadSpellAreas() if (chain) { - sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell,spellArea.auraSpell); + sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell, spellArea.auraSpell); continue; } @@ -3844,46 +3844,46 @@ void SpellMgr::LoadSpellAreas() if (chain) { - sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell,spellArea.auraSpell); + sLog.outErrorDb("Spell %u listed in `spell_area` have aura spell (%u) requirement that itself autocast from aura", spell, spellArea.auraSpell); continue; } } } - if (spellArea.raceMask && (spellArea.raceMask & RACEMASK_ALL_PLAYABLE)==0) + if (spellArea.raceMask && (spellArea.raceMask & RACEMASK_ALL_PLAYABLE) == 0) { - sLog.outErrorDb("Spell %u listed in `spell_area` have wrong race mask (%u) requirement", spell,spellArea.raceMask); + sLog.outErrorDb("Spell %u listed in `spell_area` have wrong race mask (%u) requirement", spell, spellArea.raceMask); continue; } - if (spellArea.gender!=GENDER_NONE && spellArea.gender!=GENDER_FEMALE && spellArea.gender!=GENDER_MALE) + if (spellArea.gender != GENDER_NONE && spellArea.gender != GENDER_FEMALE && spellArea.gender != GENDER_MALE) { - sLog.outErrorDb("Spell %u listed in `spell_area` have wrong gender (%u) requirement", spell,spellArea.gender); + sLog.outErrorDb("Spell %u listed in `spell_area` have wrong gender (%u) requirement", spell, spellArea.gender); continue; } - SpellArea const* sa = &mSpellAreaMap.insert(SpellAreaMap::value_type(spell,spellArea))->second; + SpellArea const* sa = &mSpellAreaMap.insert(SpellAreaMap::value_type(spell, spellArea))->second; // for search by current zone/subzone at zone/subzone change if (spellArea.areaId) - mSpellAreaForAreaMap.insert(SpellAreaForAreaMap::value_type(spellArea.areaId,sa)); + mSpellAreaForAreaMap.insert(SpellAreaForAreaMap::value_type(spellArea.areaId, sa)); // for search at quest start/reward if (spellArea.questStart) { if (spellArea.questStartCanActive) - mSpellAreaForActiveQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart,sa)); + mSpellAreaForActiveQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart, sa)); else - mSpellAreaForQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart,sa)); + mSpellAreaForQuestMap.insert(SpellAreaForQuestMap::value_type(spellArea.questStart, sa)); } // for search at quest start/reward if (spellArea.questEnd) - mSpellAreaForQuestEndMap.insert(SpellAreaForQuestMap::value_type(spellArea.questEnd,sa)); + mSpellAreaForQuestEndMap.insert(SpellAreaForQuestMap::value_type(spellArea.questEnd, sa)); // for search at aura apply if (spellArea.auraSpell) - mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(abs(spellArea.auraSpell),sa)); + mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(abs(spellArea.auraSpell), sa)); ++count; } @@ -3905,7 +3905,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell AreaGroupEntry const* groupEntry = sAreaGroupStore.LookupEntry(areaGroupId); while (groupEntry) { - for (uint32 i=0; i<6; ++i) + for (uint32 i = 0; i < 6; ++i) if (groupEntry->AreaId[i] == zone_id || groupEntry->AreaId[i] == area_id) found = true; if (found || !groupEntry->nextGroup) @@ -3941,7 +3941,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell { for (SpellAreaMap::const_iterator itr = saBounds.first; itr != saBounds.second; ++itr) { - if (itr->second.IsFitToRequirements(player,zone_id,area_id)) + if (itr->second.IsFitToRequirements(player, zone_id, area_id)) return SPELL_CAST_OK; } return SPELL_FAILED_INCORRECT_AREA; @@ -3993,7 +3993,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell MapEntry const* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry) return SPELL_FAILED_INCORRECT_AREA; - return mapEntry->IsBattleGround()? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; + return mapEntry->IsBattleGround() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 44521: // Preparation { @@ -4001,7 +4001,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell return SPELL_FAILED_REQUIRES_AREA; BattleGround* bg = player->GetBattleGround(); - return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; + return bg && bg->GetStatus() == STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_BATTLEGROUNDS; } case 32724: // Gold Team (Alliance) case 32725: // Green Team (Alliance) @@ -4018,7 +4018,7 @@ SpellCastResult SpellMgr::GetSpellAllowedInLocationError(SpellEntry const* spell return SPELL_FAILED_REQUIRES_AREA; BattleGround* bg = player->GetBattleGround(); - return bg && bg->GetStatus()==STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; + return bg && bg->GetStatus() == STATUS_WAIT_JOIN ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; } case 74410: // Arena - Dampening return player && player->InArena() ? SPELL_CAST_OK : SPELL_FAILED_ONLY_IN_ARENA; @@ -4049,7 +4049,7 @@ void SpellMgr::LoadSkillLineAbilityMap() if (!SkillInfo) continue; - mSkillLineAbilityMap.insert(SkillLineAbilityMap::value_type(SkillInfo->spellId,SkillInfo)); + mSkillLineAbilityMap.insert(SkillLineAbilityMap::value_type(SkillInfo->spellId, SkillInfo)); ++count; } @@ -4075,7 +4075,7 @@ void SpellMgr::LoadSkillRaceClassInfoMap() if (!sSkillLineStore.LookupEntry(skillRCInfo->skillId)) continue; - mSkillRaceClassInfoMap.insert(SkillRaceClassInfoMap::value_type(skillRCInfo->skillId,skillRCInfo)); + mSkillRaceClassInfoMap.insert(SkillRaceClassInfoMap::value_type(skillRCInfo->skillId, skillRCInfo)); ++count; } @@ -4090,7 +4090,7 @@ void SpellMgr::CheckUsedSpells(char const* table) uint32 countMasks = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 - QueryResult* result = WorldDatabase.PQuery("SELECT spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMaskB,SpellIcon,SpellVisual,SpellCategory,EffectType,EffectAura,EffectIdx,Name,Code FROM %s",table); + QueryResult* result = WorldDatabase.PQuery("SELECT spellid,SpellFamilyName,SpellFamilyMaskA,SpellFamilyMaskB,SpellIcon,SpellVisual,SpellCategory,EffectType,EffectAura,EffectIdx,Name,Code FROM %s", table); if (!result) { @@ -4099,7 +4099,7 @@ void SpellMgr::CheckUsedSpells(char const* table) bar.step(); sLog.outString(); - sLog.outErrorDb("`%s` table is empty!",table); + sLog.outErrorDb("`%s` table is empty!", table); return; } @@ -4128,46 +4128,46 @@ void SpellMgr::CheckUsedSpells(char const* table) if (family < -1 || family > SPELLFAMILY_PET) { - sLog.outError("Table '%s' for spell %u have wrong SpellFamily value(%u), skipped.",table,spell,family); + sLog.outError("Table '%s' for spell %u have wrong SpellFamily value(%u), skipped.", table, spell, family); continue; } // TODO: spellIcon check need dbc loading if (spellIcon < -1) { - sLog.outError("Table '%s' for spell %u have wrong SpellIcon value(%u), skipped.",table,spell,spellIcon); + sLog.outError("Table '%s' for spell %u have wrong SpellIcon value(%u), skipped.", table, spell, spellIcon); continue; } // TODO: spellVisual check need dbc loading if (spellVisual < -1) { - sLog.outError("Table '%s' for spell %u have wrong SpellVisual value(%u), skipped.",table,spell,spellVisual); + sLog.outError("Table '%s' for spell %u have wrong SpellVisual value(%u), skipped.", table, spell, spellVisual); continue; } // TODO: for spellCategory better check need dbc loading - if (category < -1 || (category >=0 && sSpellCategoryStore.find(category) == sSpellCategoryStore.end())) + if (category < -1 || (category >= 0 && sSpellCategoryStore.find(category) == sSpellCategoryStore.end())) { - sLog.outError("Table '%s' for spell %u have wrong SpellCategory value(%u), skipped.",table,spell,category); + sLog.outError("Table '%s' for spell %u have wrong SpellCategory value(%u), skipped.", table, spell, category); continue; } if (effectType < -1 || effectType >= TOTAL_SPELL_EFFECTS) { - sLog.outError("Table '%s' for spell %u have wrong SpellEffect type value(%u), skipped.",table,spell,effectType); + sLog.outError("Table '%s' for spell %u have wrong SpellEffect type value(%u), skipped.", table, spell, effectType); continue; } if (auraType < -1 || auraType >= TOTAL_AURAS) { - sLog.outError("Table '%s' for spell %u have wrong SpellAura type value(%u), skipped.",table,spell,auraType); + sLog.outError("Table '%s' for spell %u have wrong SpellAura type value(%u), skipped.", table, spell, auraType); continue; } if (effectIdx < -1 || effectIdx >= 3) { - sLog.outError("Table '%s' for spell %u have wrong EffectIdx value(%u), skipped.",table,spell,effectIdx); + sLog.outError("Table '%s' for spell %u have wrong EffectIdx value(%u), skipped.", table, spell, effectIdx); continue; } @@ -4180,13 +4180,13 @@ void SpellMgr::CheckUsedSpells(char const* table) SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell); if (!spellEntry) { - sLog.outError("Spell %u '%s' not exist but used in %s.",spell,name.c_str(),code.c_str()); + sLog.outError("Spell %u '%s' not exist but used in %s.", spell, name.c_str(), code.c_str()); continue; } if (family >= 0 && spellEntry->SpellFamilyName != uint32(family)) { - sLog.outError("Spell %u '%s' family(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->SpellFamilyName,family,code.c_str()); + sLog.outError("Spell %u '%s' family(%u) <> %u but used in %s.", spell, name.c_str(), spellEntry->SpellFamilyName, family, code.c_str()); continue; } @@ -4206,7 +4206,7 @@ void SpellMgr::CheckUsedSpells(char const* table) { if (!spellEntry->IsFitToFamilyMask(familyMaskA, familyMaskB)) { - sLog.outError("Spell %u '%s' not fit to (" I64FMT "," I32FMT ") but used in %s.",spell,name.c_str(),familyMaskA,familyMaskB,code.c_str()); + sLog.outError("Spell %u '%s' not fit to (" I64FMT "," I32FMT ") but used in %s.", spell, name.c_str(), familyMaskA, familyMaskB, code.c_str()); continue; } @@ -4215,19 +4215,19 @@ void SpellMgr::CheckUsedSpells(char const* table) if (spellIcon >= 0 && spellEntry->SpellIconID != uint32(spellIcon)) { - sLog.outError("Spell %u '%s' icon(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->SpellIconID,spellIcon,code.c_str()); + sLog.outError("Spell %u '%s' icon(%u) <> %u but used in %s.", spell, name.c_str(), spellEntry->SpellIconID, spellIcon, code.c_str()); continue; } if (spellVisual >= 0 && spellEntry->SpellVisual[0] != uint32(spellVisual)) { - sLog.outError("Spell %u '%s' visual(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->SpellVisual[0],spellVisual,code.c_str()); + sLog.outError("Spell %u '%s' visual(%u) <> %u but used in %s.", spell, name.c_str(), spellEntry->SpellVisual[0], spellVisual, code.c_str()); continue; } if (category >= 0 && spellEntry->Category != uint32(category)) { - sLog.outError("Spell %u '%s' category(%u) <> %u but used in %s.",spell,name.c_str(),spellEntry->Category,category,code.c_str()); + sLog.outError("Spell %u '%s' category(%u) <> %u but used in %s.", spell, name.c_str(), spellEntry->Category, category, code.c_str()); continue; } @@ -4235,28 +4235,28 @@ void SpellMgr::CheckUsedSpells(char const* table) { if (effectType >= 0 && spellEntry->Effect[effectIdx] != uint32(effectType)) { - sLog.outError("Spell %u '%s' effect%d <> %u but used in %s.",spell,name.c_str(),effectIdx+1,effectType,code.c_str()); + sLog.outError("Spell %u '%s' effect%d <> %u but used in %s.", spell, name.c_str(), effectIdx + 1, effectType, code.c_str()); continue; } if (auraType >= 0 && spellEntry->EffectApplyAuraName[effectIdx] != uint32(auraType)) { - sLog.outError("Spell %u '%s' aura%d <> %u but used in %s.",spell,name.c_str(),effectIdx+1,auraType,code.c_str()); + sLog.outError("Spell %u '%s' aura%d <> %u but used in %s.", spell, name.c_str(), effectIdx + 1, auraType, code.c_str()); continue; } } else { - if (effectType >= 0 && !IsSpellHaveEffect(spellEntry,SpellEffects(effectType))) + if (effectType >= 0 && !IsSpellHaveEffect(spellEntry, SpellEffects(effectType))) { - sLog.outError("Spell %u '%s' not have effect %u but used in %s.",spell,name.c_str(),effectType,code.c_str()); + sLog.outError("Spell %u '%s' not have effect %u but used in %s.", spell, name.c_str(), effectType, code.c_str()); continue; } if (auraType >= 0 && !IsSpellHaveAura(spellEntry, AuraType(auraType))) { - sLog.outError("Spell %u '%s' not have aura %u but used in %s.",spell,name.c_str(),auraType,code.c_str()); + sLog.outError("Spell %u '%s' not have aura %u but used in %s.", spell, name.c_str(), auraType, code.c_str()); continue; } } @@ -4272,7 +4272,7 @@ void SpellMgr::CheckUsedSpells(char const* table) if (!spellEntry) continue; - if (family >=0 && spellEntry->SpellFamilyName != uint32(family)) + if (family >= 0 && spellEntry->SpellFamilyName != uint32(family)) continue; if (familyMaskA != UI64LIT(0xFFFFFFFFFFFFFFFF) || familyMaskB != 0xFFFFFFFF) @@ -4300,18 +4300,18 @@ void SpellMgr::CheckUsedSpells(char const* table) if (effectIdx >= 0) { - if (effectType >=0 && spellEntry->Effect[effectIdx] != uint32(effectType)) + if (effectType >= 0 && spellEntry->Effect[effectIdx] != uint32(effectType)) continue; - if (auraType >=0 && spellEntry->EffectApplyAuraName[effectIdx] != uint32(auraType)) + if (auraType >= 0 && spellEntry->EffectApplyAuraName[effectIdx] != uint32(auraType)) continue; } else { - if (effectType >=0 && !IsSpellHaveEffect(spellEntry,SpellEffects(effectType))) + if (effectType >= 0 && !IsSpellHaveEffect(spellEntry, SpellEffects(effectType))) continue; - if (auraType >=0 && !IsSpellHaveAura(spellEntry,AuraType(auraType))) + if (auraType >= 0 && !IsSpellHaveAura(spellEntry, AuraType(auraType))) continue; } @@ -4323,10 +4323,10 @@ void SpellMgr::CheckUsedSpells(char const* table) { if (effectIdx >= 0) sLog.outError("Spells '%s' not found for family %i (" I64FMT "," I32FMT ") icon(%i) visual(%i) category(%i) effect%d(%i) aura%d(%i) but used in %s", - name.c_str(),family,familyMaskA,familyMaskB,spellIcon,spellVisual,category,effectIdx+1,effectType,effectIdx+1,auraType,code.c_str()); + name.c_str(), family, familyMaskA, familyMaskB, spellIcon, spellVisual, category, effectIdx + 1, effectType, effectIdx + 1, auraType, code.c_str()); else sLog.outError("Spells '%s' not found for family %i (" I64FMT "," I32FMT ") icon(%i) visual(%i) category(%i) effect(%i) aura(%i) but used in %s", - name.c_str(),family,familyMaskA,familyMaskB,spellIcon,spellVisual,category,effectType,auraType,code.c_str()); + name.c_str(), family, familyMaskA, familyMaskB, spellIcon, spellVisual, category, effectType, auraType, code.c_str()); continue; } } @@ -4432,23 +4432,23 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellEntry const* spellproto if (!mechanic) return DIMINISHING_NONE; - if (mechanic & ((1<<(MECHANIC_STUN-1))|(1<<(MECHANIC_SHACKLE-1)))) + if (mechanic & ((1 << (MECHANIC_STUN - 1)) | (1 << (MECHANIC_SHACKLE - 1)))) return triggered ? DIMINISHING_TRIGGER_STUN : DIMINISHING_CONTROL_STUN; - if (mechanic & ((1<<(MECHANIC_SLEEP-1))|(1<<(MECHANIC_FREEZE-1)))) + if (mechanic & ((1 << (MECHANIC_SLEEP - 1)) | (1 << (MECHANIC_FREEZE - 1)))) return DIMINISHING_FREEZE_SLEEP; - if (mechanic & ((1<<(MECHANIC_KNOCKOUT-1))|(1<<(MECHANIC_POLYMORPH-1))|(1<<(MECHANIC_SAPPED-1)))) + if (mechanic & ((1 << (MECHANIC_KNOCKOUT - 1)) | (1 << (MECHANIC_POLYMORPH - 1)) | (1 << (MECHANIC_SAPPED - 1)))) return DIMINISHING_DISORIENT; - if (mechanic & (1<<(MECHANIC_ROOT-1))) + if (mechanic & (1 << (MECHANIC_ROOT - 1))) return triggered ? DIMINISHING_TRIGGER_ROOT : DIMINISHING_CONTROL_ROOT; - if (mechanic & ((1<<(MECHANIC_FEAR-1))|(1<<(MECHANIC_CHARM-1))|(1<<(MECHANIC_TURN-1)))) + if (mechanic & ((1 << (MECHANIC_FEAR - 1)) | (1 << (MECHANIC_CHARM - 1)) | (1 << (MECHANIC_TURN - 1)))) return DIMINISHING_FEAR_CHARM_BLIND; - if (mechanic & ((1<<(MECHANIC_SILENCE-1))|(1<<(MECHANIC_INTERRUPT-1)))) + if (mechanic & ((1 << (MECHANIC_SILENCE - 1)) | (1 << (MECHANIC_INTERRUPT - 1)))) return DIMINISHING_SILENCE; - if (mechanic & (1<<(MECHANIC_DISARM-1))) + if (mechanic & (1 << (MECHANIC_DISARM - 1))) return DIMINISHING_DISARM; - if (mechanic & (1<<(MECHANIC_BANISH-1))) + if (mechanic & (1 << (MECHANIC_BANISH - 1))) return DIMINISHING_BANISH; - if (mechanic & (1<<(MECHANIC_HORROR-1))) + if (mechanic & (1 << (MECHANIC_HORROR - 1))) return DIMINISHING_HORROR; return DIMINISHING_NONE; diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 2085238da..2761adbc6 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -103,7 +103,7 @@ WeaponAttackType GetWeaponAttackType(SpellEntry const* spellInfo); inline bool IsSpellHaveEffect(SpellEntry const* spellInfo, SpellEffects effect) { for (int i = 0; i < MAX_EFFECT_INDEX; ++i) - if (SpellEffects(spellInfo->Effect[i])==effect) + if (SpellEffects(spellInfo->Effect[i]) == effect) return true; return false; } @@ -167,14 +167,14 @@ bool IsCastEndProcModifierAura(SpellEntry const* spellInfo, SpellEffectIndex eff inline bool IsSpellHaveAura(SpellEntry const* spellInfo, AuraType aura) { for (int i = 0; i < MAX_EFFECT_INDEX; ++i) - if (AuraType(spellInfo->EffectApplyAuraName[i])==aura) + if (AuraType(spellInfo->EffectApplyAuraName[i]) == aura) return true; return false; } inline bool IsSpellLastAuraEffect(SpellEntry const* spellInfo, SpellEffectIndex effecIdx) { - for (int i = effecIdx+1; i < MAX_EFFECT_INDEX; ++i) + for (int i = effecIdx + 1; i < MAX_EFFECT_INDEX; ++i) if (spellInfo->EffectApplyAuraName[i]) return false; return true; @@ -209,15 +209,15 @@ inline bool IsLootCraftingSpell(SpellEntry const* spellInfo) return (spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_RANDOM_ITEM || // different random cards from Inscription (121==Virtuoso Inking Set category) r without explicit item (spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_ITEM_2 && - (spellInfo->TotemCategory[0] != 0 || spellInfo->EffectItemType[0]==0))); + (spellInfo->TotemCategory[0] != 0 || spellInfo->EffectItemType[0] == 0))); } int32 CompareAuraRanks(uint32 spellId_1, uint32 spellId_2); // order from less to more strict -bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2); -bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2); -bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2); +bool IsSingleFromSpellSpecificPerTargetPerCaster(SpellSpecific spellSpec1, SpellSpecific spellSpec2); +bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1, SpellSpecific spellSpec2); +bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1, SpellSpecific spellSpec2); bool IsPassiveSpell(uint32 spellId); bool IsPassiveSpell(SpellEntry const* spellProto); @@ -227,7 +227,7 @@ inline bool IsPassiveSpellStackableWithRanks(SpellEntry const* spellProto) if (!IsPassiveSpell(spellProto)) return false; - return !IsSpellHaveEffect(spellProto,SPELL_EFFECT_APPLY_AURA); + return !IsSpellHaveEffect(spellProto, SPELL_EFFECT_APPLY_AURA); } inline bool IsSpellRemoveAllMovementAndControlLossEffects(SpellEntry const* spellProto) @@ -468,7 +468,7 @@ inline bool IsNeedCastSpellAtFormApply(SpellEntry const* spellInfo, ShapeshiftFo return false; // passive spells with SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT are already active without shapeshift, do no recast! - return (spellInfo->Stances & (1<<(form-1)) && !spellInfo->HasAttribute(SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT)); + return (spellInfo->Stances & (1 << (form - 1)) && !spellInfo->HasAttribute(SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT)); } @@ -494,7 +494,7 @@ inline uint32 GetSpellMechanicMask(SpellEntry const* spellInfo, uint32 effectMas continue; if (spellInfo->EffectMechanic[i]) - mask |= 1 << (spellInfo->EffectMechanic[i]-1); + mask |= 1 << (spellInfo->EffectMechanic[i] - 1); } return mask; @@ -505,9 +505,9 @@ inline uint32 GetAllSpellMechanicMask(SpellEntry const* spellInfo) uint32 mask = 0; if (spellInfo->Mechanic) mask |= 1 << (spellInfo->Mechanic - 1); - for (int i=0; i< MAX_EFFECT_INDEX; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) if (spellInfo->EffectMechanic[i]) - mask |= 1 << (spellInfo->EffectMechanic[i]-1); + mask |= 1 << (spellInfo->EffectMechanic[i] - 1); return mask; } @@ -679,13 +679,13 @@ enum SpellTargetType struct SpellTargetEntry { - SpellTargetEntry(SpellTargetType type_,uint32 targetEntry_) : type(type_), targetEntry(targetEntry_) {} + SpellTargetEntry(SpellTargetType type_, uint32 targetEntry_) : type(type_), targetEntry(targetEntry_) {} SpellTargetType type; uint32 targetEntry; }; -typedef std::multimap SpellScriptTarget; -typedef std::pair SpellScriptTargetBounds; +typedef std::multimap SpellScriptTarget; +typedef std::pair SpellScriptTargetBounds; // coordinates for spells (accessed using SpellMgr functions) struct SpellTargetPosition @@ -767,12 +767,12 @@ struct SpellArea bool IsFitToRequirements(Player const* player, uint32 newZone, uint32 newArea) const; }; -typedef std::multimap SpellAreaMap; -typedef std::multimap SpellAreaForQuestMap; -typedef std::multimap SpellAreaForAuraMap; -typedef std::multimap SpellAreaForAreaMap; -typedef std::pair SpellAreaMapBounds; -typedef std::pair SpellAreaForQuestMapBounds; +typedef std::multimap SpellAreaMap; +typedef std::multimap SpellAreaForQuestMap; +typedef std::multimap SpellAreaForAuraMap; +typedef std::multimap SpellAreaForAreaMap; +typedef std::pair SpellAreaMapBounds; +typedef std::pair SpellAreaForQuestMapBounds; typedef std::pair SpellAreaForAuraMapBounds; typedef std::pair SpellAreaForAreaMapBounds; @@ -808,13 +808,13 @@ struct SpellLearnSpellNode }; typedef std::multimap SpellLearnSpellMap; -typedef std::pair SpellLearnSpellMapBounds; +typedef std::pair SpellLearnSpellMapBounds; typedef std::multimap SkillLineAbilityMap; -typedef std::pair SkillLineAbilityMapBounds; +typedef std::pair SkillLineAbilityMapBounds; typedef std::multimap SkillRaceClassInfoMap; -typedef std::pair SkillRaceClassInfoMapBounds; +typedef std::pair SkillRaceClassInfoMapBounds; typedef std::multimap PetLevelupSpellSet; typedef std::map PetLevelupSpellMap; @@ -859,7 +859,7 @@ class SpellMgr uint32 GetSpellElixirMask(uint32 spellid) const { SpellElixirMap::const_iterator itr = mSpellElixirs.find(spellid); - if (itr==mSpellElixirs.end()) + if (itr == mSpellElixirs.end()) return 0x0; return itr->second; @@ -868,7 +868,7 @@ class SpellMgr SpellSpecific GetSpellElixirSpecific(uint32 spellid) const { uint32 mask = GetSpellElixirMask(spellid); - if ((mask & ELIXIR_FLASK_MASK)==ELIXIR_FLASK_MASK) + if ((mask & ELIXIR_FLASK_MASK) == ELIXIR_FLASK_MASK) return SPELL_FLASK_ELIXIR; else if (mask & ELIXIR_BATTLE_MASK) return SPELL_BATTLE_ELIXIR; @@ -913,7 +913,7 @@ class SpellMgr float GetItemEnchantProcChance(uint32 spellid) const { SpellProcItemEnchantMap::const_iterator itr = mSpellProcItemEnchantMap.find(spellid); - if (itr==mSpellProcItemEnchantMap.end()) + if (itr == mSpellProcItemEnchantMap.end()) return 0.0f; return itr->second; @@ -976,7 +976,7 @@ class SpellMgr for (SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr) { worker(itr->second); - doForHighRanks(itr->second,worker); + doForHighRanks(itr->second, worker); } } @@ -990,7 +990,7 @@ class SpellMgr return 0; } - uint8 IsHighRankOfSpell(uint32 spell1,uint32 spell2) const + uint8 IsHighRankOfSpell(uint32 spell1, uint32 spell2) const { SpellChainMap::const_iterator itr = mSpellChains.find(spell1); @@ -1002,13 +1002,13 @@ class SpellMgr // check present in same rank chain for (; itr != mSpellChains.end(); itr = mSpellChains.find(itr->second.prev)) - if (itr->second.prev==spell2) + if (itr->second.prev == spell2) return true; return false; } - bool IsRankSpellDueToSpell(SpellEntry const* spellInfo_1,uint32 spellId_2) const; + bool IsRankSpellDueToSpell(SpellEntry const* spellInfo_1, uint32 spellId_2) const; bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const; bool canStackSpellRanksInSpellBook(SpellEntry const* spellInfo) const; bool IsRankedSpellNonStackableInSpellBook(SpellEntry const* spellInfo) const @@ -1038,11 +1038,11 @@ class SpellMgr return mSpellLearnSpells.equal_range(spell_id); } - bool IsSpellLearnToSpell(uint32 spell_id1,uint32 spell_id2) const + bool IsSpellLearnToSpell(uint32 spell_id1, uint32 spell_id2) const { SpellLearnSpellMapBounds bounds = GetSpellLearnSpellMapBounds(spell_id1); for (SpellLearnSpellMap::const_iterator i = bounds.first; i != bounds.second; ++i) - if (i->second.spell==spell_id2) + if (i->second.spell == spell_id2) return true; return false; } @@ -1077,7 +1077,7 @@ class SpellMgr PetAura const* GetPetAura(uint32 spell_id, SpellEffectIndex eff) { - SpellPetAuraMap::const_iterator itr = mSpellPetAuraMap.find((spell_id<<8) + eff); + SpellPetAuraMap::const_iterator itr = mSpellPetAuraMap.find((spell_id << 8) + eff); if (itr != mSpellPetAuraMap.end()) return &itr->second; else diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 7616fe8bd..511b04dc0 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -93,12 +93,12 @@ bool Player::UpdateStats(Stats stat) void Player::ApplySpellPowerBonus(int32 amount, bool apply) { - m_baseSpellPower+=apply?amount:-amount; + m_baseSpellPower += apply ? amount : -amount; // For speed just update for client ApplyModUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, amount, apply); for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, amount, apply);; + ApplyModUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, amount, apply);; } void Player::UpdateSpellDamageAndHealingBonus() @@ -109,7 +109,7 @@ void Player::UpdateSpellDamageAndHealingBonus() SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL)); // Get damage bonus for all schools for (int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) - SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS+i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i))); + SetStatInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + i, SpellBaseDamageBonusDone(SpellSchoolMask(1 << i))); } bool Player::UpdateAllStats() @@ -196,7 +196,7 @@ float Player::GetHealthBonusFromStamina() float baseStam = stamina < 20 ? stamina : 20; float moreStam = stamina - baseStam; - return baseStam + (moreStam*10.0f); + return baseStam + (moreStam * 10.0f); } float Player::GetManaBonusFromIntellect() @@ -206,7 +206,7 @@ float Player::GetManaBonusFromIntellect() float baseInt = intellect < 20 ? intellect : 20; float moreInt = intellect - baseInt; - return baseInt + (moreInt*15.0f); + return baseInt + (moreInt * 15.0f); } void Player::UpdateMaxHealth() @@ -240,7 +240,7 @@ void Player::UpdateMaxPower(Powers power) void Player::ApplyFeralAPBonus(int32 amount, bool apply) { - m_baseFeralAP+= apply ? amount:-amount; + m_baseFeralAP += apply ? amount : -amount; UpdateAttackPowerAndDamage(); } @@ -265,7 +265,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) { case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f; break; case CLASS_ROGUE: val2 = level + GetStat(STAT_AGILITY) - 10.0f; break; - case CLASS_WARRIOR:val2 = level + GetStat(STAT_AGILITY) - 10.0f; break; + case CLASS_WARRIOR: val2 = level + GetStat(STAT_AGILITY) - 10.0f; break; case CLASS_DRUID: switch (GetShapeshiftForm()) { @@ -284,12 +284,12 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) { switch (getClass()) { - case CLASS_WARRIOR: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - case CLASS_PALADIN: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - case CLASS_DEATH_KNIGHT: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; - case CLASS_ROGUE: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; - case CLASS_HUNTER: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; - case CLASS_SHAMAN: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; + case CLASS_WARRIOR: val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break; + case CLASS_PALADIN: val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break; + case CLASS_DEATH_KNIGHT: val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break; + case CLASS_ROGUE: val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; + case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; + case CLASS_SHAMAN: val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break; case CLASS_DRUID: { ShapeshiftForm form = GetShapeshiftForm(); @@ -327,14 +327,14 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) switch (form) { case FORM_CAT: - val2 = GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f + mLevelBonus + m_baseFeralAP + mBonusWeaponAtt; break; + val2 = GetStat(STAT_STRENGTH) * 2.0f + GetStat(STAT_AGILITY) - 20.0f + mLevelBonus + m_baseFeralAP + mBonusWeaponAtt; break; case FORM_BEAR: case FORM_DIREBEAR: - val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f + mLevelBonus + m_baseFeralAP + mBonusWeaponAtt; break; + val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f + mLevelBonus + m_baseFeralAP + mBonusWeaponAtt; break; case FORM_MOONKIN: - val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f + m_baseFeralAP + mBonusWeaponAtt; break; + val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP + mBonusWeaponAtt; break; default: - val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break; + val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break; } break; } @@ -352,7 +352,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged) //add dynamic flat mods if (ranged) { - if ((getClassMask() & CLASSMASK_WAND_USERS)==0) + if ((getClassMask() & CLASSMASK_WAND_USERS) == 0) { AuraList const& mRAPbyStat = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT); for (AuraList::const_iterator i = mRAPbyStat.begin(); i != mRAPbyStat.end(); ++i) @@ -421,9 +421,9 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, fl break; } - float att_speed = GetAPMultiplier(attType,normalized); + float att_speed = GetAPMultiplier(attType, normalized); - float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; + float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 14.0f * att_speed; float base_pct = GetModifierValue(unitMod, BASE_PCT); float total_value = GetModifierValue(unitMod, TOTAL_VALUE); float total_pct = GetModifierValue(unitMod, TOTAL_PCT); @@ -437,8 +437,8 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, fl if (lvl > 60) lvl = 60; - weapon_mindamage = lvl*0.85f*att_speed; - weapon_maxdamage = lvl*1.25f*att_speed; + weapon_mindamage = lvl * 0.85f * att_speed; + weapon_maxdamage = lvl * 1.25f * att_speed; } else if (!CanUseEquippedWeapon(attType)) // check if player not in form but still can't use weapon (broken/etc) { @@ -460,22 +460,22 @@ void Player::UpdateDamagePhysical(WeaponAttackType attType) float mindamage; float maxdamage; - CalculateMinMaxDamage(attType,false,mindamage,maxdamage); + CalculateMinMaxDamage(attType, false, mindamage, maxdamage); switch (attType) { case BASE_ATTACK: default: - SetStatFloatValue(UNIT_FIELD_MINDAMAGE,mindamage); - SetStatFloatValue(UNIT_FIELD_MAXDAMAGE,maxdamage); + SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage); + SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage); break; case OFF_ATTACK: - SetStatFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE,mindamage); - SetStatFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE,maxdamage); + SetStatFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, mindamage); + SetStatFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, maxdamage); break; case RANGED_ATTACK: - SetStatFloatValue(UNIT_FIELD_MINRANGEDDAMAGE,mindamage); - SetStatFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE,maxdamage); + SetStatFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, mindamage); + SetStatFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, maxdamage); break; } } @@ -586,7 +586,7 @@ void Player::UpdateParryPercentage() // No parry float value = 0.0f; - uint32 pclass = getClass()-1; + uint32 pclass = getClass() - 1; if (CanParry() && parry_cap[pclass] > 0.0f) { // Base parry @@ -634,7 +634,7 @@ void Player::UpdateDodgePercentage() // Dodge from rating diminishing += GetRatingBonusValue(CR_DODGE); // apply diminishing formula to diminishing dodge chance - uint32 pclass = getClass()-1; + uint32 pclass = getClass() - 1; float value = nondiminishing + (diminishing * dodge_cap[pclass] / (diminishing + dodge_cap[pclass] * m_diminishing_k[pclass])); value = value < 0.0f ? 0.0f : value; @@ -658,7 +658,7 @@ void Player::UpdateSpellCritChance(uint32 school) // Increase crit from SPELL_AURA_MOD_ALL_CRIT_CHANCE crit += GetTotalAuraModifier(SPELL_AURA_MOD_ALL_CRIT_CHANCE); // Increase crit by school from SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL - crit += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, 1<GetTypeId()==TYPEID_PLAYER) + if (owner && owner->GetTypeId() == TYPEID_PLAYER) { if (getPetType() == HUNTER_PET) //hunter pets benefit from owner's attack power { @@ -1107,9 +1107,9 @@ void Pet::UpdateDamagePhysical(WeaponAttackType attType) UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; - float att_speed = float(GetAttackTime(BASE_ATTACK))/1000.0f; + float att_speed = float(GetAttackTime(BASE_ATTACK)) / 1000.0f; - float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType)/ 14.0f * att_speed; + float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 14.0f * att_speed; float base_pct = GetModifierValue(unitMod, BASE_PCT); float total_value = GetModifierValue(unitMod, TOTAL_VALUE); float total_pct = GetModifierValue(unitMod, TOTAL_PCT); diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index 0438d4131..0e29641e7 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -27,7 +27,7 @@ //-----------------------------------------------// template -void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner) +void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner) { if (!i_target.isValid() || !i_target->IsInWorld()) return; @@ -38,7 +38,7 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner) float x, y, z; // prevent redundant micro-movement for pets, other followers. - if (i_offset && i_target->IsWithinDistInMap(&owner,2*i_offset)) + if (i_offset && i_target->IsWithinDistInMap(&owner, 2 * i_offset)) { if (!owner.movespline->Finalized()) return; @@ -94,33 +94,33 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T& owner) } template<> -void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float /*fDistance*/) +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float /*fDistance*/) { // nothing to do for Player } template<> -void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float /*fDistance*/) +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float /*fDistance*/) { // nothing to do for Player } template<> -void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float fDistance) +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float fDistance) { i_offset = fDistance; i_recalculateTravel = true; } template<> -void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float fDistance) +void TargetedMovementGeneratorMedium >::UpdateFinalDistance(float fDistance) { i_offset = fDistance; i_recalculateTravel = true; } template -bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_diff) +bool TargetedMovementGeneratorMedium::Update(T& owner, const uint32& time_diff) { if (!i_target.isValid() || !i_target->IsInWorld()) return false; @@ -192,13 +192,13 @@ 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<> void ChaseMovementGenerator::Initialize(Player& owner) { - owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); + owner.addUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE); _setTargetLocation(owner); } @@ -206,20 +206,20 @@ template<> void ChaseMovementGenerator::Initialize(Creature& owner) { owner.SetWalk(false); - owner.addUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); + owner.addUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE); _setTargetLocation(owner); } template void ChaseMovementGenerator::Finalize(T& owner) { - owner.clearUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); + owner.clearUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE); } template void ChaseMovementGenerator::Interrupt(T& owner) { - owner.clearUnitState(UNIT_STAT_CHASE|UNIT_STAT_CHASE_MOVE); + owner.clearUnitState(UNIT_STAT_CHASE | UNIT_STAT_CHASE_MOVE); } template @@ -254,15 +254,15 @@ void FollowMovementGenerator::_updateSpeed(Creature& u) if (!((Creature&)u).IsPet() || !i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid()) return; - u.UpdateSpeed(MOVE_RUN,true); - u.UpdateSpeed(MOVE_WALK,true); - u.UpdateSpeed(MOVE_SWIM,true); + u.UpdateSpeed(MOVE_RUN, true); + u.UpdateSpeed(MOVE_WALK, true); + u.UpdateSpeed(MOVE_SWIM, true); } template<> void FollowMovementGenerator::Initialize(Player& owner) { - owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); + owner.addUnitState(UNIT_STAT_FOLLOW | UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); _setTargetLocation(owner); } @@ -270,7 +270,7 @@ void FollowMovementGenerator::Initialize(Player& owner) template<> void FollowMovementGenerator::Initialize(Creature& owner) { - owner.addUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); + owner.addUnitState(UNIT_STAT_FOLLOW | UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); _setTargetLocation(owner); } @@ -278,14 +278,14 @@ void FollowMovementGenerator::Initialize(Creature& owner) template void FollowMovementGenerator::Finalize(T& owner) { - owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); + owner.clearUnitState(UNIT_STAT_FOLLOW | UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); } template void FollowMovementGenerator::Interrupt(T& owner) { - owner.clearUnitState(UNIT_STAT_FOLLOW|UNIT_STAT_FOLLOW_MOVE); + owner.clearUnitState(UNIT_STAT_FOLLOW | UNIT_STAT_FOLLOW_MOVE); _updateSpeed(owner); } @@ -296,14 +296,14 @@ void FollowMovementGenerator::Reset(T& owner) } //-----------------------------------------------// -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player&); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player&); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature&); -template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature&); -template bool TargetedMovementGeneratorMedium >::Update(Player&, const uint32&); -template bool TargetedMovementGeneratorMedium >::Update(Player&, const uint32&); -template bool TargetedMovementGeneratorMedium >::Update(Creature&, const uint32&); -template bool TargetedMovementGeneratorMedium >::Update(Creature&, const uint32&); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player&); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Player&); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature&); +template void TargetedMovementGeneratorMedium >::_setTargetLocation(Creature&); +template bool TargetedMovementGeneratorMedium >::Update(Player&, const uint32&); +template bool TargetedMovementGeneratorMedium >::Update(Player&, const uint32&); +template bool TargetedMovementGeneratorMedium >::Update(Creature&, const uint32&); +template bool TargetedMovementGeneratorMedium >::Update(Creature&, const uint32&); template void ChaseMovementGenerator::_reachTarget(Player&); template void ChaseMovementGenerator::_reachTarget(Creature&); diff --git a/src/game/TargetedMovementGenerator.h b/src/game/TargetedMovementGenerator.h index 7e6cf263a..5feddef88 100644 --- a/src/game/TargetedMovementGenerator.h +++ b/src/game/TargetedMovementGenerator.h @@ -56,7 +56,7 @@ class MANGOS_DLL_SPEC TargetedMovementGeneratorMedium Unit* GetTarget() const { return i_target.getTarget(); } - void unitSpeedChanged() { i_recalculateTravel=true; } + void unitSpeedChanged() { i_recalculateTravel = true; } void UpdateFinalDistance(float fDistance); protected: diff --git a/src/game/TaxiHandler.cpp b/src/game/TaxiHandler.cpp index ac45e14b1..daa9d5cb9 100644 --- a/src/game/TaxiHandler.cpp +++ b/src/game/TaxiHandler.cpp @@ -48,13 +48,13 @@ void WorldSession::SendTaxiStatus(ObjectGuid guid) return; } - uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer()->GetTeam()); + uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam()); // not found nearest if (curloc == 0) return; - DEBUG_LOG("WORLD: current location %u ",curloc); + DEBUG_LOG("WORLD: current location %u ", curloc); WorldPacket data(SMSG_TAXINODE_STATUS, 9); data << ObjectGuid(guid); @@ -94,18 +94,18 @@ void WorldSession::HandleTaxiQueryAvailableNodes(WorldPacket& recv_data) void WorldSession::SendTaxiMenu(Creature* unit) { // find current node - uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer()->GetTeam()); + uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam()); if (curloc == 0) return; - DEBUG_LOG("WORLD: CMSG_TAXINODE_STATUS_QUERY %u ",curloc); + DEBUG_LOG("WORLD: CMSG_TAXINODE_STATUS_QUERY %u ", curloc); - WorldPacket data(SMSG_SHOWTAXINODES, (4+8+4+8*4)); + WorldPacket data(SMSG_SHOWTAXINODES, (4 + 8 + 4 + 8 * 4)); data << uint32(1); data << unit->GetObjectGuid(); data << uint32(curloc); - GetPlayer()->m_taxi.AppendTaximaskTo(data,GetPlayer()->isTaxiCheater()); + GetPlayer()->m_taxi.AppendTaximaskTo(data, GetPlayer()->isTaxiCheater()); SendPacket(&data); DEBUG_LOG("WORLD: Sent SMSG_SHOWTAXINODES"); @@ -117,19 +117,19 @@ void WorldSession::SendDoFlight(uint32 mountDisplayId, uint32 path, uint32 pathN if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - while (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE) + while (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE) GetPlayer()->GetMotionMaster()->MovementExpired(false); if (mountDisplayId) GetPlayer()->Mount(mountDisplayId); - GetPlayer()->GetMotionMaster()->MoveTaxiFlight(path,pathNode); + GetPlayer()->GetMotionMaster()->MoveTaxiFlight(path, pathNode); } bool WorldSession::SendLearnNewTaxiNode(Creature* unit) { // find current node - uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(),unit->GetPositionY(),unit->GetPositionZ(),unit->GetMapId(),GetPlayer()->GetTeam()); + uint32 curloc = sObjectMgr.GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam()); if (curloc == 0) return true; // `true` send to avoid WorldSession::SendTaxiMenu call with one more curlock seartch with same false result. @@ -177,7 +177,7 @@ void WorldSession::HandleActivateTaxiExpressOpcode(WorldPacket& recv_data) if (nodes.empty()) return; - DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXIEXPRESS from %d to %d" ,nodes.front(),nodes.back()); + DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXIEXPRESS from %d to %d" , nodes.front(), nodes.back()); GetPlayer()->ActivateTaxiPathTo(nodes, npc); } @@ -207,7 +207,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) // far teleport case if (curDestNode && curDestNode->map_id != GetPlayer()->GetMapId()) { - if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()==FLIGHT_MOTION_TYPE) + if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE) { // short preparations to continue flight FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top()); @@ -218,7 +218,7 @@ void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) TaxiPathNodeEntry const& node = flight->GetPath()[flight->GetCurrentNode()]; flight->SkipCurrentNode(); - GetPlayer()->TeleportTo(curDestNode->map_id,node.x,node.y,node.z,GetPlayer()->GetOrientation()); + GetPlayer()->TeleportTo(curDestNode->map_id, node.x, node.y, node.z, GetPlayer()->GetOrientation()); } return; } @@ -264,7 +264,7 @@ void WorldSession::HandleActivateTaxiOpcode(WorldPacket& recv_data) nodes.resize(2); recv_data >> guid >> nodes[0] >> nodes[1]; - DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXI from %d to %d" ,nodes[0],nodes[1]); + DEBUG_LOG("WORLD: Received CMSG_ACTIVATETAXI from %d to %d" , nodes[0], nodes[1]); Creature* npc = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_FLIGHTMASTER); if (!npc) { diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 0f49442b8..4a59090e4 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -142,7 +142,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff) } default: UnSummon(); - sLog.outError("Temporary summoned creature (entry: %u) have unknown type %u of ",GetEntry(),m_type); + sLog.outError("Temporary summoned creature (entry: %u) have unknown type %u of ", GetEntry(), m_type); break; } diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index bbfc91ac3..f2dff1afd 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -276,7 +276,7 @@ bool HostileReferenceSortPredicate(const HostileReference* lhs, const HostileRef void ThreatContainer::update() { - if (iDirty && iThreatList.size() >1) + if (iDirty && iThreatList.size() > 1) { iThreatList.sort(HostileReferenceSortPredicate); } @@ -423,7 +423,7 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho if (!pVictim->isAlive() || !getOwner()->isAlive()) return; - MANGOS_ASSERT(getOwner()->GetTypeId()== TYPEID_UNIT); + MANGOS_ASSERT(getOwner()->GetTypeId() == TYPEID_UNIT); float threat = ThreatCalcHelper::CalcThreat(pVictim, iOwner, pThreat, crit, schoolMask, pThreatSpell); @@ -556,8 +556,8 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat switch (threatRefStatusChangeEvent->getType()) { case UEV_THREAT_REF_THREAT_CHANGE: - if ((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue()<0.0f) || - (getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue()>0.0f)) + if ((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue() < 0.0f) || + (getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue() > 0.0f)) setDirty(true); // the order in the threat list might have changed break; case UEV_THREAT_REF_ONLINE_STATUS: diff --git a/src/game/ThreatManager.h b/src/game/ThreatManager.h index 1f8cdd770..02a5953ec 100644 --- a/src/game/ThreatManager.h +++ b/src/game/ThreatManager.h @@ -187,7 +187,7 @@ class MANGOS_DLL_SPEC ThreatManager void clearReferences(); void addThreat(Unit* pVictim, float threat, bool crit, SpellSchoolMask schoolMask, SpellEntry const* threatSpell); - void addThreat(Unit* pVictim, float threat) { addThreat(pVictim,threat,false,SPELL_SCHOOL_MASK_NONE,NULL); } + void addThreat(Unit* pVictim, float threat) { addThreat(pVictim, threat, false, SPELL_SCHOOL_MASK_NONE, NULL); } // add threat as raw value (ignore redirections and expection all mods applied already to it void addThreatDirectly(Unit* pVictim, float threat); diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index 78f412573..fb5340d54 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -75,7 +75,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) // Search victim if no, not attackable, or out of range, or friendly (possible in case duel end) if (!victim || !victim->isTargetableForAttack() || !m_creature->IsWithinDistInMap(victim, max_range) || - m_creature->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(m_creature,m_creature,false)) + m_creature->IsFriendlyTo(victim) || !victim->isVisibleForOrDetect(m_creature, m_creature, false)) { victim = NULL; diff --git a/src/game/TradeHandler.cpp b/src/game/TradeHandler.cpp index 23266833e..5211a54bb 100644 --- a/src/game/TradeHandler.cpp +++ b/src/game/TradeHandler.cpp @@ -37,24 +37,24 @@ void WorldSession::SendTradeStatus(TradeStatus status) switch (status) { case TRADE_STATUS_BEGIN_TRADE: - data.Initialize(SMSG_TRADE_STATUS, 4+8); + data.Initialize(SMSG_TRADE_STATUS, 4 + 8); data << uint32(status); data << uint64(0); break; case TRADE_STATUS_OPEN_WINDOW: - data.Initialize(SMSG_TRADE_STATUS, 4+4); + data.Initialize(SMSG_TRADE_STATUS, 4 + 4); data << uint32(status); data << uint32(0); // added in 2.4.0 break; case TRADE_STATUS_CLOSE_WINDOW: - data.Initialize(SMSG_TRADE_STATUS, 4+4+1+4); + data.Initialize(SMSG_TRADE_STATUS, 4 + 4 + 1 + 4); data << uint32(status); data << uint32(0); data << uint8(0); data << uint32(0); break; case TRADE_STATUS_ONLY_CONJURED: - data.Initialize(SMSG_TRADE_STATUS, 4+1); + data.Initialize(SMSG_TRADE_STATUS, 4 + 1); data << uint32(status); data << uint8(0); break; @@ -69,13 +69,13 @@ void WorldSession::SendTradeStatus(TradeStatus status) void WorldSession::HandleIgnoreTradeOpcode(WorldPacket& /*recvPacket*/) { - DEBUG_LOG("WORLD: Ignore Trade %u",_player->GetGUIDLow()); + DEBUG_LOG("WORLD: Ignore Trade %u", _player->GetGUIDLow()); // recvPacket.print_storage(); } void WorldSession::HandleBusyTradeOpcode(WorldPacket& /*recvPacket*/) { - DEBUG_LOG("WORLD: Busy Trade %u",_player->GetGUIDLow()); + DEBUG_LOG("WORLD: Busy Trade %u", _player->GetGUIDLow()); // recvPacket.print_storage(); } @@ -105,7 +105,7 @@ void WorldSession::SendUpdateTrade(bool trader_state /*= true*/) data << item->GetGuidValue(ITEM_FIELD_GIFTCREATOR); data << uint32(item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)); - for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot) + for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot) data << uint32(item->GetEnchantmentId(EnchantmentSlot(enchant_slot))); // creator data << item->GetGuidValue(ITEM_FIELD_CREATOR); @@ -140,8 +140,8 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) { ItemPosCountVec traderDst; ItemPosCountVec playerDst; - bool traderCanTrade = (myItems[i]==NULL || trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, myItems[i], false) == EQUIP_ERR_OK); - bool playerCanTrade = (hisItems[i]==NULL || _player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, hisItems[i], false) == EQUIP_ERR_OK); + bool traderCanTrade = (myItems[i] == NULL || trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, myItems[i], false) == EQUIP_ERR_OK); + bool playerCanTrade = (hisItems[i] == NULL || _player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, hisItems[i], false) == EQUIP_ERR_OK); if (traderCanTrade && playerCanTrade) { // Ok, if trade item exists and can be stored @@ -153,7 +153,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) DEBUG_LOG("partner storing: %s", myItems[i]->GetGuidStr().c_str()); if (_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", + sLog.outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", _player->GetName(), _player->GetSession()->GetAccountId(), myItems[i]->GetProto()->Name1, myItems[i]->GetEntry(), myItems[i]->GetCount(), trader->GetName(), trader->GetSession()->GetAccountId()); @@ -169,7 +169,7 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[]) DEBUG_LOG("player storing: %s", hisItems[i]->GetGuidStr().c_str()); if (trader->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_BOOL_GM_LOG_TRADE)) { - sLog.outCommand(trader->GetSession()->GetAccountId(),"GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", + sLog.outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)", trader->GetName(), trader->GetSession()->GetAccountId(), hisItems[i]->GetProto()->Name1, hisItems[i]->GetEntry(), hisItems[i]->GetCount(), _player->GetName(), _player->GetSession()->GetAccountId()); @@ -266,7 +266,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) Item* myItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; Item* hisItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL }; - bool myCanCompleteTrade=true,hisCanCompleteTrade=true; + bool myCanCompleteTrade = true, hisCanCompleteTrade = true; // set before checks to properly undo at problems (it already set in to client) my_trade->SetAccepted(true); @@ -396,8 +396,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) trader->GetSession()->SendTradeStatus(TRADE_STATUS_TRADE_ACCEPT); // test if item will fit in each inventory - hisCanCompleteTrade = (trader->CanStoreItems(myItems,TRADE_SLOT_TRADED_COUNT)== EQUIP_ERR_OK); - myCanCompleteTrade = (_player->CanStoreItems(hisItems,TRADE_SLOT_TRADED_COUNT) == EQUIP_ERR_OK); + hisCanCompleteTrade = (trader->CanStoreItems(myItems, TRADE_SLOT_TRADED_COUNT) == EQUIP_ERR_OK); + myCanCompleteTrade = (_player->CanStoreItems(hisItems, TRADE_SLOT_TRADED_COUNT) == EQUIP_ERR_OK); clearAcceptTradeMode(myItems, hisItems); @@ -446,17 +446,17 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& recvPacket) { if (_player->GetSession()->GetSecurity() > SEC_PLAYER && my_trade->GetMoney() > 0) { - sLog.outCommand(_player->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", - _player->GetName(),_player->GetSession()->GetAccountId(), + sLog.outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", + _player->GetName(), _player->GetSession()->GetAccountId(), my_trade->GetMoney(), trader->GetName(), trader->GetSession()->GetAccountId()); } if (trader->GetSession()->GetSecurity() > SEC_PLAYER && his_trade->GetMoney() > 0) { - sLog.outCommand(trader->GetSession()->GetAccountId(),"GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", + sLog.outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: %u) to player: %s (Account: %u)", trader->GetName(), trader->GetSession()->GetAccountId(), his_trade->GetMoney(), - _player->GetName(),_player->GetSession()->GetAccountId()); + _player->GetName(), _player->GetSession()->GetAccountId()); } } @@ -604,13 +604,13 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) return; } - if (pOther->GetTeam() !=_player->GetTeam()) + if (pOther->GetTeam() != _player->GetTeam()) { SendTradeStatus(TRADE_STATUS_WRONG_FACTION); return; } - if (!pOther->IsWithinDistInMap(_player,10.0f,false)) + if (!pOther->IsWithinDistInMap(_player, 10.0f, false)) { SendTradeStatus(TRADE_STATUS_TARGET_TO_FAR); return; diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index c497e2bf3..7c4876948 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -82,7 +82,7 @@ void MapManager::LoadTransports() if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed)) // skip transports with empty waypoints list { - sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.",goinfo->moTransport.taxiPathId); + sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.", goinfo->moTransport.taxiPathId); delete t; continue; } @@ -134,7 +134,7 @@ void MapManager::LoadTransports() uint32 guid = fields[0].GetUInt32(); uint32 entry = fields[1].GetUInt32(); std::string name = fields[2].GetCppString(); - sLog.outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports DON'T must have any records in `gameobject` or its behavior will be unpredictable/bugged.",entry,name.c_str(),guid); + sLog.outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports DON'T must have any records in `gameobject` or its behavior will be unpredictable/bugged.", entry, name.c_str(), guid); } while (result->NextRow()); @@ -149,13 +149,13 @@ Transport::Transport() : GameObject() bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint8 animprogress, uint16 dynamicHighValue) { - Relocate(x,y,z,ang); + Relocate(x, y, z, ang); // instance id and phaseMask isn't set to values different from std. if (!IsPositionValid()) { sLog.outError("Transport (GUID: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", - guidlow,x,y); + guidlow, x, y); return false; } @@ -165,7 +165,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, if (!goinfo) { - sLog.outErrorDb("Transport not created: entry in `gameobject_template` not found, guidlow: %u map: %u (X: %f Y: %f Z: %f) ang: %f",guidlow, mapid, x, y, z, ang); + sLog.outErrorDb("Transport not created: entry in `gameobject_template` not found, guidlow: %u map: %u (X: %f Y: %f Z: %f) ang: %f", guidlow, mapid, x, y, z, ang); return false; } @@ -225,7 +225,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set& mapids) if (mapChange == 0) { TaxiPathNodeEntry const& node_i = path[i]; - if (node_i.mapid == path[i+1].mapid) + if (node_i.mapid == path[i + 1].mapid) { keyFrame k(node_i); keyFrames.push_back(k); @@ -255,7 +255,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set& mapids) // find the rest of the distances between key points for (size_t i = 1; i < keyFrames.size(); ++i) { - if ((keyFrames[i].node->actionFlag == 1) || (keyFrames[i].node->mapid != keyFrames[i-1].node->mapid)) + if ((keyFrames[i].node->actionFlag == 1) || (keyFrames[i].node->mapid != keyFrames[i - 1].node->mapid)) { keyFrames[i].distFromPrev = 0; } @@ -288,7 +288,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set& mapids) for (int i = int(keyFrames.size()) - 1; i >= 0; i--) { - int j = (i + (firstStop+1)) % keyFrames.size(); + int j = (i + (firstStop + 1)) % keyFrames.size(); tmpDist += keyFrames[(j + 1) % keyFrames.size()].distFromPrev; keyFrames[j].distUntilStop = tmpDist; if (keyFrames[j].node->actionFlag == 2) @@ -506,11 +506,11 @@ void Transport::Update(uint32 update_diff, uint32 /*p_time*/) while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime)) { - DoEventIfAny(*m_curr,true); + DoEventIfAny(*m_curr, true); MoveToNextWayPoint(); - DoEventIfAny(*m_curr,false); + DoEventIfAny(*m_curr, false); // first check help in case client-server transport coordinates de-synchronization if (m_curr->second.mapid != GetMapId() || m_curr->second.teleport) @@ -546,7 +546,7 @@ void Transport::UpdateForMap(Map const* targetMap) if (pl.isEmpty()) return; - if (GetMapId()==targetMap->GetId()) + if (GetMapId() == targetMap->GetId()) { for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr) { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 55d916151..54f220dad 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -262,7 +262,7 @@ Unit::Unit() : m_speed_rate[i] = 1.0f; // remove aurastates allowing special moves - for (int i=0; i < MAX_REACTIVE; ++i) + for (int i = 0; i < MAX_REACTIVE; ++i) m_reactiveTimer[i] = 0; m_isCreatureLinkingTrigger = false; @@ -352,9 +352,9 @@ void Unit::Update(uint32 update_diff, uint32 p_time) // update abilities available only for fraction of time UpdateReactives(update_diff); - ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth()*0.20f); - ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth()*0.35f); - ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, GetHealth() > GetMaxHealth()*0.75f); + ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, GetHealth() < GetMaxHealth() * 0.20f); + ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, GetHealth() < GetMaxHealth() * 0.35f); + ModifyAuraState(AURA_STATE_HEALTH_ABOVE_75_PERCENT, GetHealth() > GetMaxHealth() * 0.75f); UpdateSplineMovement(p_time); i_motionMaster.UpdateMotion(p_time); } @@ -371,15 +371,15 @@ bool Unit::UpdateMeleeAttackingState() uint8 swingError = 0; if (!CanReachWithMeleeAttack(victim)) { - setAttackTimer(BASE_ATTACK,100); - setAttackTimer(OFF_ATTACK,100); + setAttackTimer(BASE_ATTACK, 100); + setAttackTimer(OFF_ATTACK, 100); swingError = 1; } //120 degrees of radiant range - else if (!HasInArc(2*M_PI_F/3, victim)) + else if (!HasInArc(2 * M_PI_F / 3, victim)) { - setAttackTimer(BASE_ATTACK,100); - setAttackTimer(OFF_ATTACK,100); + setAttackTimer(BASE_ATTACK, 100); + setAttackTimer(OFF_ATTACK, 100); swingError = 2; } else @@ -390,7 +390,7 @@ 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); @@ -400,7 +400,7 @@ 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); @@ -426,7 +426,7 @@ bool Unit::haveOffhandWeapon() const 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); @@ -469,7 +469,7 @@ bool Unit::CanReachWithMeleeAttack(Unit* pVictim, float flat_mod /*= 0.0f*/) con float dy = GetPositionY() - pVictim->GetPositionY(); float dz = GetPositionZ() - pVictim->GetPositionZ(); - return dx*dx + dy*dy + dz*dz < reach*reach; + return dx * dx + dy * dy + dz * dz < reach * reach; } void Unit::RemoveSpellsCausingAura(AuraType auraType) @@ -519,10 +519,10 @@ void Unit::DealDamageMods(Unit* pVictim, uint32& damage, uint32* absorb) uint32 originalDamage = damage; //Script Event damage Deal - if (GetTypeId()== TYPEID_UNIT && ((Creature*)this)->AI()) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) ((Creature*)this)->AI()->DamageDeal(pVictim, damage); //Script Event damage taken - if (pVictim->GetTypeId()== TYPEID_UNIT && ((Creature*)pVictim)->AI()) + if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->AI()) ((Creature*)pVictim)->AI()->DamageTaken(this, damage); if (absorb && originalDamage > damage) @@ -573,18 +573,18 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa return damage; } - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamageStart"); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageStart"); uint32 health = pVictim->GetHealth(); - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"deal dmg:%d to health:%d ",damage,health); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "deal dmg:%d to health:%d ", damage, health); // duel ends when player has 1 or less hp bool duel_hasEnded = false; - if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health-1)) + if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->duel && damage >= (health - 1)) { // prevent kill only if killed in duel and killed by opponent or opponent controlled creature - if (((Player*)pVictim)->duel->opponent==this || ((Player*)pVictim)->duel->opponent->GetObjectGuid() == GetOwnerGuid()) - damage = health-1; + if (((Player*)pVictim)->duel->opponent == this || ((Player*)pVictim)->duel->opponent->GetObjectGuid() == GetOwnerGuid()) + damage = health - 1; duel_hasEnded = true; } @@ -599,7 +599,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa } // Rage from Damage made (only from direct weapon damage) - if (cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE)) + if (cleanDamage && damagetype == DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE)) { uint32 weaponSpeedHitFactor; @@ -608,9 +608,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa case BASE_ATTACK: { if (cleanDamage->hitOutCome == MELEE_HIT_CRIT) - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 7); + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType) / 1000.0f * 7); else - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType) / 1000.0f * 3.5f); ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); @@ -619,9 +619,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa case OFF_ATTACK: { if (cleanDamage->hitOutCome == MELEE_HIT_CRIT) - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType) / 1000.0f * 3.5f); else - weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f); + weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType) / 1000.0f * 1.75f); ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); @@ -637,7 +637,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa Player* killer = ((Player*)this); // in bg, count dmg if victim is also a player - if (pVictim->GetTypeId()==TYPEID_PLAYER) + if (pVictim->GetTypeId() == TYPEID_PLAYER) { if (BattleGround* bg = killer->GetBattleGround()) { @@ -658,7 +658,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa if (health <= damage) { - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamage: victim just died"); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamage: victim just died"); // find player: owner of controlled `this` or `this` itself maybe // for loot will be sued only if group_tap==NULL @@ -684,7 +684,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa { ((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health); if (player_tap) - player_tap->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL,1,0,pVictim); + player_tap->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_SPECIAL_PVP_KILL, 1, 0, pVictim); } // call kill spell proc event (before real die and combat stop to triggering auras removed at death/combat stop) @@ -692,12 +692,12 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa { player_tap->ProcDamageAndSpell(pVictim, PROC_FLAG_KILL, PROC_FLAG_KILLED, PROC_EX_NONE, 0); - WorldPacket data(SMSG_PARTYKILLLOG, (8+8)); //send event PARTY_KILL + WorldPacket data(SMSG_PARTYKILLLOG, (8 + 8)); //send event PARTY_KILL data << player_tap->GetObjectGuid(); //player with killing blow 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); } @@ -711,7 +711,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa player_tap->RewardSinglePlayerAtKill(pVictim); } - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamageAttackStop"); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageAttackStop"); // stop combat pVictim->CombatStop(); @@ -722,12 +722,12 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa // if talent known but not triggered (check priest class for speedup check) Aura* spiritOfRedemtionTalentReady = NULL; if (!damageFromSpiritOfRedemtionTalent && // not called from SPELL_AURA_SPIRIT_OF_REDEMPTION - pVictim->GetTypeId()==TYPEID_PLAYER && pVictim->getClass()==CLASS_PRIEST) + pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->getClass() == CLASS_PRIEST) { AuraList const& vDummyAuras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); for (AuraList::const_iterator itr = vDummyAuras.begin(); itr != vDummyAuras.end(); ++itr) { - if ((*itr)->GetSpellProto()->SpellIconID==1654) + if ((*itr)->GetSpellProto()->SpellIconID == 1654) { spiritOfRedemtionTalentReady = *itr; break; @@ -737,11 +737,11 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa if (!spiritOfRedemtionTalentReady) { - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"SET JUST_DIED"); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "SET JUST_DIED"); pVictim->SetDeathState(JUST_DIED); } - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamageHealth1"); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageHealth1"); if (spiritOfRedemtionTalentReady) { @@ -754,17 +754,17 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa pVictim->RemoveAllAurasOnDeath(); // restore for use at real death - pVictim->SetUInt32Value(PLAYER_SELF_RES_SPELL,ressSpellId); + pVictim->SetUInt32Value(PLAYER_SELF_RES_SPELL, ressSpellId); // FORM_SPIRITOFREDEMPTION and related auras - pVictim->CastSpell(pVictim,27827,true,NULL,spiritOfRedemtionTalentReady); + pVictim->CastSpell(pVictim, 27827, true, NULL, spiritOfRedemtionTalentReady); } else pVictim->SetHealth(0); // remember victim PvP death for corpse type and corpse reclaim delay // at original death (not at SpiritOfRedemtionTalent timeout) - if (pVictim->GetTypeId()==TYPEID_PLAYER && !damageFromSpiritOfRedemtionTalent) + if (pVictim->GetTypeId() == TYPEID_PLAYER && !damageFromSpiritOfRedemtionTalent) ((Player*)pVictim)->SetPvPDeath(player_tap != NULL); // Call KilledUnit for creatures @@ -791,7 +791,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa if (durabilityLoss && !player_tap && !((Player*)pVictim)->InBattleGround()) { DEBUG_LOG("We are dead, loosing 10 percents durability"); - ((Player*)pVictim)->DurabilityLossAll(0.10f,false); + ((Player*)pVictim)->DurabilityLossAll(0.10f, false); // durability lost message WorldPacket data(SMSG_DURABILITY_DAMAGE_DEATH, 0); ((Player*)pVictim)->GetSession()->SendPacket(&data); @@ -799,14 +799,14 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa } else // creature died { - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamage Killed NPC"); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamage Killed NPC"); JustKilledCreature((Creature*)pVictim); } // last damage from non duel opponent or opponent controlled creature if (duel_hasEnded) { - MANGOS_ASSERT(pVictim->GetTypeId()==TYPEID_PLAYER); + MANGOS_ASSERT(pVictim->GetTypeId() == TYPEID_PLAYER); Player* he = (Player*)pVictim; MANGOS_ASSERT(he->duel); @@ -834,7 +834,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa } else // if (health <= damage) { - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamageAlive"); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageAlive"); if (pVictim->GetTypeId() == TYPEID_PLAYER) ((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, damage); @@ -847,7 +847,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa { // if not have main target then attack state with target (including AI call) //start melee attacks only after melee hit - Attack(pVictim,(damagetype == DIRECT_DAMAGE)); + Attack(pVictim, (damagetype == DIRECT_DAMAGE)); } // if damage pVictim call AI reaction @@ -856,7 +856,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa if (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE) { - if (!spellProto || !(spellProto->AuraInterruptFlags&AURA_INTERRUPT_FLAG_DIRECT_DAMAGE)) + if (!spellProto || !(spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_DIRECT_DAMAGE)) pVictim->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_DIRECT_DAMAGE); } if (pVictim->GetTypeId() != TYPEID_PLAYER) @@ -876,17 +876,17 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa // random durability for items (HIT TAKEN) if (roll_chance_f(sWorld.getConfig(CONFIG_FLOAT_RATE_DURABILITY_LOSS_DAMAGE))) { - EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); + EquipmentSlots slot = EquipmentSlots(urand(0, EQUIPMENT_SLOT_END - 1)); ((Player*)pVictim)->DurabilityPointLossForEquipSlot(slot); } } - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { // random durability for items (HIT DONE) if (roll_chance_f(sWorld.getConfig(CONFIG_FLOAT_RATE_DURABILITY_LOSS_DAMAGE))) { - EquipmentSlots slot = EquipmentSlots(urand(0,EQUIPMENT_SLOT_END-1)); + EquipmentSlots slot = EquipmentSlots(urand(0, EQUIPMENT_SLOT_END - 1)); ((Player*)this)->DurabilityPointLossForEquipSlot(slot); } } @@ -936,19 +936,19 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags; if (channelInterruptFlags & CHANNEL_FLAG_DELAY) { - if (pVictim!=this) //don't shorten the duration of channeling if you damage yourself + if (pVictim != this) //don't shorten the duration of channeling if you damage yourself spell->DelayedChannel(); } else if ((channelInterruptFlags & (CHANNEL_FLAG_DAMAGE | CHANNEL_FLAG_DAMAGE2))) { - DETAIL_LOG("Spell %u canceled at damage!",spell->m_spellInfo->Id); + DETAIL_LOG("Spell %u canceled at damage!", spell->m_spellInfo->Id); pVictim->InterruptSpell(CURRENT_CHANNELED_SPELL); } } else if (spell->getState() == SPELL_STATE_DELAYED) // break channeled spell in delayed state on damage { - DETAIL_LOG("Spell %u canceled at damage!",spell->m_spellInfo->Id); + DETAIL_LOG("Spell %u canceled at damage!", spell->m_spellInfo->Id); pVictim->InterruptSpell(CURRENT_CHANNELED_SPELL); } } @@ -957,7 +957,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa // last damage from duel opponent if (duel_hasEnded) { - MANGOS_ASSERT(pVictim->GetTypeId()==TYPEID_PLAYER); + MANGOS_ASSERT(pVictim->GetTypeId() == TYPEID_PLAYER); Player* he = (Player*)pVictim; MANGOS_ASSERT(he->duel); @@ -972,7 +972,7 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa } } - DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE,"DealDamageEnd returned %d damage", damage); + DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageEnd returned %d damage", damage); return damage; } @@ -1084,14 +1084,14 @@ void Unit::JustKilledCreature(Creature* victim) void Unit::PetOwnerKilledUnit(Unit* pVictim) { // for minipet and guardians (including protector) - CallForAllControlledUnits(PetOwnerKilledUnitHelper(pVictim), CONTROLLED_MINIPET|CONTROLLED_GUARDIANS); + CallForAllControlledUnits(PetOwnerKilledUnitHelper(pVictim), CONTROLLED_MINIPET | CONTROLLED_GUARDIANS); } 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); + if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id != except_spellid) + InterruptSpell(CurrentSpellTypes(i), false); } void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) @@ -1147,7 +1147,7 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, spell->prepare(&targets, triggeredByAura); } -void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) +void Unit::CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); @@ -1273,7 +1273,7 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage SpellNonMeleeDamage damageInfo(this, pVictim, spellInfo->Id, SpellSchoolMask(spellInfo->SchoolMask)); CalculateSpellDamage(&damageInfo, damage, spellInfo); damageInfo.target->CalculateAbsorbResistBlock(this, &damageInfo, spellInfo); - DealDamageMods(damageInfo.target,damageInfo.damage,&damageInfo.absorb); + DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); SendSpellNonMeleeDamageLog(&damageInfo); DealSpellDamage(&damageInfo, true); return damageInfo.damage; @@ -1309,7 +1309,7 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S // if crit add critical bonus if (crit) { - damageInfo->HitInfo|= SPELL_HIT_TYPE_CRIT; + damageInfo->HitInfo |= SPELL_HIT_TYPE_CRIT; damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim); // Resilience - reduce crit damage uint32 reduction_affected_damage = CalcNotIgnoreDamageReduction(damage, damageSchoolMask); @@ -1331,7 +1331,7 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S // If crit add critical bonus if (crit) { - damageInfo->HitInfo|= SPELL_HIT_TYPE_CRIT; + damageInfo->HitInfo |= SPELL_HIT_TYPE_CRIT; damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim); // Resilience - reduce crit damage uint32 reduction_affected_damage = CalcNotIgnoreDamageReduction(damage, damageSchoolMask); @@ -1446,7 +1446,7 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da damageInfo->HitInfo |= HITINFO_NORMALSWING; damageInfo->TargetState = VICTIMSTATE_IS_IMMUNE; - damageInfo->procEx |=PROC_EX_IMMUNE; + damageInfo->procEx |= PROC_EX_IMMUNE; damageInfo->damage = 0; damageInfo->cleanDamage = 0; return; @@ -1474,10 +1474,10 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da { case MELEE_HIT_EVADE: { - damageInfo->HitInfo |= HITINFO_MISS|HITINFO_SWINGNOHITSOUND; + damageInfo->HitInfo |= HITINFO_MISS | HITINFO_SWINGNOHITSOUND; damageInfo->TargetState = VICTIMSTATE_EVADES; - damageInfo->procEx|=PROC_EX_EVADE; + damageInfo->procEx |= PROC_EX_EVADE; damageInfo->damage = 0; damageInfo->cleanDamage = 0; return; @@ -1487,24 +1487,24 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da damageInfo->HitInfo |= HITINFO_MISS; damageInfo->TargetState = VICTIMSTATE_UNAFFECTED; - damageInfo->procEx|=PROC_EX_MISS; + damageInfo->procEx |= PROC_EX_MISS; damageInfo->damage = 0; damageInfo->cleanDamage = 0; break; } case MELEE_HIT_NORMAL: damageInfo->TargetState = VICTIMSTATE_NORMAL; - damageInfo->procEx|=PROC_EX_NORMAL_HIT; + damageInfo->procEx |= PROC_EX_NORMAL_HIT; break; case MELEE_HIT_CRIT: { damageInfo->HitInfo |= HITINFO_CRITICALHIT; damageInfo->TargetState = VICTIMSTATE_NORMAL; - damageInfo->procEx|=PROC_EX_CRITICAL_HIT; + damageInfo->procEx |= PROC_EX_CRITICAL_HIT; // Crit bonus calc damageInfo->damage += damageInfo->damage; - int32 mod=0; + int32 mod = 0; // Apply SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE or SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE if (damageInfo->attackType == RANGED_ATTACK) mod += damageInfo->target->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE); @@ -1517,8 +1517,8 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da // Increase crit damage from SPELL_AURA_MOD_CRIT_PERCENT_VERSUS mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, crTypeMask); - if (mod!=0) - damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod)/100.0f)); + if (mod != 0) + damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod) / 100.0f)); // Resilience - reduce crit damage uint32 reduction_affected_damage = CalcNotIgnoreDamageReduction(damageInfo->damage, damageInfo->damageSchoolMask); @@ -1619,7 +1619,7 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da reducePercent = lowEnd + rand_norm_f() * (highEnd - lowEnd); - damageInfo->cleanDamage += damageInfo->damage-uint32(reducePercent * damageInfo->damage); + damageInfo->cleanDamage += damageInfo->damage - uint32(reducePercent * damageInfo->damage); damageInfo->damage = uint32(reducePercent * damageInfo->damage); break; } @@ -1627,7 +1627,7 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da { damageInfo->HitInfo |= HITINFO_CRUSHING; damageInfo->TargetState = VICTIMSTATE_NORMAL; - damageInfo->procEx|=PROC_EX_NORMAL_HIT; + damageInfo->procEx |= PROC_EX_NORMAL_HIT; // 150% normal damage damageInfo->damage += (damageInfo->damage / 2); break; @@ -1656,16 +1656,16 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da damageInfo->procVictim |= PROC_FLAG_TAKEN_ANY_DAMAGE; // Calculate absorb & resists - uint32 absorb_affected_damage = CalcNotIgnoreAbsorbDamage(damageInfo->damage,damageInfo->damageSchoolMask); + uint32 absorb_affected_damage = CalcNotIgnoreAbsorbDamage(damageInfo->damage, damageInfo->damageSchoolMask); damageInfo->target->CalculateDamageAbsorbAndResist(this, damageInfo->damageSchoolMask, DIRECT_DAMAGE, absorb_affected_damage, &damageInfo->absorb, &damageInfo->resist, true); - damageInfo->damage-=damageInfo->absorb + damageInfo->resist; + damageInfo->damage -= damageInfo->absorb + damageInfo->resist; if (damageInfo->absorb) { - damageInfo->HitInfo|=HITINFO_ABSORB; - damageInfo->procEx|=PROC_EX_ABSORB; + damageInfo->HitInfo |= HITINFO_ABSORB; + damageInfo->procEx |= PROC_EX_ABSORB; } if (damageInfo->resist) - damageInfo->HitInfo|=HITINFO_RESIST; + damageInfo->HitInfo |= HITINFO_RESIST; } else // Umpossible get negative result but.... @@ -1674,7 +1674,7 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, uint32 damage, CalcDamageInfo* da void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) { - if (damageInfo==0) return; + if (damageInfo == 0) return; Unit* pVictim = damageInfo->target; if (!this || !pVictim) @@ -1689,9 +1689,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) return; // Hmmmm dont like this emotes client must by self do all animations - if (damageInfo->HitInfo&HITINFO_CRITICALHIT) + if (damageInfo->HitInfo & HITINFO_CRITICALHIT) pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); - if (damageInfo->blocked_amount && damageInfo->TargetState!=VICTIMSTATE_BLOCKS) + if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS) pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); if (damageInfo->TargetState == VICTIMSTATE_PARRY) @@ -1731,11 +1731,11 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) } // Call default DealDamage - CleanDamage cleanDamage(damageInfo->cleanDamage,damageInfo->attackType,damageInfo->hitOutCome); + CleanDamage cleanDamage(damageInfo->cleanDamage, damageInfo->attackType, damageInfo->hitOutCome); DealDamage(pVictim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, damageInfo->damageSchoolMask, NULL, durabilityLoss); // If this is a creature and it attacks from behind it has a probability to daze it's victim - if ((damageInfo->hitOutCome==MELEE_HIT_CRIT || damageInfo->hitOutCome==MELEE_HIT_CRUSHING || damageInfo->hitOutCome==MELEE_HIT_NORMAL || damageInfo->hitOutCome==MELEE_HIT_GLANCING) && + if ((damageInfo->hitOutCome == MELEE_HIT_CRIT || damageInfo->hitOutCome == MELEE_HIT_CRUSHING || damageInfo->hitOutCome == MELEE_HIT_NORMAL || damageInfo->hitOutCome == MELEE_HIT_GLANCING) && GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->GetCharmerOrOwnerGuid() && !pVictim->HasInArc(M_PI_F, this)) { // -probability is between 0% and 40% @@ -1744,12 +1744,12 @@ 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->GetDefenseSkillValue(); - uint32 AttackerMeleeSkill=GetUnitMeleeSkill(); + uint32 VictimDefense = pVictim->GetDefenseSkillValue(); + uint32 AttackerMeleeSkill = GetUnitMeleeSkill(); - Probability *= AttackerMeleeSkill/(float)VictimDefense; + Probability *= AttackerMeleeSkill / (float)VictimDefense; if (Probability > 40.0f) Probability = 40.0f; @@ -1773,7 +1773,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) if (alreadyDone.find(*i) == alreadyDone.end()) { alreadyDone.insert(*i); - uint32 damage=(*i)->GetModifier()->m_amount; + uint32 damage = (*i)->GetModifier()->m_amount; SpellEntry const* i_spellProto = (*i)->GetSpellProto(); //Calculate absorb resist ??? no data in opcode for this possibly unable to absorb or resist? //uint32 absorb; @@ -1781,12 +1781,12 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) //CalcAbsorbResist(pVictim, SpellSchools(spellProto->School), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); //damage-=absorb + resist; - pVictim->DealDamageMods(this,damage,NULL); + pVictim->DealDamageMods(this, damage, NULL); uint32 targetHealth = GetHealth(); uint32 overkill = damage > targetHealth ? damage - targetHealth : 0; - WorldPacket data(SMSG_SPELLDAMAGESHIELD,(8+8+4+4+4+4)); + WorldPacket data(SMSG_SPELLDAMAGESHIELD, (8 + 8 + 4 + 4 + 4 + 4)); data << pVictim->GetObjectGuid(); data << GetObjectGuid(); data << uint32(i_spellProto->Id); @@ -1838,14 +1838,14 @@ uint32 Unit::CalcNotIgnoreAbsorbDamage(uint32 damage, SpellSchoolMask damageScho Unit::AuraList const& ignoreAbsorbSchool = GetAurasByType(SPELL_AURA_MOD_IGNORE_ABSORB_SCHOOL); for (Unit::AuraList::const_iterator i = ignoreAbsorbSchool.begin(); i != ignoreAbsorbSchool.end(); ++i) if ((*i)->GetMiscValue() & damageSchoolMask) - absorb_affected_rate *= (100.0f - (*i)->GetModifier()->m_amount)/100.0f; + absorb_affected_rate *= (100.0f - (*i)->GetModifier()->m_amount) / 100.0f; if (spellInfo) { Unit::AuraList const& ignoreAbsorbForSpell = GetAurasByType(SPELL_AURA_MOD_IGNORE_ABSORB_FOR_SPELL); for (Unit::AuraList::const_iterator citr = ignoreAbsorbForSpell.begin(); citr != ignoreAbsorbForSpell.end(); ++citr) if ((*citr)->isAffectedOnSpell(spellInfo)) - absorb_affected_rate *= (100.0f - (*citr)->GetModifier()->m_amount)/100.0f; + absorb_affected_rate *= (100.0f - (*citr)->GetModifier()->m_amount) / 100.0f; } return absorb_affected_rate <= 0.0f ? 0 : (absorb_affected_rate < 1.0f ? uint32(damage * absorb_affected_rate) : damage); @@ -1857,7 +1857,7 @@ uint32 Unit::CalcNotIgnoreDamageReduction(uint32 damage, SpellSchoolMask damageS Unit::AuraList const& ignoreAbsorb = GetAurasByType(SPELL_AURA_MOD_IGNORE_DAMAGE_REDUCTION_SCHOOL); for (Unit::AuraList::const_iterator i = ignoreAbsorb.begin(); i != ignoreAbsorb.end(); ++i) if ((*i)->GetMiscValue() & damageSchoolMask) - absorb_affected_rate *= (100.0f - (*i)->GetModifier()->m_amount)/100.0f; + absorb_affected_rate *= (100.0f - (*i)->GetModifier()->m_amount) / 100.0f; return absorb_affected_rate <= 0.0f ? 0 : (absorb_affected_rate < 1.0f ? uint32(damage * absorb_affected_rate) : damage); } @@ -1871,13 +1871,13 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) armor += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_TARGET_RESISTANCE, SPELL_SCHOOL_MASK_NORMAL); // Apply Player CR_ARMOR_PENETRATION rating and percent talents - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { float maxArmorPen = 400 + 85 * pVictim->getLevel(); if (getLevel() > 59) - maxArmorPen += 4.5f * 85 * (pVictim->getLevel()-59); + maxArmorPen += 4.5f * 85 * (pVictim->getLevel() - 59); // Cap ignored armor to this value - maxArmorPen = std::min(((armor+maxArmorPen)/3), armor); + maxArmorPen = std::min(((armor + maxArmorPen) / 3), armor); // Also, armor penetration is limited to 100% since 3.1.2, before greater values did // continue to give benefit for targets with more armor than the above cap float armorPenPct = std::min(100.f, ((Player*)this)->GetArmorPenetrationPct()); @@ -1889,10 +1889,10 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage) float levelModifier = (float)getLevel(); if (levelModifier > 59) - levelModifier = levelModifier + (4.5f * (levelModifier-59)); + levelModifier = levelModifier + (4.5f * (levelModifier - 59)); float tmpvalue = 0.1f * armor / (8.5f * levelModifier + 40); - tmpvalue = tmpvalue/(1.0f + tmpvalue); + tmpvalue = tmpvalue / (1.0f + tmpvalue); if (tmpvalue < 0.0f) tmpvalue = 0.0f; @@ -1910,7 +1910,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM return; // Magic damage, check for resists - if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL)==0) + if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) { // Get base victim resistance for school float tmpvalue2 = (float)GetResistance(GetFirstSchoolInMask(schoolMask)); @@ -1926,12 +1926,12 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM if (tmpvalue2 > 0.75f) tmpvalue2 = 0.75f; uint32 ran = urand(0, 100); - float faq[4] = {24.0f,6.0f,4.0f,6.0f}; + float faq[4] = {24.0f, 6.0f, 4.0f, 6.0f}; uint8 m = 0; float Binom = 0.0f; for (uint8 i = 0; i < 4; ++i) { - Binom += 2400 *(powf(tmpvalue2, float(i)) * powf((1-tmpvalue2), float(4-i)))/faq[i]; + Binom += 2400 * (powf(tmpvalue2, float(i)) * powf((1 - tmpvalue2), float(4 - i))) / faq[i]; if (ran > Binom) ++m; else @@ -2017,7 +2017,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM int32 currentAbsorb = mod->m_amount; // Found empty aura (impossible but..) - if (currentAbsorb <=0) + if (currentAbsorb <= 0) { existExpired = true; continue; @@ -2034,7 +2034,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM if (spellProto->SpellIconID == 3066) { //reduces all damage taken while stun, fear or silence - if (unitflag & (UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING|UNIT_FLAG_SILENCED)) + if (unitflag & (UNIT_FLAG_STUNNED | UNIT_FLAG_FLEEING | UNIT_FLAG_SILENCED)) RemainingDamage -= RemainingDamage * currentAbsorb / 100; continue; } @@ -2042,7 +2042,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM if (spellProto->SpellIconID == 2115) { // while affected by Stun and Fear - if (unitflag&(UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING)) + if (unitflag & (UNIT_FLAG_STUNNED | UNIT_FLAG_FLEEING)) RemainingDamage -= RemainingDamage * currentAbsorb / 100; continue; } @@ -2104,7 +2104,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM if (spellProto->SpellIconID == 2109) { if (!preventDeathSpell && - GetTypeId()==TYPEID_PLAYER && // Only players + GetTypeId() == TYPEID_PLAYER && // Only players !((Player*)this)->HasSpellCooldown(31231) && // Only if no cooldown roll_chance_i((*i)->GetModifier()->m_amount)) @@ -2143,9 +2143,9 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM case 5064: // Rank 2 { if (RemainingDamage >= currentAbsorb) - reflectDamage = (*k)->GetModifier()->m_amount * currentAbsorb/100; + reflectDamage = (*k)->GetModifier()->m_amount * currentAbsorb / 100; else - reflectDamage = (*k)->GetModifier()->m_amount * RemainingDamage/100; + reflectDamage = (*k)->GetModifier()->m_amount * RemainingDamage / 100; reflectSpell = 33619; reflectTriggeredBy = *i; reflectTriggeredBy->SetInUse(true);// lock aura from final deletion until processing @@ -2163,7 +2163,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM if (spellProto->SpellIconID == 3066) { //reduces all damage taken while stun, fear or silence - if (unitflag & (UNIT_FLAG_STUNNED|UNIT_FLAG_FLEEING|UNIT_FLAG_SILENCED)) + if (unitflag & (UNIT_FLAG_STUNNED | UNIT_FLAG_FLEEING | UNIT_FLAG_SILENCED)) RemainingDamage -= RemainingDamage * currentAbsorb / 100; continue; } @@ -2208,7 +2208,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM RemainingDamage -= absorbed; uint32 ab_damage = absorbed; - pCaster->DealDamageMods(caster,ab_damage,NULL); + pCaster->DealDamageMods(caster, ab_damage, NULL); pCaster->DealDamage(caster, ab_damage, NULL, damagetype, schoolMask, 0, false); continue; } @@ -2231,11 +2231,11 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM incanterAbsorption += currentAbsorb; // Reduce shield amount - mod->m_amount-=currentAbsorb; + mod->m_amount -= currentAbsorb; if ((*i)->GetHolder()->DropAuraCharge()) mod->m_amount = 0; // Need remove it later - if (mod->m_amount<=0) + if (mod->m_amount <= 0) existExpired = true; } @@ -2244,7 +2244,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM { for (AuraList::const_iterator i = vSchoolAbsorb.begin(); i != vSchoolAbsorb.end();) { - if ((*i)->GetModifier()->m_amount<=0) + if ((*i)->GetModifier()->m_amount <= 0) { RemoveAurasDueToSpell((*i)->GetId(), NULL, AURA_REMOVE_BY_SHIELD_BREAK); i = vSchoolAbsorb.begin(); @@ -2268,7 +2268,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM next = i; ++next; // check damage school mask - if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + if (((*i)->GetModifier()->m_miscvalue & schoolMask) == 0) continue; int32 currentAbsorb; @@ -2340,7 +2340,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM next = i; ++next; // check damage school mask - if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + if (((*i)->GetModifier()->m_miscvalue & schoolMask) == 0) continue; // Damage can be splitted only if aura has an alive caster @@ -2359,7 +2359,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM uint32 splitted = currentAbsorb; uint32 splitted_absorb = 0; - pCaster->DealDamageMods(caster,splitted,&splitted_absorb); + pCaster->DealDamageMods(caster, splitted, &splitted_absorb); pCaster->SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, splitted_absorb, 0, false, 0, false); @@ -2373,7 +2373,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM next = i; ++next; // check damage school mask - if (((*i)->GetModifier()->m_miscvalue & schoolMask)==0) + if (((*i)->GetModifier()->m_miscvalue & schoolMask) == 0) continue; // Damage can be splitted only if aura has an alive caster @@ -2386,7 +2386,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM RemainingDamage -= int32(splitted); uint32 split_absorb = 0; - pCaster->DealDamageMods(caster,splitted,&split_absorb); + pCaster->DealDamageMods(caster, splitted, &split_absorb); pCaster->SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, split_absorb, 0, false, 0, false); @@ -2406,10 +2406,10 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM // Cheat Death if (preventDeathSpell->SpellIconID == 2109) { - CastSpell(this,31231,true); - ((Player*)this)->AddSpellCooldown(31231,0,time(NULL)+60); + CastSpell(this, 31231, true); + ((Player*)this)->AddSpellCooldown(31231, 0, time(NULL) + 60); // with health > 10% lost health until health==10%, in other case no losses - uint32 health10 = GetMaxHealth()/10; + uint32 health10 = GetMaxHealth() / 10; RemainingDamage = GetHealth() > health10 ? GetHealth() - health10 : 0; } break; @@ -2453,12 +2453,12 @@ void Unit::CalculateAbsorbResistBlock(Unit* pCaster, SpellNonMeleeDamage* damage damageInfo->blocked = GetShieldBlockValue(); if (damageInfo->damage < damageInfo->blocked) damageInfo->blocked = damageInfo->damage; - damageInfo->damage-=damageInfo->blocked; + damageInfo->damage -= damageInfo->blocked; } - uint32 absorb_affected_damage = pCaster->CalcNotIgnoreAbsorbDamage(damageInfo->damage,GetSpellSchoolMask(spellProto),spellProto); + uint32 absorb_affected_damage = pCaster->CalcNotIgnoreAbsorbDamage(damageInfo->damage, GetSpellSchoolMask(spellProto), spellProto); CalculateDamageAbsorbAndResist(pCaster, GetSpellSchoolMask(spellProto), SPELL_DIRECT_DAMAGE, absorb_affected_damage, &damageInfo->absorb, &damageInfo->resist, !spellProto->HasAttribute(SPELL_ATTR_EX2_CANT_REFLECTED)); - damageInfo->damage-= damageInfo->absorb + damageInfo->resist; + damageInfo->damage -= damageInfo->absorb + damageInfo->resist; } void Unit::CalculateHealAbsorb(const uint32 heal, uint32* absorb) @@ -2481,7 +2481,7 @@ void Unit::CalculateHealAbsorb(const uint32 heal, uint32* absorb) int32 currentAbsorb = mod->m_amount; // Found empty aura (impossible but..) - if (currentAbsorb <=0) + if (currentAbsorb <= 0) { existExpired = true; continue; @@ -2499,7 +2499,7 @@ void Unit::CalculateHealAbsorb(const uint32 heal, uint32* absorb) if ((*i)->GetHolder()->DropAuraCharge()) mod->m_amount = 0; // Need remove it later - if (mod->m_amount<=0) + if (mod->m_amount <= 0) existExpired = true; } @@ -2508,7 +2508,7 @@ void Unit::CalculateHealAbsorb(const uint32 heal, uint32* absorb) { for (AuraList::const_iterator i = vHealAbsorb.begin(); i != vHealAbsorb.end();) { - if ((*i)->GetModifier()->m_amount<=0) + if ((*i)->GetModifier()->m_amount <= 0) { RemoveAurasDueToSpell((*i)->GetId(), NULL, AURA_REMOVE_BY_SHIELD_BREAK); i = vHealAbsorb.begin(); @@ -2566,16 +2566,16 @@ void Unit::AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType, bool ext CalcDamageInfo damageInfo; CalculateMeleeDamage(pVictim, 0, &damageInfo, attType); // Send log damage message to client - DealDamageMods(pVictim,damageInfo.damage,&damageInfo.absorb); + DealDamageMods(pVictim, damageInfo.damage, &damageInfo.absorb); SendAttackStateUpdate(&damageInfo); ProcDamageAndSpell(damageInfo.target, damageInfo.procAttacker, damageInfo.procVictim, damageInfo.procEx, damageInfo.damage, damageInfo.attackType); - DealMeleeDamage(&damageInfo,true); + DealMeleeDamage(&damageInfo, true); if (GetTypeId() == TYPEID_PLAYER) - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT,"AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "AttackerStateUpdate: (Player) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); else - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT,"AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "AttackerStateUpdate: (NPC) %u attacked %u (TypeId: %u) for %u dmg, absorbed %u, blocked %u, resisted %u.", GetGUIDLow(), pVictim->GetGUIDLow(), pVictim->GetTypeId(), damageInfo.damage, damageInfo.absorb, damageInfo.blocked_amount, damageInfo.resist); // if damage pVictim call AI reaction @@ -2609,20 +2609,20 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT float parry_chance = pVictim->GetUnitParryChance(); // Useful if want to specify crit & miss chances for melee, else it could be removed - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT,"MELEE OUTCOME: miss %f crit %f dodge %f parry %f block %f", miss_chance,crit_chance,dodge_chance,parry_chance,block_chance); + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MELEE OUTCOME: miss %f crit %f dodge %f parry %f block %f", miss_chance, crit_chance, dodge_chance, parry_chance, block_chance); - return RollMeleeOutcomeAgainst(pVictim, attType, int32(crit_chance*100), int32(miss_chance*100), int32(dodge_chance*100),int32(parry_chance*100),int32(block_chance*100)); + return RollMeleeOutcomeAgainst(pVictim, attType, int32(crit_chance * 100), int32(miss_chance * 100), int32(dodge_chance * 100), int32(parry_chance * 100), int32(block_chance * 100)); } MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackType attType, int32 crit_chance, int32 miss_chance, int32 dodge_chance, int32 parry_chance, int32 block_chance) const { - if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) return MELEE_HIT_EVADE; int32 attackerMaxSkillValueForLevel = GetMaxSkillValueForLevel(pVictim); int32 victimMaxSkillValueForLevel = pVictim->GetMaxSkillValueForLevel(this); - int32 attackerWeaponSkill = GetWeaponSkillValue(attType,pVictim); + int32 attackerWeaponSkill = GetWeaponSkillValue(attType, pVictim); int32 victimDefenseSkill = pVictim->GetDefenseSkillValue(this); // bonus from skills is 0.04% @@ -2649,7 +2649,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT return MELEE_HIT_CRIT; } - bool from_behind = !pVictim->HasInArc(M_PI_F,this); + bool from_behind = !pVictim->HasInArc(M_PI_F, this); if (from_behind) DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: attack came from behind."); @@ -2661,19 +2661,19 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT { // Reduce dodge chance by attacker expertise rating if (GetTypeId() == TYPEID_PLAYER) - dodge_chance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100); + dodge_chance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100); else - dodge_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25; + dodge_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25; // Modify dodge chance by attacker SPELL_AURA_MOD_COMBAT_RESULT_CHANCE - dodge_chance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100; + dodge_chance += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE) * 100; tmp = dodge_chance; if ((tmp > 0) // check if unit _can_ dodge && ((tmp -= skillBonus) > 0) && roll < (sum += tmp)) { - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: DODGE <%d, %d)", sum-tmp, sum); + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: DODGE <%d, %d)", sum - tmp, sum); return MELEE_HIT_DODGE; } } @@ -2684,11 +2684,11 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT { // Reduce parry chance by attacker expertise rating if (GetTypeId() == TYPEID_PLAYER) - parry_chance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType)*100); + parry_chance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100); else - parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25; + parry_chance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25; - if (parry_chance > 0 && (pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY))) + if (parry_chance > 0 && (pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_PARRY))) { parry_chance -= skillBonus; @@ -2719,7 +2719,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT tmp = tmp > 4000 ? 4000 : tmp; if (roll < (sum += tmp)) { - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: GLANCING <%d, %d)", sum-4000, sum); + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: GLANCING <%d, %d)", sum - 4000, sum); return MELEE_HIT_GLANCING; } } @@ -2728,14 +2728,14 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT // check if attack comes from behind, nobody can parry or block if attacker is behind if (!from_behind) { - if (pVictim->GetTypeId()==TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) + if (pVictim->GetTypeId() == TYPEID_PLAYER || !(((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_BLOCK)) { tmp = block_chance; if ((tmp > 0) // check if unit _can_ block && ((tmp -= skillBonus) > 0) && (roll < (sum += tmp))) { - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum-tmp, sum); + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: BLOCK <%d, %d)", sum - tmp, sum); return MELEE_HIT_BLOCK; } } @@ -2746,16 +2746,16 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT if (tmp > 0 && roll < (sum += tmp)) { - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum); + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum - tmp, sum); return MELEE_HIT_CRIT; } // mobs can score crushing blows if they're 4 or more levels above victim if (GetLevelForTarget(pVictim) >= pVictim->GetLevelForTarget(this) + 4 && // can be from by creature (if can) or from controlled player that considered as creature - ((GetTypeId()!=TYPEID_PLAYER && !((Creature*)this)->IsPet() && + ((GetTypeId() != TYPEID_PLAYER && !((Creature*)this)->IsPet() && !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRUSH)) || - GetTypeId()==TYPEID_PLAYER && GetCharmerOrOwnerGuid())) + GetTypeId() == TYPEID_PLAYER && GetCharmerOrOwnerGuid())) { // when their weapon skill is 15 or more above victim's defense skill tmp = victimDefenseSkill; @@ -2770,7 +2770,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(const Unit* pVictim, WeaponAttackT tmp = tmp * 200 - 1500; if (roll < (sum += tmp)) { - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: CRUSHING <%d, %d)", sum-tmp, sum); + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "RollMeleeOutcomeAgainst: CRUSHING <%d, %d)", sum - tmp, sum); return MELEE_HIT_CRUSHING; } } @@ -2784,8 +2784,8 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized) { float min_damage, max_damage; - if (normalized && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->CalculateMinMaxDamage(attType,normalized,min_damage, max_damage); + if (normalized && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->CalculateMinMaxDamage(attType, normalized, min_damage, max_damage); else { switch (attType) @@ -2812,7 +2812,7 @@ uint32 Unit::CalculateDamage(WeaponAttackType attType, bool normalized) if (min_damage > max_damage) { - std::swap(min_damage,max_damage); + std::swap(min_damage, max_damage); } if (max_damage == 0.0f) @@ -2853,12 +2853,12 @@ void Unit::SendMeleeAttackStop(Unit* victim) if (!victim) return; - WorldPacket data(SMSG_ATTACKSTOP, (4+16)); // we guess size + WorldPacket data(SMSG_ATTACKSTOP, (4 + 16)); // we guess size data << GetPackGUID(); data << victim->GetPackGUID(); // can be 0x00... data << uint32(0); // can be 0x1 SendMessageToSet(&data, true); - DETAIL_FILTER_LOG(LOG_FILTER_COMBAT, "%s %u stopped attacking %s %u", (GetTypeId()==TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId()==TYPEID_PLAYER ? "player" : "creature"),victim->GetGUIDLow()); + DETAIL_FILTER_LOG(LOG_FILTER_COMBAT, "%s %u stopped attacking %s %u", (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), (victim->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), victim->GetGUIDLow()); /*if(victim->GetTypeId() == TYPEID_UNIT) ((Creature*)victim)->AI().EnterEvadeMode(this);*/ @@ -2896,7 +2896,7 @@ bool Unit::IsSpellBlocked(Unit* pCaster, SpellEntry const* spellEntry, WeaponAtt } float blockChance = GetUnitBlockChance(); - blockChance += (int32(pCaster->GetWeaponSkillValue(attackType)) - int32(GetMaxSkillValueForLevel()))*0.04f; + blockChance += (int32(pCaster->GetWeaponSkillValue(attackType)) - int32(GetMaxSkillValueForLevel())) * 0.04f; return roll_chance_f(blockChance); } @@ -2954,13 +2954,13 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) attType = RANGED_ATTACK; // bonus from skills is 0.04% per skill Diff - int32 attackerWeaponSkill = (spell->EquippedItemClass == ITEM_CLASS_WEAPON) ? int32(GetWeaponSkillValue(attType,pVictim)) : GetMaxSkillValueForLevel(); + int32 attackerWeaponSkill = (spell->EquippedItemClass == ITEM_CLASS_WEAPON) ? int32(GetWeaponSkillValue(attType, pVictim)) : GetMaxSkillValueForLevel(); int32 skillDiff = attackerWeaponSkill - int32(pVictim->GetMaxSkillValueForLevel(this)); int32 fullSkillDiff = attackerWeaponSkill - int32(pVictim->GetDefenseSkillValue(this)); uint32 roll = urand(0, 10000); - uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell)*100.0f); + uint32 missChance = uint32(MeleeSpellMissChance(pVictim, attType, fullSkillDiff, spell) * 100.0f); // Roll miss uint32 tmp = spell->HasAttribute(SPELL_ATTR_EX3_CANT_MISS) ? 0 : missChance; if (roll < tmp) @@ -2975,8 +2975,8 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) if (effect_mech) { int32 temp = pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_MECHANIC_RESISTANCE, effect_mech); - if (resist_mech < temp*100) - resist_mech = temp*100; + if (resist_mech < temp * 100) + resist_mech = temp * 100; } } // Roll chance @@ -2991,7 +2991,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) if (spell->HasAttribute(SPELL_ATTR_IMPOSSIBLE_DODGE_PARRY_BLOCK)) return SPELL_MISS_NONE; - bool from_behind = !pVictim->HasInArc(M_PI_F,this); + bool from_behind = !pVictim->HasInArc(M_PI_F, this); // Ranged attack cannot be parry/dodge only deflect if (attType == RANGED_ATTACK) @@ -2999,7 +2999,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) // only if in front or special ability if (!from_behind || pVictim->HasAuraType(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT)) { - int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100; + int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; //if (from_behind) -- only 100% currently and not 100% sure way value apply // deflect_chance = int32(deflect_chance * (pVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT) - 1); @@ -3022,7 +3022,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) canParry = false; } // Check creatures flags_extra for disable parry - if (pVictim->GetTypeId()==TYPEID_UNIT) + if (pVictim->GetTypeId() == TYPEID_UNIT) { uint32 flagEx = ((Creature*)pVictim)->GetCreatureInfo()->flags_extra; if (flagEx & CREATURE_FLAG_EXTRA_NO_PARRY) @@ -3048,14 +3048,14 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) if (canDodge) { // Roll dodge - int32 dodgeChance = int32(pVictim->GetUnitDodgeChance()*100.0f) - skillDiff * 4; + int32 dodgeChance = int32(pVictim->GetUnitDodgeChance() * 100.0f) - skillDiff * 4; // Reduce enemy dodge chance by SPELL_AURA_MOD_COMBAT_RESULT_CHANCE - dodgeChance+= GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE)*100; + dodgeChance += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_COMBAT_RESULT_CHANCE, VICTIMSTATE_DODGE) * 100; // Reduce dodge chance by attacker expertise rating if (GetTypeId() == TYPEID_PLAYER) - dodgeChance-=int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); + dodgeChance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); else - dodgeChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25; + dodgeChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25; if (dodgeChance < 0) dodgeChance = 0; @@ -3067,12 +3067,12 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell) if (canParry) { // Roll parry - int32 parryChance = int32(pVictim->GetUnitParryChance()*100.0f) - skillDiff * 4; + int32 parryChance = int32(pVictim->GetUnitParryChance() * 100.0f) - skillDiff * 4; // Reduce parry chance by attacker expertise rating if (GetTypeId() == TYPEID_PLAYER) - parryChance-=int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); + parryChance -= int32(((Player*)this)->GetExpertiseDodgeOrParryReduction(attType) * 100.0f); else - parryChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE)*25; + parryChance -= GetTotalAuraModifier(SPELL_AURA_MOD_EXPERTISE) * 25; if (parryChance < 0) parryChance = 0; @@ -3110,15 +3110,15 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell) if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance); // Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras - modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask); + modHitChance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask); // Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras - modHitChance+= pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask); + modHitChance += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask); // Reduce spell hit chance for Area of effect spells from victim SPELL_AURA_MOD_AOE_AVOIDANCE aura if (IsAreaOfEffectSpell(spell)) - modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE); + modHitChance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE); // Reduce spell hit chance for dispel mechanic spells from victim SPELL_AURA_MOD_DISPEL_RESIST if (IsDispelSpell(spell)) - modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST); + modHitChance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_DISPEL_RESIST); // Chance resist mechanic (select max value from every mechanic spell effect) int32 resist_mech = 0; // Get effects mechanic and chance @@ -3133,35 +3133,35 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell) } } // Apply mod - modHitChance-=resist_mech; + modHitChance -= resist_mech; // Chance resist debuff - modHitChance-=pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spell->Dispel)); + modHitChance -= pVictim->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DEBUFF_RESISTANCE, int32(spell->Dispel)); int32 HitChance = modHitChance * 100; // Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings - HitChance += int32(m_modSpellHitChance*100.0f); + HitChance += int32(m_modSpellHitChance * 100.0f); // Decrease hit chance from victim rating bonus - if (pVictim->GetTypeId()==TYPEID_PLAYER) - HitChance -= int32(((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_SPELL)*100.0f); + if (pVictim->GetTypeId() == TYPEID_PLAYER) + HitChance -= int32(((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_SPELL) * 100.0f); if (HitChance < 100) HitChance = 100; if (HitChance > 10000) HitChance = 10000; int32 tmp = spell->HasAttribute(SPELL_ATTR_EX3_CANT_MISS) ? 0 : (10000 - HitChance); - int32 rand = irand(0,10000); + int32 rand = irand(0, 10000); if (rand < tmp) return SPELL_MISS_MISS; - bool from_behind = !pVictim->HasInArc(M_PI_F,this); + bool from_behind = !pVictim->HasInArc(M_PI_F, this); // cast by caster in front of victim or behind with special ability if (!from_behind || pVictim->HasAuraType(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT)) { - int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100; + int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100; //if (from_behind) -- only 100% currently and not 100% sure way value apply // deflect_chance = int32(deflect_chance * (pVictim->GetTotalAuraMultiplier(SPELL_AURA_MOD_PARRY_FROM_BEHIND_PERCENT)) - 1); @@ -3185,7 +3185,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell) SpellMissInfo Unit::SpellHitResult(Unit* pVictim, SpellEntry const* spell, bool CanReflect) { // Return evade for units in evade mode - if (pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) + if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()) return SPELL_MISS_EVADE; // Check for immune @@ -3273,7 +3273,7 @@ float Unit::MeleeMissChanceCalc(const Unit* pVictim, WeaponAttackType attType) c missChance -= m_modMeleeHitChance; // Hit chance for victim based on ratings - if (pVictim->GetTypeId()==TYPEID_PLAYER) + if (pVictim->GetTypeId() == TYPEID_PLAYER) { if (attType == RANGED_ATTACK) missChance += ((Player*)pVictim)->GetRatingBonusValue(CR_HIT_TAKEN_RANGED); @@ -3342,9 +3342,9 @@ float Unit::GetUnitParryChance() const Player const* player = (Player const*)this; if (player->CanParry()) { - Item* tmpitem = player->GetWeaponForAttack(BASE_ATTACK,true,true); + Item* tmpitem = player->GetWeaponForAttack(BASE_ATTACK, true, true); if (!tmpitem) - tmpitem = player->GetWeaponForAttack(OFF_ATTACK,true,true); + tmpitem = player->GetWeaponForAttack(OFF_ATTACK, true, true); if (tmpitem) chance = GetFloatValue(PLAYER_PARRY_PERCENTAGE); @@ -3448,7 +3448,7 @@ uint32 Unit::GetWeaponSkillValue(WeaponAttackType attType, Unit const* target) c uint32 value = 0; if (GetTypeId() == TYPEID_PLAYER) { - Item* item = ((Player*)this)->GetWeaponForAttack(attType,true,true); + Item* item = ((Player*)this)->GetWeaponForAttack(attType, true, true); // feral or unarmed skill only for base attack if (attType != BASE_ATTACK && !item) @@ -3468,9 +3468,9 @@ uint32 Unit::GetWeaponSkillValue(WeaponAttackType attType, Unit const* target) c value += uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL)); switch (attType) { - case BASE_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND)); break; - case OFF_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND)); break; - case RANGED_ATTACK: value+=uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED)); break; + case BASE_ATTACK: value += uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_MAINHAND)); break; + case OFF_ATTACK: value += uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_OFFHAND)); break; + case RANGED_ATTACK: value += uint32(((Player*)this)->GetRatingBonusValue(CR_WEAPON_SKILL_RANGED)); break; } } else @@ -3592,7 +3592,7 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell) if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self // break same type spell if it is not delayed - InterruptSpell(CSpellType,false); + InterruptSpell(CSpellType, false); // special breakage effects: switch (CSpellType) @@ -3600,7 +3600,7 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell) case CURRENT_GENERIC_SPELL: { // generic spells always break channeled not delayed spells - InterruptSpell(CURRENT_CHANNELED_SPELL,false); + InterruptSpell(CURRENT_CHANNELED_SPELL, false); // autorepeat breaking if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]) @@ -3614,7 +3614,7 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell) case CURRENT_CHANNELED_SPELL: { // channel spells always break generic non-delayed and any channeled spells - InterruptSpell(CURRENT_GENERIC_SPELL,false); + InterruptSpell(CURRENT_GENERIC_SPELL, false); InterruptSpell(CURRENT_CHANNELED_SPELL); // it also does break autorepeat if not Auto Shot @@ -3629,11 +3629,11 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell) if (pSpell->m_spellInfo->Id != SPELL_ID_AUTOSHOT) { // generic autorepeats break generic non-delayed and channeled non-delayed spells - InterruptSpell(CURRENT_GENERIC_SPELL,false); - InterruptSpell(CURRENT_CHANNELED_SPELL,false); + InterruptSpell(CURRENT_GENERIC_SPELL, false); + InterruptSpell(CURRENT_CHANNELED_SPELL, false); // special action: first cast delay if (getAttackTimer(RANGED_ATTACK) < 500) - setAttackTimer(RANGED_ATTACK,500); + setAttackTimer(RANGED_ATTACK, 500); } } break; @@ -3718,15 +3718,15 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id) { // generic spells are interrupted if they are not finished or delayed if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id == spell_id)) - InterruptSpell(CURRENT_GENERIC_SPELL,withDelayed); + InterruptSpell(CURRENT_GENERIC_SPELL, withDelayed); // autorepeat spells are interrupted if they are not finished or delayed if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id == spell_id)) - InterruptSpell(CURRENT_AUTOREPEAT_SPELL,withDelayed); + InterruptSpell(CURRENT_AUTOREPEAT_SPELL, withDelayed); // channeled spells are interrupted if they are not finished, even if they are delayed if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id == spell_id)) - InterruptSpell(CURRENT_CHANNELED_SPELL,true); + InterruptSpell(CURRENT_CHANNELED_SPELL, true); } Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const @@ -3769,12 +3769,12 @@ bool Unit::isInAccessablePlaceFor(Creature const* c) const bool Unit::IsInWater() const { - return GetTerrain()->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ()); + return GetTerrain()->IsInWater(GetPositionX(), GetPositionY(), GetPositionZ()); } bool Unit::IsUnderWater() const { - return GetTerrain()->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ()); + return GetTerrain()->IsUnderWater(GetPositionX(), GetPositionY(), GetPositionZ()); } void Unit::DeMorph() @@ -3799,7 +3799,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auratype) const AuraList const& mTotalAuraList = GetAurasByType(auratype); for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) - multiplier *= (100.0f + (*i)->GetModifier()->m_amount)/100.0f; + multiplier *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; return multiplier; } @@ -3857,7 +3857,7 @@ float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue & misc_mask) - multiplier *= (100.0f + mod->m_amount)/100.0f; + multiplier *= (100.0f + mod->m_amount) / 100.0f; } return multiplier; } @@ -3921,7 +3921,7 @@ float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_valu { Modifier* mod = (*i)->GetModifier(); if (mod->m_miscvalue == misc_value) - multiplier *= (100.0f + mod->m_amount)/100.0f; + multiplier *= (100.0f + mod->m_amount) / 100.0f; } return multiplier; } @@ -3967,8 +3967,8 @@ float Unit::GetTotalAuraMultiplierByMiscValueForMask(AuraType auratype, uint32 m for (AuraList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { Modifier* mod = (*i)->GetModifier(); - if (mask & (1 << (mod->m_miscvalue -1))) - multiplier *= (100.0f + mod->m_amount)/100.0f; + if (mask & (1 << (mod->m_miscvalue - 1))) + multiplier *= (100.0f + mod->m_amount) / 100.0f; } return multiplier; } @@ -3980,7 +3980,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder) // ghost spell check, allow apply any auras at player loading in ghost mode (will be cleanup after load) if (!isAlive() && !IsDeathPersistentSpell(aurSpellInfo) && !IsDeathOnlySpell(aurSpellInfo) && - (GetTypeId()!=TYPEID_PLAYER || !((Player*)this)->GetSession()->PlayerLoading())) + (GetTypeId() != TYPEID_PLAYER || !((Player*)this)->GetSession()->PlayerLoading())) { delete holder; return false; @@ -3989,8 +3989,8 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder) if (holder->GetTarget() != this) { sLog.outError("Holder (spell %u) add to spell aura holder list of %s (lowguid: %u) but spell aura holder target is %s (lowguid: %u)", - holder->GetId(),(GetTypeId()==TYPEID_PLAYER?"player":"creature"),GetGUIDLow(), - (holder->GetTarget()->GetTypeId()==TYPEID_PLAYER?"player":"creature"),holder->GetTarget()->GetGUIDLow()); + holder->GetId(), (GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), GetGUIDLow(), + (holder->GetTarget()->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), holder->GetTarget()->GetGUIDLow()); delete holder; return false; } @@ -4077,7 +4077,7 @@ bool Unit::AddSpellAuraHolder(SpellAuraHolder* holder) case SPELL_AURA_PERIODIC_ENERGIZE: // all or self or clear non-stackable default: // not allow // can be only single (this check done at _each_ aura add - RemoveSpellAuraHolder(foundHolder,AURA_REMOVE_BY_STACK); + RemoveSpellAuraHolder(foundHolder, AURA_REMOVE_BY_STACK); stop = true; break; } @@ -4162,7 +4162,7 @@ void Unit::RemoveRankAurasDueToSpell(uint32 spellId) SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId); if (!spellInfo) return; - SpellAuraHolderMap::const_iterator i,next; + SpellAuraHolderMap::const_iterator i, next; for (i = m_spellAuraHolders.begin(); i != m_spellAuraHolders.end(); i = next) { next = i; @@ -4170,7 +4170,7 @@ void Unit::RemoveRankAurasDueToSpell(uint32 spellId) uint32 i_spellId = (*i).second->GetId(); if ((*i).second && i_spellId && i_spellId != spellId) { - if (sSpellMgr.IsRankSpellDueToSpell(spellInfo,i_spellId)) + if (sSpellMgr.IsRankSpellDueToSpell(spellInfo, i_spellId)) { RemoveAurasDueToSpell(i_spellId); @@ -4203,7 +4203,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) SpellSpecific spellId_spec = GetSpellSpecific(spellId); - SpellAuraHolderMap::iterator i,next; + SpellAuraHolderMap::iterator i, next; for (i = m_spellAuraHolders.begin(); i != m_spellAuraHolders.end(); i = next) { next = i; @@ -4248,8 +4248,8 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); // single allowed spell specific from same caster or from any caster at target - bool is_spellSpecPerTargetPerCaster = IsSingleFromSpellSpecificPerTargetPerCaster(spellId_spec,i_spellId_spec); - bool is_spellSpecPerTarget = IsSingleFromSpellSpecificPerTarget(spellId_spec,i_spellId_spec); + bool is_spellSpecPerTargetPerCaster = IsSingleFromSpellSpecificPerTargetPerCaster(spellId_spec, i_spellId_spec); + bool is_spellSpecPerTarget = IsSingleFromSpellSpecificPerTarget(spellId_spec, i_spellId_spec); if (is_spellSpecPerTarget || (is_spellSpecPerTargetPerCaster && holder->GetCasterGuid() == (*i).second->GetCasterGuid())) { // cannot remove higher rank @@ -4275,7 +4275,7 @@ bool Unit::RemoveNoStackAurasDueToAuraHolder(SpellAuraHolder* holder) // spell with spell specific that allow single ranks for spell from diff caster // same caster case processed or early or later - bool is_spellPerTarget = IsSingleFromSpellSpecificSpellRanksPerTarget(spellId_spec,i_spellId_spec); + bool is_spellPerTarget = IsSingleFromSpellSpecificSpellRanksPerTarget(spellId_spec, i_spellId_spec); if (is_spellPerTarget && holder->GetCasterGuid() != (*i).second->GetCasterGuid() && sSpellMgr.IsRankSpellDueToSpell(spellProto, i_spellId)) { // cannot remove higher rank @@ -4401,7 +4401,7 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount // Unstable Affliction if (spellEntry->SpellFamilyName == SPELLFAMILY_WARLOCK && (spellEntry->SpellFamilyFlags & UI64LIT(0x010000000000))) { - if (Aura* dotAura = GetAura(SPELL_AURA_PERIODIC_DAMAGE,SPELLFAMILY_WARLOCK,UI64LIT(0x010000000000), 0x00000000, casterGuid)) + if (Aura* dotAura = GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, UI64LIT(0x010000000000), 0x00000000, casterGuid)) { // use clean value for initial damage int32 damage = dotAura->GetSpellProto()->CalculateSimpleValue(EFFECT_INDEX_0); @@ -4446,9 +4446,9 @@ void Unit::RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount { switch ((*i)->GetId()) { - case 51480: triggeredSpell=64694; break;// Lava Flows, Rank 1 - case 51481: triggeredSpell=65263; break;// Lava Flows, Rank 2 - case 51482: triggeredSpell=65264; break;// Lava Flows, Rank 3 + case 51480: triggeredSpell = 64694; break; // Lava Flows, Rank 1 + case 51481: triggeredSpell = 65263; break; // Lava Flows, Rank 2 + case 51482: triggeredSpell = 65264; break; // Lava Flows, Rank 3 default: continue; } break; @@ -4495,7 +4495,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, U // set its duration and maximum duration // max duration 2 minutes (in msecs) int32 dur = holder->GetAuraDuration(); - int32 max_dur = 2*MINUTE*IN_MILLISECONDS; + int32 max_dur = 2 * MINUTE * IN_MILLISECONDS; int32 new_max_dur = max_dur > dur ? dur : max_dur; new_holder->SetAuraMaxDuration(new_max_dur); new_holder->SetAuraDuration(new_max_dur); @@ -4550,7 +4550,7 @@ void Unit::RemoveAurasWithDispelType(DispelType type, ObjectGuid casterGuid) for (SpellAuraHolderMap::iterator itr = auras.begin(); itr != auras.end();) { SpellEntry const* spell = itr->second->GetSpellProto(); - if (((1<Dispel) & dispelMask) && (!casterGuid || casterGuid == itr->second->GetCasterGuid())) + if (((1 << spell->Dispel) & dispelMask) && (!casterGuid || casterGuid == itr->second->GetCasterGuid())) { // Dispel aura RemoveAurasDueToSpell(spell->Id); @@ -4598,7 +4598,7 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, SpellAuraHolder* except, AuraRe } } -void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) +void Unit::RemoveAurasDueToItemSpell(Item* castItem, uint32 spellId) { SpellAuraHolderBounds bounds = GetSpellAuraHolderBounds(spellId); for (SpellAuraHolderMap::iterator iter = bounds.first; iter != bounds.second;) @@ -4719,7 +4719,7 @@ void Unit::RemoveSpellAuraHolder(SpellAuraHolder* holder, AuraRemoveMode mode) Totem* statue = NULL; Unit* caster = holder->GetCaster(); if (IsChanneledSpell(AurSpellInfo) && caster) - if (caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->IsTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) + if (caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->IsTotem() && ((Totem*)caster)->GetTotemType() == TOTEM_STATUE) statue = ((Totem*)caster); if (m_spellAuraHoldersUpdateIterator != m_spellAuraHolders.end() && m_spellAuraHoldersUpdateIterator->second == holder) @@ -4796,7 +4796,7 @@ void Unit::RemoveAura(Aura* Aur, AuraRemoveMode mode) // remove aura from list before to prevent deleting it before ///m_Auras.erase(i); - DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Aura %u now is remove mode %d",Aur->GetModifier()->m_auraname, mode); + DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Aura %u now is remove mode %d", Aur->GetModifier()->m_auraname, mode); // aura _MUST_ be remove from holder before unapply. // un-apply code expected that aura not find by diff searches @@ -4812,13 +4812,13 @@ void Unit::RemoveAura(Aura* Aur, AuraRemoveMode mode) case SPELL_AURA_MOD_POSSESS: case SPELL_AURA_MOD_POSSESS_PET: case SPELL_AURA_CONTROL_VEHICLE: - Aur->ApplyModifier(false,true); + Aur->ApplyModifier(false, true); break; default: break; } } else - Aur->ApplyModifier(false,true); + Aur->ApplyModifier(false, true); // If aura in use (removed from code that plan access to it data after return) // store it in aura list with delayed deletion @@ -4833,7 +4833,7 @@ void Unit::RemoveAllAuras(AuraRemoveMode mode /*= AURA_REMOVE_BY_DEFAULT*/) while (!m_spellAuraHolders.empty()) { SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); - RemoveSpellAuraHolder(iter->second,mode); + RemoveSpellAuraHolder(iter->second, mode); } } @@ -5099,7 +5099,7 @@ void Unit::RemoveGameObject(GameObject* gameObj, bool del) { RemoveAurasDueToSpell(spellid); - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { SpellEntry const* createBySpell = sSpellStore.LookupEntry(spellid); // Need activate spell use for owner @@ -5163,7 +5163,7 @@ void Unit::SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log) uint32 targetHealth = log->target->GetHealth(); uint32 overkill = log->damage > targetHealth ? log->damage - targetHealth : 0; - WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16+4+4+4+1+4+4+1+1+4+4+1)); // we guess size + WorldPacket data(SMSG_SPELLNONMELEEDAMAGELOG, (16 + 4 + 4 + 4 + 1 + 4 + 4 + 1 + 1 + 4 + 4 + 1)); // we guess size data << log->target->GetPackGUID(); data << log->attacker->GetPackGUID(); data << uint32(log->SpellID); @@ -5245,16 +5245,16 @@ void Unit::ProcDamageAndSpell(Unit* pVictim, uint32 procAttacker, uint32 procVic { // Not much to do if no flags are set. if (procAttacker) - ProcDamageAndSpellFor(false,pVictim,procAttacker, procExtra,attType, procSpell, amount); + ProcDamageAndSpellFor(false, pVictim, procAttacker, procExtra, attType, procSpell, amount); // Now go on with a victim's events'n'auras // Not much to do if no flags are set or there is no victim if (pVictim && pVictim->isAlive() && procVictim) - pVictim->ProcDamageAndSpellFor(true,this,procVictim, procExtra, attType, procSpell, amount); + pVictim->ProcDamageAndSpellFor(true, this, procVictim, procExtra, attType, procSpell, amount); } void Unit::SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo) { - WorldPacket data(SMSG_SPELLLOGMISS, (4+8+1+4+8+1)); + WorldPacket data(SMSG_SPELLLOGMISS, (4 + 8 + 1 + 4 + 8 + 1)); data << uint32(spellID); data << GetObjectGuid(); data << uint8(0); // can be 0 or 1 @@ -5375,19 +5375,19 @@ void Unit::setPowerType(Powers new_powertype) case POWER_MANA: break; case POWER_RAGE: - SetMaxPower(POWER_RAGE,GetCreatePowers(POWER_RAGE)); - SetPower(POWER_RAGE,0); + SetMaxPower(POWER_RAGE, GetCreatePowers(POWER_RAGE)); + SetPower(POWER_RAGE, 0); break; case POWER_FOCUS: - SetMaxPower(POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); - SetPower(POWER_FOCUS,GetCreatePowers(POWER_FOCUS)); + SetMaxPower(POWER_FOCUS, GetCreatePowers(POWER_FOCUS)); + SetPower(POWER_FOCUS, GetCreatePowers(POWER_FOCUS)); break; case POWER_ENERGY: - SetMaxPower(POWER_ENERGY,GetCreatePowers(POWER_ENERGY)); + SetMaxPower(POWER_ENERGY, GetCreatePowers(POWER_ENERGY)); break; case POWER_HAPPINESS: - SetMaxPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS)); - SetPower(POWER_HAPPINESS,GetCreatePowers(POWER_HAPPINESS)); + SetMaxPower(POWER_HAPPINESS, GetCreatePowers(POWER_HAPPINESS)); + SetPower(POWER_HAPPINESS, GetCreatePowers(POWER_HAPPINESS)); break; } } @@ -5491,7 +5491,7 @@ bool Unit::IsHostileTo(Unit const* unit) const if (target_faction->faction) { // forced reaction - if (ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction)) + if (ReputationRank const* force = ((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction)) return *force <= REP_HOSTILE; // if faction have reputation then hostile state for tester at 100% dependent from at_war state @@ -5603,7 +5603,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const if (target_faction->faction) { // forced reaction - if (ReputationRank const* force =((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction)) + if (ReputationRank const* force = ((Player*)tester)->GetReputationMgr().GetForcedRankIfAny(target_faction)) return *force >= REP_FRIENDLY; // if faction have reputation then friendly state for tester at 100% dependent from at_war state @@ -5618,12 +5618,12 @@ bool Unit::IsFriendlyTo(Unit const* unit) const if (tester_faction->faction) { // forced reaction - if (ReputationRank const* force =((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) + if (ReputationRank const* force = ((Player*)target)->GetReputationMgr().GetForcedRankIfAny(tester_faction)) return *force >= REP_FRIENDLY; // apply reputation state if (FactionEntry const* raw_tester_faction = sFactionStore.LookupEntry(tester_faction->faction)) - if (raw_tester_faction->reputationListID >=0) + if (raw_tester_faction->reputationListID >= 0) return ((Player const*)target)->GetReputationMgr().GetRank(raw_tester_faction) >= REP_FRIENDLY; } } @@ -5639,7 +5639,7 @@ bool Unit::IsHostileToPlayers() const return false; FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if (raw_faction && raw_faction->reputationListID >=0) + if (raw_faction && raw_faction->reputationListID >= 0) return false; return my_faction->IsHostileToPlayers(); @@ -5652,7 +5652,7 @@ bool Unit::IsNeutralToAll() const return true; FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction); - if (raw_faction && raw_faction->reputationListID >=0) + if (raw_faction && raw_faction->reputationListID >= 0) return false; return my_faction->IsNeutralToAll(); @@ -5668,11 +5668,11 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) return false; // player cannot attack in mount state - if (GetTypeId()==TYPEID_PLAYER && IsMounted()) + if (GetTypeId() == TYPEID_PLAYER && IsMounted()) return false; // nobody can attack GM in GM-mode - if (victim->GetTypeId()==TYPEID_PLAYER) + if (victim->GetTypeId() == TYPEID_PLAYER) { if (((Player*)victim)->isGameMaster()) return false; @@ -5709,7 +5709,7 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) else { // set position before any AI calls/assistance - if (GetTypeId()==TYPEID_UNIT) + if (GetTypeId() == TYPEID_UNIT) ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); } @@ -5771,7 +5771,7 @@ bool Unit::AttackStop(bool targetSwitch /*=false*/) InterruptSpell(CURRENT_MELEE_SPELL); // reset only at real combat stop - if (!targetSwitch && GetTypeId()==TYPEID_UNIT) + if (!targetSwitch && GetTypeId() == TYPEID_UNIT) { ((Creature*)this)->SetNoCallAssistance(false); @@ -5795,7 +5795,7 @@ void Unit::CombatStop(bool includingCast) AttackStop(); RemoveAllAttackers(); - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) ((Player*)this)->SendAttackSwingCancelAttack(); // melee and ranged forced attack cancel else if (GetTypeId() == TYPEID_UNIT) { @@ -5816,7 +5816,7 @@ struct CombatStopWithPetsHelper void Unit::CombatStopWithPets(bool includingCast) { CombatStop(includingCast); - CallForAllControlledUnits(CombatStopWithPetsHelper(includingCast), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); + CallForAllControlledUnits(CombatStopWithPetsHelper(includingCast), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); } struct IsAttackingPlayerHelper @@ -5830,7 +5830,7 @@ bool Unit::isAttackingPlayer() const if (hasUnitState(UNIT_STAT_ATTACK_PLAYER)) return true; - return CheckAllControlledUnits(IsAttackingPlayerHelper(), CONTROLLED_PET|CONTROLLED_TOTEMS|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); + return CheckAllControlledUnits(IsAttackingPlayerHelper(), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); } void Unit::RemoveAllAttackers() @@ -5875,9 +5875,9 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) { if (apply) { - if (!HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1))) + if (!HasFlag(UNIT_FIELD_AURASTATE, 1 << (flag - 1))) { - SetFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); + SetFlag(UNIT_FIELD_AURASTATE, 1 << (flag - 1)); if (GetTypeId() == TYPEID_PLAYER) { const PlayerSpellMap& sp_list = ((Player*)this)->GetSpellMap(); @@ -5894,9 +5894,9 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) } else { - if (HasFlag(UNIT_FIELD_AURASTATE,1<<(flag-1))) + if (HasFlag(UNIT_FIELD_AURASTATE, 1 << (flag - 1))) { - RemoveFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); + RemoveFlag(UNIT_FIELD_AURASTATE, 1 << (flag - 1)); if (flag != AURA_STATE_ENRAGE) // enrage aura state triggering continues auras { @@ -5933,7 +5933,7 @@ Unit* Unit::GetCharmer() const bool Unit::IsCharmerOrOwnerPlayerOrPlayerItself() const { - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) return true; return GetCharmerOrOwnerGuid().IsPlayer(); @@ -5945,7 +5945,7 @@ Player* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() if (guid.IsPlayer()) return ObjectAccessor::FindPlayer(guid); - return GetTypeId()==TYPEID_PLAYER ? (Player*)this : NULL; + return GetTypeId() == TYPEID_PLAYER ? (Player*)this : NULL; } Player const* Unit::GetCharmerOrOwnerPlayerOrPlayerItself() const @@ -6022,7 +6022,7 @@ float Unit::GetCombatDistance(const Unit* target) const float dx = GetPositionX() - target->GetPositionX(); float dy = GetPositionY() - target->GetPositionY(); float dz = GetPositionZ() - target->GetPositionZ(); - float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - radius; + float dist = sqrt((dx * dx) + (dy * dy) + (dz * dz)) - radius; return (dist > 0 ? dist : 0); } @@ -6202,7 +6202,7 @@ Unit* Unit::SelectMagnetTarget(Unit* victim, Spell* spell, SpellEffectIndex eff) void Unit::SendHealSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, uint32 OverHeal, bool critical, uint32 absorb) { // we guess size - WorldPacket data(SMSG_SPELLHEALLOG, (8+8+4+4+1)); + WorldPacket data(SMSG_SPELLHEALLOG, (8 + 8 + 4 + 4 + 1)); data << pVictim->GetPackGUID(); data << GetPackGUID(); data << uint32(SpellID); @@ -6216,7 +6216,7 @@ void Unit::SendHealSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, uint32 void Unit::SendEnergizeSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, Powers powertype) { - WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); + WorldPacket data(SMSG_SPELLENERGIZELOG, (8 + 8 + 4 + 4 + 4 + 1)); data << pVictim->GetPackGUID(); data << GetPackGUID(); data << uint32(SpellID); @@ -6238,7 +6238,7 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int3 float coeff = 1.0f; // Not apply this to creature casted spells - if (GetTypeId()==TYPEID_UNIT && !((Creature*)this)->IsPet()) + if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->IsPet()) coeff = 1.0f; // Check for table values else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id)) @@ -6272,7 +6272,7 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int3 if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_SPELL_BONUS_DAMAGE, coeff); + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_SPELL_BONUS_DAMAGE, coeff); coeff /= 100.0f; } @@ -6292,7 +6292,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u return pdamage; // For totems get damage bonus from owner (statue isn't totem in fact) - if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE) { if (Unit* owner = GetOwner()) return owner->SpellDamageBonusDone(pVictim, spellProto, pdamage, damagetype); @@ -6324,19 +6324,19 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u AuraList const& mDamageDoneVersus = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_VERSUS); for (AuraList::const_iterator i = mDamageDoneVersus.begin(); i != mDamageDoneVersus.end(); ++i) if (creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; AuraList const& mDamageDoneCreature = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE); for (AuraList::const_iterator i = mDamageDoneCreature.begin(); i != mDamageDoneCreature.end(); ++i) { if (creatureTypeMask & uint32((*i)->GetModifier()->m_miscvalue)) - DoneTotalMod += ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod += ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; } // done scripted mod (take it from owner) Unit* owner = GetOwner(); if (!owner) owner = this; - AuraList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& mOverrideClassScript = owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) @@ -6350,7 +6350,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u case 6928: { if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) - DoneTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; + DoneTotalMod *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; break; } // Soul Siphon @@ -6376,19 +6376,19 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u break; } } - DoneTotalMod *= (modPercent+100.0f)/100.0f; + DoneTotalMod *= (modPercent + 100.0f) / 100.0f; break; } case 6916: // Death's Embrace case 6925: case 6927: if (HasAuraState(AURA_STATE_HEALTHLESS_20_PERCENT)) - DoneTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; + DoneTotalMod *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; break; case 5481: // Starfire Bonus { if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, UI64LIT(0x0000000000200002))) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } case 4418: // Increased Shock Damage @@ -6400,7 +6400,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u case 6008: // Increased Lightning Damage case 8627: // Totem of Hex { - DoneTotal+=(*i)->GetModifier()->m_amount; + DoneTotal += (*i)->GetModifier()->m_amount; break; } // Tundra Stalker @@ -6411,13 +6411,13 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u if ((*i)->GetSpellProto()->SpellIconID == 2656) { if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) - DoneTotalMod *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; + DoneTotalMod *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; } else // Tundra Stalker { // Frost Fever (target debuff) if (pVictim->GetAura(SPELL_AURA_MOD_MELEE_HASTE, SPELLFAMILY_DEATHKNIGHT, UI64LIT(0x0000000000000000), 0x00000002)) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } break; @@ -6425,14 +6425,14 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u case 7293: // Rage of Rivendare { if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, UI64LIT(0x0200000000000000))) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } // Twisted Faith case 7377: { if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x0000000000008000), 0, GetObjectGuid())) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } // Marked for Death @@ -6443,7 +6443,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u case 7602: { if (pVictim->GetAura(SPELL_AURA_MOD_STALKED, SPELLFAMILY_HUNTER, UI64LIT(0x0000000000000400))) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } } @@ -6480,7 +6480,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u { if ((*i)->GetSpellProto()->SpellIconID == 3263) { - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f) / 100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } } @@ -6506,7 +6506,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, UI64LIT(0x00100000))) // Glyph of Smite if (Aura* aur = GetAura(55692, EFFECT_INDEX_0)) - DoneTotalMod *= (aur->GetModifier()->m_amount+100.0f) / 100.0f; + DoneTotalMod *= (aur->GetModifier()->m_amount + 100.0f) / 100.0f; } // Shadow word: Death else if (spellProto->IsFitToFamilyMask(UI64LIT(0x0000000200000000))) @@ -6535,7 +6535,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u { if ((*iter)->GetSpellProto()->SpellIconID == 1771) { - DoneTotalMod *= ((*iter)->GetModifier()->m_amount+100.0f) / 100.0f; + DoneTotalMod *= ((*iter)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } } @@ -6551,7 +6551,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u // search disease bool found = false; Unit::SpellAuraHolderMap const& auras = pVictim->GetSpellAuraHolderMap(); - for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE) { @@ -6568,7 +6568,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u { if ((*i)->GetSpellProto()->EffectMiscValue[(*i)->GetEffIndex()] == 7244) { - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f) / 100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } } @@ -6610,7 +6610,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* pVictim, SpellEntry const* spellProto, u */ uint32 Unit::SpellDamageBonusTaken(Unit* pCaster, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { - if (!spellProto || !pCaster || damagetype==DIRECT_DAMAGE) + if (!spellProto || !pCaster || damagetype == DIRECT_DAMAGE) return pdamage; uint32 schoolMask = spellProto->SchoolMask; @@ -6634,7 +6634,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* pCaster, SpellEntry const* spellProto, if (GetTypeId() != TYPEID_PLAYER) continue; - float mod = ((Player*)this)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f); + float mod = ((Player*)this)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f); if (mod < float((*i)->GetModifier()->m_amount)) mod = float((*i)->GetModifier()->m_amount); @@ -6664,7 +6664,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* pCaster, SpellEntry const* spellProto, } // Mod damage from spell mechanic - TakenTotalMod *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT,GetAllSpellMechanicMask(spellProto)); + TakenTotalMod *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT, GetAllSpellMechanicMask(spellProto)); // Mod damage taken from AoE spells if (IsAreaOfEffectSpell(spellProto)) @@ -6702,7 +6702,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) if (GetTypeId() == TYPEID_PLAYER) { // Base value - DoneAdvertisedBenefit +=((Player*)this)->GetBaseSpellPowerBonus(); + DoneAdvertisedBenefit += ((Player*)this)->GetBaseSpellPowerBonus(); // Damage bonus from stats AuraList const& mDamageDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_STAT_PERCENT); @@ -6717,7 +6717,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) } // ... and attack power AuraList const& mDamageDonebyAP = GetAurasByType(SPELL_AURA_MOD_SPELL_DAMAGE_OF_ATTACK_POWER); - for (AuraList::const_iterator i =mDamageDonebyAP.begin(); i != mDamageDonebyAP.end(); ++i) + for (AuraList::const_iterator i = mDamageDonebyAP.begin(); i != mDamageDonebyAP.end(); ++i) { if ((*i)->GetModifier()->m_miscvalue & schoolMask) DoneAdvertisedBenefit += int32(GetTotalAttackPowerValue(BASE_ATTACK) * (*i)->GetModifier()->m_amount / 100.0f); @@ -6789,24 +6789,24 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM { case 849: //Shatter Rank 1 if (pVictim->isFrozen() || IsIgnoreUnitState(spellProto, IGNORE_UNIT_TARGET_NON_FROZEN)) - crit_chance+= 17.0f; + crit_chance += 17.0f; break; case 910: //Shatter Rank 2 if (pVictim->isFrozen() || IsIgnoreUnitState(spellProto, IGNORE_UNIT_TARGET_NON_FROZEN)) - crit_chance+= 34.0f; + crit_chance += 34.0f; break; case 911: //Shatter Rank 3 if (pVictim->isFrozen() || IsIgnoreUnitState(spellProto, IGNORE_UNIT_TARGET_NON_FROZEN)) - crit_chance+= 50.0f; + crit_chance += 50.0f; break; case 7917: // Glyph of Shadowburn if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) - crit_chance+=(*i)->GetModifier()->m_amount; + crit_chance += (*i)->GetModifier()->m_amount; break; case 7997: // Renewed Hope case 7998: if (pVictim->HasAura(6788)) - crit_chance+=(*i)->GetModifier()->m_amount; + crit_chance += (*i)->GetModifier()->m_amount; break; default: break; @@ -6832,16 +6832,16 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM // Flash Heal if (spellProto->IsFitToFamilyMask(UI64LIT(0x0000000000000800))) { - if (pVictim->GetHealth() > pVictim->GetMaxHealth()/2) + if (pVictim->GetHealth() > pVictim->GetMaxHealth() / 2) break; AuraList const& mDummyAuras = GetAurasByType(SPELL_AURA_DUMMY); - for (AuraList::const_iterator i = mDummyAuras.begin(); i!= mDummyAuras.end(); ++i) + for (AuraList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i) { // Improved Flash Heal if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_PRIEST && (*i)->GetSpellProto()->SpellIconID == 2542) { - crit_chance+=(*i)->GetModifier()->m_amount; + crit_chance += (*i)->GetModifier()->m_amount; break; } } @@ -6872,7 +6872,7 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM { Aura* aura = pVictim->GetDummyAura(58597); if (aura && aura->GetCasterGuid() == GetObjectGuid()) - crit_chance+=aura->GetModifier()->m_amount; + crit_chance += aura->GetModifier()->m_amount; } // Exorcism else if (spellProto->Category == 19) @@ -6900,7 +6900,7 @@ bool Unit::IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolM if (pVictim) crit_chance = GetUnitCriticalChance(attackType, pVictim); - crit_chance+= GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, schoolMask); + crit_chance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_SPELL_CRIT_CHANCE_SCHOOL, schoolMask); break; } default: @@ -6948,15 +6948,15 @@ uint32 Unit::SpellCriticalDamageBonus(SpellEntry const* spellProto, uint32 damag critPctDamageMod += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE); } else - critPctDamageMod += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_DAMAGE,GetSpellSchoolMask(spellProto)); + critPctDamageMod += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_DAMAGE, GetSpellSchoolMask(spellProto)); critPctDamageMod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, GetSpellSchoolMask(spellProto)); uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); critPctDamageMod += GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask); - if (critPctDamageMod!=0) - crit_bonus = int32(crit_bonus * float((100.0f + critPctDamageMod)/100.0f)); + if (critPctDamageMod != 0) + crit_bonus = int32(crit_bonus * float((100.0f + critPctDamageMod) / 100.0f)); if (crit_bonus > 0) damage += crit_bonus; @@ -7001,7 +7001,7 @@ uint32 Unit::SpellCriticalHealingBonus(SpellEntry const* spellProto, uint32 dama uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack) { // For totems get healing bonus from owner (statue isn't totem in fact) - if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType()!=TOTEM_STATUE) + if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE) if (Unit* owner = GetOwner()) return owner->SpellHealingBonusDone(pVictim, spellProto, healamount, damagetype, stack); @@ -7022,7 +7022,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, // done scripted mod (take it from owner) Unit* owner = GetOwner(); if (!owner) owner = this; - AuraList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& mOverrideClassScript = owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) @@ -7032,23 +7032,23 @@ uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, case 4415: // Increased Rejuvenation Healing case 4953: case 3736: // Hateful Totem of the Third Wind / Increased Lesser Healing Wave / LK Arena (4/5/6) Totem of the Third Wind / Savage Totem of the Third Wind - DoneTotal+=(*i)->GetModifier()->m_amount; + DoneTotal += (*i)->GetModifier()->m_amount; break; case 7997: // Renewed Hope case 7998: if (pVictim->HasAura(6788)) - DoneTotalMod *=((*i)->GetModifier()->m_amount + 100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; case 21: // Test of Faith case 6935: case 6918: - if (pVictim->GetHealth() < pVictim->GetMaxHealth()/2) - DoneTotalMod *=((*i)->GetModifier()->m_amount + 100.0f)/100.0f; + if (pVictim->GetHealth() < pVictim->GetMaxHealth() / 2) + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; case 7798: // Glyph of Regrowth { if (pVictim->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, UI64LIT(0x0000000000000040))) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } case 8477: // Nourish Heal Boost @@ -7070,7 +7070,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, case 7871: // Glyph of Lesser Healing Wave { if (pVictim->GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, UI64LIT(0x0000040000000000), 0, GetObjectGuid())) - DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DoneTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } default: @@ -7122,7 +7122,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true, 1.88f); // use float as more appropriate for negative values and percent applying - float heal = (healamount + DoneTotal * int32(stack))*DoneTotalMod; + float heal = (healamount + DoneTotal * int32(stack)) * DoneTotalMod; // apply spellmod to Done amount if (Player* modOwner = GetSpellModOwner()) modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); @@ -7171,7 +7171,7 @@ uint32 Unit::SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, // apply benefit affected by spell power implicit coeffs and spell level penalties TakenTotal = SpellBonusWithCoeffs(spellProto, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false, 1.88f); - AuraList const& mHealingGet= GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED); + AuraList const& mHealingGet = GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED); for (AuraList::const_iterator i = mHealingGet.begin(); i != mHealingGet.end(); ++i) if ((*i)->isAffectedOnSpell(spellProto)) TakenTotalMod *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; @@ -7195,7 +7195,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) if (GetTypeId() == TYPEID_PLAYER) { // Base value - AdvertisedBenefit +=((Player*)this)->GetBaseSpellPowerBonus(); + AdvertisedBenefit += ((Player*)this)->GetBaseSpellPowerBonus(); // Healing bonus from stats AuraList const& mHealingDoneOfStatPercent = GetAurasByType(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT); @@ -7275,7 +7275,7 @@ bool Unit::IsImmuneToSpell(SpellEntry const* spellInfo) AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) - if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic-1))) + if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic - 1))) return true; } @@ -7300,7 +7300,7 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i AuraList const& immuneAuraApply = GetAurasByType(SPELL_AURA_MECHANIC_IMMUNITY_MASK); for (AuraList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) - if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic-1))) + if ((*iter)->GetModifier()->m_miscvalue & (1 << (mechanic - 1))) return true; } @@ -7332,14 +7332,14 @@ bool Unit::IsImmuneToSpellEffect(SpellEntry const* spellInfo, SpellEffectIndex i * Calculates caster part of melee damage bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) +uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage, WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) { if (!pVictim || pdamage == 0 || (spellProto && spellProto->HasAttribute(SPELL_ATTR_EX6_NO_DMG_MODS))) return pdamage; // differentiate for weapon damage based spells bool isWeaponDamageBasedSpell = !(spellProto && (damagetype == DOT || IsSpellHaveEffect(spellProto, SPELL_EFFECT_SCHOOL_DAMAGE))); - Item* pWeapon = GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetWeaponForAttack(attType,true,false) : NULL; + Item* pWeapon = GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetWeaponForAttack(attType, true, false) : NULL; uint32 creatureTypeMask = pVictim->GetCreatureTypeMask(); uint32 schoolMask = spellProto ? spellProto->SchoolMask : GetMeleeDamageSchoolMask(); @@ -7398,7 +7398,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType (((*i)->GetSpellProto()->EquippedItemClass == -1) || // general, weapon independent (pWeapon && pWeapon->IsFitToSpellRequirements((*i)->GetSpellProto())))) // OR used weapon fits aura requirements { - DonePercent *= ((*i)->GetModifier()->m_amount+100.0f) / 100.0f; + DonePercent *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; } } @@ -7418,7 +7418,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType // ..done (class scripts) if (spellProto) { - AuraList const& mOverrideClassScript= owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); + AuraList const& mOverrideClassScript = owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { if (!(*i)->isAffectedOnSpell(spellProto)) @@ -7434,13 +7434,13 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType if ((*i)->GetSpellProto()->SpellIconID == 2656) { if (pVictim->HasAuraState(AURA_STATE_HEALTHLESS_35_PERCENT)) - DonePercent *= (100.0f+(*i)->GetModifier()->m_amount)/100.0f; + DonePercent *= (100.0f + (*i)->GetModifier()->m_amount) / 100.0f; } else // Tundra Stalker { // Frost Fever (target debuff) if (pVictim->GetAura(SPELL_AURA_MOD_MELEE_HASTE, SPELLFAMILY_DEATHKNIGHT, UI64LIT(0x0000000000000000), 0x00000002)) - DonePercent *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DonePercent *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } break; @@ -7448,7 +7448,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType case 7293: // Rage of Rivendare { if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, UI64LIT(0x0200000000000000))) - DonePercent *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DonePercent *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } // Marked for Death @@ -7459,7 +7459,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType case 7602: { if (pVictim->GetAura(SPELL_AURA_MOD_STALKED, SPELLFAMILY_HUNTER, UI64LIT(0x0000000000000400))) - DonePercent *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; + DonePercent *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } } @@ -7480,7 +7480,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType Aura* eff0 = GetAura((*i)->GetId(), EFFECT_INDEX_0); if (!eff0 || (*i)->GetEffIndex() != EFFECT_INDEX_1) { - sLog.outError("Spell structure of DD (%u) changed.",(*i)->GetId()); + sLog.outError("Spell structure of DD (%u) changed.", (*i)->GetId()); continue; } @@ -7499,7 +7499,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType // search disease bool found = false; Unit::SpellAuraHolderMap const& auras = pVictim->GetSpellAuraHolderMap(); - for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (Unit::SpellAuraHolderMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (itr->second->GetSpellProto()->Dispel == DISPEL_DISEASE) { @@ -7516,7 +7516,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType { if ((*i)->GetSpellProto()->EffectMiscValue[(*i)->GetEffIndex()] == 7244) { - DonePercent *= ((*i)->GetModifier()->m_amount+100.0f) / 100.0f; + DonePercent *= ((*i)->GetModifier()->m_amount + 100.0f) / 100.0f; break; } } @@ -7529,7 +7529,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType if (Aura* aur = GetDummyAura(56826)) // check for Serpent Sting at target if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_HUNTER, UI64LIT(0x0000000000004000))) - DonePercent *= (aur->GetModifier()->m_amount+100.0f) / 100.0f; + DonePercent *= (aur->GetModifier()->m_amount + 100.0f) / 100.0f; } } @@ -7548,7 +7548,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType else if (APbonus || DoneFlat) { bool normalized = spellProto ? IsSpellHaveEffect(spellProto, SPELL_EFFECT_NORMALIZED_WEAPON_DMG) : false; - DoneTotal += int32(APbonus / 14.0f * GetAPMultiplier(attType,normalized)); + DoneTotal += int32(APbonus / 14.0f * GetAPMultiplier(attType, normalized)); // for weapon damage based spells we still have to apply damage done percent mods // (that are already included into pdamage) to not-yet included DoneFlat @@ -7584,7 +7584,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* pVictim, uint32 pdamage,WeaponAttackType * Calculates target part of melee damage bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage,WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) +uint32 Unit::MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage, WeaponAttackType attType, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack) { if (!pCaster) return pdamage; @@ -7598,8 +7598,8 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage,WeaponAttackTyp uint32 mechanicMask = spellProto ? GetAllSpellMechanicMask(spellProto) : 0; // Shred also have bonus as MECHANIC_BLEED damages - if (spellProto && spellProto->SpellFamilyName==SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags & UI64LIT(0x00008000)) - mechanicMask |= (1 << (MECHANIC_BLEED-1)); + if (spellProto && spellProto->SpellFamilyName == SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags & UI64LIT(0x00008000)) + mechanicMask |= (1 << (MECHANIC_BLEED - 1)); // FLAT damage bonus auras // ======================= @@ -7622,7 +7622,7 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage,WeaponAttackTyp TakenPercent *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, schoolMask); // ..taken pct (by mechanic mask) - TakenPercent *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT,mechanicMask); + TakenPercent *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT, mechanicMask); // ..taken pct (melee/ranged) if (attType == RANGED_ATTACK) @@ -7653,7 +7653,7 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage,WeaponAttackTyp if (GetTypeId() != TYPEID_PLAYER) continue; - float mod = ((Player*)this)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*(-8.0f); + float mod = ((Player*)this)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE) * (-8.0f); if (mod < float((*i)->GetModifier()->m_amount)) mod = float((*i)->GetModifier()->m_amount); @@ -7716,7 +7716,7 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply) void Unit::ApplySpellDispelImmunity(const SpellEntry* spellProto, DispelType type, bool apply) { - ApplySpellImmune(spellProto->Id,IMMUNITY_DISPEL, type, apply); + ApplySpellImmune(spellProto->Id, IMMUNITY_DISPEL, type, apply); if (apply && spellProto->HasAttribute(SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY)) RemoveAurasWithDispelType(type); @@ -7773,7 +7773,7 @@ void Unit::Mount(uint32 mount, uint32 spellId) ((Player*)this)->UnsummonPetTemporaryIfAny(); } else - pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS,true); + pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS, true); } } } @@ -7803,7 +7803,7 @@ void Unit::Unmount(bool from_aura) if (GetTypeId() == TYPEID_PLAYER) { if (Pet* pet = GetPet()) - pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS,false); + pet->ApplyModeFlags(PET_MODE_DISABLE_ACTIONS, false); else ((Player*)this)->ResummonPetTemporaryUnSummonedIfAny(); } @@ -7825,13 +7825,13 @@ void Unit::SetInCombatWith(Unit* enemy) { if (myOwner->IsInDuelWith((Player const*)eOwner)) { - SetInCombatState(true,enemy); + SetInCombatState(true, enemy); return; } } } - SetInCombatState(false,enemy); + SetInCombatState(false, enemy); } void Unit::SetInCombatState(bool PvP, Unit* enemy) @@ -7843,18 +7843,18 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy) if (PvP) m_CombatTimer = 5000; - bool creatureNotInCombat = GetTypeId()==TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); + 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())) + if (isCharmed() || (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->IsPet())) 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 (creatureNotInCombat) { @@ -7887,7 +7887,7 @@ void Unit::ClearInCombat() m_CombatTimer = 0; RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT); - if (isCharmed() || (GetTypeId()!=TYPEID_PLAYER && ((Creature*)this)->IsPet())) + if (isCharmed() || (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->IsPet())) RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); // Player's state will be cleared in Player::UpdateContestedPvP @@ -7904,7 +7904,7 @@ void Unit::ClearInCombat() bool Unit::isTargetableForAttack(bool inverseAlive /*=false*/) const { - if (GetTypeId()==TYPEID_PLAYER && ((Player*)this)->isGameMaster()) + if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->isGameMaster()) return false; if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE)) @@ -7925,7 +7925,7 @@ int32 Unit::ModifyHealth(int32 dVal) { int32 gain = 0; - if (dVal==0) + if (dVal == 0) return 0; int32 curHealth = (int32)GetHealth(); @@ -7957,7 +7957,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) { int32 gain = 0; - if (dVal==0) + if (dVal == 0) return 0; int32 curPower = (int32)GetPower(power); @@ -7965,7 +7965,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) int32 val = dVal + curPower; if (val <= 0) { - SetPower(power,0); + SetPower(power, 0); return -curPower; } @@ -7973,12 +7973,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal) if (val < maxPower) { - SetPower(power,val); + SetPower(power, val); gain = val - curPower; } else if (curPower != maxPower) { - SetPower(power,maxPower); + SetPower(power, maxPower); gain = maxPower - curPower; } @@ -7991,13 +7991,13 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return false; // Always can see self - if (u==this) + if (u == this) return true; // player visible for other player if not logout and at same transport // including case when player is out of world bool at_same_transport = - GetTypeId() == TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER && + GetTypeId() == TYPEID_PLAYER && u->GetTypeId() == TYPEID_PLAYER && !((Player*)this)->GetSession()->PlayerLogout() && !((Player*)u)->GetSession()->PlayerLogout() && !((Player*)this)->GetSession()->PlayerLoading() && !((Player*)u)->GetSession()->PlayerLoading() && ((Player*)this)->GetTransport() && ((Player*)this)->GetTransport() == ((Player*)u)->GetTransport(); @@ -8007,12 +8007,12 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return false; // forbidden to seen (at GM respawn command) - if (m_Visibility==VISIBILITY_RESPAWN) + if (m_Visibility == VISIBILITY_RESPAWN) return false; Map& _map = *u->GetMap(); // Grid dead/alive checks - if (u->GetTypeId()==TYPEID_PLAYER) + if (u->GetTypeId() == TYPEID_PLAYER) { // non visible at grid for any stealth state if (!IsVisibleInGridForPlayer((Player*)u)) @@ -8033,7 +8033,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo if (u->IsTaxiFlying()) // what see player in flight { // use object grey distance for all (only see objects any way) - if (!IsWithinDistInMap(viewPoint,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) + if (!IsWithinDistInMap(viewPoint, World::GetMaxVisibleDistanceInFlight() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), is3dDistance)) return false; } else if (!at_same_transport) // distance for show player/pet/creature (no transport case) @@ -8055,7 +8055,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return false; // Visible units, always are visible for all units, except for units under invisibility and phases - if (m_Visibility == VISIBILITY_ON && u->m_invisibilityMask==0) + if (m_Visibility == VISIBILITY_ON && u->m_invisibilityMask == 0) return true; // GMs see any players, not higher GMs and all units in any phase @@ -8072,12 +8072,12 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return false; // raw invisibility - bool invisible = (m_invisibilityMask != 0 || u->m_invisibilityMask !=0); + bool invisible = (m_invisibilityMask != 0 || u->m_invisibilityMask != 0); // detectable invisibility case if (invisible && ( // Invisible units, always are visible for units under same invisibility type - (m_invisibilityMask & u->m_invisibilityMask)!=0 || + (m_invisibilityMask & u->m_invisibilityMask) != 0 || // Invisible units, always are visible for unit that can detect this invisibility (have appropriate level for detect) u->canDetectInvisibilityOf(this) || // Units that can detect invisibility always are visible for units that can be detected @@ -8093,7 +8093,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo if (!u->IsHostileTo(this)) { // player see other player with stealth/invisibility only if he in same group or raid or same team (raid/team case dependent from conf setting) - if (GetTypeId()==TYPEID_PLAYER && u->GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER && u->GetTypeId() == TYPEID_PLAYER) { if (((Player*)this)->IsGroupVisibleFor(((Player*)u))) return true; @@ -8143,7 +8143,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo return true; // If there is collision rogue is seen regardless of level difference - if (IsWithinDist(u,0.24f)) + if (IsWithinDist(u, 0.24f)) return true; //If a mob or player is stunned he will not be able to detect stealth @@ -8164,7 +8164,7 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo //Calculation if target is in front //Visible distance based on stealth value (stealth rank 4 300MOD, 10.5 - 3 = 7.5) - visibleDistance = 10.5f - (GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH)/100.0f); + visibleDistance = 10.5f - (GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH) / 100.0f); //Visible distance is modified by //-Level Diff (every level diff = 1.0f in visible distance) @@ -8177,18 +8177,18 @@ bool Unit::isVisibleForOrDetect(Unit const* u, WorldObject const* viewPoint, boo //-Stealth Mod(positive like Master of Deception) and Stealth Detection(negative like paranoia) //based on wowwiki every 5 mod we have 1 more level diff in calculation - visibleDistance += (int32(u->GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_DETECT)) - stealthMod)/5.0f; + visibleDistance += (int32(u->GetTotalAuraModifier(SPELL_AURA_MOD_STEALTH_DETECT)) - stealthMod) / 5.0f; visibleDistance = visibleDistance > MAX_PLAYER_STEALTH_DETECT_RANGE ? MAX_PLAYER_STEALTH_DETECT_RANGE : visibleDistance; // recheck new distance - if (visibleDistance <= 0 || !IsWithinDist(viewPoint,visibleDistance)) + if (visibleDistance <= 0 || !IsWithinDist(viewPoint, visibleDistance)) return false; } // Now check is target visible with LoS - float ox,oy,oz; - viewPoint->GetPosition(ox,oy,oz); - return IsWithinLOS(ox,oy,oz); + float ox, oy, oz; + viewPoint->GetPosition(ox, oy, oz); + return IsWithinLOS(ox, oy, oz); } void Unit::UpdateVisibilityAndView() @@ -8206,7 +8206,7 @@ void Unit::UpdateVisibilityAndView() Aura* aura = (*it); Unit* owner = aura->GetCaster(); - if (!owner || !isVisibleForOrDetect(owner,this,false)) + if (!owner || !isVisibleForOrDetect(owner, this, false)) { alist.erase(it); RemoveAura(aura); @@ -8237,24 +8237,24 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const { for (int32 i = 0; i < 32; ++i) { - if (((1 << i) & mask)==0) + if (((1 << i) & mask) == 0) continue; // find invisibility level int32 invLevel = 0; Unit::AuraList const& iAuras = u->GetAurasByType(SPELL_AURA_MOD_INVISIBILITY); for (Unit::AuraList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr) - if ((*itr)->GetModifier()->m_miscvalue==i && invLevel < (*itr)->GetModifier()->m_amount) + if ((*itr)->GetModifier()->m_miscvalue == i && invLevel < (*itr)->GetModifier()->m_amount) invLevel = (*itr)->GetModifier()->m_amount; // find invisibility detect level int32 detectLevel = 0; Unit::AuraList const& dAuras = GetAurasByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION); for (Unit::AuraList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr) - if ((*itr)->GetModifier()->m_miscvalue==i && detectLevel < (*itr)->GetModifier()->m_amount) + if ((*itr)->GetModifier()->m_miscvalue == i && detectLevel < (*itr)->GetModifier()->m_amount) detectLevel = (*itr)->GetModifier()->m_amount; - if (i==6 && GetTypeId()==TYPEID_PLAYER) // special drunk detection case + if (i == 6 && GetTypeId() == TYPEID_PLAYER) // special drunk detection case detectLevel = ((Player*)this)->GetDrunkValue(); if (invLevel <= detectLevel) @@ -8300,13 +8300,13 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) { main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_MOUNTED_SPEED); stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_MOUNTED_SPEED_ALWAYS); - non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK))/100.0f; + non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MOUNTED_SPEED_NOT_STACK)) / 100.0f; } else { main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SPEED); stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_SPEED_ALWAYS); - non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_SPEED_NOT_STACK))/100.0f; + non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_SPEED_NOT_STACK)) / 100.0f; } break; } @@ -8325,13 +8325,13 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) { main_speed_mod = GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED); stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_STACKING); - non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_NOT_STACKING))/100.0f; + non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED_NOT_STACKING)) / 100.0f; } else // Use not mount (shapeshift for example) auras (should stack) { main_speed_mod = GetTotalAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED); stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_FLIGHT_SPEED_STACKING); - non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACKING))/100.0f; + non_stack_bonus = (100.0f + GetMaxPositiveAuraModifier(SPELL_AURA_MOD_FLIGHT_SPEED_NOT_STACKING)) / 100.0f; } break; } @@ -8344,7 +8344,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) float bonus = non_stack_bonus > stack_bonus ? non_stack_bonus : stack_bonus; // now we ready for speed calculation - float speed = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus; + float speed = main_speed_mod ? bonus * (100.0f + main_speed_mod) / 100.0f : bonus; switch (mtype) { @@ -8384,7 +8384,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) int32 slow = GetMaxNegativeAuraModifier(SPELL_AURA_MOD_DECREASE_SPEED); if (slow) { - speed *=(100.0f + slow)/100.0f; + speed *= (100.0f + slow) / 100.0f; float min_speed = (float)GetMaxPositiveAuraModifier(SPELL_AURA_MOD_MINIMUM_SPEED) / 100.0f; if (speed < min_speed) speed = min_speed; @@ -8410,13 +8410,13 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) float Unit::GetSpeed(UnitMoveType mtype) const { - return m_speed_rate[mtype]*baseMoveSpeed[mtype]; + return m_speed_rate[mtype] * baseMoveSpeed[mtype]; } struct SetSpeedRateHelper { explicit SetSpeedRateHelper(UnitMoveType _mtype, bool _forced) : mtype(_mtype), forced(_forced) {} - void operator()(Unit* unit) const { unit->UpdateSpeed(mtype,forced); } + void operator()(Unit* unit) const { unit->UpdateSpeed(mtype, forced); } UnitMoveType mtype; bool forced; }; @@ -8432,7 +8432,7 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced) m_speed_rate[mtype] = rate; propagateSpeedChange(); - const uint16 SetSpeed2Opc_table[MAX_MOVE_TYPE][2]= + const uint16 SetSpeed2Opc_table[MAX_MOVE_TYPE][2] = { {MSG_MOVE_SET_WALK_SPEED, SMSG_FORCE_WALK_SPEED_CHANGE}, {MSG_MOVE_SET_RUN_SPEED, SMSG_FORCE_RUN_SPEED_CHANGE}, @@ -8441,7 +8441,7 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced) {MSG_MOVE_SET_SWIM_BACK_SPEED, SMSG_FORCE_SWIM_BACK_SPEED_CHANGE}, {MSG_MOVE_SET_TURN_RATE, SMSG_FORCE_TURN_RATE_CHANGE}, {MSG_MOVE_SET_FLIGHT_SPEED, SMSG_FORCE_FLIGHT_SPEED_CHANGE}, - {MSG_MOVE_SET_FLIGHT_BACK_SPEED,SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE}, + {MSG_MOVE_SET_FLIGHT_BACK_SPEED, SMSG_FORCE_FLIGHT_BACK_SPEED_CHANGE}, {MSG_MOVE_SET_PITCH_RATE, SMSG_FORCE_PITCH_RATE_CHANGE}, }; @@ -8474,12 +8474,12 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced) } } - CallForAllControlledUnits(SetSpeedRateHelper(mtype,forced), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM|CONTROLLED_MINIPET); + CallForAllControlledUnits(SetSpeedRateHelper(mtype, forced), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM | CONTROLLED_MINIPET); } void Unit::SetDeathState(DeathState s) { - if (s != ALIVE && s!= JUST_ALIVED) + if (s != ALIVE && s != JUST_ALIVED) { CombatStop(); DeleteThreatList(); @@ -8496,7 +8496,7 @@ void Unit::SetDeathState(DeathState s) RemoveMiniPet(); UnsummonAllTotems(); - i_motionMaster.Clear(false,true); + i_motionMaster.Clear(false, true); i_motionMaster.MoveIdle(); StopMoving(); @@ -8794,7 +8794,7 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt level = (int32)spellProto->maxLevel; else if (level < (int32)spellProto->baseLevel) level = (int32)spellProto->baseLevel; - level-= (int32)spellProto->spellLevel; + level -= (int32)spellProto->spellLevel; float basePointsPerLevel = spellProto->EffectRealPointsPerLevel[effect_index]; int32 basePoints = effBasePoints ? *effBasePoints - 1 : spellProto->EffectBasePoints[effect_index]; @@ -8846,7 +8846,7 @@ int32 Unit::CalculateSpellDamage(Unit const* target, SpellEntry const* spellProt spellProto->Effect[effect_index] != SPELL_EFFECT_WEAPON_PERCENT_DAMAGE && spellProto->Effect[effect_index] != SPELL_EFFECT_KNOCK_BACK && (spellProto->Effect[effect_index] != SPELL_EFFECT_APPLY_AURA || spellProto->EffectApplyAuraName[effect_index] != SPELL_AURA_MOD_DECREASE_SPEED)) - value = int32(value*0.25f*exp(getLevel()*(70-spellProto->spellLevel)/1000.0f)); + value = int32(value * 0.25f * exp(getLevel() * (70 - spellProto->spellLevel) / 1000.0f)); return value; } @@ -8861,7 +8861,7 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas for (int32 mechanic = FIRST_MECHANIC; mechanic < MAX_MECHANIC; ++mechanic) { - if (!(mechanicMask & (1 << (mechanic-1)))) + if (!(mechanicMask & (1 << (mechanic - 1)))) continue; int32 stackingMod = GetTotalAuraModifierByMiscValue(SPELL_AURA_MECHANIC_DURATION_MOD, mechanic); @@ -8883,7 +8883,7 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas if (durationMod != 0) { - duration = int32(int64(duration) * (100+durationMod) / 100); + duration = int32(int64(duration) * (100 + durationMod) / 100); if (duration < 0) duration = 0; @@ -8940,7 +8940,7 @@ DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) return DIMINISHING_LEVEL_1; // If last spell was casted more than 15 seconds ago - reset the count. - if (i->stack==0 && WorldTimer::getMSTimeDiff(i->hitTime,WorldTimer::getMSTime()) > 15*IN_MILLISECONDS) + if (i->stack == 0 && WorldTimer::getMSTimeDiff(i->hitTime, WorldTimer::getMSTime()) > 15 * IN_MILLISECONDS) { i->hitCount = DIMINISHING_LEVEL_1; return DIMINISHING_LEVEL_1; @@ -8965,10 +8965,10 @@ void Unit::IncrDiminishing(DiminishingGroup group) i->hitCount += 1; return; } - m_Diminishing.push_back(DiminishingReturn(group,WorldTimer::getMSTime(),DIMINISHING_LEVEL_2)); + m_Diminishing.push_back(DiminishingReturn(group, WorldTimer::getMSTime(), DIMINISHING_LEVEL_2)); } -void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration,Unit* caster,DiminishingLevels Level, int32 limitduration, bool isReflected) +void Unit::ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, Unit* caster, DiminishingLevels Level, int32 limitduration, bool isReflected) { if (duration == -1 || group == DIMINISHING_NONE || (!isReflected && caster->IsFriendlyTo(this))) return; @@ -9083,7 +9083,7 @@ bool Unit::HandleStatModifier(UnitMods unitMod, UnitModifierType modifierType, f amount = -200.0f; val = (100.0f + amount) / 100.0f; - m_auraModifiersGroup[unitMod][modifierType] *= apply ? val : (1.0f/val); + m_auraModifiersGroup[unitMod][modifierType] *= apply ? val : (1.0f / val); break; default: @@ -9231,7 +9231,7 @@ Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const case UNIT_MOD_ENERGY: return POWER_ENERGY; case UNIT_MOD_HAPPINESS: return POWER_HAPPINESS; case UNIT_MOD_RUNE: return POWER_RUNE; - case UNIT_MOD_RUNIC_POWER:return POWER_RUNIC_POWER; + case UNIT_MOD_RUNIC_POWER: return POWER_RUNIC_POWER; default: return POWER_MANA; } } @@ -9254,7 +9254,7 @@ float Unit::GetTotalAttackPowerValue(WeaponAttackType attType) const } } -float Unit::GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const +float Unit::GetWeaponDamageRange(WeaponAttackType attType , WeaponDamageRange type) const { if (attType == OFF_ATTACK && !haveOffhandWeapon()) return 0.0f; @@ -9325,7 +9325,7 @@ void Unit::SetMaxHealth(uint32 val) void Unit::SetHealthPercent(float percent) { - uint32 newHealth = GetMaxHealth() * percent/100.0f; + uint32 newHealth = GetMaxHealth() * percent / 100.0f; SetHealth(newHealth); } @@ -9398,7 +9398,7 @@ void Unit::SetMaxPower(Powers power, uint32 val) void Unit::ApplyPowerMod(Powers power, uint32 val, bool apply) { - ApplyModUInt32Value(UNIT_FIELD_POWER1+power, val, apply); + ApplyModUInt32Value(UNIT_FIELD_POWER1 + power, val, apply); // group update if (GetTypeId() == TYPEID_PLAYER) @@ -9420,7 +9420,7 @@ void Unit::ApplyPowerMod(Powers power, uint32 val, bool apply) void Unit::ApplyMaxPowerMod(Powers power, uint32 val, bool apply) { - ApplyModUInt32Value(UNIT_FIELD_MAXPOWER1+power, val, apply); + ApplyModUInt32Value(UNIT_FIELD_MAXPOWER1 + power, val, apply); // group update if (GetTypeId() == TYPEID_PLAYER) @@ -9500,7 +9500,7 @@ void Unit::CleanupsBeforeDelete() CombatStop(); ClearComboPointHolders(); DeleteThreatList(); - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) getHostileRefManager().setOnlineOfflineState(false); else getHostileRefManager().deleteReferences(); @@ -9520,29 +9520,29 @@ CharmInfo::CharmInfo(Unit* unit) : m_unit(unit), m_CommandState(COMMAND_FOLLOW), m_reactState(REACT_PASSIVE), m_petnumber(0) { for (int i = 0; i < CREATURE_MAX_SPELLS; ++i) - m_charmspells[i].SetActionAndType(0,ACT_DISABLED); + m_charmspells[i].SetActionAndType(0, ACT_DISABLED); } void CharmInfo::InitPetActionBar() { // the first 3 SpellOrActions are attack, follow and stay for (uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_START - ACTION_BAR_INDEX_START; ++i) - SetActionBar(ACTION_BAR_INDEX_START + i,COMMAND_ATTACK - i,ACT_COMMAND); + SetActionBar(ACTION_BAR_INDEX_START + i, COMMAND_ATTACK - i, ACT_COMMAND); // middle 4 SpellOrActions are spells/special attacks/abilities - for (uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_END-ACTION_BAR_INDEX_PET_SPELL_START; ++i) - SetActionBar(ACTION_BAR_INDEX_PET_SPELL_START + i,0,ACT_DISABLED); + for (uint32 i = 0; i < ACTION_BAR_INDEX_PET_SPELL_END - ACTION_BAR_INDEX_PET_SPELL_START; ++i) + SetActionBar(ACTION_BAR_INDEX_PET_SPELL_START + i, 0, ACT_DISABLED); // last 3 SpellOrActions are reactions for (uint32 i = 0; i < ACTION_BAR_INDEX_END - ACTION_BAR_INDEX_PET_SPELL_END; ++i) - SetActionBar(ACTION_BAR_INDEX_PET_SPELL_END + i,COMMAND_ATTACK - i,ACT_REACTION); + SetActionBar(ACTION_BAR_INDEX_PET_SPELL_END + i, COMMAND_ATTACK - i, ACT_REACTION); } void CharmInfo::InitEmptyActionBar() { - SetActionBar(ACTION_BAR_INDEX_START,COMMAND_ATTACK,ACT_COMMAND); - for (uint32 x = ACTION_BAR_INDEX_START+1; x < ACTION_BAR_INDEX_END; ++x) - SetActionBar(x,0,ACT_PASSIVE); + SetActionBar(ACTION_BAR_INDEX_START, COMMAND_ATTACK, ACT_COMMAND); + for (uint32 x = ACTION_BAR_INDEX_START + 1; x < ACTION_BAR_INDEX_END; ++x) + SetActionBar(x, 0, ACT_PASSIVE); } void CharmInfo::InitPossessCreateSpells() @@ -9577,18 +9577,18 @@ void CharmInfo::InitCharmCreateSpells() if (!spellId) { - m_charmspells[x].SetActionAndType(spellId,ACT_DISABLED); + m_charmspells[x].SetActionAndType(spellId, ACT_DISABLED); continue; } if (IsPassiveSpell(spellId)) { m_unit->CastSpell(m_unit, spellId, true); - m_charmspells[x].SetActionAndType(spellId,ACT_PASSIVE); + m_charmspells[x].SetActionAndType(spellId, ACT_PASSIVE); } else { - m_charmspells[x].SetActionAndType(spellId,ACT_DISABLED); + m_charmspells[x].SetActionAndType(spellId, ACT_DISABLED); ActiveStates newstate; bool onlyselfcast = true; @@ -9633,7 +9633,7 @@ bool CharmInfo::AddSpellToActionBar(uint32 spell_id, ActiveStates newstate) { if (!PetActionBar[i].GetAction() && PetActionBar[i].IsActionBarForSpell()) { - SetActionBar(i,spell_id,newstate == ACT_DECIDE ? ACT_DISABLED : newstate); + SetActionBar(i, spell_id, newstate == ACT_DECIDE ? ACT_DISABLED : newstate); return true; } } @@ -9650,7 +9650,7 @@ bool CharmInfo::RemoveSpellFromActionBar(uint32 spell_id) { if (PetActionBar[i].IsActionBarForSpell() && sSpellMgr.GetFirstSpellInChain(action) == first_id) { - SetActionBar(i,0,ACT_DISABLED); + SetActionBar(i, 0, ACT_DISABLED); return true; } } @@ -9684,7 +9684,7 @@ void CharmInfo::LoadPetActionBar(const std::string& data) Tokens tokens = StrSplit(data, " "); - if (tokens.size() != (ACTION_BAR_INDEX_END-ACTION_BAR_INDEX_START)*2) + if (tokens.size() != (ACTION_BAR_INDEX_END - ACTION_BAR_INDEX_START) * 2) return; // non critical, will reset to default int index; @@ -9696,11 +9696,11 @@ void CharmInfo::LoadPetActionBar(const std::string& data) ++iter; uint32 action = atol((*iter).c_str()); - PetActionBar[index].SetActionAndType(action,ActiveStates(type)); + PetActionBar[index].SetActionAndType(action, ActiveStates(type)); // check correctness if (PetActionBar[index].IsActionBarForSpell() && !sSpellStore.LookupEntry(PetActionBar[index].GetAction())) - SetActionBar(index,0,ACT_DISABLED); + SetActionBar(index, 0, ACT_DISABLED); } } @@ -9743,20 +9743,20 @@ uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missC { uint32 procEx = PROC_EX_NONE; // Check victim state - if (missCondition!=SPELL_MISS_NONE) + if (missCondition != SPELL_MISS_NONE) switch (missCondition) { - case SPELL_MISS_MISS: procEx|=PROC_EX_MISS; break; - case SPELL_MISS_RESIST: procEx|=PROC_EX_RESIST; break; - case SPELL_MISS_DODGE: procEx|=PROC_EX_DODGE; break; - case SPELL_MISS_PARRY: procEx|=PROC_EX_PARRY; break; - case SPELL_MISS_BLOCK: procEx|=PROC_EX_BLOCK; break; - case SPELL_MISS_EVADE: procEx|=PROC_EX_EVADE; break; - case SPELL_MISS_IMMUNE: procEx|=PROC_EX_IMMUNE; break; - case SPELL_MISS_IMMUNE2: procEx|=PROC_EX_IMMUNE; break; - case SPELL_MISS_DEFLECT: procEx|=PROC_EX_DEFLECT; break; - case SPELL_MISS_ABSORB: procEx|=PROC_EX_ABSORB; break; - case SPELL_MISS_REFLECT: procEx|=PROC_EX_REFLECT; break; + case SPELL_MISS_MISS: procEx |= PROC_EX_MISS; break; + case SPELL_MISS_RESIST: procEx |= PROC_EX_RESIST; break; + case SPELL_MISS_DODGE: procEx |= PROC_EX_DODGE; break; + case SPELL_MISS_PARRY: procEx |= PROC_EX_PARRY; break; + case SPELL_MISS_BLOCK: procEx |= PROC_EX_BLOCK; break; + case SPELL_MISS_EVADE: procEx |= PROC_EX_EVADE; break; + case SPELL_MISS_IMMUNE: procEx |= PROC_EX_IMMUNE; break; + case SPELL_MISS_IMMUNE2: procEx |= PROC_EX_IMMUNE; break; + case SPELL_MISS_DEFLECT: procEx |= PROC_EX_DEFLECT; break; + case SPELL_MISS_ABSORB: procEx |= PROC_EX_ABSORB; break; + case SPELL_MISS_REFLECT: procEx |= PROC_EX_REFLECT; break; default: break; } @@ -9764,15 +9764,15 @@ uint32 createProcExtendMask(SpellNonMeleeDamage* damageInfo, SpellMissInfo missC { // On block if (damageInfo->blocked) - procEx|=PROC_EX_BLOCK; + procEx |= PROC_EX_BLOCK; // On absorb if (damageInfo->absorb) - procEx|=PROC_EX_ABSORB; + procEx |= PROC_EX_ABSORB; // On crit if (damageInfo->HitInfo & SPELL_HIT_TYPE_CRIT) - procEx|=PROC_EX_CRITICAL_HIT; + procEx |= PROC_EX_CRITICAL_HIT; else - procEx|=PROC_EX_NORMAL_HIT; + procEx |= PROC_EX_NORMAL_HIT; } return procEx; } @@ -9786,23 +9786,23 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag, if (GetTypeId() == TYPEID_PLAYER) { // On melee based hit/miss/resist need update skill (for victim and attacker) - if (procExtra&(PROC_EX_NORMAL_HIT|PROC_EX_MISS|PROC_EX_RESIST)) + if (procExtra & (PROC_EX_NORMAL_HIT | PROC_EX_MISS | PROC_EX_RESIST)) { if (pTarget->GetTypeId() != TYPEID_PLAYER && pTarget->GetCreatureType() != CREATURE_TYPE_CRITTER) ((Player*)this)->UpdateCombatSkills(pTarget, attType, isVictim); } // Update defence if player is victim and parry/dodge/block - if (isVictim && procExtra&(PROC_EX_DODGE|PROC_EX_PARRY|PROC_EX_BLOCK)) + if (isVictim && procExtra & (PROC_EX_DODGE | PROC_EX_PARRY | PROC_EX_BLOCK)) ((Player*)this)->UpdateDefense(); } // If exist crit/parry/dodge/block need update aura state (for victim and attacker) - if (procExtra & (PROC_EX_CRITICAL_HIT|PROC_EX_PARRY|PROC_EX_DODGE|PROC_EX_BLOCK)) + if (procExtra & (PROC_EX_CRITICAL_HIT | PROC_EX_PARRY | PROC_EX_DODGE | PROC_EX_BLOCK)) { // for victim if (isVictim) { // if victim and dodge attack - if (procExtra&PROC_EX_DODGE) + if (procExtra & PROC_EX_DODGE) { //Update AURA_STATE on dodge if (getClass() != CLASS_ROGUE) // skip Rogue Riposte @@ -9829,14 +9829,14 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag, // if and victim block attack if (procExtra & PROC_EX_BLOCK) { - ModifyAuraState(AURA_STATE_DEFENSE,true); + ModifyAuraState(AURA_STATE_DEFENSE, true); StartReactiveTimer(REACTIVE_DEFENSE); } } else //For attacker { // Overpower on victim dodge - if (procExtra&PROC_EX_DODGE && GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) + if (procExtra & PROC_EX_DODGE && GetTypeId() == TYPEID_PLAYER && getClass() == CLASS_WARRIOR) { ((Player*)this)->AddComboPoints(pTarget, 1); StartReactiveTimer(REACTIVE_OVERPOWER); @@ -9848,7 +9848,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, uint32 procFlag, RemoveSpellList removedSpells; ProcTriggeredList procTriggered; // Fill procTriggered list - for (SpellAuraHolderMap::const_iterator itr = GetSpellAuraHolderMap().begin(); itr!= GetSpellAuraHolderMap().end(); ++itr) + for (SpellAuraHolderMap::const_iterator itr = GetSpellAuraHolderMap().begin(); itr != GetSpellAuraHolderMap().end(); ++itr) { // skip deleted auras (possible at recursive triggered call if (itr->second->IsDeleted()) @@ -9962,12 +9962,12 @@ SpellSchoolMask Unit::GetMeleeDamageSchoolMask() const Player* Unit::GetSpellModOwner() const { - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) return (Player*)this; if (((Creature*)this)->IsPet() || ((Creature*)this)->IsTotem()) { Unit* owner = GetOwner(); - if (owner && owner->GetTypeId()==TYPEID_PLAYER) + if (owner && owner->GetTypeId() == TYPEID_PLAYER) return (Player*)owner; } return NULL; @@ -10151,7 +10151,7 @@ void Unit::SetFeignDeath(bool apply, ObjectGuid casterGuid, uint32 /*spellID*/) // prevent interrupt message if (casterGuid == GetObjectGuid()) - FinishSpell(CURRENT_GENERIC_SPELL,false); + FinishSpell(CURRENT_GENERIC_SPELL, false); InterruptNonMeleeSpells(true); getHostileRefManager().deleteReferences(); } @@ -10206,7 +10206,7 @@ void Unit::SetStandState(uint8 state) if (IsStandState()) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_SEATED); - if (GetTypeId()==TYPEID_PLAYER) + if (GetTypeId() == TYPEID_PLAYER) { WorldPacket data(SMSG_STANDSTATE_UPDATE, 1); data << (uint8)state; @@ -10216,7 +10216,7 @@ void Unit::SetStandState(uint8 state) bool Unit::IsPolymorphed() const { - return GetSpellSpecific(getTransForm())==SPELL_MAGE_POLYMORPH; + return GetSpellSpecific(getTransForm()) == SPELL_MAGE_POLYMORPH; } void Unit::SetDisplayId(uint32 modelId) @@ -10267,7 +10267,7 @@ void Unit::ClearComboPointHolders() void Unit::ClearAllReactives() { - for (int i=0; i < MAX_REACTIVE; ++i) + for (int i = 0; i < MAX_REACTIVE; ++i) m_reactiveTimer[i] = 0; if (HasAuraState(AURA_STATE_DEFENSE)) @@ -10347,7 +10347,7 @@ Unit* Unit::SelectRandomUnfriendlyTarget(Unit* except /*= NULL*/, float radius / return NULL; // select random - uint32 rIdx = urand(0,targets.size()-1); + uint32 rIdx = urand(0, targets.size() - 1); std::list::const_iterator tcIter = targets.begin(); for (uint32 i = 0; i < rIdx; ++i) ++tcIter; @@ -10386,7 +10386,7 @@ Unit* Unit::SelectRandomFriendlyTarget(Unit* except /*= NULL*/, float radius /*= return NULL; // select random - uint32 rIdx = urand(0,targets.size()-1); + uint32 rIdx = urand(0, targets.size() - 1); std::list::const_iterator tcIter = targets.begin(); for (uint32 i = 0; i < rIdx; ++i) ++tcIter; @@ -10404,26 +10404,26 @@ bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag) return false; } -void Unit::ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply) +void Unit::ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply) { if (val > 0) { ApplyPercentModFloatVar(m_modAttackSpeedPct[att], val, !apply); - ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val,!apply); + ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME + att, val, !apply); } else { ApplyPercentModFloatVar(m_modAttackSpeedPct[att], -val, apply); - ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME+att,-val,apply); + ApplyPercentModFloatValue(UNIT_FIELD_BASEATTACKTIME + att, -val, apply); } } void Unit::ApplyCastTimePercentMod(float val, bool apply) { if (val > 0) - ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,val,!apply); + ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED, val, !apply); else - ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED,-val,apply); + ApplyPercentModFloatValue(UNIT_MOD_CAST_SPEED, -val, apply); } void Unit::UpdateAuraForGroup(uint8 slot) @@ -10455,7 +10455,7 @@ void Unit::UpdateAuraForGroup(uint8 slot) float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) { if (!normalized || GetTypeId() != TYPEID_PLAYER) - return float(GetAttackTime(attType))/1000.0f; + return float(GetAttackTime(attType)) / 1000.0f; Item* Weapon = ((Player*)this)->GetWeaponForAttack(attType, true, false); if (!Weapon) @@ -10473,7 +10473,7 @@ float Unit::GetAPMultiplier(WeaponAttackType attType, bool normalized) case INVTYPE_WEAPONMAINHAND: case INVTYPE_WEAPONOFFHAND: default: - return Weapon->GetProto()->SubClass==ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f; + return Weapon->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER ? 1.7f : 2.4f; } } @@ -10561,7 +10561,7 @@ struct SetPhaseMaskHelper void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) { - if (newPhaseMask==GetPhaseMask()) + if (newPhaseMask == GetPhaseMask()) return; // first move to both phase for proper update controlled units @@ -10572,7 +10572,7 @@ void Unit::SetPhaseMask(uint32 newPhaseMask, bool update) RemoveNotOwnSingleTargetAuras(newPhaseMask); // we can lost access to caster or target // all controlled except not owned charmed units - CallForAllControlledUnits(SetPhaseMaskHelper(newPhaseMask), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_MINIPET|CONTROLLED_TOTEMS); + CallForAllControlledUnits(SetPhaseMaskHelper(newPhaseMask), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_MINIPET | CONTROLLED_TOTEMS); } WorldObject::SetPhaseMask(newPhaseMask, update); @@ -10607,7 +10607,7 @@ void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool cas void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath, bool forceDestination) { Movement::MoveSplineInit init(*this); - init.MoveTo(x,y,z, generatePath, forceDestination); + init.MoveTo(x, y, z, generatePath, forceDestination); init.SetVelocity(speed); init.Launch(); } @@ -10626,7 +10626,7 @@ void Unit::SetPvP(bool state) else RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); - CallForAllControlledUnits(SetPvPHelper(state), CONTROLLED_PET|CONTROLLED_TOTEMS|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); + CallForAllControlledUnits(SetPvPHelper(state), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); } struct SetFFAPvPHelper @@ -10643,7 +10643,7 @@ void Unit::SetFFAPvP(bool state) else RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP); - CallForAllControlledUnits(SetFFAPvPHelper(state), CONTROLLED_PET|CONTROLLED_TOTEMS|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); + CallForAllControlledUnits(SetFFAPvPHelper(state), CONTROLLED_PET | CONTROLLED_TOTEMS | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); } void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpeed) @@ -10654,7 +10654,7 @@ void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpee if (GetTypeId() == TYPEID_PLAYER) { - WorldPacket data(SMSG_MOVE_KNOCK_BACK, 9+4+4+4+4+4); + WorldPacket data(SMSG_MOVE_KNOCK_BACK, 9 + 4 + 4 + 4 + 4 + 4); data << GetPackGUID(); data << uint32(0); // Sequence data << float(vcos); // x direction @@ -10666,7 +10666,7 @@ void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpee else { float moveTimeHalf = verticalSpeed / Movement::gravity; - float max_height = -Movement::computeFallElevation(moveTimeHalf,false,-verticalSpeed); + float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -verticalSpeed); float dis = 2 * moveTimeHalf * horizontalSpeed; float ox, oy, oz; @@ -10674,9 +10674,9 @@ void Unit::KnockBackFrom(Unit* target, float horizontalSpeed, float verticalSpee float fx = ox + dis * vcos; float fy = oy + dis * vsin; float fz = oz; - GetMap()->GetObjectHitPos(ox,oy,oz+0.5f, fx,fy,oz+0.5f,fx,fy,fz, -0.5f); + GetMap()->GetObjectHitPos(ox, oy, oz + 0.5f, fx, fy, oz + 0.5f, fx, fy, fz, -0.5f); UpdateAllowedPositionZ(fx, fy, fz); - GetMotionMaster()->MoveJump(fx,fy,fz,horizontalSpeed,max_height); + GetMotionMaster()->MoveJump(fx, fy, fz, horizontalSpeed, max_height); } } @@ -10768,7 +10768,7 @@ void Unit::StopAttackFaction(uint32 faction_id) { if (Unit* victim = getVictim()) { - if (victim->getFactionTemplateEntry()->faction==faction_id) + if (victim->getFactionTemplateEntry()->faction == faction_id) { AttackStop(); if (IsNonMeleeSpellCasted(false)) @@ -10783,7 +10783,7 @@ void Unit::StopAttackFaction(uint32 faction_id) AttackerSet const& attackers = getAttackers(); for (AttackerSet::const_iterator itr = attackers.begin(); itr != attackers.end();) { - if ((*itr)->getFactionTemplateEntry()->faction==faction_id) + if ((*itr)->getFactionTemplateEntry()->faction == faction_id) { (*itr)->AttackStop(); itr = attackers.begin(); @@ -10794,7 +10794,7 @@ void Unit::StopAttackFaction(uint32 faction_id) getHostileRefManager().deleteReferencesForFaction(faction_id); - CallForAllControlledUnits(StopAttackFactionHelper(faction_id), CONTROLLED_PET|CONTROLLED_GUARDIANS|CONTROLLED_CHARM); + CallForAllControlledUnits(StopAttackFactionHelper(faction_id), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); } bool Unit::IsIgnoreUnitState(SpellEntry const* spell, IgnoreUnitState ignoreState) @@ -10901,12 +10901,12 @@ class RelocationNotifyEvent : public BasicEvent if (m_owner.GetTypeId() == TYPEID_PLAYER) { MaNGOS::PlayerRelocationNotifier notify((Player&)m_owner); - Cell::VisitAllObjects(&m_owner,notify,radius); + Cell::VisitAllObjects(&m_owner, notify, radius); } else //if(m_owner.GetTypeId() == TYPEID_UNIT) { MaNGOS::CreatureRelocationNotifier notify((Creature&)m_owner); - Cell::VisitAllObjects(&m_owner,notify,radius); + Cell::VisitAllObjects(&m_owner, notify, radius); } m_owner._SetAINotifyScheduled(false); return true; @@ -10933,7 +10933,7 @@ void Unit::OnRelocated() float dx = m_last_notified_position.x - GetPositionX(); float dy = m_last_notified_position.y - GetPositionY(); float dz = m_last_notified_position.z - GetPositionZ(); - float distsq = dx*dx+dy*dy+dz*dz; + float distsq = dx * dx + dy * dy + dz * dz; if (distsq > World::GetRelocationLowerLimitSq()) { m_last_notified_position.x = GetPositionX(); @@ -10996,14 +10996,14 @@ void Unit::UpdateSplineMovement(uint32 t_diff) Movement::Location loc = movespline->ComputePosition(); if (GetTypeId() == TYPEID_PLAYER) - ((Player*)this)->SetPosition(loc.x,loc.y,loc.z,loc.orientation); + ((Player*)this)->SetPosition(loc.x, loc.y, loc.z, loc.orientation); else - GetMap()->CreatureRelocation((Creature*)this,loc.x,loc.y,loc.z,loc.orientation); + GetMap()->CreatureRelocation((Creature*)this, loc.x, loc.y, loc.z, loc.orientation); } } void Unit::DisableSpline() { - m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEFLAG_SPLINE_ENABLED|MOVEFLAG_FORWARD)); + m_movementInfo.RemoveMovementFlag(MovementFlags(MOVEFLAG_SPLINE_ENABLED | MOVEFLAG_FORWARD)); movespline->_Interrupt(); } diff --git a/src/game/Unit.h b/src/game/Unit.h index 99e53dca2..737af5669 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -634,10 +634,10 @@ enum MovementFlags // flags that use in movement check for example at spell casting MovementFlags const movementFlagsMask = MovementFlags( - MOVEFLAG_FORWARD |MOVEFLAG_BACKWARD |MOVEFLAG_STRAFE_LEFT |MOVEFLAG_STRAFE_RIGHT| - MOVEFLAG_PITCH_UP|MOVEFLAG_PITCH_DOWN|MOVEFLAG_ROOT | - MOVEFLAG_FALLING |MOVEFLAG_FALLINGFAR|MOVEFLAG_ASCENDING | - MOVEFLAG_FLYING |MOVEFLAG_SPLINE_ELEVATION + MOVEFLAG_FORWARD | MOVEFLAG_BACKWARD | MOVEFLAG_STRAFE_LEFT | MOVEFLAG_STRAFE_RIGHT | + MOVEFLAG_PITCH_UP | MOVEFLAG_PITCH_DOWN | MOVEFLAG_ROOT | + MOVEFLAG_FALLING | MOVEFLAG_FALLINGFAR | MOVEFLAG_ASCENDING | + MOVEFLAG_FLYING | MOVEFLAG_SPLINE_ELEVATION ); MovementFlags const movementOrTurningFlagsMask = MovementFlags( @@ -775,8 +775,8 @@ struct DiminishingReturn : DRGroup(group), stack(0), hitTime(t), hitCount(count) {} - DiminishingGroup DRGroup:16; - uint16 stack:16; + DiminishingGroup DRGroup: 16; + uint16 stack: 16; uint32 hitTime; uint32 hitCount; }; @@ -900,7 +900,7 @@ struct GlobalCooldown uint32 cast_time; }; -typedef UNORDERED_MAP GlobalCooldownList; +typedef UNORDERED_MAP < uint32 /*category*/, GlobalCooldown > GlobalCooldownList; class GlobalCooldownMgr // Shared by Player and CharmInfo { @@ -963,12 +963,12 @@ struct UnitActionBarEntry void SetActionAndType(uint32 action, ActiveStates type) { - packedData = MAKE_UNIT_ACTION_BUTTON(action,type); + packedData = MAKE_UNIT_ACTION_BUTTON(action, type); } void SetType(ActiveStates type) { - packedData = MAKE_UNIT_ACTION_BUTTON(UNIT_ACTION_BUTTON_ACTION(packedData),type); + packedData = MAKE_UNIT_ACTION_BUTTON(UNIT_ACTION_BUTTON_ACTION(packedData), type); } void SetAction(uint32 action) @@ -1014,9 +1014,9 @@ struct CharmInfo void LoadPetActionBar(const std::string& data); void BuildActionBar(WorldPacket* data); void SetSpellAutocast(uint32 spell_id, bool state); - void SetActionBar(uint8 index, uint32 spellOrAction,ActiveStates type) + void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type) { - PetActionBar[index].SetActionAndType(spellOrAction,type); + PetActionBar[index].SetActionAndType(spellOrAction, type); } UnitActionBarEntry const* GetActionBarEntry(uint8 index) const { return &(PetActionBar[index]); } @@ -1105,7 +1105,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject DiminishingLevels GetDiminishing(DiminishingGroup group); void IncrDiminishing(DiminishingGroup group); - void ApplyDiminishingToDuration(DiminishingGroup group, int32& duration,Unit* caster, DiminishingLevels Level, int32 limitduration, bool isReflected); + void ApplyDiminishingToDuration(DiminishingGroup group, int32& duration, Unit* caster, DiminishingLevels Level, int32 limitduration, bool isReflected); void ApplyDiminishingAura(DiminishingGroup group, bool apply); void ClearDiminishings() { m_Diminishing.clear(); } @@ -1185,22 +1185,22 @@ class MANGOS_DLL_SPEC Unit : public WorldObject virtual uint32 GetLevelForTarget(Unit const* /*target*/) const { return getLevel(); } void SetLevel(uint32 lvl); virtual uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); } - uint32 getRaceMask() const { return getRace() ? 1 << (getRace()-1) : 0; } + uint32 getRaceMask() const { return getRace() ? 1 << (getRace() - 1) : 0; } uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); } - uint32 getClassMask() const { return 1 << (getClass()-1); } + uint32 getClassMask() const { return 1 << (getClass() - 1); } uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, 2); } - float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0+stat)); } - void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0+stat, val); } + float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0 + stat)); } + void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0 + stat, val); } uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL) ; } void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); } - uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES+school); } - void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES+school,val); } + uint32 GetResistance(SpellSchools school) const { return GetUInt32Value(UNIT_FIELD_RESISTANCES + school); } + void SetResistance(SpellSchools school, int32 val) { SetStatInt32Value(UNIT_FIELD_RESISTANCES + school, val); } uint32 GetHealth() const { return GetUInt32Value(UNIT_FIELD_HEALTH); } uint32 GetMaxHealth() const { return GetUInt32Value(UNIT_FIELD_MAXHEALTH); } - float GetHealthPercent() const { return (GetHealth()*100.0f) / GetMaxHealth(); } + float GetHealthPercent() const { return (GetHealth() * 100.0f) / GetMaxHealth(); } void SetHealth(uint32 val); void SetMaxHealth(uint32 val); void SetHealthPercent(float percent); @@ -1208,17 +1208,17 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Powers getPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, 3)); } void setPowerType(Powers power); - uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); } - uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); } + uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 + power); } + uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1 + power); } void SetPower(Powers power, uint32 val); void SetMaxPower(Powers power, uint32 val); int32 ModifyPower(Powers power, int32 val); void ApplyPowerMod(Powers power, uint32 val, bool apply); void ApplyMaxPowerMod(Powers power, uint32 val, bool apply); - uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME+att)/m_modAttackSpeedPct[att]); } - void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att,val*m_modAttackSpeedPct[att]); } - void ApplyAttackTimePercentMod(WeaponAttackType att,float val, bool apply); + uint32 GetAttackTime(WeaponAttackType att) const { return (uint32)(GetFloatValue(UNIT_FIELD_BASEATTACKTIME + att) / m_modAttackSpeedPct[att]); } + void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME + att, val * m_modAttackSpeedPct[att]); } + void ApplyAttackTimePercentMod(WeaponAttackType att, float val, bool apply); void ApplyCastTimePercentMod(float val, bool apply); SheathState GetSheath() const { return SheathState(GetByteValue(UNIT_FIELD_BYTES_2, 0)); } @@ -1255,8 +1255,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsStandState() const; void SetStandState(uint8 state); - void SetStandFlags(uint8 flags) { SetByteFlag(UNIT_FIELD_BYTES_1, 2,flags); } - void RemoveStandFlags(uint8 flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, 2,flags); } + void SetStandFlags(uint8 flags) { SetByteFlag(UNIT_FIELD_BYTES_1, 2, flags); } + void RemoveStandFlags(uint8 flags) { RemoveByteFlag(UNIT_FIELD_BYTES_1, 2, flags); } bool IsMounted() const { return HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_MOUNT); } uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); } @@ -1317,7 +1317,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject float GetUnitBlockChance() const; float GetUnitCriticalChance(WeaponAttackType attackType, const Unit* pVictim) const; - virtual uint32 GetShieldBlockValue() const =0; + virtual uint32 GetShieldBlockValue() const = 0; uint32 GetUnitMeleeSkill(Unit const* target = NULL) const { return (target ? GetLevelForTarget(target) : getLevel()) * 5; } uint32 GetDefenseSkillValue(Unit const* target = NULL) const; uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = NULL) const; @@ -1396,13 +1396,13 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool isInAccessablePlaceFor(Creature const* c) const; void SendHealSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, uint32 OverHeal, bool critical = false, uint32 absorb = 0); - void SendEnergizeSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage,Powers powertype); + void SendEnergizeSpellLog(Unit* pVictim, uint32 SpellID, uint32 Damage, Powers powertype); void EnergizeBySpell(Unit* pVictim, uint32 SpellID, uint32 Damage, Powers powertype); uint32 SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage); void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastSpell(Unit* Victim,SpellEntry const* spellInfo, bool triggered, Item* castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); - void CastCustomSpell(Unit* Victim,SpellEntry const* spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem= NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); + void CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); void CastSpell(float x, float y, float z, SpellEntry const* spellInfo, bool triggered, Item* castItem = NULL, Aura* triggeredByAura = NULL, ObjectGuid originalCaster = ObjectGuid(), SpellEntry const* triggeredBy = NULL); @@ -1411,7 +1411,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SendAttackStateUpdate(CalcDamageInfo* damageInfo); void SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 SwingType, SpellSchoolMask damageSchoolMask, uint32 Damage, uint32 AbsorbDamage, uint32 Resist, VictimState TargetState, uint32 BlockedAmount); void SendSpellNonMeleeDamageLog(SpellNonMeleeDamage* log); - void SendSpellNonMeleeDamageLog(Unit* target,uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); + void SendSpellNonMeleeDamageLog(Unit* target, uint32 SpellID, uint32 Damage, SpellSchoolMask damageSchoolMask, uint32 AbsorbedDamage, uint32 Resist, bool PhysicalDamage, uint32 Blocked, bool CriticalHit = false); void SendPeriodicAuraLog(SpellPeriodicAuraLogInfo* pInfo); void SendSpellMiss(Unit* target, uint32 spellID, SpellMissInfo missInfo); @@ -1526,7 +1526,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject // removing specific aura stacks by diff reasons and selections void RemoveAurasDueToSpell(uint32 spellId, SpellAuraHolder* except = NULL, AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT); - void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); + void RemoveAurasDueToItemSpell(Item* castItem, uint32 spellId); void RemoveAurasByCasterSpell(uint32 spellId, ObjectGuid casterGuid); void RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, Unit* stealer); void RemoveAurasDueToSpellByCancel(uint32 spellId); @@ -1551,20 +1551,20 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void DelaySpellAuraHolder(uint32 spellId, int32 delaytime, ObjectGuid casterGuid); - float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school); } - void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school,val); } - void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } - void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE+school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE+school, val, apply); } + float GetResistanceBuffMods(SpellSchools school, bool positive) const { return GetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school); } + void SetResistanceBuffMods(SpellSchools school, bool positive, float val) { SetFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school, val); } + void ApplyResistanceBuffModsMod(SpellSchools school, bool positive, float val, bool apply) { ApplyModSignedFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school, val, apply); } + void ApplyResistanceBuffModsPercentMod(SpellSchools school, bool positive, float val, bool apply) { ApplyPercentModFloatValue(positive ? UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + school : UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + school, val, apply); } void InitStatBuffMods() { - for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0+i, 0); - for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0); + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_POSSTAT0 + i, 0); + for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) SetFloatValue(UNIT_FIELD_NEGSTAT0 + i, 0); } - void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0+stat : UNIT_FIELD_NEGSTAT0+stat), val, apply); } + void ApplyStatBuffMod(Stats stat, float val, bool apply) { ApplyModSignedFloatValue((val > 0 ? UNIT_FIELD_POSSTAT0 + stat : UNIT_FIELD_NEGSTAT0 + stat), val, apply); } void ApplyStatPercentBuffMod(Stats stat, float val, bool apply) { - ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0+stat, val, apply); - ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0+stat, val, apply); + ApplyPercentModFloatValue(UNIT_FIELD_POSSTAT0 + stat, val, apply); + ApplyPercentModFloatValue(UNIT_FIELD_NEGSTAT0 + stat, val, apply); } void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; } void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); } @@ -1572,8 +1572,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); } uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); } uint32 GetCreatePowers(Powers power) const; - float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0+stat); } - float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0+stat); } + float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0 + stat); } + float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0 + stat); } float GetCreateStat(Stats stat) const { return m_createStats[stat]; } void SetCurrentCastedSpell(Spell* pSpell); @@ -1647,8 +1647,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0; virtual void UpdateDamagePhysical(WeaponAttackType attType) = 0; float GetTotalAttackPowerValue(WeaponAttackType attType) const; - float GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange type) const; - void SetBaseWeaponDamage(WeaponAttackType attType ,WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } + float GetWeaponDamageRange(WeaponAttackType attType , WeaponDamageRange type) const; + void SetBaseWeaponDamage(WeaponAttackType attType , WeaponDamageRange damageRange, float value) { m_weaponDamage[attType][damageRange] = value; } // Visibility system UnitVisibility GetVisibility() const { return m_Visibility; } @@ -1761,7 +1761,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 CalculateDamage(WeaponAttackType attType, bool normalized); float GetAPMultiplier(WeaponAttackType attType, bool normalized); void ModifyAuraState(AuraState flag, bool apply); - bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); } + bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1 << (flag - 1)); } bool HasAuraStateForCaster(AuraState flag, ObjectGuid casterGuid) const; void UnsummonAllTotems(); Unit* SelectMagnetTarget(Unit* victim, Spell* spell = NULL, SpellEffectIndex eff = EFFECT_INDEX_0); @@ -1776,7 +1776,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 SpellHealingBonusDone(Unit* pVictim, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); uint32 SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); uint32 MeleeDamageBonusDone(Unit* pVictim, uint32 damage, WeaponAttackType attType, SpellEntry const* spellProto = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1); - uint32 MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage,WeaponAttackType attType, SpellEntry const* spellProto = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1); + uint32 MeleeDamageBonusTaken(Unit* pCaster, uint32 pdamage, WeaponAttackType attType, SpellEntry const* spellProto = NULL, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1); bool IsSpellBlocked(Unit* pCaster, SpellEntry const* spellProto, WeaponAttackType attackType = BASE_ATTACK); bool IsSpellCrit(Unit* pVictim, SpellEntry const* spellProto, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK); diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp index 60b83c24a..47c13a664 100644 --- a/src/game/UnitAuraProcHandler.cpp +++ b/src/game/UnitAuraProcHandler.cpp @@ -30,7 +30,7 @@ #include "CreatureAI.h" #include "Util.h" -pAuraProcHandler AuraProcHandler[TOTAL_AURAS]= +pAuraProcHandler AuraProcHandler[TOTAL_AURAS] = { &Unit::HandleNULLProc, // 0 SPELL_AURA_NONE &Unit::HandleNULLProc, // 1 SPELL_AURA_BIND_SIGHT @@ -400,14 +400,14 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, S else item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED); - if (!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + if (!item || item->IsBroken() || item->GetProto()->Class != ITEM_CLASS_WEAPON || !((1 << item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } else if (spellProto->EquippedItemClass == ITEM_CLASS_ARMOR) { // Check if player is wearing shield Item* item = ((Player*)this)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if (!item || item->IsBroken() || !CanUseEquippedWeapon(OFF_ATTACK) || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1<GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) + if (!item || item->IsBroken() || !CanUseEquippedWeapon(OFF_ATTACK) || item->GetProto()->Class != ITEM_CLASS_ARMOR || !((1 << item->GetProto()->SubClass) & spellProto->EquippedItemSubClassMask)) return false; } } @@ -425,8 +425,8 @@ bool Unit::IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, S // Apply chance modifier aura if (Player* modOwner = GetSpellModOwner()) { - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_CHANCE_OF_SUCCESS,chance); - modOwner->ApplySpellMod(spellProto->Id,SPELLMOD_FREQUENCY_OF_SUCCESS,chance); + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CHANCE_OF_SUCCESS, chance); + modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_FREQUENCY_OF_SUCCESS, chance); } return roll_chance_f(chance); @@ -436,7 +436,7 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura { SpellEntry const* hasteSpell = triggeredByAura->GetSpellProto(); - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; uint32 triggered_spell_id = 0; @@ -473,7 +473,7 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura if (!triggerEntry) { - sLog.outError("Unit::HandleHasteAuraProc: Spell %u have nonexistent triggered spell %u",hasteSpell->Id,triggered_spell_id); + sLog.outError("Unit::HandleHasteAuraProc: Spell %u have nonexistent triggered spell %u", hasteSpell->Id, triggered_spell_id); return SPELL_AURA_PROC_FAILED; } @@ -481,16 +481,16 @@ SpellAuraProcResult Unit::HandleHasteAuraProc(Unit* pVictim, uint32 damage, Aura if (!target || (target != this && !target->isAlive())) return SPELL_AURA_PROC_FAILED; - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) return SPELL_AURA_PROC_FAILED; if (basepoints0) - CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + CastCustomSpell(target, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura); else - CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); + CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura); - if (cooldown && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + if (cooldown && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown); return SPELL_AURA_PROC_OK; } @@ -502,7 +502,7 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /* SpellEntry const* triggeredByAuraSpell = triggeredByAura->GetSpellProto(); - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; uint32 triggered_spell_id = 0; @@ -538,7 +538,7 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /* if (!triggerEntry) { - sLog.outError("Unit::HandleHasteAuraProc: Spell %u have nonexistent triggered spell %u",triggeredByAuraSpell->Id,triggered_spell_id); + sLog.outError("Unit::HandleHasteAuraProc: Spell %u have nonexistent triggered spell %u", triggeredByAuraSpell->Id, triggered_spell_id); return SPELL_AURA_PROC_FAILED; } @@ -546,16 +546,16 @@ SpellAuraProcResult Unit::HandleSpellCritChanceAuraProc(Unit* pVictim, uint32 /* if (!target || (target != this && !target->isAlive())) return SPELL_AURA_PROC_FAILED; - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) return SPELL_AURA_PROC_FAILED; if (basepoints0) - CastCustomSpell(target,triggered_spell_id,&basepoints0,NULL,NULL,true,castItem,triggeredByAura); + CastCustomSpell(target, triggered_spell_id, &basepoints0, NULL, NULL, true, castItem, triggeredByAura); else - CastSpell(target,triggered_spell_id,true,castItem,triggeredByAura); + CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura); - if (cooldown && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + if (cooldown && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown); return SPELL_AURA_PROC_OK; } @@ -566,7 +566,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura SpellEffectIndex effIndex = triggeredByAura->GetEffIndex(); int32 triggerAmount = triggeredByAura->GetModifier()->m_amount; - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // some dummy spells have trigger spell in spell data already (from 3.0.3) @@ -585,9 +585,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 25988: { // return damage % to attacker but < 50% own total health - basepoints[0] = triggerAmount*int32(damage)/100; - if (basepoints[0] > (int32)GetMaxHealth()/2) - basepoints[0] = (int32)GetMaxHealth()/2; + basepoints[0] = triggerAmount * int32(damage) / 100; + if (basepoints[0] > (int32)GetMaxHealth() / 2) + basepoints[0] = (int32)GetMaxHealth() / 2; triggered_spell_id = 25997; break; @@ -640,9 +640,9 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { if (SpellEntry const* iterSpellProto = (*iter)->GetSpellProto()) { - if (iterSpellProto->SpellFamilyName==SPELLFAMILY_MAGE && (iterSpellProto->SpellFamilyFlags & UI64LIT(0x10000000))) + if (iterSpellProto->SpellFamilyName == SPELLFAMILY_MAGE && (iterSpellProto->SpellFamilyFlags & UI64LIT(0x10000000))) { - found=true; + found = true; break; } } @@ -768,15 +768,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case CLASS_PALADIN: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 case CLASS_DRUID: // 39511,40997,40998,40999,41002,41005,41009,41011,41409 { - uint32 RandomSpell[]= {39511,40997,40998,40999,41002,41005,41009,41011,41409}; - triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; + uint32 RandomSpell[] = {39511, 40997, 40998, 40999, 41002, 41005, 41009, 41011, 41409}; + triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell) - 1)]; break; } case CLASS_ROGUE: // 39511,40997,40998,41002,41005,41011 case CLASS_WARRIOR: // 39511,40997,40998,41002,41005,41011 { - uint32 RandomSpell[]= {39511,40997,40998,41002,41005,41011}; - triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; + uint32 RandomSpell[] = {39511, 40997, 40998, 41002, 41005, 41011}; + triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell) - 1)]; break; } case CLASS_PRIEST: // 40999,41002,41005,41009,41011,41406,41409 @@ -784,14 +784,14 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case CLASS_MAGE: // 40999,41002,41005,41009,41011,41406,41409 case CLASS_WARLOCK: // 40999,41002,41005,41009,41011,41406,41409 { - uint32 RandomSpell[]= {40999,41002,41005,41009,41011,41406,41409}; - triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; + uint32 RandomSpell[] = {40999, 41002, 41005, 41009, 41011, 41406, 41409}; + triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell) - 1)]; break; } case CLASS_HUNTER: // 40997,40999,41002,41005,41009,41011,41406,41409 { - uint32 RandomSpell[]= {40997,40999,41002,41005,41009,41011,41406,41409}; - triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell)-1)]; + uint32 RandomSpell[] = {40997, 40999, 41002, 41005, 41009, 41011, 41406, 41409}; + triggered_spell_id = RandomSpell[urand(0, countof(RandomSpell) - 1)]; break; } default: @@ -827,7 +827,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura target = getVictim(); if (!target) { - target = ObjectAccessor::GetUnit(*this,((Player*)this)->GetSelectionGuid()); + target = ObjectAccessor::GetUnit(*this, ((Player*)this)->GetSelectionGuid()); if (!target) return SPELL_AURA_PROC_FAILED; } @@ -941,7 +941,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // Glyph of Shadowfiend (need cast as self cast for owner, no hidden cooldown) - owner->CastSpell(owner,58227,true,castItem,triggeredByAura); + owner->CastSpell(owner, 58227, true, castItem, triggeredByAura); return SPELL_AURA_PROC_OK; } // Kill Command, pet aura @@ -1029,8 +1029,8 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // mana cost save int32 cost = procSpell->manaCost + procSpell->ManaCostPercentage * GetCreateMana() / 100; - basepoints[0] = cost * triggerAmount/100; - if (basepoints[0] <=0) + basepoints[0] = cost * triggerAmount / 100; + if (basepoints[0] <= 0) return SPELL_AURA_PROC_FAILED; target = this; @@ -1050,7 +1050,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 31571: triggered_spell_id = 57529; break; case 31572: triggered_spell_id = 57531; break; default: - sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u",dummySpell->Id); + sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u", dummySpell->Id); return SPELL_AURA_PROC_FAILED; } break; @@ -1069,7 +1069,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura Modifier* mod = counter->GetModifier(); if (procEx & PROC_EX_CRITICAL_HIT) { - mod->m_amount *=2; + mod->m_amount *= 2; if (mod->m_amount < 100) // not enough return SPELL_AURA_PROC_OK; // Critical counted -> roll chance @@ -1086,8 +1086,8 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; int32 cost = procSpell->manaCost + procSpell->ManaCostPercentage * GetCreateMana() / 100; - basepoints[0] = cost * triggerAmount/100; - if (basepoints[0] <=0) + basepoints[0] = cost * triggerAmount / 100; + if (basepoints[0] <= 0) return SPELL_AURA_PROC_FAILED; triggered_spell_id = 44450; target = this; @@ -1104,13 +1104,13 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura { switch (dummySpell->Id) { - case 11119: basepoints[0] = int32(0.04f*damage); break; - case 11120: basepoints[0] = int32(0.08f*damage); break; - case 12846: basepoints[0] = int32(0.12f*damage); break; - case 12847: basepoints[0] = int32(0.16f*damage); break; - case 12848: basepoints[0] = int32(0.20f*damage); break; + case 11119: basepoints[0] = int32(0.04f * damage); break; + case 11120: basepoints[0] = int32(0.08f * damage); break; + case 12846: basepoints[0] = int32(0.12f * damage); break; + case 12847: basepoints[0] = int32(0.16f * damage); break; + case 12848: basepoints[0] = int32(0.20f * damage); break; default: - sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (IG)",dummySpell->Id); + sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (IG)", dummySpell->Id); return SPELL_AURA_PROC_FAILED; } @@ -1167,7 +1167,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->SpellIconID == 1697) { // only for spells and hit/crit (trigger start always) and not start from self casted spells (5530 Mace Stun Effect for example) - if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == pVictim) + if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) || this == pVictim) return SPELL_AURA_PROC_FAILED; // Need stun or root mechanic if (!(GetAllSpellMechanicMask(procSpell) & IMMUNE_TO_ROOT_AND_STUN_MASK)) @@ -1175,11 +1175,11 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura switch (dummySpell->Id) { - case 29838: triggered_spell_id=29842; break; - case 29834: triggered_spell_id=29841; break; - case 42770: triggered_spell_id=42771; break; + case 29838: triggered_spell_id = 29842; break; + case 29834: triggered_spell_id = 29841; break; + case 42770: triggered_spell_id = 42771; break; default: - sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (SW)",dummySpell->Id); + sLog.outError("Unit::HandleDummyAuraProc: non handled spell id: %u (SW)", dummySpell->Id); return SPELL_AURA_PROC_FAILED; } @@ -1231,7 +1231,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura } // Damage counting - mod->m_amount-=damage; + mod->m_amount -= damage; return SPELL_AURA_PROC_OK; } // Seed of Corruption (Mobs cast) - no die req @@ -1252,7 +1252,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_OK; // no hidden cooldown } // Damage counting - mod->m_amount-=damage; + mod->m_amount -= damage; return SPELL_AURA_PROC_OK; } // Fel Synergy @@ -1282,7 +1282,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 30296: { // health - basepoints[0] = int32(damage*triggerAmount/100); + basepoints[0] = int32(damage * triggerAmount / 100); target = this; triggered_spell_id = 30294; break; @@ -1301,7 +1301,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // heal amount - basepoints[0] = damage * triggerAmount/100; + basepoints[0] = damage * triggerAmount / 100; triggered_spell_id = 37382; break; } @@ -1357,7 +1357,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Divine Aegis case 2820: { - basepoints[0] = damage * triggerAmount/100; + basepoints[0] = damage * triggerAmount / 100; triggered_spell_id = 47753; break; } @@ -1429,7 +1429,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 26169: { // heal amount - basepoints[0] = int32(damage * 10/100); + basepoints[0] = int32(damage * 10 / 100); target = this; triggered_spell_id = 26170; break; @@ -1437,11 +1437,11 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Frozen Shadoweave (Shadow's Embrace set) warning! its not only priest set case 39372: { - if (!procSpell || (GetSpellSchoolMask(procSpell) & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW))==0) + if (!procSpell || (GetSpellSchoolMask(procSpell) & (SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_SHADOW)) == 0) return SPELL_AURA_PROC_FAILED; // heal amount - basepoints[0] = damage * triggerAmount/100; + basepoints[0] = damage * triggerAmount / 100; target = this; triggered_spell_id = 39373; break; @@ -1602,7 +1602,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura else radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(procSpell->rangeIndex)); - ((Player*)this)->ApplySpellMod(procSpell->Id, SPELLMOD_RADIUS, radius,NULL); + ((Player*)this)->ApplySpellMod(procSpell->Id, SPELLMOD_RADIUS, radius, NULL); Unit* second = pVictim->SelectRandomFriendlyTarget(pVictim, radius); @@ -1743,7 +1743,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // energy cost save - basepoints[0] = procSpell->manaCost * triggerAmount/100; + basepoints[0] = procSpell->manaCost * triggerAmount / 100; if (basepoints[0] <= 0) return SPELL_AURA_PROC_FAILED; @@ -1763,7 +1763,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // mana cost save int32 mana = procSpell->manaCost + procSpell->ManaCostPercentage * GetCreateMana() / 100; - basepoints[0] = mana * 40/100; + basepoints[0] = mana * 40 / 100; if (basepoints[0] <= 0) return SPELL_AURA_PROC_FAILED; @@ -1833,7 +1833,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura int32 holy = SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_HOLY); if (holy < 0) holy = 0; - basepoints[0] = GetAttackTime(BASE_ATTACK) * int32(ap*0.022f + 0.044f * holy) / 1000; + basepoints[0] = GetAttackTime(BASE_ATTACK) * int32(ap * 0.022f + 0.044f * holy) / 1000; break; } // Righteous Vengeance @@ -1944,7 +1944,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // dont count overhealing - uint32 diff = GetMaxHealth()-GetHealth(); + uint32 diff = GetMaxHealth() - GetHealth(); if (!diff) return SPELL_AURA_PROC_FAILED; basepoints[0] = triggerAmount * (damage > diff ? diff : damage) / 100; @@ -1965,7 +1965,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Add 5-stack effect from Holy Vengeance uint32 stacks = 0; AuraList const& auras = target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for (AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (((*itr)->GetId() == 31803) && (*itr)->GetCasterGuid() == GetObjectGuid()) { @@ -1974,7 +1974,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura } } if (stacks >= 5) - CastSpell(target,42463,true,NULL,triggeredByAura); + CastSpell(target, 42463, true, NULL, triggeredByAura); break; } // Judgements of the Wise @@ -2006,7 +2006,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura chance = 15.0f; } // Judgement (any) - else if (GetSpellSpecific(procSpell->Id)==SPELL_JUDGEMENT) + else if (GetSpellSpecific(procSpell->Id) == SPELL_JUDGEMENT) { triggered_spell_id = 40472; chance = 50.0f; @@ -2048,10 +2048,10 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; triggered_spell_id = 53652; // Beacon of Light - basepoints[0] = triggeredByAura->GetModifier()->m_amount*damage/100; + basepoints[0] = triggeredByAura->GetModifier()->m_amount * damage / 100; // cast with original caster set but beacon to beacon for apply caster mods and avoid LoS check - beacon->CastCustomSpell(beacon,triggered_spell_id,&basepoints[0],NULL,NULL,true,castItem,triggeredByAura,pVictim->GetObjectGuid()); + beacon->CastCustomSpell(beacon, triggered_spell_id, &basepoints[0], NULL, NULL, true, castItem, triggeredByAura, pVictim->GetObjectGuid()); return SPELL_AURA_PROC_OK; } // Seal of Corruption (damage calc on apply aura) @@ -2067,7 +2067,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Add 5-stack effect from Blood Corruption uint32 stacks = 0; AuraList const& auras = target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); - for (AuraList::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) + for (AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { if (((*itr)->GetId() == 53742) && (*itr)->GetCasterGuid() == GetObjectGuid()) { @@ -2121,7 +2121,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura uint32 maxStack = mote->StackAmount - (dummySpell->Id == 71545 ? 1 : 0); SpellAuraHolder* aurHolder = GetSpellAuraHolder(71432); - if (aurHolder && uint32(aurHolder->GetStackAmount() +1) >= maxStack) + if (aurHolder && uint32(aurHolder->GetStackAmount() + 1) >= maxStack) { RemoveAurasDueToSpell(71432); // Mote of Anger @@ -2214,7 +2214,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Windfury Weapon (Passive) 1-5 Ranks case 33757: { - if (GetTypeId()!=TYPEID_PLAYER) + if (GetTypeId() != TYPEID_PLAYER) return SPELL_AURA_PROC_FAILED; if (!castItem || !castItem->IsEquipped()) @@ -2232,15 +2232,15 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 283: spellId = 8232; break; // 1 Rank case 284: spellId = 8235; break; // 2 Rank case 525: spellId = 10486; break; // 3 Rank - case 1669:spellId = 16362; break; // 4 Rank - case 2636:spellId = 25505; break; // 5 Rank - case 3785:spellId = 58801; break; // 6 Rank - case 3786:spellId = 58803; break; // 7 Rank - case 3787:spellId = 58804; break; // 8 Rank + case 1669: spellId = 16362; break; // 4 Rank + case 2636: spellId = 25505; break; // 5 Rank + case 3785: spellId = 58801; break; // 6 Rank + case 3786: spellId = 58803; break; // 7 Rank + case 3787: spellId = 58804; break; // 8 Rank default: { sLog.outError("Unit::HandleDummyAuraProc: non handled item enchantment (rank?) %u for spell id: %u (Windfury)", - castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)),dummySpell->Id); + castItem->GetEnchantmentId(EnchantmentSlot(TEMP_ENCHANTMENT_SLOT)), dummySpell->Id); return SPELL_AURA_PROC_FAILED; } } @@ -2248,7 +2248,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura SpellEntry const* windfurySpellEntry = sSpellStore.LookupEntry(spellId); if (!windfurySpellEntry) { - sLog.outError("Unit::HandleDummyAuraProc: nonexistent spell id: %u (Windfury)",spellId); + sLog.outError("Unit::HandleDummyAuraProc: nonexistent spell id: %u (Windfury)", spellId); return SPELL_AURA_PROC_FAILED; } @@ -2262,24 +2262,24 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (castItem->GetSlot() == EQUIPMENT_SLOT_OFFHAND) { // Value gained from additional AP - basepoints[0] = int32(extra_attack_power/14.0f * GetAttackTime(OFF_ATTACK)/1000/2); + basepoints[0] = int32(extra_attack_power / 14.0f * GetAttackTime(OFF_ATTACK) / 1000 / 2); triggered_spell_id = 33750; } // Main-Hand case else { // Value gained from additional AP - basepoints[0] = int32(extra_attack_power/14.0f * GetAttackTime(BASE_ATTACK)/1000); + basepoints[0] = int32(extra_attack_power / 14.0f * GetAttackTime(BASE_ATTACK) / 1000); triggered_spell_id = 25504; } // apply cooldown before cast to prevent processing itself if (cooldown) - ((Player*)this)->AddSpellCooldown(dummySpell->Id,0,time(NULL) + cooldown); + ((Player*)this)->AddSpellCooldown(dummySpell->Id, 0, time(NULL) + cooldown); // Attack Twice - for (uint32 i = 0; i<2; ++i) - CastCustomSpell(pVictim,triggered_spell_id,&basepoints[0],NULL,NULL,true,castItem,triggeredByAura); + for (uint32 i = 0; i < 2; ++i) + CastCustomSpell(pVictim, triggered_spell_id, &basepoints[0], NULL, NULL, true, castItem, triggeredByAura); return SPELL_AURA_PROC_OK; } @@ -2318,7 +2318,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura case 55440: { // Not proc from self heals - if (this==pVictim) + if (this == pVictim) return SPELL_AURA_PROC_FAILED; basepoints[0] = triggerAmount * damage / 100; target = this; @@ -2348,7 +2348,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura for (AuraList::const_iterator i = spellPower.begin(); i != spellPower.end(); ++i) { // select proper aura for format aura type in spell proto - if ((*i)->GetTarget()==totem && (*i)->GetSpellProto()->EffectApplyAuraName[(*i)->GetEffIndex()] == SPELL_AURA_MOD_HEALING_DONE && + if ((*i)->GetTarget() == totem && (*i)->GetSpellProto()->EffectApplyAuraName[(*i)->GetEffIndex()] == SPELL_AURA_MOD_HEALING_DONE && (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_SHAMAN && (*i)->GetSpellProto()->SpellFamilyFlags & UI64LIT(0x0000000004000000)) { basepoints[0] = triggerAmount * (*i)->GetModifier()->m_amount / 100; @@ -2410,7 +2410,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura // Flametongue Weapon (Passive), Ranks if (dummySpell->SpellFamilyFlags & UI64LIT(0x0000000000200000)) { - if (GetTypeId()!=TYPEID_PLAYER || !castItem) + if (GetTypeId() != TYPEID_PLAYER || !castItem) return SPELL_AURA_PROC_FAILED; // Only proc for enchanted weapon @@ -2487,7 +2487,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura return SPELL_AURA_PROC_FAILED; // custom cooldown processing case - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(dummySpell->Id)) return SPELL_AURA_PROC_FAILED; uint32 spellId = 0; @@ -2719,7 +2719,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (dummySpell->Id == 61257) { // only for spells and hit/crit (trigger start always) and not start from self casted spells - if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == pVictim) + if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) || this == pVictim) return SPELL_AURA_PROC_FAILED; // Need snare or root mechanic if (!(GetAllSpellMechanicMask(procSpell) & IMMUNE_TO_ROOT_AND_SNARE_MASK)) @@ -2761,7 +2761,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (!triggerEntry) { - sLog.outError("Unit::HandleDummyAuraProc: Spell %u have nonexistent triggered spell %u",dummySpell->Id,triggered_spell_id); + sLog.outError("Unit::HandleDummyAuraProc: Spell %u have nonexistent triggered spell %u", dummySpell->Id, triggered_spell_id); return SPELL_AURA_PROC_FAILED; } @@ -2769,7 +2769,7 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura if (!target || (target != this && !target->isAlive())) return SPELL_AURA_PROC_FAILED; - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) return SPELL_AURA_PROC_FAILED; if (basepoints[EFFECT_INDEX_0] || basepoints[EFFECT_INDEX_1] || basepoints[EFFECT_INDEX_2]) @@ -2781,8 +2781,8 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit* pVictim, uint32 damage, Aura else CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura); - if (cooldown && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + if (cooldown && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown); return SPELL_AURA_PROC_OK; } @@ -2803,7 +2803,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d if (triggeredByAura->GetModifier()->m_auraname == SPELL_AURA_PROC_TRIGGER_SPELL_WITH_VALUE) basepoints[0] = triggerAmount; - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // Try handle unknown trigger spells @@ -2922,7 +2922,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // agility if (GetStat(STAT_AGILITY) > stat) { trigger_spell_id = 60233; stat = GetStat(STAT_AGILITY); } // intellect - if (GetStat(STAT_INTELLECT)> stat) { trigger_spell_id = 60234; stat = GetStat(STAT_INTELLECT);} + if (GetStat(STAT_INTELLECT) > stat) { trigger_spell_id = 60234; stat = GetStat(STAT_INTELLECT);} // spirit if (GetStat(STAT_SPIRIT) > stat) { trigger_spell_id = 60235; } break; @@ -3006,7 +3006,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d trigger_spell_id = 31643; break; default: - sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u miss possibly Blazing Speed",auraSpellInfo->Id); + sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u miss possibly Blazing Speed", auraSpellInfo->Id); return SPELL_AURA_PROC_FAILED; } } @@ -3033,9 +3033,9 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // DW should benefit of attack power, damage percent mods etc. // TODO: check if using offhand damage is correct and if it should be divided by 2 if (haveOffhandWeapon() && getAttackTimer(BASE_ATTACK) > getAttackTimer(OFF_ATTACK)) - weaponDamage = (GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE) + GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE))/2; + weaponDamage = (GetFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE) + GetFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE)) / 2; else - weaponDamage = (GetFloatValue(UNIT_FIELD_MINDAMAGE) + GetFloatValue(UNIT_FIELD_MAXDAMAGE))/2; + weaponDamage = (GetFloatValue(UNIT_FIELD_MINDAMAGE) + GetFloatValue(UNIT_FIELD_MAXDAMAGE)) / 2; switch (auraSpellInfo->Id) { @@ -3044,7 +3044,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d case 12867: basepoints[0] = int32(weaponDamage * 48 / 100); break; // Impossible case default: - sLog.outError("Unit::HandleProcTriggerSpellAuraProc: DW unknown spell rank %u",auraSpellInfo->Id); + sLog.outError("Unit::HandleProcTriggerSpellAuraProc: DW unknown spell rank %u", auraSpellInfo->Id); return SPELL_AURA_PROC_FAILED; } @@ -3135,7 +3135,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d case SPELLFAMILY_PRIEST: { // Greater Heal Refund (Avatar Raiment set) - if (auraSpellInfo->Id==37594) + if (auraSpellInfo->Id == 37594) { // Not give if target already have full health if (pVictim->GetHealth() == pVictim->GetMaxHealth()) @@ -3168,7 +3168,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d case SPELLFAMILY_DRUID: { // Druid Forms Trinket - if (auraSpellInfo->Id==37336) + if (auraSpellInfo->Id == 37336) { switch (GetShapeshiftForm()) { @@ -3183,7 +3183,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d } } // Druid T9 Feral Relic (Lacerate, Swipe, Mangle, and Shred) - else if (auraSpellInfo->Id==67353) + else if (auraSpellInfo->Id == 67353) { switch (GetShapeshiftForm()) { @@ -3256,19 +3256,19 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d } */ // Healing Discount - if (auraSpellInfo->Id==37705) + if (auraSpellInfo->Id == 37705) { trigger_spell_id = 37706; target = this; } // Soul Preserver - if (auraSpellInfo->Id==60510) + if (auraSpellInfo->Id == 60510) { trigger_spell_id = 60515; target = this; } // Illumination - else if (auraSpellInfo->SpellIconID==241) + else if (auraSpellInfo->SpellIconID == 241) { if (!procSpell) return SPELL_AURA_PROC_FAILED; @@ -3287,24 +3287,24 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d case 48820: originalSpellId = 48824; break; case 48821: originalSpellId = 48825; break; default: - sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u not handled in HShock",procSpell->Id); + sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u not handled in HShock", procSpell->Id); return SPELL_AURA_PROC_FAILED; } } SpellEntry const* originalSpell = sSpellStore.LookupEntry(originalSpellId); if (!originalSpell) { - sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u unknown but selected as original in Illu",originalSpellId); + sLog.outError("Unit::HandleProcTriggerSpellAuraProc: Spell %u unknown but selected as original in Illu", originalSpellId); return SPELL_AURA_PROC_FAILED; } // percent stored in effect 1 (class scripts) base points int32 cost = originalSpell->manaCost + originalSpell->ManaCostPercentage * GetCreateMana() / 100; - basepoints[0] = cost*auraSpellInfo->CalculateSimpleValue(EFFECT_INDEX_1)/100; + basepoints[0] = cost * auraSpellInfo->CalculateSimpleValue(EFFECT_INDEX_1) / 100; trigger_spell_id = 20272; target = this; } // Lightning Capacitor - else if (auraSpellInfo->Id==37657) + else if (auraSpellInfo->Id == 37657) { if (!pVictim || !pVictim->isAlive()) return SPELL_AURA_PROC_FAILED; @@ -3408,7 +3408,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d return SPELL_AURA_PROC_FAILED; if (pVictim && pVictim->isAlive()) - pVictim->getThreatManager().modifyThreatPercent(this,-10); + pVictim->getThreatManager().modifyThreatPercent(this, -10); basepoints[0] = triggerAmount * GetMaxHealth() / 100; trigger_spell_id = 31616; @@ -3519,7 +3519,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // Enlightenment (trigger only from mana cost spells) case 35095: { - if (!procSpell || procSpell->powerType!=POWER_MANA || procSpell->manaCost==0 && procSpell->ManaCostPercentage==0 && procSpell->manaCostPerlevel==0) + if (!procSpell || procSpell->powerType != POWER_MANA || procSpell->manaCost == 0 && procSpell->ManaCostPercentage == 0 && procSpell->manaCostPerlevel == 0) return SPELL_AURA_PROC_FAILED; break; } @@ -3566,7 +3566,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // PPM = 2.5 * (rank of talent), uint32 rank = sSpellMgr.GetSpellRank(auraSpellInfo->Id); // 5 rank -> 100% 4 rank -> 80% and etc from full rate - if (!roll_chance_i(20*rank)) + if (!roll_chance_i(20 * rank)) return SPELL_AURA_PROC_FAILED; break; } @@ -3576,16 +3576,16 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d if (!procSpell) return SPELL_AURA_PROC_FAILED; // For trigger from Blizzard need exist Improved Blizzard - if (procSpell->SpellFamilyName==SPELLFAMILY_MAGE && (procSpell->SpellFamilyFlags & UI64LIT(0x0000000000000080))) + if (procSpell->SpellFamilyName == SPELLFAMILY_MAGE && (procSpell->SpellFamilyFlags & UI64LIT(0x0000000000000080))) { bool found = false; AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { int32 script = (*i)->GetModifier()->m_miscvalue; - if (script==836 || script==988 || script==989) + if (script == 836 || script == 988 || script == 989) { - found=true; + found = true; break; } } @@ -3597,7 +3597,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d // Astral Shift case 52179: { - if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT|PROC_EX_CRITICAL_HIT)) || this == pVictim) + if (procSpell == 0 || !(procEx & (PROC_EX_NORMAL_HIT | PROC_EX_CRITICAL_HIT)) || this == pVictim) return SPELL_AURA_PROC_FAILED; // Need stun, fear or silence mechanic @@ -3639,7 +3639,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d } } - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(trigger_spell_id)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(trigger_spell_id)) return SPELL_AURA_PROC_FAILED; // try detect target manually if not set @@ -3651,16 +3651,16 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit* pVictim, uint32 d return SPELL_AURA_PROC_FAILED; if (basepoints[EFFECT_INDEX_0] || basepoints[EFFECT_INDEX_1] || basepoints[EFFECT_INDEX_2]) - CastCustomSpell(target,trigger_spell_id, + CastCustomSpell(target, trigger_spell_id, basepoints[EFFECT_INDEX_0] ? &basepoints[EFFECT_INDEX_0] : NULL, basepoints[EFFECT_INDEX_1] ? &basepoints[EFFECT_INDEX_1] : NULL, basepoints[EFFECT_INDEX_2] ? &basepoints[EFFECT_INDEX_2] : NULL, true, castItem, triggeredByAura); else - CastSpell(target,trigger_spell_id,true,castItem,triggeredByAura); + CastSpell(target, trigger_spell_id, true, castItem, triggeredByAura); - if (cooldown && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->AddSpellCooldown(trigger_spell_id,0,time(NULL) + cooldown); + if (cooldown && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->AddSpellCooldown(trigger_spell_id, 0, time(NULL) + cooldown); return SPELL_AURA_PROC_OK; } @@ -3673,20 +3673,20 @@ SpellAuraProcResult Unit::HandleProcTriggerDamageAuraProc(Unit* pVictim, uint32 SpellNonMeleeDamage damageInfo(this, pVictim, spellInfo->Id, SpellSchoolMask(spellInfo->SchoolMask)); CalculateSpellDamage(&damageInfo, triggeredByAura->GetModifier()->m_amount, spellInfo); damageInfo.target->CalculateAbsorbResistBlock(this, &damageInfo, spellInfo); - DealDamageMods(damageInfo.target,damageInfo.damage,&damageInfo.absorb); + DealDamageMods(damageInfo.target, damageInfo.damage, &damageInfo.absorb); SendSpellNonMeleeDamageLog(&damageInfo); DealSpellDamage(&damageInfo, true); return SPELL_AURA_PROC_OK; } -SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/ ,uint32 cooldown) +SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/ , uint32 cooldown) { int32 scriptId = triggeredByAura->GetModifier()->m_miscvalue; if (!pVictim || !pVictim->isAlive()) return SPELL_AURA_PROC_FAILED; - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // Basepoints of trigger aura @@ -3749,7 +3749,7 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 triggered_spell_id = 37445; // Mana Surge break; case 6953: // Warbringer - RemoveAurasAtMechanicImmunity(IMMUNE_TO_ROOT_AND_SNARE_MASK,0,true); + RemoveAurasAtMechanicImmunity(IMMUNE_TO_ROOT_AND_SNARE_MASK, 0, true); return SPELL_AURA_PROC_OK; case 7010: // Revitalize (rank 1) case 7011: // Revitalize (rank 2) @@ -3779,17 +3779,17 @@ SpellAuraProcResult Unit::HandleOverrideClassScriptAuraProc(Unit* pVictim, uint3 if (!triggerEntry) { - sLog.outError("Unit::HandleOverrideClassScriptAuraProc: Spell %u triggering for class script id %u",triggered_spell_id,scriptId); + sLog.outError("Unit::HandleOverrideClassScriptAuraProc: Spell %u triggering for class script id %u", triggered_spell_id, scriptId); return SPELL_AURA_PROC_FAILED; } - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) return SPELL_AURA_PROC_FAILED; CastSpell(pVictim, triggered_spell_id, true, castItem, triggeredByAura); - if (cooldown && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + if (cooldown && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown); return SPELL_AURA_PROC_OK; } @@ -3803,10 +3803,10 @@ SpellAuraProcResult Unit::HandleMendingAuraProc(Unit* /*pVictim*/, uint32 /*dama ObjectGuid caster_guid = triggeredByAura->GetCasterGuid(); // jumps - int32 jumps = triggeredByAura->GetHolder()->GetAuraCharges()-1; + int32 jumps = triggeredByAura->GetHolder()->GetAuraCharges() - 1; // next target selection - if (jumps > 0 && GetTypeId()==TYPEID_PLAYER && caster_guid.IsPlayer()) + if (jumps > 0 && GetTypeId() == TYPEID_PLAYER && caster_guid.IsPlayer()) { float radius; if (spellProto->EffectRadiusIndex[effIdx]) @@ -3845,7 +3845,7 @@ SpellAuraProcResult Unit::HandleMendingAuraProc(Unit* /*pVictim*/, uint32 /*dama } // heal - CastCustomSpell(this,33110,&heal,NULL,NULL,true,NULL,NULL,caster_guid, spellProto); + CastCustomSpell(this, 33110, &heal, NULL, NULL, true, NULL, NULL, caster_guid, spellProto); return SPELL_AURA_PROC_OK; } @@ -3872,7 +3872,7 @@ SpellAuraProcResult Unit::HandleModPowerCostSchoolAuraProc(Unit* /*pVictim*/, ui SpellAuraProcResult Unit::HandleMechanicImmuneResistanceAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 /*procEx*/, uint32 /*cooldown*/) { // Compare mechanic - return !(procSpell==NULL || int32(procSpell->Mechanic) != triggeredByAura->GetModifier()->m_miscvalue) + return !(procSpell == NULL || int32(procSpell->Mechanic) != triggeredByAura->GetModifier()->m_miscvalue) ? SPELL_AURA_PROC_OK : SPELL_AURA_PROC_FAILED; } @@ -3910,7 +3910,7 @@ SpellAuraProcResult Unit::HandleAddFlatModifierAuraProc(Unit* pVictim, uint32 /* SpellAuraProcResult Unit::HandleAddPctModifierAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 procEx, uint32 /*cooldown*/) { SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; switch (spellInfo->SpellFamilyName) @@ -3955,16 +3955,16 @@ SpellAuraProcResult Unit::HandleAddPctModifierAuraProc(Unit* /*pVictim*/, uint32 SpellAuraProcResult Unit::HandleModDamagePercentDoneAuraProc(Unit* /*pVictim*/, uint32 /*damage*/, Aura* triggeredByAura, SpellEntry const* procSpell, uint32 /*procFlag*/, uint32 procEx, uint32 cooldown) { SpellEntry const* spellInfo = triggeredByAura->GetSpellProto(); - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; // Aspect of the Viper if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->SpellFamilyFlags & UI64LIT(0x4000000000000)) { uint32 maxmana = GetMaxPower(POWER_MANA); - int32 bp = int32(maxmana* GetAttackTime(RANGED_ATTACK)/1000.0f/100.0f); + int32 bp = int32(maxmana * GetAttackTime(RANGED_ATTACK) / 1000.0f / 100.0f); - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(34075)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(34075)) return SPELL_AURA_PROC_FAILED; CastCustomSpell(this, 34075, &bp, NULL, NULL, true, castItem, triggeredByAura); @@ -4009,7 +4009,7 @@ SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit* pVictim, uint32 damage, { SpellEntry const* dummySpell = triggeredByAura->GetSpellProto(); - Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId()==TYPEID_PLAYER + Item* castItem = triggeredByAura->GetCastItemGuid() && GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetItemByGuid(triggeredByAura->GetCastItemGuid()) : NULL; uint32 triggered_spell_id = 0; @@ -4043,7 +4043,7 @@ SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit* pVictim, uint32 damage, if (!triggerEntry) { - sLog.outError("Unit::HandleManaShieldAuraProc: Spell %u have nonexistent triggered spell %u",dummySpell->Id,triggered_spell_id); + sLog.outError("Unit::HandleManaShieldAuraProc: Spell %u have nonexistent triggered spell %u", dummySpell->Id, triggered_spell_id); return SPELL_AURA_PROC_FAILED; } @@ -4051,13 +4051,13 @@ SpellAuraProcResult Unit::HandleManaShieldAuraProc(Unit* pVictim, uint32 damage, if (!target || (target != this && !target->isAlive())) return SPELL_AURA_PROC_FAILED; - if (cooldown && GetTypeId()==TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) + if (cooldown && GetTypeId() == TYPEID_PLAYER && ((Player*)this)->HasSpellCooldown(triggered_spell_id)) return SPELL_AURA_PROC_FAILED; CastSpell(target, triggered_spell_id, true, castItem, triggeredByAura); - if (cooldown && GetTypeId()==TYPEID_PLAYER) - ((Player*)this)->AddSpellCooldown(triggered_spell_id,0,time(NULL) + cooldown); + if (cooldown && GetTypeId() == TYPEID_PLAYER) + ((Player*)this)->AddSpellCooldown(triggered_spell_id, 0, time(NULL) + cooldown); return SPELL_AURA_PROC_OK; } diff --git a/src/game/UnitEvents.h b/src/game/UnitEvents.h index 10649d459..67a3629fa 100644 --- a/src/game/UnitEvents.h +++ b/src/game/UnitEvents.h @@ -31,25 +31,25 @@ class HostileReference; enum UnitThreatEventType { // Player/Pet changed on/offline status - UEV_THREAT_REF_ONLINE_STATUS = 1<<0, + UEV_THREAT_REF_ONLINE_STATUS = 1 << 0, // Threat for Player/Pet changed - UEV_THREAT_REF_THREAT_CHANGE = 1<<1, + UEV_THREAT_REF_THREAT_CHANGE = 1 << 1, // Player/Pet will be removed from list (dead) [for internal use] - UEV_THREAT_REF_REMOVE_FROM_LIST = 1<<2, + UEV_THREAT_REF_REMOVE_FROM_LIST = 1 << 2, // Player/Pet entered/left water or some other place where it is/was not accessible for the creature - UEV_THREAT_REF_ASSECCIBLE_STATUS = 1<<3, + UEV_THREAT_REF_ASSECCIBLE_STATUS = 1 << 3, // Threat list is going to be sorted (if dirty flag is set) - UEV_THREAT_SORT_LIST = 1<<4, + UEV_THREAT_SORT_LIST = 1 << 4, // New target should be fetched, could tbe the current target as well - UEV_THREAT_SET_NEXT_TARGET = 1<<5, + UEV_THREAT_SET_NEXT_TARGET = 1 << 5, // A new victim (target) was set. Could be NULL - UEV_THREAT_VICTIM_CHANGED = 1<<6, + UEV_THREAT_VICTIM_CHANGED = 1 << 6, }; #define UEV_THREAT_REF_EVENT_MASK ( UEV_THREAT_REF_ONLINE_STATUS | UEV_THREAT_REF_THREAT_CHANGE | UEV_THREAT_REF_REMOVE_FROM_LIST | UEV_THREAT_REF_ASSECCIBLE_STATUS) diff --git a/src/game/UpdateData.cpp b/src/game/UpdateData.cpp index c009cb883..d4a24d9ce 100644 --- a/src/game/UpdateData.cpp +++ b/src/game/UpdateData.cpp @@ -32,7 +32,7 @@ UpdateData::UpdateData() : m_blockCount(0) void UpdateData::AddOutOfRangeGUID(GuidSet& guids) { - m_outOfRangeGUIDs.insert(guids.begin(),guids.end()); + m_outOfRangeGUIDs.insert(guids.begin(), guids.end()); } void UpdateData::AddOutOfRangeGUID(ObjectGuid const& guid) @@ -58,7 +58,7 @@ void UpdateData::Compress(void* dst, uint32* dst_size, void* src, int src_size) int z_res = deflateInit(&c_stream, sWorld.getConfig(CONFIG_UINT32_COMPRESSION)); if (z_res != Z_OK) { - sLog.outError("Can't compress update packet (zlib: deflateInit) Error code: %i (%s)",z_res,zError(z_res)); + sLog.outError("Can't compress update packet (zlib: deflateInit) Error code: %i (%s)", z_res, zError(z_res)); *dst_size = 0; return; } @@ -71,7 +71,7 @@ void UpdateData::Compress(void* dst, uint32* dst_size, void* src, int src_size) z_res = deflate(&c_stream, Z_NO_FLUSH); if (z_res != Z_OK) { - sLog.outError("Can't compress update packet (zlib: deflate) Error code: %i (%s)",z_res,zError(z_res)); + sLog.outError("Can't compress update packet (zlib: deflate) Error code: %i (%s)", z_res, zError(z_res)); *dst_size = 0; return; } @@ -86,7 +86,7 @@ void UpdateData::Compress(void* dst, uint32* dst_size, void* src, int src_size) z_res = deflate(&c_stream, Z_FINISH); if (z_res != Z_STREAM_END) { - sLog.outError("Can't compress update packet (zlib: deflate should report Z_STREAM_END instead %i (%s)",z_res,zError(z_res)); + sLog.outError("Can't compress update packet (zlib: deflate should report Z_STREAM_END instead %i (%s)", z_res, zError(z_res)); *dst_size = 0; return; } @@ -94,7 +94,7 @@ void UpdateData::Compress(void* dst, uint32* dst_size, void* src, int src_size) z_res = deflateEnd(&c_stream); if (z_res != Z_OK) { - sLog.outError("Can't compress update packet (zlib: deflateEnd) Error code: %i (%s)",z_res,zError(z_res)); + sLog.outError("Can't compress update packet (zlib: deflateEnd) Error code: %i (%s)", z_res, zError(z_res)); *dst_size = 0; return; } diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index 7e0ff7e08..b59bcfa54 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -45,7 +45,7 @@ WaypointBehavior::WaypointBehavior(const WaypointBehavior& b) spell = b.spell; model1 = b.model1; model2 = b.model2; - for (int i=0; i < MAX_WAYPOINT_TEXT; ++i) + for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) textid[i] = b.textid[i]; } @@ -128,7 +128,7 @@ void WaypointManager::Load() // the cleanup queries make sure the following is true MANGOS_ASSERT(point >= 1 && point <= path.size()); - WaypointNode& node = path[point-1]; + WaypointNode& node = path[point - 1]; node.x = fields[2].GetFloat(); node.y = fields[3].GetFloat(); @@ -181,7 +181,7 @@ void WaypointManager::Load() for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) { - be.textid[i] = fields[7+i].GetUInt32(); + be.textid[i] = fields[7 + i].GetUInt32(); if (be.textid[i]) { @@ -202,7 +202,7 @@ void WaypointManager::Load() if (be.emote) { if (!sEmotesStore.LookupEntry(be.emote)) - sLog.outErrorDb("Waypoint path %u (Point %u) are using emote %u, but emote does not exist.",id, point, be.emote); + sLog.outErrorDb("Waypoint path %u (Point %u) are using emote %u, but emote does not exist.", id, point, be.emote); } // save memory by not storing empty behaviors @@ -301,7 +301,7 @@ void WaypointManager::Load() // the cleanup queries make sure the following is true MANGOS_ASSERT(point >= 1 && point <= path.size()); - WaypointNode& node = path[point-1]; + WaypointNode& node = path[point - 1]; node.x = fields[2].GetFloat(); node.y = fields[3].GetFloat(); @@ -344,7 +344,7 @@ void WaypointManager::Load() for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i) { - be.textid[i] = fields[7+i].GetUInt32(); + be.textid[i] = fields[7 + i].GetUInt32(); if (be.textid[i]) { @@ -493,7 +493,7 @@ void WaypointManager::DeleteNode(uint32 id, uint32 point) WorldDatabase.PExecuteLog("UPDATE creature_movement SET point=point-1 WHERE id=%u AND point>%u", id, point); WaypointPathMap::iterator itr = m_pathMap.find(id); if (itr != m_pathMap.end() && point <= itr->second.size()) - itr->second.erase(itr->second.begin() + (point-1)); + itr->second.erase(itr->second.begin() + (point - 1)); } void WaypointManager::DeletePath(uint32 id) @@ -515,9 +515,9 @@ void WaypointManager::SetNodePosition(uint32 id, uint32 point, float x, float y, WaypointPathMap::iterator itr = m_pathMap.find(id); if (itr != m_pathMap.end() && point <= itr->second.size()) { - itr->second[point-1].x = x; - itr->second[point-1].y = y; - itr->second[point-1].z = z; + itr->second[point - 1].x = x; + itr->second[point - 1].y = y; + itr->second[point - 1].z = z; } } @@ -542,7 +542,7 @@ void WaypointManager::SetNodeText(uint32 id, uint32 point, const char* text_fiel WaypointPathMap::iterator itr = m_pathMap.find(id); if (itr != m_pathMap.end() && point <= itr->second.size()) { - WaypointNode& node = itr->second[point-1]; + WaypointNode& node = itr->second[point - 1]; if (!node.behavior) node.behavior = new WaypointBehavior(); // if(field == "text1") node.behavior->text[0] = text ? text : ""; @@ -595,7 +595,7 @@ void WaypointManager::CheckTextsExistance(std::set& ids) if (zeroCount) { // Correct textid but some zeros leading, so move it forward. - be->textid[j-zeroCount] = be->textid[j]; + be->textid[j - zeroCount] = be->textid[j]; be->textid[j] = 0; } } @@ -639,7 +639,7 @@ void WaypointManager::CheckTextsExistance(std::set& ids) if (zeroCount) { // Correct textid but some zeros leading, so move it forward. - be->textid[j-zeroCount] = be->textid[j]; + be->textid[j - zeroCount] = be->textid[j]; be->textid[j] = 0; } } diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index ad1387f2d..6b44ffacd 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -82,24 +82,24 @@ void WaypointMovementGenerator::LoadPath(Creature& creature) void WaypointMovementGenerator::Initialize(Creature& creature) { LoadPath(creature); - creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); } void WaypointMovementGenerator::Finalize(Creature& creature) { - creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.SetWalk(false); } void WaypointMovementGenerator::Interrupt(Creature& creature) { - creature.clearUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.clearUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); creature.SetWalk(false); } void WaypointMovementGenerator::Reset(Creature& creature) { - creature.addUnitState(UNIT_STAT_ROAMING|UNIT_STAT_ROAMING_MOVE); + creature.addUnitState(UNIT_STAT_ROAMING | UNIT_STAT_ROAMING_MOVE); StartMoveNow(creature); } @@ -173,7 +173,7 @@ void WaypointMovementGenerator::StartMove(Creature& creature) } if (m_isArrivalDone) - i_currentNode = (i_currentNode+1) % i_path->size(); + i_currentNode = (i_currentNode + 1) % i_path->size(); m_isArrivalDone = false; @@ -269,7 +269,7 @@ void FlightPathMovementGenerator::Finalize(Player& player) player.clearUnitState(UNIT_STAT_TAXI_FLIGHT); player.Unmount(); - player.RemoveFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); + player.RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); if (player.m_taxi.empty()) { @@ -295,13 +295,13 @@ void FlightPathMovementGenerator::Reset(Player& player) { player.getHostileRefManager().setOnlineOfflineState(false); player.addUnitState(UNIT_STAT_TAXI_FLIGHT); - player.SetFlag(UNIT_FIELD_FLAGS,UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); + player.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_MOVE | UNIT_FLAG_TAXI_FLIGHT); Movement::MoveSplineInit init(player); uint32 end = GetPathAtMapEnd(); for (uint32 i = GetCurrentNode(); i != end; ++i) { - G3D::Vector3 vertice((*i_path)[i].x,(*i_path)[i].y,(*i_path)[i].z); + G3D::Vector3 vertice((*i_path)[i].x, (*i_path)[i].y, (*i_path)[i].z); init.Path().push_back(vertice); } init.SetFirstPointId(GetCurrentNode()); @@ -318,7 +318,7 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff) bool departureEvent = true; do { - DoEventIfAny(player,(*i_path)[i_currentNode],departureEvent); + DoEventIfAny(player, (*i_path)[i_currentNode], departureEvent); if (pointId == i_currentNode) break; i_currentNode += (uint32)departureEvent; @@ -327,7 +327,7 @@ bool FlightPathMovementGenerator::Update(Player& player, const uint32& diff) while (true); } - return i_currentNode < (i_path->size()-1); + return i_currentNode < (i_path->size() - 1); } void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h index 6b3eac33b..c9c39e935 100644 --- a/src/game/WaypointMovementGenerator.h +++ b/src/game/WaypointMovementGenerator.h @@ -113,7 +113,7 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator */ class MANGOS_DLL_SPEC FlightPathMovementGenerator : public MovementGeneratorMedium< Player, FlightPathMovementGenerator >, - public PathMovementBase + public PathMovementBase { public: explicit FlightPathMovementGenerator(TaxiPathNodeList const& pathnodes, uint32 startNode = 0) diff --git a/src/game/Weather.cpp b/src/game/Weather.cpp index 4fc637866..54f68171d 100644 --- a/src/game/Weather.cpp +++ b/src/game/Weather.cpp @@ -35,7 +35,7 @@ Weather::Weather(uint32 zone, WeatherZoneChances const* weatherChances) : m_zone m_type = WEATHER_TYPE_FINE; m_grade = 0; - DETAIL_FILTER_LOG(LOG_FILTER_WEATHER, "WORLD: Starting weather system for zone %u (change every %u minutes).", m_zone, (m_timer.GetInterval() / (MINUTE*IN_MILLISECONDS))); + DETAIL_FILTER_LOG(LOG_FILTER_WEATHER, "WORLD: Starting weather system for zone %u (change every %u minutes).", m_zone, (m_timer.GetInterval() / (MINUTE * IN_MILLISECONDS))); } /// Launch a weather update @@ -86,7 +86,7 @@ bool Weather::ReGenerate() // season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html time_t gtime = sWorld.GetGameTime(); struct tm* ltime = localtime(>ime); - uint32 season = ((ltime->tm_yday - 78 + 365)/91)%4; + uint32 season = ((ltime->tm_yday - 78 + 365) / 91) % 4; static char const* seasonName[WEATHER_SEASONS] = { "spring", "summer", "fall", "winter" }; @@ -127,7 +127,7 @@ bool Weather::ReGenerate() if (m_grade > 0.6666667f) { // Severe change, but how severe? - uint32 rnd = urand(0,99); + uint32 rnd = urand(0, 99); if (rnd < 50) { m_grade -= 0.6666667f; @@ -141,8 +141,8 @@ bool Weather::ReGenerate() // At this point, only weather that isn't doing anything remains but that have weather data uint32 chance1 = m_weatherChances->data[season].rainChance; - uint32 chance2 = chance1+ m_weatherChances->data[season].snowChance; - uint32 chance3 = chance2+ m_weatherChances->data[season].stormChance; + uint32 chance2 = chance1 + m_weatherChances->data[season].snowChance; + uint32 chance3 = chance2 + m_weatherChances->data[season].stormChance; uint32 rnd = urand(0, 99); if (rnd <= chance1) @@ -184,7 +184,7 @@ bool Weather::ReGenerate() void Weather::SendWeatherUpdateToPlayer(Player* player) { - WorldPacket data(SMSG_WEATHER, (4+4+1)); + WorldPacket data(SMSG_WEATHER, (4 + 4 + 1)); data << uint32(GetWeatherState()) << (float)m_grade << uint8(0); player->GetSession()->SendPacket(&data); @@ -192,7 +192,7 @@ void Weather::SendWeatherUpdateToPlayer(Player* player) void Weather::SendFineWeatherUpdateToPlayer(Player* player) { - WorldPacket data(SMSG_WEATHER, (4+4+1)); + WorldPacket data(SMSG_WEATHER, (4 + 4 + 1)); data << (uint32)WEATHER_STATE_FINE << (float)0.0f << uint8(0); player->GetSession()->SendPacket(&data); @@ -213,7 +213,7 @@ bool Weather::UpdateWeather() WeatherState state = GetWeatherState(); - WorldPacket data(SMSG_WEATHER, (4+4+1)); + WorldPacket data(SMSG_WEATHER, (4 + 4 + 1)); data << uint32(state) << (float)m_grade << uint8(0); player->SendMessageToSet(&data, true); @@ -279,29 +279,29 @@ void Weather::SetWeather(WeatherType type, float grade) /// Get the sound number associated with the current weather WeatherState Weather::GetWeatherState() const { - if (m_grade<0.27f) + if (m_grade < 0.27f) return WEATHER_STATE_FINE; switch (m_type) { case WEATHER_TYPE_RAIN: - if (m_grade<0.40f) + if (m_grade < 0.40f) return WEATHER_STATE_LIGHT_RAIN; - else if (m_grade<0.70f) + else if (m_grade < 0.70f) return WEATHER_STATE_MEDIUM_RAIN; else return WEATHER_STATE_HEAVY_RAIN; case WEATHER_TYPE_SNOW: - if (m_grade<0.40f) + if (m_grade < 0.40f) return WEATHER_STATE_LIGHT_SNOW; - else if (m_grade<0.70f) + else if (m_grade < 0.70f) return WEATHER_STATE_MEDIUM_SNOW; else return WEATHER_STATE_HEAVY_SNOW; case WEATHER_TYPE_STORM: - if (m_grade<0.40f) + if (m_grade < 0.40f) return WEATHER_STATE_LIGHT_SANDSTORM; - else if (m_grade<0.70f) + else if (m_grade < 0.70f) return WEATHER_STATE_MEDIUM_SANDSTORM; else return WEATHER_STATE_HEAVY_SANDSTORM; diff --git a/src/game/World.cpp b/src/game/World.cpp index 59f9a9fb8..c20352ff5 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -90,8 +90,8 @@ World::World() m_allowMovement = true; m_ShutdownMask = 0; m_ShutdownTimer = 0; - m_gameTime=time(NULL); - m_startTime=m_gameTime; + m_gameTime = time(NULL); + m_startTime = m_gameTime; m_maxActiveSessionCount = 0; m_maxQueuedSessionCount = 0; m_NextDailyQuestReset = 0; @@ -321,7 +321,7 @@ bool World::RemoveQueuedSession(WorldSession* sess) for (; iter != m_QueuedSessions.end(); ++iter, ++position) { - if (*iter==sess) + if (*iter == sess) { sess->SetInQueue(false); iter = m_QueuedSessions.erase(iter); @@ -400,7 +400,7 @@ Weather* World::AddWeather(uint32 zone_id) if (!weatherChances) return NULL; - Weather* w = new Weather(zone_id,weatherChances); + Weather* w = new Weather(zone_id, weatherChances); m_weathers[w->GetZone()] = w; w->ReGenerate(); w->UpdateWeather(); @@ -414,7 +414,7 @@ void World::LoadConfigSettings(bool reload) { if (!sConfig.Reload()) { - sLog.outError("World settings reload fail: can't read settings from %s.",sConfig.GetFilename().c_str()); + sLog.outError("World settings reload fail: can't read settings from %s.", sConfig.GetFilename().c_str()); return; } } @@ -452,7 +452,7 @@ void World::LoadConfigSettings(bool reload) setConfig(CONFIG_FLOAT_RATE_POWER_RAGE_INCOME, "Rate.Rage.Income", 1.0f); setConfigPos(CONFIG_FLOAT_RATE_POWER_RAGE_LOSS, "Rate.Rage.Loss", 1.0f); setConfig(CONFIG_FLOAT_RATE_POWER_RUNICPOWER_INCOME, "Rate.RunicPower.Income", 1.0f); - setConfigPos(CONFIG_FLOAT_RATE_POWER_RUNICPOWER_LOSS,"Rate.RunicPower.Loss", 1.0f); + setConfigPos(CONFIG_FLOAT_RATE_POWER_RUNICPOWER_LOSS, "Rate.RunicPower.Loss", 1.0f); setConfig(CONFIG_FLOAT_RATE_POWER_FOCUS, "Rate.Focus", 1.0f); setConfig(CONFIG_FLOAT_RATE_POWER_ENERGY, "Rate.Energy", 1.0f); setConfigPos(CONFIG_FLOAT_RATE_SKILL_DISCOVERY, "Rate.Skill.Discovery", 1.0f); @@ -495,7 +495,7 @@ void World::LoadConfigSettings(bool reload) setConfig(CONFIG_FLOAT_RATE_AUCTION_DEPOSIT, "Rate.Auction.Deposit", 1.0f); setConfig(CONFIG_FLOAT_RATE_AUCTION_CUT, "Rate.Auction.Cut", 1.0f); setConfig(CONFIG_UINT32_AUCTION_DEPOSIT_MIN, "Auction.Deposit.Min", SILVER); - setConfig(CONFIG_FLOAT_RATE_HONOR, "Rate.Honor",1.0f); + setConfig(CONFIG_FLOAT_RATE_HONOR, "Rate.Honor", 1.0f); setConfigPos(CONFIG_FLOAT_RATE_MINING_AMOUNT, "Rate.Mining.Amount", 1.0f); setConfigPos(CONFIG_FLOAT_RATE_MINING_NEXT, "Rate.Mining.Next", 1.0f); setConfigPos(CONFIG_FLOAT_RATE_INSTANCE_RESET_TIME, "Rate.InstanceResetTime", 1.0f); @@ -639,7 +639,7 @@ void World::LoadConfigSettings(bool reload) setConfig(CONFIG_UINT32_UPTIME_UPDATE, "UpdateUptimeInterval", 10); if (reload) { - m_timers[WUPDATE_UPTIME].SetInterval(getConfig(CONFIG_UINT32_UPTIME_UPDATE)*MINUTE*IN_MILLISECONDS); + m_timers[WUPDATE_UPTIME].SetInterval(getConfig(CONFIG_UINT32_UPTIME_UPDATE)*MINUTE * IN_MILLISECONDS); m_timers[WUPDATE_UPTIME].Reset(); } @@ -782,64 +782,64 @@ void World::LoadConfigSettings(bool reload) setConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT, "PetUnsummonAtMount", true); m_relocation_ai_notify_delay = sConfig.GetIntDefault("Visibility.AIRelocationNotifyDelay", 1000u); - m_relocation_lower_limit_sq = pow(sConfig.GetFloatDefault("Visibility.RelocationLowerLimit",10), 2); + m_relocation_lower_limit_sq = pow(sConfig.GetFloatDefault("Visibility.RelocationLowerLimit", 10), 2); m_VisibleUnitGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Unit", 1); if (m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { - sLog.outError("Visibility.Distance.Grey.Unit can't be greater %f",MAX_VISIBILITY_DISTANCE); + sLog.outError("Visibility.Distance.Grey.Unit can't be greater %f", MAX_VISIBILITY_DISTANCE); m_VisibleUnitGreyDistance = MAX_VISIBILITY_DISTANCE; } m_VisibleObjectGreyDistance = sConfig.GetFloatDefault("Visibility.Distance.Grey.Object", 10); if (m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { - sLog.outError("Visibility.Distance.Grey.Object can't be greater %f",MAX_VISIBILITY_DISTANCE); + sLog.outError("Visibility.Distance.Grey.Object can't be greater %f", MAX_VISIBILITY_DISTANCE); m_VisibleObjectGreyDistance = MAX_VISIBILITY_DISTANCE; } //visibility on continents m_MaxVisibleDistanceOnContinents = sConfig.GetFloatDefault("Visibility.Distance.Continents", DEFAULT_VISIBILITY_DISTANCE); - if (m_MaxVisibleDistanceOnContinents < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceOnContinents < 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) { - sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceOnContinents = 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); + sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceOnContinents = 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); } else if (m_MaxVisibleDistanceOnContinents + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { - sLog.outError("Visibility.Distance.Continents can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); + sLog.outError("Visibility.Distance.Continents can't be greater %f", MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceOnContinents = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; } //visibility in instances m_MaxVisibleDistanceInInstances = sConfig.GetFloatDefault("Visibility.Distance.Instances", DEFAULT_VISIBILITY_INSTANCE); - if (m_MaxVisibleDistanceInInstances < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceInInstances < 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) { - sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f",45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceInInstances = 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); + sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f", 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceInInstances = 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); } else if (m_MaxVisibleDistanceInInstances + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { - sLog.outError("Visibility.Distance.Instances can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); + sLog.outError("Visibility.Distance.Instances can't be greater %f", MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceInInstances = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; } //visibility in BG/Arenas m_MaxVisibleDistanceInBGArenas = sConfig.GetFloatDefault("Visibility.Distance.BGArenas", DEFAULT_VISIBILITY_BGARENAS); - if (m_MaxVisibleDistanceInBGArenas < 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) + if (m_MaxVisibleDistanceInBGArenas < 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)) { - sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f",45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); - m_MaxVisibleDistanceInBGArenas = 45*getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); + sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f", 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO)); + m_MaxVisibleDistanceInBGArenas = 45 * getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); } else if (m_MaxVisibleDistanceInBGArenas + m_VisibleUnitGreyDistance > MAX_VISIBILITY_DISTANCE) { - sLog.outError("Visibility.Distance.BGArenas can't be greater %f",MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); + sLog.outError("Visibility.Distance.BGArenas can't be greater %f", MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance); m_MaxVisibleDistanceInBGArenas = MAX_VISIBILITY_DISTANCE - m_VisibleUnitGreyDistance; } m_MaxVisibleDistanceInFlight = sConfig.GetFloatDefault("Visibility.Distance.InFlight", DEFAULT_VISIBILITY_DISTANCE); if (m_MaxVisibleDistanceInFlight + m_VisibleObjectGreyDistance > MAX_VISIBILITY_DISTANCE) { - sLog.outError("Visibility.Distance.InFlight can't be greater %f",MAX_VISIBILITY_DISTANCE-m_VisibleObjectGreyDistance); + sLog.outError("Visibility.Distance.InFlight can't be greater %f", MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance); m_MaxVisibleDistanceInFlight = MAX_VISIBILITY_DISTANCE - m_VisibleObjectGreyDistance; } @@ -862,7 +862,7 @@ void World::LoadConfigSettings(bool reload) if (dataPath.empty()) dataPath = "./"; // normalize dir path to path/ or path\ form - else if (dataPath.at(dataPath.length()-1) != '/' && dataPath.at(dataPath.length()-1) != '\\') + else if (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\') dataPath.append("/"); if (reload) @@ -889,7 +889,7 @@ void World::LoadConfigSettings(bool reload) VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str()); sLog.outString("WORLD: VMap support included. LineOfSight:%i, getHeight:%i, indoorCheck:%i", enableLOS, enableHeight, getConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK) ? 1 : 0); - sLog.outString("WORLD: VMap data directory is: %svmaps",m_dataPath.c_str()); + sLog.outString("WORLD: VMap data directory is: %svmaps", m_dataPath.c_str()); setConfig(CONFIG_BOOL_MMAP_ENABLED, "mmap.enabled", true); std::string ignoreMapIds = sConfig.GetStringDefault("mmap.ignoreMapIds", ""); @@ -913,17 +913,17 @@ void World::SetInitialWorldSettings() LoadConfigSettings(); ///- Check the existence of the map files for all races start areas. - if (!MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f) || - !MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) || - !MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f) || - !MapManager::ExistMapAndVMap(1,-618.518f,-4251.67f) || + if (!MapManager::ExistMapAndVMap(0, -6240.32f, 331.033f) || + !MapManager::ExistMapAndVMap(0, -8949.95f, -132.493f) || + !MapManager::ExistMapAndVMap(0, -8949.95f, -132.493f) || + !MapManager::ExistMapAndVMap(1, -618.518f, -4251.67f) || !MapManager::ExistMapAndVMap(0, 1676.35f, 1677.45f) || !MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f) || - !MapManager::ExistMapAndVMap(1,-2917.58f,-257.98f) || + !MapManager::ExistMapAndVMap(1, -2917.58f, -257.98f) || (m_configUint32Values[CONFIG_UINT32_EXPANSION] && - (!MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f)))) + (!MapManager::ExistMapAndVMap(530, 10349.6f, -6357.29f) || !MapManager::ExistMapAndVMap(530, -3961.64f, -13931.2f)))) { - sLog.outError("Correct *.map files not found in path '%smaps' or *.vmtree/*.vmtile files in '%svmaps'. Please place *.map and vmap files in appropriate directories or correct the DataDir value in the mangosd.conf file.",m_dataPath.c_str(),m_dataPath.c_str()); + sLog.outError("Correct *.map files not found in path '%smaps' or *.vmtree/*.vmtile files in '%svmaps'. Please place *.map and vmap files in appropriate directories or correct the DataDir value in the mangosd.conf file.", m_dataPath.c_str(), m_dataPath.c_str()); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -946,7 +946,7 @@ void World::SetInitialWorldSettings() LoginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%u'", server_type, realm_zone, realmID); ///- Remove the bones (they should not exist in DB though) and old corpses after a restart - CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0' OR time < (UNIX_TIMESTAMP()-'%u')", 3*DAY); + CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0' OR time < (UNIX_TIMESTAMP()-'%u')", 3 * DAY); ///- Load the DBC files sLog.outString("Initialize data stores..."); @@ -1326,33 +1326,33 @@ void World::SetInitialWorldSettings() ///- Initialize game time and timers sLog.outString("DEBUG:: Initialize game time and timers"); m_gameTime = time(NULL); - m_startTime=m_gameTime; + m_startTime = m_gameTime; tm local; time_t curr; time(&curr); - local=*(localtime(&curr)); // dereference and assign + local = *(localtime(&curr)); // dereference and assign char isoDate[128]; sprintf(isoDate, "%04d-%02d-%02d %02d:%02d:%02d", - local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); + local.tm_year + 1900, local.tm_mon + 1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec); LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime) VALUES('%u', " UI64FMTD ", '%s', 0)", realmID, uint64(m_startTime), isoDate); - m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILLISECONDS); - m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS); - m_timers[WUPDATE_UPTIME].SetInterval(getConfig(CONFIG_UINT32_UPTIME_UPDATE)*MINUTE*IN_MILLISECONDS); + m_timers[WUPDATE_WEATHERS].SetInterval(1 * IN_MILLISECONDS); + m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE * IN_MILLISECONDS); + m_timers[WUPDATE_UPTIME].SetInterval(getConfig(CONFIG_UINT32_UPTIME_UPDATE)*MINUTE * IN_MILLISECONDS); //Update "uptime" table based on configuration entry in minutes. - m_timers[WUPDATE_CORPSES].SetInterval(20*MINUTE*IN_MILLISECONDS); - m_timers[WUPDATE_DELETECHARS].SetInterval(DAY*IN_MILLISECONDS); // check for chars to delete every day + m_timers[WUPDATE_CORPSES].SetInterval(20 * MINUTE * IN_MILLISECONDS); + m_timers[WUPDATE_DELETECHARS].SetInterval(DAY * IN_MILLISECONDS); // check for chars to delete every day // for AhBot - m_timers[WUPDATE_AHBOT].SetInterval(20*IN_MILLISECONDS); // every 20 sec + m_timers[WUPDATE_AHBOT].SetInterval(20 * IN_MILLISECONDS); // every 20 sec //to set mailtimer to return mails every day between 4 and 5 am //mailtimer is increased when updating auctions //one second is 1000 -(tested on win system) - mail_timer = uint32((((localtime(&m_gameTime)->tm_hour + 20) % 24)* HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval()); + mail_timer = uint32((((localtime(&m_gameTime)->tm_hour + 20) % 24) * HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval()); //1440 mail_timer_expires = uint32((DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval())); DEBUG_LOG("Mail timer set to: %u, mail return is called every %u minutes", mail_timer, mail_timer_expires); @@ -1408,7 +1408,7 @@ void World::DetectDBCLang() if (m_lang_confid != 255 && m_lang_confid >= MAX_LOCALE) { - sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)",MAX_LOCALE); + sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)", MAX_LOCALE); m_lang_confid = LOCALE_enUS; } @@ -1418,7 +1418,7 @@ void World::DetectDBCLang() std::string availableLocalsStr; uint32 default_locale = MAX_LOCALE; - for (int i = MAX_LOCALE-1; i >= 0; --i) + for (int i = MAX_LOCALE - 1; i >= 0; --i) { if (strlen(race->name[i]) > 0) // check by race names { @@ -1444,7 +1444,7 @@ void World::DetectDBCLang() m_defaultDbcLocale = LocaleConstant(default_locale); - sLog.outString("Using %s DBC Locale as default. All available DBC locales: %s",localeNames[m_defaultDbcLocale],availableLocalsStr.empty() ? "" : availableLocalsStr.c_str()); + sLog.outString("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[m_defaultDbcLocale], availableLocalsStr.empty() ? "" : availableLocalsStr.c_str()); sLog.outString(); } @@ -1454,7 +1454,7 @@ void World::Update(uint32 diff) ///- Update the different timers for (int i = 0; i < WUPDATE_COUNT; ++i) { - if (m_timers[i].GetCurrent()>=0) + if (m_timers[i].GetCurrent() >= 0) m_timers[i].Update(diff); else m_timers[i].SetCurrent(0); @@ -1606,25 +1606,25 @@ namespace MaNGOS explicit WorldWorldTextBuilder(int32 textId, va_list* args = NULL) : i_textId(textId), i_args(args) {} void operator()(WorldPacketList& data_list, int32 loc_idx) { - char const* text = sObjectMgr.GetMangosString(i_textId,loc_idx); + char const* text = sObjectMgr.GetMangosString(i_textId, loc_idx); if (i_args) { // we need copy va_list before use or original va_list will corrupted va_list ap; - va_copy(ap,*i_args); + va_copy(ap, *i_args); char str [2048]; - vsnprintf(str,2048,text, ap); + vsnprintf(str, 2048, text, ap); va_end(ap); - do_helper(data_list,&str[0]); + do_helper(data_list, &str[0]); } else - do_helper(data_list,(char*)text); + do_helper(data_list, (char*)text); } private: - char* lineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; } + char* lineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = NULL; return start; } void do_helper(WorldPacketList& data_list, char* text) { char* pos = text; @@ -1741,7 +1741,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_ { LoginDatabase.escape_string(nameOrIP); LoginDatabase.escape_string(reason); - std::string safe_author=author; + std::string safe_author = author; LoginDatabase.escape_string(safe_author); QueryResult* resultAccounts = NULL; //used for kicking @@ -1751,16 +1751,16 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_ { case BAN_IP: //No SQL injection as strings are escaped - resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str()); - LoginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str()); + resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'", nameOrIP.c_str()); + LoginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')", nameOrIP.c_str(), duration_secs, safe_author.c_str(), reason.c_str()); break; case BAN_ACCOUNT: //No SQL injection as string is escaped - resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str()); + resultAccounts = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", nameOrIP.c_str()); break; case BAN_CHARACTER: //No SQL injection as string is escaped - resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str()); + resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", nameOrIP.c_str()); break; default: return BAN_SYNTAX_ERROR; @@ -1768,7 +1768,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_ if (!resultAccounts) { - if (mode==BAN_IP) + if (mode == BAN_IP) return BAN_SUCCESS; // ip correctly banned but nobody affected (yet) else return BAN_NOTFOUND; // Nobody to ban @@ -1780,11 +1780,11 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_ Field* fieldsAccount = resultAccounts->Fetch(); uint32 account = fieldsAccount->GetUInt32(); - if (mode!=BAN_IP) + if (mode != BAN_IP) { //No SQL injection as strings are escaped LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')", - account,duration_secs,safe_author.c_str(),reason.c_str()); + account, duration_secs, safe_author.c_str(), reason.c_str()); } if (WorldSession* sess = FindSession(account)) @@ -1803,7 +1803,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) if (mode == BAN_IP) { LoginDatabase.escape_string(nameOrIP); - LoginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str()); + LoginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'", nameOrIP.c_str()); } else { @@ -1817,7 +1817,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP) return false; //NO SQL injection as account is uint32 - LoginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'",account); + LoginDatabase.PExecute("UPDATE account_banned SET active = '0' WHERE id = '%u'", account); } return true; } @@ -1836,7 +1836,7 @@ void World::_UpdateGameTime() ///- ... and it is overdue, stop the world (set m_stopEvent) if (m_ShutdownTimer <= elapsed) { - if (!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + if (!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0) m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; // minimum timer value to wait idle state @@ -1862,9 +1862,9 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode) m_ExitCode = exitcode; ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions) - if (time==0) + if (time == 0) { - if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount()==0) + if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0) m_stopEvent = true; // exist code already set else m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick @@ -1896,8 +1896,8 @@ void World::ShutdownMsg(bool show, Player* player) ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_TIME : SERVER_MSG_SHUTDOWN_TIME; - SendServerMessage(msgid,str.c_str(),player); - DEBUG_LOG("Server is %s in %s",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutting down"),str.c_str()); + SendServerMessage(msgid, str.c_str(), player); + DEBUG_LOG("Server is %s in %s", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutting down"), str.c_str()); } } @@ -1915,7 +1915,7 @@ void World::ShutdownCancel() m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value SendServerMessage(msgid); - DEBUG_LOG("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutdown")); + DEBUG_LOG("Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutdown")); } /// Send a server message to the user(s) @@ -2174,8 +2174,8 @@ void World::SetPlayerLimit(int32 limit, bool needUpdate) void World::UpdateMaxSessionCounters() { - m_maxActiveSessionCount = std::max(m_maxActiveSessionCount,uint32(m_sessions.size()-m_QueuedSessions.size())); - m_maxQueuedSessionCount = std::max(m_maxQueuedSessionCount,uint32(m_QueuedSessions.size())); + m_maxActiveSessionCount = std::max(m_maxActiveSessionCount, uint32(m_sessions.size() - m_QueuedSessions.size())); + m_maxQueuedSessionCount = std::max(m_maxQueuedSessionCount, uint32(m_QueuedSessions.size())); } void World::LoadDBVersion() @@ -2202,7 +2202,7 @@ void World::LoadDBVersion() void World::setConfig(eConfigUInt32Values index, char const* fieldname, uint32 defvalue) { - setConfig(index, sConfig.GetIntDefault(fieldname,defvalue)); + setConfig(index, sConfig.GetIntDefault(fieldname, defvalue)); if (int32(getConfig(index)) < 0) { sLog.outError("%s (%i) can't be negative. Using %u instead.", fieldname, int32(getConfig(index)), defvalue); @@ -2212,17 +2212,17 @@ void World::setConfig(eConfigUInt32Values index, char const* fieldname, uint32 d void World::setConfig(eConfigInt32Values index, char const* fieldname, int32 defvalue) { - setConfig(index, sConfig.GetIntDefault(fieldname,defvalue)); + setConfig(index, sConfig.GetIntDefault(fieldname, defvalue)); } void World::setConfig(eConfigFloatValues index, char const* fieldname, float defvalue) { - setConfig(index, sConfig.GetFloatDefault(fieldname,defvalue)); + setConfig(index, sConfig.GetFloatDefault(fieldname, defvalue)); } void World::setConfig(eConfigBoolValues index, char const* fieldname, bool defvalue) { - setConfig(index, sConfig.GetBoolDefault(fieldname,defvalue)); + setConfig(index, sConfig.GetBoolDefault(fieldname, defvalue)); } void World::setConfigPos(eConfigFloatValues index, char const* fieldname, float defvalue) diff --git a/src/game/World.h b/src/game/World.h index e82070dbb..c46aba62c 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -423,7 +423,7 @@ struct CliCommandHolder CliCommandHolder(uint32 accountId, AccountTypes cliAccessLevel, void* callbackArg, const char* command, Print* zprint, CommandFinished* commandFinished) : m_cliAccountId(accountId), m_cliAccessLevel(cliAccessLevel), m_callbackArg(callbackArg), m_print(zprint), m_commandFinished(commandFinished) { - size_t len = strlen(command)+1; + size_t len = strlen(command) + 1; m_command = new char[len]; memcpy(m_command, command, len); } @@ -500,7 +500,7 @@ class World uint16 GetConfigMaxSkillValue() const { uint32 lvl = getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); - return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl*5; + return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl * 5; } void SetInitialWorldSettings(); @@ -527,22 +527,22 @@ class World void UpdateSessions(uint32 diff); /// Get a server configuration element (see #eConfigFloatValues) - void setConfig(eConfigFloatValues index,float value) { m_configFloatValues[index]=value; } + void setConfig(eConfigFloatValues index, float value) { m_configFloatValues[index] = value; } /// Get a server configuration element (see #eConfigFloatValues) float getConfig(eConfigFloatValues rate) const { return m_configFloatValues[rate]; } /// Set a server configuration element (see #eConfigUInt32Values) - void setConfig(eConfigUInt32Values index, uint32 value) { m_configUint32Values[index]=value; } + void setConfig(eConfigUInt32Values index, uint32 value) { m_configUint32Values[index] = value; } /// Get a server configuration element (see #eConfigUInt32Values) uint32 getConfig(eConfigUInt32Values index) const { return m_configUint32Values[index]; } /// Set a server configuration element (see #eConfigInt32Values) - void setConfig(eConfigInt32Values index, int32 value) { m_configInt32Values[index]=value; } + void setConfig(eConfigInt32Values index, int32 value) { m_configInt32Values[index] = value; } /// Get a server configuration element (see #eConfigInt32Values) int32 getConfig(eConfigInt32Values index) const { return m_configInt32Values[index]; } /// Set a server configuration element (see #eConfigBoolValues) - void setConfig(eConfigBoolValues index, bool value) { m_configBoolValues[index]=value; } + void setConfig(eConfigBoolValues index, bool value) { m_configBoolValues[index] = value; } /// Get a server configuration element (see #eConfigBoolValues) bool getConfig(eConfigBoolValues index) const { return m_configBoolValues[index]; } @@ -655,7 +655,7 @@ class World static uint32 m_relocation_ai_notify_delay; // CLI command holder to be thread safe - ACE_Based::LockedQueue cliCmdQueue; + ACE_Based::LockedQueue cliCmdQueue; // next daily quests reset time time_t m_NextDailyQuestReset; diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 3bf55ea99..6a6e02f37 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -82,7 +82,7 @@ bool WorldSessionFilter::Process(WorldPacket* packet) /// WorldSession constructor WorldSession::WorldSession(uint32 id, WorldSocket* sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale) : - m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0), + m_muteTime(mute_time), _player(NULL), m_Socket(sock), _security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0), m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false), m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)), m_latency(0), m_tutorialState(TUTORIALDATA_UNCHANGED) @@ -118,7 +118,7 @@ WorldSession::~WorldSession() void WorldSession::SizeError(WorldPacket const& packet, uint32 size) const { sLog.outError("Client (account %u) send packet %s (%u) with size " SIZEFMTD " but expected %u (attempt crash server?), skipped", - GetAccountId(),LookupOpcodeName(packet.GetOpcode()),packet.GetOpcode(),packet.size(),size); + GetAccountId(), LookupOpcodeName(packet.GetOpcode()), packet.GetOpcode(), packet.size(), size); } /// Get the player name @@ -149,18 +149,18 @@ void WorldSession::SendPacket(WorldPacket const* packet) if ((cur_time - lastTime) < 60) { - sendPacketCount+=1; - sendPacketBytes+=packet->size(); + sendPacketCount += 1; + sendPacketBytes += packet->size(); - sendLastPacketCount+=1; - sendLastPacketBytes+=packet->size(); + sendLastPacketCount += 1; + sendLastPacketBytes += packet->size(); } else { uint64 minTime = uint64(cur_time - lastTime); uint64 fullTime = uint64(lastTime - firstTime); - DETAIL_LOG("Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u",sendPacketCount,sendPacketBytes,float(sendPacketCount)/fullTime,float(sendPacketBytes)/fullTime,uint32(fullTime)); - DETAIL_LOG("Send last min packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f",sendLastPacketCount,sendLastPacketBytes,float(sendLastPacketCount)/minTime,float(sendLastPacketBytes)/minTime); + DETAIL_LOG("Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u", sendPacketCount, sendPacketBytes, float(sendPacketCount) / fullTime, float(sendPacketBytes) / fullTime, uint32(fullTime)); + DETAIL_LOG("Send last min packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f", sendLastPacketCount, sendLastPacketBytes, float(sendLastPacketCount) / minTime, float(sendLastPacketBytes) / minTime); lastTime = cur_time; sendLastPacketCount = 1; @@ -194,7 +194,7 @@ void WorldSession::LogUnprocessedTail(WorldPacket* packet) sLog.outError("SESSION: opcode %s (0x%.4X) have unprocessed tail data (read stop at " SIZEFMTD " from " SIZEFMTD ")", LookupOpcodeName(packet->GetOpcode()), packet->GetOpcode(), - packet->rpos(),packet->wpos()); + packet->rpos(), packet->wpos()); } /// Update the WorldSession (triggered by World update) @@ -334,7 +334,7 @@ void WorldSession::LogoutPlayer(bool Save) if (_player) { - sLog.outChar("Account: %d (IP: %s) Logout Character:[%s] (guid: %u)", GetAccountId(), GetRemoteAddress().c_str(), _player->GetName() ,_player->GetGUIDLow()); + 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); @@ -360,10 +360,10 @@ void WorldSession::LogoutPlayer(bool Save) Unit* owner = (*itr)->GetOwner(); // including player controlled case if (owner) { - if (owner->GetTypeId()==TYPEID_PLAYER) + if (owner->GetTypeId() == TYPEID_PLAYER) aset.insert((Player*)owner); } - else if ((*itr)->GetTypeId()==TYPEID_PLAYER) + else if ((*itr)->GetTypeId() == TYPEID_PLAYER) aset.insert((Player*)(*itr)); } @@ -374,13 +374,13 @@ void WorldSession::LogoutPlayer(bool Save) // give honor to all attackers from set like group case for (std::set::const_iterator itr = aset.begin(); itr != aset.end(); ++itr) - (*itr)->RewardHonor(_player,aset.size()); + (*itr)->RewardHonor(_player, aset.size()); // give bg rewards and update counters like kill by first from attackers // 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)) { @@ -408,7 +408,7 @@ void WorldSession::LogoutPlayer(bool Save) while (_player->IsBeingTeleportedFar()) HandleMoveWorldportAckOpcode(); - for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) { if (BattleGroundQueueTypeId bgQueueTypeId = _player->GetBattleGroundQueueTypeId(i)) { @@ -521,14 +521,14 @@ void WorldSession::SendAreaTriggerMessage(const char* Text, ...) vsnprintf(szStr, 1024, Text, ap); va_end(ap); - uint32 length = strlen(szStr)+1; - WorldPacket data(SMSG_AREA_TRIGGER_MESSAGE, 4+length); + uint32 length = strlen(szStr) + 1; + WorldPacket data(SMSG_AREA_TRIGGER_MESSAGE, 4 + length); data << length; data << szStr; SendPacket(&data); } -void WorldSession::SendNotification(const char* format,...) +void WorldSession::SendNotification(const char* format, ...) { if (format) { @@ -539,13 +539,13 @@ void WorldSession::SendNotification(const char* format,...) vsnprintf(szStr, 1024, format, ap); va_end(ap); - WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr)+1)); + WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr) + 1)); data << szStr; SendPacket(&data); } } -void WorldSession::SendNotification(int32 string_id,...) +void WorldSession::SendNotification(int32 string_id, ...) { char const* format = GetMangosString(string_id); if (format) @@ -557,7 +557,7 @@ void WorldSession::SendNotification(int32 string_id,...) vsnprintf(szStr, 1024, format, ap); va_end(ap); - WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr)+1)); + WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr) + 1)); data << szStr; SendPacket(&data); } @@ -572,7 +572,7 @@ void WorldSession::SendSetPhaseShift(uint32 PhaseShift) const char* WorldSession::GetMangosString(int32 entry) const { - return sObjectMgr.GetMangosString(entry,GetSessionDbLocaleIndex()); + return sObjectMgr.GetMangosString(entry, GetSessionDbLocaleIndex()); } void WorldSession::Handle_NULL(WorldPacket& recvPacket) @@ -613,7 +613,7 @@ void WorldSession::SendAuthWaitQue(uint32 position) } else { - WorldPacket packet(SMSG_AUTH_RESPONSE, 1+4+1); + WorldPacket packet(SMSG_AUTH_RESPONSE, 1 + 4 + 1); packet << uint8(AUTH_WAIT_QUEUE); packet << uint32(position); packet << uint8(0); // unk 3.3.0 @@ -650,7 +650,7 @@ void WorldSession::LoadAccountData(QueryResult* result, uint32 mask) continue; } - if ((mask & (1 << type))==0) + if ((mask & (1 << type)) == 0) { sLog.outError("Table `%s` have non appropriate for table account data type (%u), ignore.", mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type); @@ -711,7 +711,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin void WorldSession::SendAccountDataTimes(uint32 mask) { - WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4); // changed in WotLK + WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4 + 1 + 4 + 8 * 4); // changed in WotLK data << uint32(time(NULL)); // unix time of something data << uint8(1); data << uint32(mask); // type mask @@ -750,7 +750,7 @@ void WorldSession::LoadTutorialsData() void WorldSession::SendTutorialsData() { - WorldPacket data(SMSG_TUTORIAL_FLAGS, 4*8); + WorldPacket data(SMSG_TUTORIAL_FLAGS, 4 * 8); for (uint32 i = 0; i < 8; ++i) data << m_Tutorials[i]; SendPacket(&data); @@ -827,7 +827,7 @@ void WorldSession::ReadAddonsInfo(WorldPacket& data) uint32 crc, unk1; // check next addon data format correctness - if (addonInfo.rpos()+1 > addonInfo.size()) + if (addonInfo.rpos() + 1 > addonInfo.size()) return; addonInfo >> addonName; diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 443837560..7b9cf9691 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -241,14 +241,14 @@ class MANGOS_DLL_SPEC WorldSession void SendAddonsInfo(); void SendPacket(WorldPacket const* packet); - void SendNotification(const char* format,...) ATTR_PRINTF(2,3); - void SendNotification(int32 string_id,...); + void SendNotification(const char* format, ...) ATTR_PRINTF(2, 3); + void SendNotification(int32 string_id, ...); void SendPetNameInvalid(uint32 error, const std::string& name, DeclinedName* declinedName); void SendLfgSearchResults(LfgType type, uint32 entry); void SendLfgJoinResult(LfgJoinResult result); void SendLfgUpdate(bool isGroup, LfgUpdateType updateType, uint32 id); void SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res); - void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2,3); + void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3); void SendSetPhaseShift(uint32 phaseShift); void SendQueryTimeResponse(); void SendRedirectClient(std::string& ip, uint16 port); diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 4e38ba938..4649cc9e0 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -56,23 +56,23 @@ struct ServerPktHeader */ ServerPktHeader(uint32 size, uint16 cmd) : size(size) { - uint8 headerIndex=0; + uint8 headerIndex = 0; if (isLargePacket()) { DEBUG_LOG("initializing large server to client packet. Size: %u, cmd: %u", size, cmd); - header[headerIndex++] = 0x80|(0xFF &(size>>16)); + header[headerIndex++] = 0x80 | (0xFF & (size >> 16)); } - header[headerIndex++] = 0xFF &(size>>8); - header[headerIndex++] = 0xFF &size; + header[headerIndex++] = 0xFF & (size >> 8); + header[headerIndex++] = 0xFF & size; header[headerIndex++] = 0xFF & cmd; - header[headerIndex++] = 0xFF & (cmd>>8); + header[headerIndex++] = 0xFF & (cmd >> 8); } uint8 getHeaderLength() { // cmd = 2 bytes, size= 2||3bytes - return 2+(isLargePacket()?3:2); + return 2 + (isLargePacket() ? 3 : 2); } bool isLargePacket() @@ -111,8 +111,8 @@ WorldSocket::WorldSocket(void) : { reference_counting_policy().value(ACE_Event_Handler::Reference_Counting_Policy::ENABLED); - msg_queue()->high_water_mark(8*1024*1024); - msg_queue()->low_water_mark(8*1024*1024); + msg_queue()->high_water_mark(8 * 1024 * 1024); + msg_queue()->low_water_mark(8 * 1024 * 1024); } WorldSocket::~WorldSocket(void) @@ -167,7 +167,7 @@ int WorldSocket::SendPacket(const WorldPacket& pct) // Dump outgoing packet. sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), LookupOpcodeName(pct.GetOpcode()), &pct, false); - ServerPktHeader header(pct.size()+2, pct.GetOpcode()); + ServerPktHeader header(pct.size() + 2, pct.GetOpcode()); m_Crypt.EncryptSend((uint8*)header.header, header.getHeaderLength()); if (m_OutBuffer->space() >= pct.size() + header.getHeaderLength() && msg_queue()->is_empty()) @@ -192,7 +192,7 @@ int WorldSocket::SendPacket(const WorldPacket& pct) if (!pct.empty()) mb->copy((const char*)pct.contents(), pct.size()); - if (msg_queue()->enqueue_tail(mb,(ACE_Time_Value*)&ACE_Time_Value::zero) == -1) + if (msg_queue()->enqueue_tail(mb, (ACE_Time_Value*)&ACE_Time_Value::zero) == -1) { sLog.outError("WorldSocket::SendPacket enqueue_tail"); mb->release(); @@ -718,7 +718,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) catch (ByteBufferException&) { sLog.outError("WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i.", - opcode, GetRemoteAddress().c_str(), m_Session?m_Session->GetAccountId():-1); + opcode, GetRemoteAddress().c_str(), m_Session ? m_Session->GetAccountId() : -1); if (sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG)) { DEBUG_LOG("Dumping error-causing packet:"); @@ -728,7 +728,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct) if (sWorld.getConfig(CONFIG_BOOL_KICK_PLAYER_ON_BAD_PACKET)) { DETAIL_LOG("Disconnecting session [account id %i / address %s] for badly formatted packet.", - m_Session?m_Session->GetAccountId():-1, GetRemoteAddress().c_str()); + m_Session ? m_Session->GetAccountId() : -1, GetRemoteAddress().c_str()); return -1; } diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index 04de1a0bb..1efa79e7f 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -81,7 +81,7 @@ bool ChatHandler::HandleDebugSendPoiCommand(char* args) if (!ExtractUInt32(&args, flags)) return false; - DETAIL_LOG("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon,flags); + 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"); return true; } @@ -287,7 +287,7 @@ bool ChatHandler::HandleDebugSendChannelNotifyCommand(char* args) if (!ExtractUInt32(&args, code) || code > 255) return false; - WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10)); + WorldPacket data(SMSG_CHANNEL_NOTIFY, (1 + 10)); data << uint8(code); // notify type data << name; // channel name data << uint32(0); @@ -700,11 +700,11 @@ bool ChatHandler::HandleDebugSetAuraStateCommand(char* args) { // reset all states for (int i = 1; i <= 32; ++i) - unit->ModifyAuraState(AuraState(i),false); + unit->ModifyAuraState(AuraState(i), false); return true; } - unit->ModifyAuraState(AuraState(abs(state)),state > 0); + unit->ModifyAuraState(AuraState(abs(state)), state > 0); return true; } @@ -841,10 +841,10 @@ bool ChatHandler::HandleGetValueHelper(Object* target, uint32 field, char* typeS { // starting 0 if need as required bitstring format std::string res; - res.reserve(1+32+1); - res = iValue & (1 << (32-1)) ? "0" : " "; + res.reserve(1 + 32 + 1); + res = iValue & (1 << (32 - 1)) ? "0" : " "; for (int i = 32; i > 0; --i) - res += iValue & (1 << (i-1)) ? "1" : "0"; + res += iValue & (1 << (i - 1)) ? "1" : "0"; DEBUG_LOG(GetMangosString(LANG_GET_BITSTR), guid.GetString().c_str(), field, res.c_str()); PSendSysMessage(LANG_GET_BITSTR_FIELD, guid.GetString().c_str(), field, res.c_str()); break; @@ -927,11 +927,11 @@ bool ChatHandler::HandlerDebugModValueHelper(Object* target, uint32 field, char* type = 1; else if (strncmp(typeStr, "float", strlen(typeStr)) == 0) type = 0; - else if (strncmp(typeStr, "|=", strlen("|=")+1) == 0) // exactly copy + else if (strncmp(typeStr, "|=", strlen("|=") + 1) == 0) // exactly copy type = 2; - else if (strncmp(typeStr, "&=", strlen("&=")+1) == 0) // exactly copy + else if (strncmp(typeStr, "&=", strlen("&=") + 1) == 0) // exactly copy type = 3; - else if (strncmp(typeStr, "&=~", strlen("&=~")+1) == 0) // exactly copy + else if (strncmp(typeStr, "&=~", strlen("&=~") + 1) == 0) // exactly copy type = 4; else return false; @@ -1106,7 +1106,7 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args) return false; uint32 effidx; - if (!ExtractUInt32(&args, effidx) || effidx >= 64+32) + if (!ExtractUInt32(&args, effidx) || effidx >= 64 + 32) return false; uint32 spellmodop; @@ -1135,7 +1135,7 @@ bool ChatHandler::HandleDebugSpellModsCommand(char* args) ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLMODS_CHANGED, GetNameLink().c_str(), opcode == SMSG_SET_FLAT_SPELL_MODIFIER ? "flat" : "pct", spellmodop, value, effidx); - WorldPacket data(opcode, (1+1+2+2)); + WorldPacket data(opcode, (1 + 1 + 2 + 2)); data << uint8(effidx); data << uint8(spellmodop); data << int32(value); diff --git a/src/game/movement/MoveSpline.cpp b/src/game/movement/MoveSpline.cpp index adc94a1f5..fa133dd5d 100644 --- a/src/game/movement/MoveSpline.cpp +++ b/src/game/movement/MoveSpline.cpp @@ -32,7 +32,7 @@ namespace Movement MANGOS_ASSERT(Initialized()); float u = 1.f; - int32 seg_time = spline.length(point_Idx,point_Idx+1); + int32 seg_time = spline.length(point_Idx, point_Idx + 1); if (seg_time > 0) u = (time_passed - spline.length(point_Idx)) / (float)seg_time; Location c; @@ -51,15 +51,15 @@ namespace Movement if (splineflags.final_angle) c.orientation = facing.angle; else if (splineflags.final_point) - c.orientation = atan2(facing.f.y-c.y, facing.f.x-c.x); + c.orientation = atan2(facing.f.y - c.y, facing.f.x - c.x); //nothing to do for MoveSplineFlag::Final_Target flag } else { - if (!splineflags.hasFlag(MoveSplineFlag::OrientationFixed|MoveSplineFlag::Falling)) + if (!splineflags.hasFlag(MoveSplineFlag::OrientationFixed | MoveSplineFlag::Falling)) { Vector3 hermite; - spline.evaluate_derivative(point_Idx,u,hermite); + spline.evaluate_derivative(point_Idx, u, hermite); c.orientation = atan2(hermite.y, hermite.x); } @@ -103,7 +103,7 @@ namespace Movement float start_elevation; inline int32 operator()(Spline& s, int32 i) { - return Movement::computeFallTime(start_elevation - s.getPoint(i+1).z,false) * 1000.f; + return Movement::computeFallTime(start_elevation - s.getPoint(i + 1).z, false) * 1000.f; } }; @@ -114,7 +114,7 @@ namespace Movement struct CommonInitializer { - CommonInitializer(float _velocity) : velocityInv(1000.f/_velocity), time(minimal_duration) {} + CommonInitializer(float _velocity) : velocityInv(1000.f / _velocity), time(minimal_duration) {} float velocityInv; int32 time; inline int32 operator()(Spline& s, int32 i) @@ -126,7 +126,7 @@ namespace Movement void MoveSpline::init_spline(const MoveSplineInitArgs& args) { - const SplineBase::EvaluationMode modes[2] = {SplineBase::ModeLinear,SplineBase::ModeCatmullrom}; + const SplineBase::EvaluationMode modes[2] = {SplineBase::ModeLinear, SplineBase::ModeCatmullrom}; if (args.flags.cyclic) { uint32 cyclic_point = 0; @@ -222,9 +222,9 @@ namespace Movement { MAX_OFFSET = (1 << 11) / 2, }; - Vector3 middle = (path.front()+path.back()) / 2; + Vector3 middle = (path.front() + path.back()) / 2; Vector3 offset; - for (uint32 i = 1; i < path.size()-1; ++i) + for (uint32 i = 1; i < path.size() - 1; ++i) { offset = path[i] - middle; if (fabs(offset.x) >= MAX_OFFSET || fabs(offset.y) >= MAX_OFFSET || fabs(offset.z) >= MAX_OFFSET) @@ -313,7 +313,7 @@ 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/MoveSpline.h b/src/game/movement/MoveSpline.h index e33276756..f2319f434 100644 --- a/src/game/movement/MoveSpline.h +++ b/src/game/movement/MoveSpline.h @@ -27,7 +27,7 @@ namespace Movement struct Location : public Vector3 { Location() : orientation(0) {} - Location(float x, float y, float z, float o) : Vector3(x,y,z), orientation(o) {} + Location(float x, float y, float z, float o) : Vector3(x, y, z), orientation(o) {} Location(const Vector3& v) : Vector3(v), orientation(0) {} Location(const Vector3& v, float o) : Vector3(v), orientation(o) {} @@ -76,8 +76,8 @@ namespace Movement void computeFallElevation(float& el) const; UpdateResult _updateState(int32& ms_time_diff); - int32 next_timestamp() const { return spline.length(point_Idx+1);} - int32 segment_time_elapsed() const { return next_timestamp()-time_passed;} + int32 next_timestamp() const { return spline.length(point_Idx + 1);} + int32 segment_time_elapsed() const { return next_timestamp() - time_passed;} int32 timeElapsed() const { return Duration() - time_passed;} int32 timePassed() const { return time_passed;} @@ -116,7 +116,7 @@ namespace Movement bool Finalized() const { return splineflags.done; } bool isCyclic() const { return splineflags.cyclic;} const Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last()) : Vector3();} - const Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx+1) : Vector3();} + const Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx + 1) : Vector3();} int32 currentPathIdx() const; int32 Duration() const { return spline.length();} diff --git a/src/game/movement/MoveSplineFlag.h b/src/game/movement/MoveSplineFlag.h index d4e452adc..fb140d468 100644 --- a/src/game/movement/MoveSplineFlag.h +++ b/src/game/movement/MoveSplineFlag.h @@ -71,11 +71,11 @@ namespace Movement // CatmullRom interpolation mode used Mask_CatmullRom = Flying | Catmullrom, // Unused, not suported flags - Mask_Unused = No_Spline|Enter_Cycle|Frozen|Unknown5|Unknown6|Unknown7|Unknown8|Unknown10|Unknown11|Unknown12|Unknown13, + Mask_Unused = No_Spline | Enter_Cycle | Frozen | Unknown5 | Unknown6 | Unknown7 | Unknown8 | Unknown10 | Unknown11 | Unknown12 | Unknown13, }; - inline uint32& raw() { return (uint32&)*this;} - inline const uint32& raw() const { return (const uint32&)*this;} + inline uint32& raw() { return (uint32&) * this;} + inline const uint32& raw() const { return (const uint32&) * this;} MoveSplineFlag() { raw() = 0; } MoveSplineFlag(uint32 f) { raw() = f; } @@ -99,9 +99,9 @@ namespace Movement void operator &= (uint32 f) { raw() &= f;} void operator |= (uint32 f) { raw() |= f;} - void EnableAnimation(uint8 anim) { raw() = raw() & ~(Mask_Animations|Falling|Parabolic) | Animation|anim;} - void EnableParabolic() { raw() = raw() & ~(Mask_Animations|Falling|Animation) | Parabolic;} - void EnableFalling() { raw() = raw() & ~(Mask_Animations|Parabolic|Animation) | Falling;} + void EnableAnimation(uint8 anim) { raw() = raw() & ~(Mask_Animations | Falling | Parabolic) | Animation | anim;} + void EnableParabolic() { raw() = raw() & ~(Mask_Animations | Falling | Animation) | Parabolic;} + void EnableFalling() { raw() = raw() & ~(Mask_Animations | Parabolic | Animation) | Falling;} void EnableFlying() { raw() = raw() & ~Catmullrom | Flying; } void EnableCatmullRom() { raw() = raw() & ~Flying | Catmullrom; } void EnableFacingPoint() { raw() = raw() & ~Mask_Final_Facing | Final_Point;} diff --git a/src/game/movement/MoveSplineInit.cpp b/src/game/movement/MoveSplineInit.cpp index ca40e55cf..4ceb22592 100644 --- a/src/game/movement/MoveSplineInit.cpp +++ b/src/game/movement/MoveSplineInit.cpp @@ -54,7 +54,7 @@ namespace Movement { MoveSpline& move_spline = *unit.movespline; - Location real_position(unit.GetPositionX(),unit.GetPositionY(),unit.GetPositionZ(),unit.GetOrientation()); + Location real_position(unit.GetPositionX(), unit.GetPositionY(), unit.GetPositionZ(), unit.GetOrientation()); // there is a big chane 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()) @@ -76,7 +76,7 @@ namespace Movement else moveFlags &= ~MOVEFLAG_WALK_MODE; - moveFlags |= (MOVEFLAG_SPLINE_ENABLED|MOVEFLAG_FORWARD); + moveFlags |= (MOVEFLAG_SPLINE_ENABLED | MOVEFLAG_FORWARD); if (args.velocity == 0.f) args.velocity = unit.GetSpeed(SelectSpeedType(moveFlags)); @@ -90,7 +90,7 @@ namespace Movement WorldPacket data(SMSG_MONSTER_MOVE, 64); data << unit.GetPackGUID(); PacketBuilder::WriteMonsterMove(move_spline, data); - unit.SendMessageToSet(&data,true); + unit.SendMessageToSet(&data, true); return move_spline.Duration(); } @@ -99,7 +99,7 @@ namespace Movement { // mix existing state into new args.flags.walkmode = unit.m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE); - args.flags.flying = unit.m_movementInfo.HasMovementFlag((MovementFlags)(MOVEFLAG_FLYING|MOVEFLAG_LEVITATING)); + args.flags.flying = unit.m_movementInfo.HasMovementFlag((MovementFlags)(MOVEFLAG_FLYING | MOVEFLAG_LEVITATING)); } void MoveSplineInit::SetFacing(const Unit* target) diff --git a/src/game/movement/MoveSplineInit.h b/src/game/movement/MoveSplineInit.h index 086fb2616..bd9fc9d41 100644 --- a/src/game/movement/MoveSplineInit.h +++ b/src/game/movement/MoveSplineInit.h @@ -132,12 +132,12 @@ namespace Movement inline void MoveSplineInit::MovebyPath(const PointsArray& controls, int32 path_offset) { args.path_Idx_offset = path_offset; - args.path.assign(controls.begin(),controls.end()); + args.path.assign(controls.begin(), controls.end()); } inline void MoveSplineInit::MoveTo(float x, float y, float z, bool generatePath, bool forceDestination) { - Vector3 v(x,y,z); + Vector3 v(x, y, z); MoveTo(v, generatePath, forceDestination); } diff --git a/src/game/movement/MoveSplineInitArgs.h b/src/game/movement/MoveSplineInitArgs.h index fc0ea6fe3..75044c3b5 100644 --- a/src/game/movement/MoveSplineInitArgs.h +++ b/src/game/movement/MoveSplineInitArgs.h @@ -30,7 +30,7 @@ namespace Movement { struct { - float x,y,z; + float x, y, z; } f; uint64 target; float angle; diff --git a/src/game/movement/spline.cpp b/src/game/movement/spline.cpp index 235e7a8ea..ff7157ce6 100644 --- a/src/game/movement/spline.cpp +++ b/src/game/movement/spline.cpp @@ -61,7 +61,7 @@ namespace Movement using G3D::Matrix4; static const Matrix4 s_catmullRomCoeffs( - -0.5f, 1.5f,-1.5f, 0.5f, + -0.5f, 1.5f, -1.5f, 0.5f, 1.f, -2.5f, 2.f, -0.5f, -0.5f, 0.f, 0.5f, 0.f, 0.f, 1.f, 0.f, 0.f); @@ -98,7 +98,7 @@ namespace Movement inline void C_Evaluate(const Vector3* vertice, float t, const Matrix4& matr, Vector3& result) { - Vector4 tvec(t*t*t, t*t, t, 1.f); + Vector4 tvec(t * t * t, t * t, t, 1.f); Vector4 weights(tvec * matr); result = vertice[0] * weights[0] + vertice[1] * weights[1] @@ -107,7 +107,7 @@ namespace Movement inline void C_Evaluate_Derivative(const Vector3* vertice, float t, const Matrix4& matr, Vector3& result) { - Vector4 tvec(3.f*t*t, 2.f*t, 1.f, 0.f); + Vector4 tvec(3.f * t * t, 2.f * t, 1.f, 0.f); Vector4 weights(tvec * matr); result = vertice[0] * weights[0] + vertice[1] * weights[1] @@ -117,7 +117,7 @@ namespace Movement void SplineBase::EvaluateLinear(index_type index, float u, Vector3& result) const { MANGOS_ASSERT(index >= index_lo && index < index_hi); - result = points[index] + (points[index+1] - points[index]) * u; + result = points[index] + (points[index + 1] - points[index]) * u; } void SplineBase::EvaluateCatmullRom(index_type index, float t, Vector3& result) const @@ -136,7 +136,7 @@ namespace Movement void SplineBase::EvaluateDerivativeLinear(index_type index, float, Vector3& result) const { MANGOS_ASSERT(index >= index_lo && index < index_hi); - result = points[index+1] - points[index]; + result = points[index + 1] - points[index]; } void SplineBase::EvaluateDerivativeCatmullRom(index_type index, float t, Vector3& result) const @@ -155,7 +155,7 @@ namespace Movement float SplineBase::SegLengthLinear(index_type index) const { MANGOS_ASSERT(index >= index_lo && index < index_hi); - return (points[index] - points[index+1]).length(); + return (points[index] - points[index + 1]).length(); } float SplineBase::SegLengthCatmullRom(index_type index) const @@ -225,14 +225,14 @@ namespace Movement points.resize(real_size); - memcpy(&points[0],controls, sizeof(Vector3) * count); + memcpy(&points[0], controls, sizeof(Vector3) * count); // 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]; else - points[count] = controls[count-1]; + points[count] = controls[count - 1]; index_lo = 0; index_hi = cyclic ? count : (count - 1); @@ -240,31 +240,31 @@ namespace Movement void SplineBase::InitCatmullRom(const Vector3* controls, index_type count, bool cyclic, index_type cyclic_point) { - const int real_size = count + (cyclic ? (1+2) : (1+1)); + const int real_size = count + (cyclic ? (1 + 2) : (1 + 1)); points.resize(real_size); int lo_index = 1; int high_index = lo_index + count - 1; - memcpy(&points[lo_index],controls, sizeof(Vector3) * count); + memcpy(&points[lo_index], controls, sizeof(Vector3) * count); // 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) { if (cyclic_point == 0) - points[0] = controls[count-1]; + points[0] = controls[count - 1]; else points[0] = controls[0].lerp(controls[1], -1); - points[high_index+1] = controls[cyclic_point]; - points[high_index+2] = controls[cyclic_point+1]; + points[high_index + 1] = controls[cyclic_point]; + points[high_index + 2] = controls[cyclic_point + 1]; } else { points[0] = controls[0].lerp(controls[1], -1); - points[high_index+1] = controls[count-1]; + points[high_index + 1] = controls[count - 1]; } index_lo = lo_index; @@ -277,10 +277,10 @@ namespace Movement index_type t = c / 3u; points.resize(c); - memcpy(&points[0],controls, sizeof(Vector3) * c); + memcpy(&points[0], controls, sizeof(Vector3) * c); index_lo = 0; - index_hi = t-1; + index_hi = t - 1; //mov_assert(points.size() % 3 == 0); } diff --git a/src/game/movement/spline.h b/src/game/movement/spline.h index 3ac46e793..61e6958eb 100644 --- a/src/game/movement/spline.h +++ b/src/game/movement/spline.h @@ -63,7 +63,7 @@ namespace Movement void EvaluateLinear(index_type, float, Vector3&) const; void EvaluateCatmullRom(index_type, float, Vector3&) const; void EvaluateBezier3(index_type, float, Vector3&) const; - typedef void (SplineBase::*EvaluationMethtod)(index_type,float,Vector3&) const; + typedef void (SplineBase::*EvaluationMethtod)(index_type, float, Vector3&) const; static EvaluationMethtod evaluators[ModesEnd]; void EvaluateDerivativeLinear(index_type, float, Vector3&) const; @@ -93,13 +93,13 @@ namespace Movement @param t - percent of segment length, assumes that t in range [0, 1] @param Idx - spline segment index, should be in range [first, last) */ - void evaluate_percent(index_type Idx, float u, Vector3& c) const {(this->*evaluators[m_mode])(Idx,u,c);} + void evaluate_percent(index_type Idx, float u, Vector3& c) const {(this->*evaluators[m_mode])(Idx, u, c);} /** Caclulates derivation in index Idx, and percent of segment length t @param Idx - spline segment index, should be in range [first, last) @param t - percent of spline segment length, assumes that t in range [0, 1] */ - void evaluate_derivative(index_type Idx, float u, Vector3& hermite) const {(this->*derivative_evaluators[m_mode])(Idx,u,hermite);} + void evaluate_derivative(index_type Idx, float u, Vector3& hermite) const {(this->*derivative_evaluators[m_mode])(Idx, u, hermite);} /** Bounds for spline indexes. All indexes should be in range [first, last). */ index_type first() const { return index_lo;} @@ -121,7 +121,7 @@ namespace Movement would be no harm to have some custom initializers. */ template inline void init_spline(Init& initializer) { - initializer(m_mode,cyclic,points,index_lo,index_hi); + initializer(m_mode, cyclic, points, index_lo, index_hi); } void clear(); @@ -158,20 +158,20 @@ namespace Movement /** Calculates the position for given segment Idx, and percent of segment length t @param t = partial_segment_length / whole_segment_length @param Idx - spline segment index, should be in range [first, last). */ - void evaluate_percent(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_percent(Idx,u,c);} + void evaluate_percent(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_percent(Idx, u, c);} /** Caclulates derivation for index Idx, and percent of segment length t @param Idx - spline segment index, should be in range [first, last) @param t - percent of spline segment length, assumes that t in range [0, 1]. */ - void evaluate_derivative(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_derivative(Idx,u,c);} + void evaluate_derivative(index_type Idx, float u, Vector3& c) const { SplineBase::evaluate_derivative(Idx, u, c);} // Assumes that t in range [0, 1] index_type computeIndexInBounds(float t) const; void computeIndex(float t, index_type& out_idx, float& out_u) const; /** Initializes spline. Don't call other methods while spline not initialized. */ - void init_spline(const Vector3* controls, index_type count, EvaluationMode m) { SplineBase::init_spline(controls,count,m);} - void init_cyclic_spline(const Vector3* controls, index_type count, EvaluationMode m, index_type cyclic_point) { SplineBase::init_cyclic_spline(controls,count,m,cyclic_point);} + void init_spline(const Vector3* controls, index_type count, EvaluationMode m) { SplineBase::init_spline(controls, count, m);} + void init_cyclic_spline(const Vector3* controls, index_type count, EvaluationMode m, index_type cyclic_point) { SplineBase::init_cyclic_spline(controls, count, m, cyclic_point);} /** Initializes lengths with SplineBase::SegLength method. */ void initLengths(); @@ -181,7 +181,7 @@ namespace Movement template inline void initLengths(T& cacher) { index_type i = index_lo; - lengths.resize(index_hi+1); + lengths.resize(index_hi + 1); length_type prev_length = 0, new_length = 0; while (i < index_hi) { @@ -196,7 +196,7 @@ namespace Movement /** Returns length of the whole spline. */ length_type length() const { return lengths[index_hi];} /** Returns length between given nodes. */ - length_type length(index_type first, index_type last) const { return lengths[last]-lengths[first];} + length_type length(index_type first, index_type last) const { return lengths[last] - lengths[first];} length_type length(index_type Idx) const { return lengths[Idx];} void set_length(index_type i, length_type length) { lengths[i] = length;} diff --git a/src/game/movement/spline.impl.h b/src/game/movement/spline.impl.h index 209551bf7..ff297610c 100644 --- a/src/game/movement/spline.impl.h +++ b/src/game/movement/spline.impl.h @@ -55,7 +55,7 @@ namespace Movement index_type i = index_lo; index_type N = index_hi; - while (i+1 < N && lengths[i+1] < length_) + while (i + 1 < N && lengths[i + 1] < length_) ++i; return i; @@ -67,7 +67,7 @@ namespace Movement length_type length_ = t * length(); index = computeIndexInBounds(length_); MANGOS_ASSERT(index < index_hi); - u = (length_ - length(index)) / (float)length(index, index+1); + u = (length_ - length(index)) / (float)length(index, index + 1); } template SplineBase::index_type Spline::computeIndexInBounds(float t) const @@ -80,7 +80,7 @@ namespace Movement { index_type i = index_lo; length_type length = 0; - lengths.resize(index_hi+1); + lengths.resize(index_hi + 1); while (i < index_hi) { length += SegLength(i); diff --git a/src/game/movement/util.cpp b/src/game/movement/util.cpp index f1b38c90d..b419a5ac1 100644 --- a/src/game/movement/util.cpp +++ b/src/game/movement/util.cpp @@ -30,7 +30,7 @@ namespace Movement const float terminal_length = float(terminalVelocity* terminalVelocity) / (2.f* gravity); const float terminal_savefall_length = (terminalSavefallVelocity* terminalSavefallVelocity) / (2.f* gravity); - const float terminalFallTime = float(terminalVelocity/gravity); // the time that needed to reach terminalVelocity + const float terminalFallTime = float(terminalVelocity / gravity); // the time that needed to reach terminalVelocity float computeFallTime(float path_length, bool isSafeFall) { @@ -41,16 +41,16 @@ namespace Movement 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); + 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); + time = sqrtf(2.f * path_length / gravity); } return time; @@ -73,8 +73,8 @@ namespace Movement if (t_passed > terminal_time) { - result = terminalVelocity*(t_passed - terminal_time) + - start_velocity*terminal_time + gravity*terminal_time*terminal_time*0.5f; + result = terminalVelocity * (t_passed - terminal_time) + + start_velocity * terminal_time + gravity * terminal_time * terminal_time * 0.5f; } else result = t_passed * (start_velocity + t_passed * gravity * 0.5f); @@ -100,7 +100,7 @@ namespace Movement #define STR(x) #x - const char* g_MovementFlag_names[]= + const char* g_MovementFlag_names[] = { STR(Forward), // 0x00000001, STR(Backward), // 0x00000002, @@ -153,7 +153,7 @@ namespace Movement STR(Unk10), }; - const char* g_SplineFlag_names[32]= + const char* g_SplineFlag_names[32] = { STR(AnimBit1), // 0x00000001, STR(AnimBit2), // 0x00000002, @@ -190,7 +190,7 @@ namespace Movement }; template - void print_flags(Flags t, const char* (&names)[N], std::string& str) + void print_flags(Flags t, const char * (&names)[N], std::string& str) { for (int i = 0; i < N; ++i) { @@ -202,7 +202,7 @@ namespace Movement std::string MoveSplineFlag::ToString() const { std::string str; - print_flags(raw(),g_SplineFlag_names,str); + print_flags(raw(), g_SplineFlag_names, str); return str; } } diff --git a/src/game/vmap/BIH.cpp b/src/game/vmap/BIH.cpp index a564e2d70..b632726a9 100644 --- a/src/game/vmap/BIH.cpp +++ b/src/game/vmap/BIH.cpp @@ -251,7 +251,7 @@ void BIH::subdivide(int left, int right, std::vector& tempTree, buildDat bool BIH::writeToFile(FILE* wf) const { uint32 treeSize = tree.size(); - uint32 check=0, count=0; + uint32 check = 0, count = 0; check += fwrite(&bounds.low(), sizeof(float), 3, wf); check += fwrite(&bounds.high(), sizeof(float), 3, wf); check += fwrite(&treeSize, sizeof(uint32), 1, wf); @@ -266,7 +266,7 @@ bool BIH::readFromFile(FILE* rf) { uint32 treeSize; Vector3 lo, hi; - uint32 check=0, count=0; + uint32 check = 0, count = 0; check += fread(&lo, sizeof(float), 3, rf); check += fread(&hi, sizeof(float), 3, rf); bounds = AABox(lo, hi); diff --git a/src/game/vmap/BIH.h b/src/game/vmap/BIH.h index 3c65283ba..6772a123a 100644 --- a/src/game/vmap/BIH.h +++ b/src/game/vmap/BIH.h @@ -50,7 +50,7 @@ static inline uint32 floatToRawIntBits(float f) uint32 ival; float fval; } temp; - temp.fval=f; + temp.fval = f; return temp.ival; } @@ -61,7 +61,7 @@ static inline float intBitsToFloat(uint32 i) uint32 ival; float fval; } temp; - temp.ival=i; + temp.ival = i; return temp.fval; } @@ -82,7 +82,7 @@ class BIH public: BIH() {}; template< class T, class BoundsFunc > - void build(const std::vector& primitives, BoundsFunc& getBounds, uint32 leafSize = 3, bool printStats=false) + void build(const std::vector& primitives, BoundsFunc& getBounds, uint32 leafSize = 3, bool printStats = false) { if (primitives.size() == 0) return; @@ -92,7 +92,7 @@ class BIH dat.indices = new uint32[dat.numPrims]; dat.primBound = new AABox[dat.numPrims]; getBounds(primitives[0], bounds); - for (uint32 i=0; i - void intersectRay(const Ray& r, RayCallback& intersectCallback, float& maxDist, bool stopAtFirst=false) const + void intersectRay(const Ray& r, RayCallback& intersectCallback, float& maxDist, bool stopAtFirst = false) const { float intervalMin = -1.f; float intervalMax = -1.f; Vector3 org = r.origin(); Vector3 dir = r.direction(); Vector3 invDir; - for (int i=0; i<3; ++i) + for (int i = 0; i < 3; ++i) { invDir[i] = 1.f / dir[i]; if (G3D::fuzzyNe(dir[i], 0.0f)) @@ -154,7 +154,7 @@ class BIH uint32 offsetBack3[3]; // compute custom offsets from direction sign bit - for (int i=0; i<3; ++i) + for (int i = 0; i < 3; ++i) { offsetFront[i] = floatToRawIntBits(dir[i]) >> 31; offsetBack[i] = offsetFront[i] ^ 1; @@ -229,7 +229,7 @@ class BIH } else { - if (axis>2) + if (axis > 2) return; // should not happen float tf = (intBitsToFloat(tree[node + offsetFront[axis]]) - org[axis]) * invDir[axis]; float tb = (intBitsToFloat(tree[node + offsetBack[axis]]) - org[axis]) * invDir[axis]; @@ -321,7 +321,7 @@ class BIH } else // BVH2 node (empty space cut off left and right) { - if (axis>2) + if (axis > 2) return; // should not happen float tl = intBitsToFloat(tree[node + 1]); float tr = intBitsToFloat(tree[node + 2]); @@ -383,7 +383,7 @@ class BIH maxObjects(0xFFFFFFFF), sumDepth(0), minDepth(0x0FFFFFFF), maxDepth(0xFFFFFFFF), numBVH2(0) { - for (int i=0; i<6; ++i) numLeavesN[i] = 0; + for (int i = 0; i < 6; ++i) numLeavesN[i] = 0; } void updateInner() { numNodes++; } diff --git a/src/game/vmap/IVMapManager.h b/src/game/vmap/IVMapManager.h index deed23a57..91f728a50 100644 --- a/src/game/vmap/IVMapManager.h +++ b/src/game/vmap/IVMapManager.h @@ -70,7 +70,7 @@ namespace VMAP /** send debug commands */ - virtual bool processCommand(char* pCommand)= 0; + virtual bool processCommand(char* pCommand) = 0; /** Enable/disable LOS calculation @@ -87,13 +87,13 @@ namespace VMAP bool isHeightCalcEnabled() const { return(iEnableHeightCalc); } bool isMapLoadingEnabled() const { return(iEnableLineOfSightCalc || iEnableHeightCalc); } - virtual std::string getDirFileName(unsigned int pMapId, int x, int y) const =0; + virtual std::string getDirFileName(unsigned int pMapId, int x, int y) const = 0; /** Query world model area info. \param z gets adjusted to the ground height for which this are info is valid */ - virtual bool getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const=0; - virtual bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float& level, float& floor, uint32& type) const=0; + virtual bool getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const = 0; + virtual bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float& level, float& floor, uint32& type) const = 0; }; } diff --git a/src/game/vmap/MapTree.cpp b/src/game/vmap/MapTree.cpp index 92312c9fe..ff1b4742a 100644 --- a/src/game/vmap/MapTree.cpp +++ b/src/game/vmap/MapTree.cpp @@ -35,7 +35,7 @@ namespace VMAP { public: MapRayCallback(ModelInstance* val): prims(val), hit(false) {} - bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit=true) + bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit = true) { bool result = prims[entry].intersectRay(ray, distance, pStopAtFirstHit); if (result) @@ -121,7 +121,7 @@ namespace VMAP StaticMapTree::StaticMapTree(uint32 mapID, const std::string& basePath): iMapID(mapID), iTreeValues(0), iBasePath(basePath) { - if (iBasePath.length() > 0 && (iBasePath[iBasePath.length()-1] != '/' && iBasePath[iBasePath.length()-1] != '\\')) + if (iBasePath.length() > 0 && (iBasePath[iBasePath.length() - 1] != '/' && iBasePath[iBasePath.length() - 1] != '\\')) iBasePath.append("/"); } @@ -158,7 +158,7 @@ namespace VMAP if (maxDist < 1e-10f) return true; // direction with length of 1 - G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1)/maxDist); + G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1) / maxDist); if (getIntersectionTime(ray, maxDist, true)) return false; @@ -172,7 +172,7 @@ namespace VMAP bool StaticMapTree::getObjectHitPos(const Vector3& pPos1, const Vector3& pPos2, Vector3& pResultHitPos, float pModifyDist) const { - bool result=false; + bool result = false; float maxDist = (pPos2 - pPos1).magnitude(); // valid map coords should *never ever* produce float overflow, but this would produce NaNs too: MANGOS_ASSERT(maxDist < std::numeric_limits::max()); @@ -182,7 +182,7 @@ namespace VMAP pResultHitPos = pPos2; return false; } - Vector3 dir = (pPos2 - pPos1)/maxDist; // direction with length of 1 + Vector3 dir = (pPos2 - pPos1) / maxDist; // direction with length of 1 G3D::Ray ray(pPos1, dir); float dist = maxDist; if (getIntersectionTime(ray, dist, false)) @@ -192,7 +192,7 @@ namespace VMAP { if ((pResultHitPos - pPos1).magnitude() > -pModifyDist) { - pResultHitPos = pResultHitPos + dir*pModifyDist; + pResultHitPos = pResultHitPos + dir * pModifyDist; } else { @@ -201,7 +201,7 @@ namespace VMAP } else { - pResultHitPos = pResultHitPos + dir*pModifyDist; + pResultHitPos = pResultHitPos + dir * pModifyDist; } result = true; } @@ -218,7 +218,7 @@ namespace VMAP float StaticMapTree::getHeight(const Vector3& pPos, float maxSearchDist) const { float height = G3D::inf(); - Vector3 dir = Vector3(0,0,-1); + Vector3 dir = Vector3(0, 0, -1); G3D::Ray ray(pPos, dir); // direction with length of 1 float maxDist = maxSearchDist; if (getIntersectionTime(ray, maxDist, false)) @@ -233,7 +233,7 @@ namespace VMAP bool StaticMapTree::CanLoadMap(const std::string& vmapPath, uint32 mapID, uint32 tileX, uint32 tileY) { std::string basePath = vmapPath; - if (basePath.length() > 0 && (basePath[basePath.length()-1] != '/' && basePath[basePath.length()-1] != '\\')) + if (basePath.length() > 0 && (basePath[basePath.length() - 1] != '/' && basePath[basePath.length() - 1] != '\\')) basePath.append("/"); std::string fullname = basePath + VMapManager2::getMapFileName(mapID); bool success = true; @@ -363,7 +363,7 @@ namespace VMAP uint32 numSpawns; if (result && fread(&numSpawns, sizeof(uint32), 1, tf) != 1) result = false; - for (uint32 i=0; i>16; tileY = ID&0xFF; } + static uint32 packTileID(uint32 tileX, uint32 tileY) { return tileX << 16 | tileY; } + static void unpackTileID(uint32 ID, uint32& tileX, uint32& tileY) { tileX = ID >> 16; tileY = ID & 0xFF; } static bool CanLoadMap(const std::string& basePath, uint32 mapID, uint32 tileX, uint32 tileY); StaticMapTree(uint32 mapID, const std::string& basePath); diff --git a/src/game/vmap/ModelInstance.cpp b/src/game/vmap/ModelInstance.cpp index 0086c818d..4aba0d517 100644 --- a/src/game/vmap/ModelInstance.cpp +++ b/src/game/vmap/ModelInstance.cpp @@ -28,8 +28,8 @@ namespace VMAP { ModelInstance::ModelInstance(const ModelSpawn& spawn, WorldModel* model): ModelSpawn(spawn), iModel(model) { - iInvRot = G3D::Matrix3::fromEulerAnglesZYX(G3D::pi()*iRot.y/180.f, G3D::pi()*iRot.x/180.f, G3D::pi()*iRot.z/180.f).inverse(); - iInvScale = 1.f/iScale; + iInvRot = G3D::Matrix3::fromEulerAnglesZYX(G3D::pi() * iRot.y / 180.f, G3D::pi() * iRot.x / 180.f, G3D::pi() * iRot.z / 180.f).inverse(); + iInvScale = 1.f / iScale; } bool ModelInstance::intersectRay(const G3D::Ray& pRay, float& pMaxDist, bool pStopAtFirstHit) const @@ -152,7 +152,7 @@ namespace VMAP bool ModelSpawn::readFromFile(FILE* rf, ModelSpawn& spawn) { - uint32 check=0, nameLen; + uint32 check = 0, nameLen; check += fread(&spawn.flags, sizeof(uint32), 1, rf); // EoF? if (!check) @@ -181,7 +181,7 @@ namespace VMAP return false; } char nameBuff[500]; - if (nameLen>500) // file names should never be that long, must be file error + if (nameLen > 500) // file names should never be that long, must be file error { ERROR_LOG("Error reading ModelSpawn, file name too long!"); return false; @@ -198,7 +198,7 @@ namespace VMAP bool ModelSpawn::writeToFile(FILE* wf, const ModelSpawn& spawn) { - uint32 check=0; + uint32 check = 0; check += fwrite(&spawn.flags, sizeof(uint32), 1, wf); check += fwrite(&spawn.adtId, sizeof(uint16), 1, wf); check += fwrite(&spawn.ID, sizeof(uint32), 1, wf); diff --git a/src/game/vmap/ModelInstance.h b/src/game/vmap/ModelInstance.h index 59334a506..d53286941 100644 --- a/src/game/vmap/ModelInstance.h +++ b/src/game/vmap/ModelInstance.h @@ -35,8 +35,8 @@ namespace VMAP enum ModelFlags { MOD_M2 = 1, - MOD_WORLDSPAWN = 1<<1, - MOD_HAS_BOUND = 1<<2 + MOD_WORLDSPAWN = 1 << 1, + MOD_HAS_BOUND = 1 << 2 }; class ModelSpawn diff --git a/src/game/vmap/TileAssembler.cpp b/src/game/vmap/TileAssembler.cpp index 43a3102c5..6c6c62470 100644 --- a/src/game/vmap/TileAssembler.cpp +++ b/src/game/vmap/TileAssembler.cpp @@ -95,7 +95,7 @@ namespace VMAP { // TODO: remove extractor hack and uncomment below line: //entry->second.iPos += Vector3(533.33333f*32, 533.33333f*32, 0.f); - entry->second.iBound = entry->second.iBound + Vector3(533.33333f*32, 533.33333f*32, 0.f); + entry->second.iBound = entry->second.iBound + Vector3(533.33333f * 32, 533.33333f * 32, 0.f); } mapSpawns.push_back(&(entry->second)); spawnedModelFiles.insert(entry->second.name); @@ -107,7 +107,7 @@ namespace VMAP // ===> possibly move this code to StaticMapTree class std::map modelNodeIdx; - for (uint32 i=0; i(mapSpawns[i]->ID, i)); // write map tree file @@ -133,7 +133,7 @@ namespace VMAP // global map spawns (WDT), if any (most instances) if (success && fwrite("GOBJ", 4, 1, mapfile) != 1) success = false; - for (TileMap::iterator glob=globalRange.first; glob != globalRange.second && success; ++glob) + for (TileMap::iterator glob = globalRange.first; glob != globalRange.second && success; ++glob) { success = ModelSpawn::writeToFile(mapfile, map_iter->second->UniqueEntries[glob->second]); } @@ -163,7 +163,7 @@ namespace VMAP // write number of tile spawns if (success && fwrite(&nSpawns, sizeof(uint32), 1, tilefile) != 1) success = false; // write tile spawns - for (uint32 s=0; s0) + if (nvectors > 0) { - vectorarray = new float[nvectors*3]; - READ_OR_RETURN(vectorarray, nvectors*sizeof(float)*3); + vectorarray = new float[nvectors * 3]; + READ_OR_RETURN(vectorarray, nvectors * sizeof(float) * 3); } else { @@ -317,13 +317,13 @@ namespace VMAP return false; } - for (uint32 i=0, indexNo=0; indexNo0) + if (filename.length() > 0) filename.append("/"); filename.append(pModelFilename); FILE* rf = fopen(filename.c_str(), "rb"); if (!rf) { - printf("ERROR: Can't open model file in form: %s",pModelFilename.c_str()); - printf("... or form: %s",filename.c_str()); + printf("ERROR: Can't open model file in form: %s", pModelFilename.c_str()); + printf("... or form: %s", filename.c_str()); return false; } @@ -391,7 +391,7 @@ namespace VMAP std::vector groupsArray; - for (uint32 g=0; g triangles; std::vector vertexArray; @@ -401,8 +401,8 @@ namespace VMAP READ_OR_RETURN(&GroupWMOID, sizeof(uint32)); float bbox1[3], bbox2[3]; - READ_OR_RETURN(bbox1, sizeof(float)*3); - READ_OR_RETURN(bbox2, sizeof(float)*3); + READ_OR_RETURN(bbox1, sizeof(float) * 3); + READ_OR_RETURN(bbox2, sizeof(float) * 3); uint32 liquidflags; READ_OR_RETURN(&liquidflags, sizeof(uint32)); @@ -413,7 +413,7 @@ namespace VMAP CMP_OR_RETURN(blockId, "GRP "); READ_OR_RETURN(&blocksize, sizeof(int)); READ_OR_RETURN(&branches, sizeof(uint32)); - for (uint32 b=0; b0) + if (nindexes > 0) { uint16* indexarray = new uint16[nindexes]; - READ_OR_RETURN(indexarray, nindexes*sizeof(uint16)); - for (uint32 i=0; i0) + if (nvectors > 0) { - float* vectorarray = new float[nvectors*3]; - READ_OR_RETURN(vectorarray, nvectors*sizeof(float)*3); - for (uint32 i=0; iGetHeightStorage(), size*sizeof(float)); - size = hlq.xtiles*hlq.ytiles; + uint32 size = hlq.xverts * hlq.yverts; + READ_OR_RETURN(liquid->GetHeightStorage(), size * sizeof(float)); + size = hlq.xtiles * hlq.ytiles; READ_OR_RETURN(liquid->GetFlagsStorage(), size); } diff --git a/src/game/vmap/TileAssembler.h b/src/game/vmap/TileAssembler.h index 87e8f8666..910b82f03 100644 --- a/src/game/vmap/TileAssembler.h +++ b/src/game/vmap/TileAssembler.h @@ -43,7 +43,7 @@ namespace VMAP float iScale; void init() { - iRotation = G3D::Matrix3::fromEulerAnglesZYX(G3D::pi()*iDir.y/180.f, G3D::pi()*iDir.x/180.f, G3D::pi()*iDir.z/180.f); + iRotation = G3D::Matrix3::fromEulerAnglesZYX(G3D::pi() * iDir.y / 180.f, G3D::pi() * iDir.x / 180.f, G3D::pi() * iDir.z / 180.f); } G3D::Vector3 transform(const G3D::Vector3& pIn) const; void moveToBasePos(const G3D::Vector3& pBasePos) { iPos -= pBasePos; } diff --git a/src/game/vmap/VMapFactory.cpp b/src/game/vmap/VMapFactory.cpp index 257f13fa4..4c0b75a41 100644 --- a/src/game/vmap/VMapFactory.cpp +++ b/src/game/vmap/VMapFactory.cpp @@ -26,24 +26,24 @@ namespace VMAP { void chompAndTrim(std::string& str) { - while (str.length() >0) + while (str.length() > 0) { - char lc = str[str.length()-1]; + char lc = str[str.length() - 1]; if (lc == '\r' || lc == '\n' || lc == ' ' || lc == '"' || lc == '\'') { - str = str.substr(0,str.length()-1); + str = str.substr(0, str.length() - 1); } else { break; } } - while (str.length() >0) + while (str.length() > 0) { char lc = str[0]; if (lc == ' ' || lc == '"' || lc == '\'') { - str = str.substr(1,str.length()-1); + str = str.substr(1, str.length() - 1); } else { @@ -53,7 +53,7 @@ namespace VMAP } IVMapManager* gVMapManager = 0; - Table* iIgnoreSpellIds=0; + Table* iIgnoreSpellIds = 0; //=============================================== // result false, if no more id are found @@ -62,17 +62,17 @@ namespace VMAP { bool result = false; unsigned int i; - for (i=pStartPos; ipStartPos) + if (i > pStartPos) { - std::string idString = pString.substr(pStartPos, i-pStartPos); - pStartPos = i+1; + std::string idString = pString.substr(pStartPos, i - pStartPos); + pStartPos = i + 1; chompAndTrim(idString); pId = atoi(idString.c_str()); result = true; @@ -91,7 +91,7 @@ namespace VMAP iIgnoreSpellIds = new Table(); if (pSpellIdString != NULL) { - unsigned int pos =0; + unsigned int pos = 0; unsigned int id; std::string confString(pSpellIdString); chompAndTrim(confString); @@ -114,7 +114,7 @@ namespace VMAP IVMapManager* VMapFactory::createOrGetVMapManager() { if (gVMapManager == 0) - gVMapManager= new VMapManager2(); // should be taken from config ... Please change if you like :-) + gVMapManager = new VMapManager2(); // should be taken from config ... Please change if you like :-) return gVMapManager; } diff --git a/src/game/vmap/VMapManager2.cpp b/src/game/vmap/VMapManager2.cpp index 02cb040b3..e74d65a39 100644 --- a/src/game/vmap/VMapManager2.cpp +++ b/src/game/vmap/VMapManager2.cpp @@ -160,8 +160,8 @@ namespace VMAP InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId); if (instanceTree != iInstanceMapTrees.end()) { - Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1); - Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2); + Vector3 pos1 = convertPositionToInternalRep(x1, y1, z1); + Vector3 pos2 = convertPositionToInternalRep(x2, y2, z2); if (pos1 != pos2) { result = instanceTree->second->isInLineOfSight(pos1, pos2); @@ -177,19 +177,19 @@ namespace VMAP bool VMapManager2::getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float pModifyDist) { bool result = false; - rx=x2; - ry=y2; - rz=z2; + rx = x2; + ry = y2; + rz = z2; if (isLineOfSightCalcEnabled()) { InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId); if (instanceTree != iInstanceMapTrees.end()) { - Vector3 pos1 = convertPositionToInternalRep(x1,y1,z1); - Vector3 pos2 = convertPositionToInternalRep(x2,y2,z2); + Vector3 pos1 = convertPositionToInternalRep(x1, y1, z1); + Vector3 pos2 = convertPositionToInternalRep(x2, y2, z2); Vector3 resultPos; result = instanceTree->second->getObjectHitPos(pos1, pos2, resultPos, pModifyDist); - resultPos = convertPositionToMangosRep(resultPos.x,resultPos.y,resultPos.z); + resultPos = convertPositionToMangosRep(resultPos.x, resultPos.y, resultPos.z); rx = resultPos.x; ry = resultPos.y; rz = resultPos.z; @@ -211,7 +211,7 @@ namespace VMAP InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId); if (instanceTree != iInstanceMapTrees.end()) { - Vector3 pos = convertPositionToInternalRep(x,y,z); + Vector3 pos = convertPositionToInternalRep(x, y, z); height = instanceTree->second->getHeight(pos, maxSearchDist); if (!(height < G3D::inf())) { @@ -226,7 +226,7 @@ namespace VMAP bool VMapManager2::getAreaInfo(unsigned int pMapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const { - bool result=false; + bool result = false; InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(pMapId); if (instanceTree != iInstanceMapTrees.end()) { diff --git a/src/game/vmap/WorldModel.cpp b/src/game/vmap/WorldModel.cpp index 74c13b2f9..3e98621f7 100644 --- a/src/game/vmap/WorldModel.cpp +++ b/src/game/vmap/WorldModel.cpp @@ -107,8 +107,8 @@ namespace VMAP WmoLiquid::WmoLiquid(uint32 width, uint32 height, const Vector3& corner, uint32 type): iTilesX(width), iTilesY(height), iCorner(corner), iType(type) { - iHeight = new float[(width+1)*(height+1)]; - iFlags = new uint8[width*height]; + iHeight = new float[(width + 1) * (height + 1)]; + iFlags = new uint8[width * height]; } WmoLiquid::WmoLiquid(const WmoLiquid& other): iHeight(0), iFlags(0) @@ -134,8 +134,8 @@ namespace VMAP delete iFlags; if (other.iHeight) { - iHeight = new float[(iTilesX+1)*(iTilesY+1)]; - memcpy(iHeight, other.iHeight, (iTilesX+1)*(iTilesY+1)*sizeof(float)); + iHeight = new float[(iTilesX + 1) * (iTilesY + 1)]; + memcpy(iHeight, other.iHeight, (iTilesX + 1) * (iTilesY + 1)*sizeof(float)); } else iHeight = 0; @@ -151,18 +151,18 @@ namespace VMAP bool WmoLiquid::GetLiquidHeight(const Vector3& pos, float& liqHeight) const { - float tx_f = (pos.x - iCorner.x)/LIQUID_TILE_SIZE; + float tx_f = (pos.x - iCorner.x) / LIQUID_TILE_SIZE; uint32 tx = uint32(tx_f); if (tx_f < 0.0f || tx >= iTilesX) return false; - float ty_f = (pos.y - iCorner.y)/LIQUID_TILE_SIZE; + float ty_f = (pos.y - iCorner.y) / LIQUID_TILE_SIZE; uint32 ty = uint32(ty_f); if (ty_f < 0.0f || ty >= iTilesY) 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) + if ((iFlags[tx + ty * iTilesX] & 0x0F) == 0x0F) return false; // (dx, dy) coordinates inside tile, in [0,1]^2 @@ -184,14 +184,14 @@ namespace VMAP const uint32 rowOffset = iTilesX + 1; if (dx > dy) // case (a) { - float sx = iHeight[tx+1 + ty * rowOffset] - iHeight[tx + ty * rowOffset]; - float sy = iHeight[tx+1 + (ty+1) * rowOffset] - iHeight[tx+1 + ty * rowOffset]; + float sx = iHeight[tx + 1 + ty * rowOffset] - iHeight[tx + ty * rowOffset]; + float sy = iHeight[tx + 1 + (ty + 1) * rowOffset] - iHeight[tx + 1 + ty * rowOffset]; liqHeight = iHeight[tx + ty * rowOffset] + dx * sx + dy * sy; } else // case (b) { - float sx = iHeight[tx+1 + (ty+1) * rowOffset] - iHeight[tx + (ty+1) * rowOffset]; - float sy = iHeight[tx + (ty+1) * rowOffset] - iHeight[tx + ty * rowOffset]; + float sx = iHeight[tx + 1 + (ty + 1) * rowOffset] - iHeight[tx + (ty + 1) * rowOffset]; + float sy = iHeight[tx + (ty + 1) * rowOffset] - iHeight[tx + ty * rowOffset]; liqHeight = iHeight[tx + ty * rowOffset] + dx * sx + dy * sy; } return true; @@ -201,7 +201,7 @@ namespace VMAP { return 2 * sizeof(uint32) + sizeof(Vector3) + - (iTilesX + 1)*(iTilesY + 1) * sizeof(float) + + (iTilesX + 1) * (iTilesY + 1) * sizeof(float) + iTilesX * iTilesY; } @@ -212,9 +212,9 @@ namespace VMAP if (result && fwrite(&iTilesY, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&iCorner, sizeof(Vector3), 1, wf) != 1) result = false; if (result && fwrite(&iType, sizeof(uint32), 1, wf) != 1) result = false; - uint32 size = (iTilesX + 1)*(iTilesY + 1); + uint32 size = (iTilesX + 1) * (iTilesY + 1); if (result && fwrite(iHeight, sizeof(float), size, wf) != size) result = false; - size = iTilesX*iTilesY; + size = iTilesX * iTilesY; if (result && fwrite(iFlags, sizeof(uint8), size, wf) != size) result = false; return result; } @@ -227,7 +227,7 @@ namespace VMAP if (result && fread(&liquid->iTilesY, sizeof(uint32), 1, rf) != 1) result = false; if (result && fread(&liquid->iCorner, sizeof(Vector3), 1, rf) != 1) result = false; if (result && fread(&liquid->iType, sizeof(uint32), 1, rf) != 1) result = false; - uint32 size = (liquid->iTilesX + 1)*(liquid->iTilesY + 1); + uint32 size = (liquid->iTilesX + 1) * (liquid->iTilesY + 1); liquid->iHeight = new float[size]; if (result && fread(liquid->iHeight, sizeof(float), size, rf) != size) result = false; size = liquid->iTilesX * liquid->iTilesY; @@ -269,7 +269,7 @@ namespace VMAP // write vertices if (result && fwrite("VERT", 1, 4, wf) != 4) result = false; count = vertices.size(); - chunkSize = sizeof(uint32)+ sizeof(Vector3)*count; + chunkSize = sizeof(uint32) + sizeof(Vector3) * count; 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 @@ -279,7 +279,7 @@ namespace VMAP // write triangle mesh if (result && fwrite("TRIM", 1, 4, wf) != 4) result = false; count = triangles.size(); - chunkSize = sizeof(uint32)+ sizeof(MeshTriangle)*count; + chunkSize = sizeof(uint32) + sizeof(MeshTriangle) * count; if (result && fwrite(&chunkSize, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&count, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&triangles[0], sizeof(MeshTriangle), count, wf) != count) result = false; @@ -352,7 +352,7 @@ namespace VMAP bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit) { bool result = IntersectTriangle(triangles[entry], vertices, ray, distance); - if (result) hit=true; + if (result) hit = true; return hit; } std::vector::const_iterator vertices; @@ -412,7 +412,7 @@ namespace VMAP bool operator()(const G3D::Ray& ray, uint32 entry, float& distance, bool pStopAtFirstHit) { bool result = models[entry].IntersectRay(ray, distance, pStopAtFirstHit); - if (result) hit=true; + if (result) hit = true; return hit; } std::vector::const_iterator models; @@ -510,21 +510,21 @@ namespace VMAP bool result = true; uint32 chunkSize, count; - result = fwrite(VMAP_MAGIC,1,8,wf) == 8; + result = fwrite(VMAP_MAGIC, 1, 8, wf) == 8; if (result && fwrite("WMOD", 1, 4, wf) != 4) result = false; chunkSize = sizeof(uint32) + sizeof(uint32); if (result && fwrite(&chunkSize, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&RootWMOID, sizeof(uint32), 1, wf) != 1) result = false; // write group models - count=groupModels.size(); + count = groupModels.size(); if (count) { if (result && fwrite("GMOD", 1, 4, wf) != 4) result = false; //chunkSize = sizeof(uint32)+ sizeof(GroupModel)*count; //if (result && fwrite(&chunkSize, sizeof(uint32), 1, wf) != 1) result = false; if (result && fwrite(&count, sizeof(uint32), 1, wf) != 1) result = false; - for (uint32 i=0; i"); continue; diff --git a/src/mangosd/MaNGOSsoap.cpp b/src/mangosd/MaNGOSsoap.cpp index 14f63f868..01f392727 100644 --- a/src/mangosd/MaNGOSsoap.cpp +++ b/src/mangosd/MaNGOSsoap.cpp @@ -56,7 +56,7 @@ void MaNGOSsoapRunnable::run() continue; } - DEBUG_LOG("MaNGOSsoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF); + DEBUG_LOG("MaNGOSsoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF); struct soap* thread_soap = soap_copy(&soap);// make a safe copy ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*)); diff --git a/src/mangosd/Main.cpp b/src/mangosd/Main.cpp index e4fc62983..071e2cfdc 100644 --- a/src/mangosd/Main.cpp +++ b/src/mangosd/Main.cpp @@ -74,7 +74,7 @@ void usage(const char* prog) " -s run run as daemon\n\r" " -s stop stop daemon\n\r" #endif - ,prog); + , prog); } /// Launch the mangos server @@ -104,7 +104,7 @@ extern int main(int argc, char** argv) cfg_file = cmd_opts.opt_arg(); break; case 'v': - printf("%s\n", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID)); + printf("%s\n", _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID)); return 0; case 's': { @@ -179,7 +179,7 @@ extern int main(int argc, char** argv) } #endif - sLog.outString("%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID)); + sLog.outString("%s [world-daemon]", _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID)); sLog.outString(" to stop."); sLog.outString("\n\n" "MM MM MM MM MMMMM MMMM MMMMM\n" diff --git a/src/mangosd/Master.cpp b/src/mangosd/Master.cpp index 7f3e44ec8..3b0a039c3 100644 --- a/src/mangosd/Master.cpp +++ b/src/mangosd/Master.cpp @@ -69,7 +69,7 @@ class FreezeDetectorRunnable : public ACE_Based::Runnable { if (!_delaytime) return; - sLog.outString("Starting up anti-freeze thread (%u seconds max stuck time)...",_delaytime/1000); + sLog.outString("Starting up anti-freeze thread (%u seconds max stuck time)...", _delaytime / 1000); m_loops = 0; w_loops = 0; m_lastchange = 0; @@ -253,20 +253,20 @@ int Master::Run() ULONG_PTR appAff; ULONG_PTR sysAff; - if (GetProcessAffinityMask(hProcess,&appAff,&sysAff)) + if (GetProcessAffinityMask(hProcess, &appAff, &sysAff)) { ULONG_PTR curAff = Aff & appAff; // remove non accessible processors if (!curAff) { - sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for mangosd. Accessible processors bitmask (hex): %x",Aff,appAff); + sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for mangosd. Accessible processors bitmask (hex): %x", Aff, appAff); } else { - if (SetProcessAffinityMask(hProcess,curAff)) + if (SetProcessAffinityMask(hProcess, curAff)) sLog.outString("Using processors (bitmask, hex): %x", curAff); else - sLog.outError("Can't set used processors (hex): %x",curAff); + sLog.outError("Can't set used processors (hex): %x", curAff); } } sLog.outString(); @@ -277,7 +277,7 @@ int Master::Run() // if(Prio && (m_ServiceStatus == -1)/* need set to default process priority class in service mode*/) if (Prio) { - if (SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS)) + if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS)) sLog.outString("mangosd process priority class set to HIGH"); else sLog.outError("Can't set mangosd process priority class."); @@ -302,7 +302,7 @@ int Master::Run() if (uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0)) { FreezeDetectorRunnable* fdr = new FreezeDetectorRunnable(); - fdr->SetDelayTime(freeze_delay*1000); + fdr->SetDelayTime(freeze_delay * 1000); freeze_thread = new ACE_Based::Thread(fdr); freeze_thread->setPriority(ACE_Based::Highest); } @@ -436,11 +436,11 @@ bool Master::_StartDB() ///- Initialise the world database if (!WorldDatabase.Initialize(dbstring.c_str(), nConnections)) { - sLog.outError("Cannot connect to world database %s",dbstring.c_str()); + sLog.outError("Cannot connect to world database %s", dbstring.c_str()); return false; } - if (!WorldDatabase.CheckRequiredField("db_version",REVISION_DB_MANGOS)) + if (!WorldDatabase.CheckRequiredField("db_version", REVISION_DB_MANGOS)) { ///- Wait for already started DB delay threads to end WorldDatabase.HaltDelayThread(); @@ -462,14 +462,14 @@ bool Master::_StartDB() ///- Initialise the Character database if (!CharacterDatabase.Initialize(dbstring.c_str(), nConnections)) { - sLog.outError("Cannot connect to Character database %s",dbstring.c_str()); + sLog.outError("Cannot connect to Character database %s", dbstring.c_str()); ///- Wait for already started DB delay threads to end WorldDatabase.HaltDelayThread(); return false; } - if (!CharacterDatabase.CheckRequiredField("character_db_version",REVISION_DB_CHARACTERS)) + if (!CharacterDatabase.CheckRequiredField("character_db_version", REVISION_DB_CHARACTERS)) { ///- Wait for already started DB delay threads to end WorldDatabase.HaltDelayThread(); @@ -494,7 +494,7 @@ bool Master::_StartDB() sLog.outString("Login Database total connections: %i", nConnections + 1); if (!LoginDatabase.Initialize(dbstring.c_str(), nConnections)) { - sLog.outError("Cannot connect to login database %s",dbstring.c_str()); + sLog.outError("Cannot connect to login database %s", dbstring.c_str()); ///- Wait for already started DB delay threads to end WorldDatabase.HaltDelayThread(); @@ -502,7 +502,7 @@ bool Master::_StartDB() return false; } - if (!LoginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD)) + if (!LoginDatabase.CheckRequiredField("realmd_db_version", REVISION_DB_REALMD)) { ///- Wait for already started DB delay threads to end WorldDatabase.HaltDelayThread(); diff --git a/src/mangosd/RASocket.cpp b/src/mangosd/RASocket.cpp index 91c7cc572..a44f6f80b 100644 --- a/src/mangosd/RASocket.cpp +++ b/src/mangosd/RASocket.cpp @@ -33,12 +33,12 @@ /// RASocket constructor RASocket::RASocket() - :RAHandler(), - pendingCommands(0, USYNC_THREAD, "pendingCommands"), - outActive(false), - inputBufferLen(0), - outputBufferLen(0), - stage(NONE) + : RAHandler(), + pendingCommands(0, USYNC_THREAD, "pendingCommands"), + outActive(false), + inputBufferLen(0), + outputBufferLen(0), + stage(NONE) { ///- Get the config parameters bSecure = sConfig.GetBoolDefault("RA.Secure", true); @@ -72,7 +72,7 @@ int RASocket::open(void*) } - sLog.outRALog("Incoming connection from %s.",remote_addr.get_host_addr()); + sLog.outRALog("Incoming connection from %s.", remote_addr.get_host_addr()); ///- print Motd sendf(sWorld.GetMotd()); @@ -133,10 +133,10 @@ int RASocket::handle_output(ACE_HANDLE) ssize_t n = peer().send(outputBuffer, outputBufferLen); #endif // MSG_NOSIGNAL - if (n<=0) + if (n <= 0) return -1; - ACE_OS::memmove(outputBuffer, outputBuffer+n, outputBufferLen-n); + ACE_OS::memmove(outputBuffer, outputBuffer + n, outputBufferLen - n); outputBufferLen -= n; @@ -153,7 +153,7 @@ int RASocket::handle_input(ACE_HANDLE) return -1; } - size_t readBytes = peer().recv(inputBuffer+inputBufferLen, RA_BUFF_SIZE-inputBufferLen-1); + size_t readBytes = peer().recv(inputBuffer + inputBufferLen, RA_BUFF_SIZE - inputBufferLen - 1); if (readBytes <= 0) { @@ -162,13 +162,13 @@ int RASocket::handle_input(ACE_HANDLE) } ///- Discard data after line break or line feed - bool gotenter=false; + bool gotenter = false; for (; readBytes > 0 ; --readBytes) { char c = inputBuffer[inputBufferLen]; - if (c=='\r'|| c=='\n') + if (c == '\r' || c == '\n') { - gotenter=true; + gotenter = true; break; } ++inputBufferLen; @@ -176,14 +176,14 @@ int RASocket::handle_input(ACE_HANDLE) if (gotenter) { - inputBuffer[inputBufferLen]=0; - inputBufferLen=0; + inputBuffer[inputBufferLen] = 0; + inputBufferLen = 0; switch (stage) { ///
  • If the input is '' case NONE: { - std::string szLogin=inputBuffer; + std::string szLogin = inputBuffer; accId = sAccountMgr.GetId(szLogin); @@ -191,7 +191,7 @@ int RASocket::handle_input(ACE_HANDLE) if (!accId) { sendf("-No such user.\r\n"); - sLog.outRALog("User %s does not exist.",szLogin.c_str()); + sLog.outRALog("User %s does not exist.", szLogin.c_str()); if (bSecure) { handle_output(); @@ -208,7 +208,7 @@ int RASocket::handle_input(ACE_HANDLE) if (accAccessLevel < iMinLevel) { sendf("-Not enough privileges.\r\n"); - sLog.outRALog("User %s has no privilege.",szLogin.c_str()); + sLog.outRALog("User %s has no privilege.", szLogin.c_str()); if (bSecure) { handle_output(); @@ -223,7 +223,7 @@ int RASocket::handle_input(ACE_HANDLE) if (accAccessLevel >= SEC_ADMINISTRATOR && !bStricted) accAccessLevel = SEC_CONSOLE; - stage=LG; + stage = LG; sendf(sObjectMgr.GetMangosStringForDBCLocale(LANG_RA_PASS)); break; } @@ -235,7 +235,7 @@ int RASocket::handle_input(ACE_HANDLE) if (sAccountMgr.CheckPassword(accId, pw)) { - stage=OK; + stage = OK; sendf("+Logged in.\r\n"); sLog.outRALog("User account %u has logged in.", accId); @@ -260,8 +260,8 @@ int RASocket::handle_input(ACE_HANDLE) case OK: if (strlen(inputBuffer)) { - sLog.outRALog("Got '%s' cmd.",inputBuffer); - if (strncmp(inputBuffer,"quit",4)==0) + sLog.outRALog("Got '%s' cmd.", inputBuffer); + if (strncmp(inputBuffer, "quit", 4) == 0) return -1; else { @@ -306,10 +306,10 @@ int RASocket::sendf(const char* msg) int msgLen = strlen(msg); - if (msgLen+outputBufferLen > RA_BUFF_SIZE) + if (msgLen + outputBufferLen > RA_BUFF_SIZE) return -1; - ACE_OS::memcpy(outputBuffer+outputBufferLen, msg, msgLen); + ACE_OS::memcpy(outputBuffer + outputBufferLen, msg, msgLen); outputBufferLen += msgLen; if (!outActive) diff --git a/src/mangosd/WorldRunnable.cpp b/src/mangosd/WorldRunnable.cpp index c9f5b599f..c2a586004 100644 --- a/src/mangosd/WorldRunnable.cpp +++ b/src/mangosd/WorldRunnable.cpp @@ -64,9 +64,9 @@ void WorldRunnable::run() // we want that next d1 + t1 == WORLD_SLEEP_CONST // we can't know next t1 and then can use (t0 + d1) == WORLD_SLEEP_CONST requirement // d1 = WORLD_SLEEP_CONST - t0 = WORLD_SLEEP_CONST - (D0 - d0) = WORLD_SLEEP_CONST + d0 - D0 - if (diff <= WORLD_SLEEP_CONST+prevSleepTime) + if (diff <= WORLD_SLEEP_CONST + prevSleepTime) { - prevSleepTime = WORLD_SLEEP_CONST+prevSleepTime-diff; + prevSleepTime = WORLD_SLEEP_CONST + prevSleepTime - diff; ACE_Based::Thread::Sleep(prevSleepTime); } else diff --git a/src/mangosd/soapC.cpp b/src/mangosd/soapC.cpp index 87156be18..f834f6a79 100644 --- a/src/mangosd/soapC.cpp +++ b/src/mangosd/soapC.cpp @@ -162,7 +162,7 @@ extern "C" { if (soap_peek_element(soap)) return NULL; if (!*soap->id || !(*type = soap_lookup_type(soap, soap->id))) - *type = soap_lookup_type(soap, soap->href); + * type = soap_lookup_type(soap, soap->href); switch (*type) { case SOAP_TYPE_byte: @@ -301,9 +301,9 @@ extern "C" { case SOAP_TYPE_PointerTostring: return soap_out_PointerTostring(soap, tag, id, (char** const*)ptr, "xsd:string"); case SOAP_TYPE__QName: - return soap_out_string(soap, "xsd:QName", id, (char*const*)&ptr, NULL); + return soap_out_string(soap, "xsd:QName", id, (char * const*)&ptr, NULL); case SOAP_TYPE_string: - return soap_out_string(soap, tag, id, (char*const*)&ptr, "xsd:string"); + return soap_out_string(soap, tag, id, (char * const*)&ptr, "xsd:string"); } return SOAP_OK; } @@ -333,10 +333,10 @@ extern "C" { soap_serialize_PointerTostring(soap, (char** const*)ptr); break; case SOAP_TYPE__QName: - soap_serialize_string(soap, (char*const*)&ptr); + soap_serialize_string(soap, (char * const*)&ptr); break; case SOAP_TYPE_string: - soap_serialize_string(soap, (char*const*)&ptr); + soap_serialize_string(soap, (char * const*)&ptr); break; } } @@ -549,7 +549,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Fault(struct soap* soap, const char const char* soap_tmp_faultcode = soap_QName2s(soap, a->faultcode); if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Fault), type)) return soap->error; - if (soap_out__QName(soap, "faultcode", -1, (char*const*)&soap_tmp_faultcode, "")) + if (soap_out__QName(soap, "faultcode", -1, (char * const*)&soap_tmp_faultcode, "")) return soap->error; if (soap_out_string(soap, "faultstring", -1, &a->faultstring, "")) return soap->error; @@ -677,7 +677,7 @@ SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Fault(struct soap* soap, struct SOAP_FMAC3 struct SOAP_ENV__Fault* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Fault(struct soap* soap, int n, const char* type, const char* arrayType, size_t* size) { - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Fault(%d, %s, %s)\n", n, type ? type : "", arrayType ? arrayType : "")); struct soap_clist* cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Fault, n, soap_fdelete); if (!cp) return NULL; @@ -799,7 +799,7 @@ SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Reason(struct soap* soap, struc SOAP_FMAC3 struct SOAP_ENV__Reason* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Reason(struct soap* soap, int n, const char* type, const char* arrayType, size_t* size) { - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Reason(%d, %s, %s)\n", n, type ? type : "", arrayType ? arrayType : "")); struct soap_clist* cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Reason, n, soap_fdelete); if (!cp) return NULL; @@ -930,7 +930,7 @@ SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Detail(struct soap* soap, struc SOAP_FMAC3 struct SOAP_ENV__Detail* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Detail(struct soap* soap, int n, const char* type, const char* arrayType, size_t* size) { - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Detail(%d, %s, %s)\n", n, type ? type : "", arrayType ? arrayType : "")); struct soap_clist* cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Detail, n, soap_fdelete); if (!cp) return NULL; @@ -991,7 +991,7 @@ SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Code(struct soap* soap, const char* const char* soap_tmp_SOAP_ENV__Value = soap_QName2s(soap, a->SOAP_ENV__Value); if (soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Code), type)) return soap->error; - if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char*const*)&soap_tmp_SOAP_ENV__Value, "")) + if (soap_out__QName(soap, "SOAP-ENV:Value", -1, (char * const*)&soap_tmp_SOAP_ENV__Value, "")) return soap->error; if (soap_out_PointerToSOAP_ENV__Code(soap, "SOAP-ENV:Subcode", -1, &a->SOAP_ENV__Subcode, "")) return soap->error; @@ -1063,7 +1063,7 @@ SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Code(struct soap* soap, struct SOAP_FMAC3 struct SOAP_ENV__Code* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Code(struct soap* soap, int n, const char* type, const char* arrayType, size_t* size) { - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Code(%d, %s, %s)\n", n, type ? type : "", arrayType ? arrayType : "")); struct soap_clist* cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Code, n, soap_fdelete); if (!cp) return NULL; @@ -1174,7 +1174,7 @@ SOAP_FMAC5 void SOAP_FMAC6 soap_delete_SOAP_ENV__Header(struct soap* soap, struc SOAP_FMAC3 struct SOAP_ENV__Header* SOAP_FMAC4 soap_instantiate_SOAP_ENV__Header(struct soap* soap, int n, const char* type, const char* arrayType, size_t* size) { - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_SOAP_ENV__Header(%d, %s, %s)\n", n, type ? type : "", arrayType ? arrayType : "")); struct soap_clist* cp = soap_link(soap, NULL, SOAP_TYPE_SOAP_ENV__Header, n, soap_fdelete); if (!cp) return NULL; @@ -1294,7 +1294,7 @@ SOAP_FMAC5 void SOAP_FMAC6 soap_delete_ns1__executeCommand(struct soap* soap, st SOAP_FMAC3 struct ns1__executeCommand* SOAP_FMAC4 soap_instantiate_ns1__executeCommand(struct soap* soap, int n, const char* type, const char* arrayType, size_t* size) { - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommand(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommand(%d, %s, %s)\n", n, type ? type : "", arrayType ? arrayType : "")); struct soap_clist* cp = soap_link(soap, NULL, SOAP_TYPE_ns1__executeCommand, n, soap_fdelete); if (!cp) return NULL; @@ -1412,7 +1412,7 @@ SOAP_FMAC5 void SOAP_FMAC6 soap_delete_ns1__executeCommandResponse(struct soap* SOAP_FMAC3 struct ns1__executeCommandResponse* SOAP_FMAC4 soap_instantiate_ns1__executeCommandResponse(struct soap* soap, int n, const char* type, const char* arrayType, size_t* size) { - DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommandResponse(%d, %s, %s)\n", n, type?type:"", arrayType?arrayType:"")); + DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_instantiate_ns1__executeCommandResponse(%d, %s, %s)\n", n, type ? type : "", arrayType ? arrayType : "")); struct soap_clist* cp = soap_link(soap, NULL, SOAP_TYPE_ns1__executeCommandResponse, n, soap_fdelete); if (!cp) return NULL; diff --git a/src/realmd/AuthSocket.cpp b/src/realmd/AuthSocket.cpp index 0054080a5..7d5b5e18a 100644 --- a/src/realmd/AuthSocket.cpp +++ b/src/realmd/AuthSocket.cpp @@ -389,7 +389,7 @@ bool AuthSocket::_HandleLogonChallenge() ///- Get the account details from the account table // No SQL injection (escaped user name) - result = LoginDatabase.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel,v,s FROM account WHERE username = '%s'",_safelogin.c_str()); + result = LoginDatabase.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel,v,s FROM account WHERE username = '%s'", _safelogin.c_str()); if (result) { ///- If the IP is 'locked', check that the player comes indeed from the correct IP address @@ -398,11 +398,11 @@ bool AuthSocket::_HandleLogonChallenge() { DEBUG_LOG("[AuthChallenge] Account '%s' is locked to IP - '%s'", _login.c_str(), (*result)[3].GetString()); DEBUG_LOG("[AuthChallenge] Player address is '%s'", get_remote_address().c_str()); - if (strcmp((*result)[3].GetString(),get_remote_address().c_str())) + if (strcmp((*result)[3].GetString(), get_remote_address().c_str())) { DEBUG_LOG("[AuthChallenge] Account IP differs"); pkt << (uint8) WOW_FAIL_SUSPENDED; - locked=true; + locked = true; } else { @@ -424,12 +424,12 @@ bool AuthSocket::_HandleLogonChallenge() if ((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64()) { pkt << (uint8) WOW_FAIL_BANNED; - BASIC_LOG("[AuthChallenge] Banned account %s tries to login!",_login.c_str()); + BASIC_LOG("[AuthChallenge] Banned account %s tries to login!", _login.c_str()); } else { pkt << (uint8) WOW_FAIL_SUSPENDED; - BASIC_LOG("[AuthChallenge] Temporarily banned account %s tries to login!",_login.c_str()); + BASIC_LOG("[AuthChallenge] Temporarily banned account %s tries to login!", _login.c_str()); } delete banresult; @@ -446,7 +446,7 @@ bool AuthSocket::_HandleLogonChallenge() DEBUG_LOG("database authentication values: v='%s' s='%s'", databaseV.c_str(), databaseS.c_str()); // multiply with 2, bytes are stored as hexstring - if (databaseV.size() != s_BYTE_SIZE*2 || databaseS.size() != s_BYTE_SIZE*2) + if (databaseV.size() != s_BYTE_SIZE * 2 || databaseS.size() != s_BYTE_SIZE * 2) _SetVSFields(rI); else { @@ -502,7 +502,7 @@ bool AuthSocket::_HandleLogonChallenge() _localizationName.resize(4); for (int i = 0; i < 4; ++i) - _localizationName[i] = ch->country[4-i-1]; + _localizationName[i] = ch->country[4 - i - 1]; BASIC_LOG("[AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", _login.c_str(), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName)); } @@ -511,7 +511,7 @@ bool AuthSocket::_HandleLogonChallenge() } else // no account { - pkt<< (uint8) WOW_FAIL_UNKNOWN_ACCOUNT; + pkt << (uint8) WOW_FAIL_UNKNOWN_ACCOUNT; } } send((char const*)pkt.contents(), pkt.size()); @@ -698,13 +698,13 @@ bool AuthSocket::_HandleLogonProof() char data[2] = { CMD_AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT}; send(data, sizeof(data)); } - BASIC_LOG("[AuthChallenge] account %s tried to login with wrong password!",_login.c_str()); + BASIC_LOG("[AuthChallenge] account %s tried to login with wrong password!", _login.c_str()); uint32 MaxWrongPassCount = sConfig.GetIntDefault("WrongPass.MaxCount", 0); if (MaxWrongPassCount > 0) { //Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP - LoginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str()); + LoginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'", _safelogin.c_str()); if (QueryResult* loginfail = LoginDatabase.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str())) { @@ -798,7 +798,7 @@ bool AuthSocket::_HandleReconnectChallenge() pkt << (uint8) CMD_AUTH_RECONNECT_CHALLENGE; pkt << (uint8) 0x00; _reconnectProof.SetRand(16 * 8); - pkt.append(_reconnectProof.AsByteArray(16),16); // 16 bytes random + pkt.append(_reconnectProof.AsByteArray(16), 16); // 16 bytes random pkt << (uint64) 0x00 << (uint64) 0x00; // 16 bytes zeros send((char const*)pkt.contents(), pkt.size()); return true; @@ -859,10 +859,10 @@ bool AuthSocket::_HandleRealmList() ///- Get the user id (else close the connection) // No SQL injection (escaped user name) - QueryResult* result = LoginDatabase.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str()); + QueryResult* result = LoginDatabase.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'", _safelogin.c_str()); if (!result) { - sLog.outError("[ERROR] user %s tried to login and we cannot find him in the database.",_login.c_str()); + sLog.outError("[ERROR] user %s tried to login and we cannot find him in the database.", _login.c_str()); close_connection(); return false; } @@ -926,7 +926,7 @@ void AuthSocket::LoadRealmlist(ByteBuffer& pkt, uint32 acctid) if (realmflags & REALM_FLAG_SPECIFYBUILD) { char buf[20]; - snprintf(buf, 20," (%u,%u,%u)", buildInfo->major_version, buildInfo->minor_version, buildInfo->bugfix_version); + snprintf(buf, 20, " (%u,%u,%u)", buildInfo->major_version, buildInfo->minor_version, buildInfo->bugfix_version); name += buf; } diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index e3b68ce1d..a58635cc7 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -82,7 +82,7 @@ void usage(const char* prog) " -s run run as daemon\n\r" " -s stop stop daemon\n\r" #endif - ,prog); + , prog); } /// Launch the realm server @@ -107,7 +107,7 @@ extern int main(int argc, char** argv) cfg_file = cmd_opts.opt_arg(); break; case 'v': - printf("%s\n", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID)); + printf("%s\n", _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID)); return 0; case 's': @@ -185,7 +185,7 @@ extern int main(int argc, char** argv) sLog.Initialize(); - sLog.outString("%s [realm-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID)); + sLog.outString("%s [realm-daemon]", _FULLVERSION(REVISION_DATE, REVISION_TIME, REVISION_NR, REVISION_ID)); sLog.outString(" to stop.\n"); sLog.outString("Using configuration file %s.", cfg_file); @@ -285,17 +285,17 @@ extern int main(int argc, char** argv) ULONG_PTR appAff; ULONG_PTR sysAff; - if (GetProcessAffinityMask(hProcess,&appAff,&sysAff)) + if (GetProcessAffinityMask(hProcess, &appAff, &sysAff)) { ULONG_PTR curAff = Aff & appAff; // remove non accessible processors if (!curAff) { - sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for realmd. Accessible processors bitmask (hex): %x",Aff,appAff); + sLog.outError("Processors marked in UseProcessors bitmask (hex) %x not accessible for realmd. Accessible processors bitmask (hex): %x", Aff, appAff); } else { - if (SetProcessAffinityMask(hProcess,curAff)) + if (SetProcessAffinityMask(hProcess, curAff)) sLog.outString("Using processors (bitmask, hex): %x", curAff); else sLog.outError("Can't set used processors (hex): %x", curAff); @@ -308,7 +308,7 @@ extern int main(int argc, char** argv) if (Prio) { - if (SetPriorityClass(hProcess,HIGH_PRIORITY_CLASS)) + if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS)) sLog.outString("realmd process priority class set to HIGH"); else sLog.outError("Can't set realmd process priority class."); @@ -396,7 +396,7 @@ bool StartDB() return false; } - if (!LoginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD)) + if (!LoginDatabase.CheckRequiredField("realmd_db_version", REVISION_DB_REALMD)) { ///- Wait for already started DB delay threads to end LoginDatabase.HaltDelayThread(); diff --git a/src/realmd/PatchHandler.cpp b/src/realmd/PatchHandler.cpp index bc0af705c..05022a45a 100644 --- a/src/realmd/PatchHandler.cpp +++ b/src/realmd/PatchHandler.cpp @@ -162,7 +162,7 @@ void PatchCache::LoadPatchMD5(const char* szFileName) MD5_CTX ctx; MD5_Init(&ctx); - const size_t check_chunk_size = 4*1024; + const size_t check_chunk_size = 4 * 1024; ACE_UINT8 buf[check_chunk_size]; diff --git a/src/realmd/RealmList.cpp b/src/realmd/RealmList.cpp index e29b21f98..31c3482bd 100644 --- a/src/realmd/RealmList.cpp +++ b/src/realmd/RealmList.cpp @@ -43,8 +43,8 @@ static RealmBuildInfo ExpectedRealmdClientBuilds[] = {11159, 3, 3, 0, 'a'}, {10505, 3, 2, 2, 'a'}, {8606, 2, 4, 3, ' '}, - {6005, 1,12, 2, ' '}, - {5875, 1,12, 1, ' '}, + {6005, 1, 12, 2, ' '}, + {5875, 1, 12, 1, ' '}, {0, 0, 0, 0, ' '} // terminator }; @@ -155,14 +155,14 @@ void RealmList::UpdateRealms(bool init) uint8 realmflags = fields[5].GetUInt8(); - if (realmflags & ~(REALM_FLAG_OFFLINE|REALM_FLAG_NEW_PLAYERS|REALM_FLAG_RECOMMENDED|REALM_FLAG_SPECIFYBUILD)) + if (realmflags & ~(REALM_FLAG_OFFLINE | REALM_FLAG_NEW_PLAYERS | REALM_FLAG_RECOMMENDED | REALM_FLAG_SPECIFYBUILD)) { sLog.outError("Realm allowed have only OFFLINE Mask 0x2), or NEWPLAYERS (mask 0x20), or RECOMMENDED (mask 0x40), or SPECIFICBUILD (mask 0x04) flags in DB"); - realmflags &= (REALM_FLAG_OFFLINE|REALM_FLAG_NEW_PLAYERS|REALM_FLAG_RECOMMENDED|REALM_FLAG_SPECIFYBUILD); + realmflags &= (REALM_FLAG_OFFLINE | REALM_FLAG_NEW_PLAYERS | REALM_FLAG_RECOMMENDED | REALM_FLAG_SPECIFYBUILD); } UpdateRealm( - fields[0].GetUInt32(), fields[1].GetCppString(),fields[2].GetCppString(),fields[3].GetUInt32(), + fields[0].GetUInt32(), fields[1].GetCppString(), fields[2].GetCppString(), fields[3].GetUInt32(), fields[4].GetUInt8(), RealmFlags(realmflags), fields[6].GetUInt8(), (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), fields[8].GetFloat(), fields[9].GetCppString()); diff --git a/src/shared/Auth/BigNumber.cpp b/src/shared/Auth/BigNumber.cpp index 11f850c3e..471d00598 100644 --- a/src/shared/Auth/BigNumber.cpp +++ b/src/shared/Auth/BigNumber.cpp @@ -162,7 +162,7 @@ uint32 BigNumber::AsDword() bool BigNumber::isZero() const { - return BN_is_zero(_bn)!=0; + return BN_is_zero(_bn) != 0; } uint8* BigNumber::AsByteArray(int minSize, bool reverse) diff --git a/src/shared/ByteBuffer.h b/src/shared/ByteBuffer.h index 705c0cb65..5b266d8e2 100644 --- a/src/shared/ByteBuffer.h +++ b/src/shared/ByteBuffer.h @@ -76,10 +76,10 @@ class ByteBuffer _rpos = _wpos = 0; } - template void put(size_t pos,T value) + template void put(size_t pos, T value) { EndianConvert(value); - put(pos,(uint8*)&value,sizeof(value)); + put(pos, (uint8*)&value, sizeof(value)); } ByteBuffer& operator<<(uint8 value) @@ -384,7 +384,7 @@ class ByteBuffer void appendPackGUID(uint64 guid) { - uint8 packGUID[8+1]; + uint8 packGUID[8 + 1]; packGUID[0] = 0; size_t size = 1; for (uint8 i = 0; guid != 0; ++i) diff --git a/src/shared/Common.cpp b/src/shared/Common.cpp index 3acb03bdd..608e787d9 100644 --- a/src/shared/Common.cpp +++ b/src/shared/Common.cpp @@ -50,7 +50,7 @@ LocaleNameStr const fullLocaleNameList[] = LocaleConstant GetLocaleByName(const std::string& name) { for (LocaleNameStr const* itr = &fullLocaleNameList[0]; itr->name; ++itr) - if (name==itr->name) + if (name == itr->name) return itr->locale; return LOCALE_enUS; // including enGB case diff --git a/src/shared/Common.h b/src/shared/Common.h index 2a41baa67..1e98a2167 100644 --- a/src/shared/Common.h +++ b/src/shared/Common.h @@ -166,11 +166,11 @@ inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; } enum TimeConstants { MINUTE = 60, - HOUR = MINUTE*60, - DAY = HOUR*24, - WEEK = DAY*7, - MONTH = DAY*30, - YEAR = MONTH*12, + HOUR = MINUTE * 60, + DAY = HOUR * 24, + WEEK = DAY * 7, + MONTH = DAY * 30, + YEAR = MONTH * 12, IN_MILLISECONDS = 1000 }; diff --git a/src/shared/Database/DBCFileLoader.cpp b/src/shared/Database/DBCFileLoader.cpp index 0731429db..e31d73269 100644 --- a/src/shared/Database/DBCFileLoader.cpp +++ b/src/shared/Database/DBCFileLoader.cpp @@ -35,35 +35,35 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt) if (data) { delete [] data; - data=NULL; + data = NULL; } - FILE* f=fopen(filename,"rb"); + FILE* f = fopen(filename, "rb"); if (!f)return false; - if (fread(&header,4,1,f)!=1) // Number of records + if (fread(&header, 4, 1, f) != 1) // Number of records return false; EndianConvert(header); - if (header!=0x43424457) + if (header != 0x43424457) return false; //'WDBC' - if (fread(&recordCount,4,1,f)!=1) // Number of records + if (fread(&recordCount, 4, 1, f) != 1) // Number of records return false; EndianConvert(recordCount); - if (fread(&fieldCount,4,1,f)!=1) // Number of fields + if (fread(&fieldCount, 4, 1, f) != 1) // Number of fields return false; EndianConvert(fieldCount); - if (fread(&recordSize,4,1,f)!=1) // Size of a record + if (fread(&recordSize, 4, 1, f) != 1) // Size of a record return false; EndianConvert(recordSize); - if (fread(&stringSize,4,1,f)!=1) // String size + if (fread(&stringSize, 4, 1, f) != 1) // String size return false; EndianConvert(stringSize); @@ -79,10 +79,10 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt) fieldsOffset[i] += 4; } - data = new unsigned char[recordSize*recordCount+stringSize]; - stringTable = data + recordSize*recordCount; + data = new unsigned char[recordSize * recordCount + stringSize]; + stringTable = data + recordSize * recordCount; - if (fread(data,recordSize*recordCount+stringSize,1,f)!=1) + if (fread(data, recordSize * recordCount + stringSize, 1, f) != 1) return false; fclose(f); @@ -100,10 +100,10 @@ DBCFileLoader::~DBCFileLoader() DBCFileLoader::Record DBCFileLoader::getRecord(size_t id) { assert(data); - return Record(*this, data + id*recordSize); + return Record(*this, data + id * recordSize); } -uint32 DBCFileLoader::GetFormatRecordSize(const char* format,int32* index_pos) +uint32 DBCFileLoader::GetFormatRecordSize(const char* format, int32* index_pos) { uint32 recordsize = 0; int32 i = -1; @@ -121,10 +121,10 @@ uint32 DBCFileLoader::GetFormatRecordSize(const char* format,int32* index_pos) recordsize += sizeof(char*); break; case FT_SORT: - i=x; + i = x; break; case FT_IND: - i=x; + i = x; recordsize += sizeof(uint32); break; case FT_BYTE: @@ -162,27 +162,27 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char** */ typedef char* ptr; - if (strlen(format)!=fieldCount) + if (strlen(format) != fieldCount) return NULL; //get struct size and index pos int32 i; - uint32 recordsize=GetFormatRecordSize(format,&i); + uint32 recordsize = GetFormatRecordSize(format, &i); - if (i>=0) + if (i >= 0) { - uint32 maxi=0; + uint32 maxi = 0; //find max index - for (uint32 y=0; ymaxi)maxi=ind; + uint32 ind = getRecord(y).getUInt(i); + if (ind > maxi)maxi = ind; } ++maxi; - records=maxi; - indexTable=new ptr[maxi]; - memset(indexTable,0,maxi*sizeof(ptr)); + records = maxi; + indexTable = new ptr[maxi]; + memset(indexTable, 0, maxi * sizeof(ptr)); } else { @@ -190,38 +190,38 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char** indexTable = new ptr[recordCount]; } - char* dataTable= new char[recordCount*recordsize]; + char* dataTable = new char[recordCount * recordsize]; - uint32 offset=0; + uint32 offset = 0; - for (uint32 y =0; y < recordCount; ++y) + for (uint32 y = 0; y < recordCount; ++y) { if (i >= 0) { - indexTable[getRecord(y).getUInt(i)]=&dataTable[offset]; + indexTable[getRecord(y).getUInt(i)] = &dataTable[offset]; } else - indexTable[y]=&dataTable[offset]; + indexTable[y] = &dataTable[offset]; for (uint32 x = 0; x < fieldCount; ++x) { switch (format[x]) { case FT_FLOAT: - *((float*)(&dataTable[offset]))=getRecord(y).getFloat(x); + *((float*)(&dataTable[offset])) = getRecord(y).getFloat(x); offset += sizeof(float); break; case FT_IND: case FT_INT: - *((uint32*)(&dataTable[offset]))=getRecord(y).getUInt(x); + *((uint32*)(&dataTable[offset])) = getRecord(y).getUInt(x); offset += sizeof(uint32); break; case FT_BYTE: - *((uint8*)(&dataTable[offset]))=getRecord(y).getUInt8(x); + *((uint8*)(&dataTable[offset])) = getRecord(y).getUInt8(x); offset += sizeof(uint8); break; case FT_STRING: - *((char**)(&dataTable[offset]))=NULL; // will be replaces non-empty or "" strings in AutoProduceStrings + *((char**)(&dataTable[offset])) = NULL; // will be replaces non-empty or "" strings in AutoProduceStrings offset += sizeof(char*); break; case FT_LOGIC: @@ -243,15 +243,15 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char** char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable) { - if (strlen(format)!=fieldCount) + if (strlen(format) != fieldCount) return NULL; - char* stringPool= new char[stringSize]; - memcpy(stringPool,stringTable,stringSize); + char* stringPool = new char[stringSize]; + memcpy(stringPool, stringTable, stringSize); - uint32 offset=0; + uint32 offset = 0; - for (uint32 y =0; y < recordCount; ++y) + for (uint32 y = 0; y < recordCount; ++y) { for (uint32 x = 0; x < fieldCount; ++x) { @@ -274,7 +274,7 @@ char* DBCFileLoader::AutoProduceStrings(const char* format, char* dataTable) if (!*slot || !** slot) { const char* st = getRecord(y).getString(x); - *slot=stringPool+(st-(const char*)stringTable); + *slot = stringPool + (st - (const char*)stringTable); } offset += sizeof(char*); break; diff --git a/src/shared/Database/DBCFileLoader.h b/src/shared/Database/DBCFileLoader.h index 61ccc4331..fd77a9523 100644 --- a/src/shared/Database/DBCFileLoader.h +++ b/src/shared/Database/DBCFileLoader.h @@ -24,17 +24,17 @@ enum { - FT_NA='x', // ignore/ default, 4 byte size, in Source String means field is ignored, in Dest String means field is filled with default value - FT_NA_BYTE='X', // ignore/ default, 1 byte size, see above - FT_NA_FLOAT='F', // ignore/ default, float size, see above - FT_NA_POINTER='p', // fill default value into dest, pointer size, Use this only with static data (otherwise mem-leak) - FT_STRING='s', //char* - FT_FLOAT='f', //float - FT_INT='i', //uint32 - FT_BYTE='b', //uint8 - FT_SORT='d', //sorted by this field, field is not included - FT_IND='n', //the same,but parsed to data - FT_LOGIC='l' //Logical (boolean) + FT_NA = 'x', // ignore/ default, 4 byte size, in Source String means field is ignored, in Dest String means field is filled with default value + FT_NA_BYTE = 'X', // ignore/ default, 1 byte size, see above + FT_NA_FLOAT = 'F', // ignore/ default, float size, see above + FT_NA_POINTER = 'p', // fill default value into dest, pointer size, Use this only with static data (otherwise mem-leak) + FT_STRING = 's', //char* + FT_FLOAT = 'f', //float + FT_INT = 'i', //uint32 + FT_BYTE = 'b', //uint8 + FT_SORT = 'd', //sorted by this field, field is not included + FT_IND = 'n', //the same,but parsed to data + FT_LOGIC = 'l' //Logical (boolean) }; class DBCFileLoader @@ -51,21 +51,21 @@ class DBCFileLoader float getFloat(size_t field) const { assert(field < file.fieldCount); - float val = *reinterpret_cast(offset+file.GetOffset(field)); + float val = *reinterpret_cast(offset + file.GetOffset(field)); EndianConvert(val); return val; } uint32 getUInt(size_t field) const { assert(field < file.fieldCount); - uint32 val = *reinterpret_cast(offset+file.GetOffset(field)); + uint32 val = *reinterpret_cast(offset + file.GetOffset(field)); EndianConvert(val); return val; } uint8 getUInt8(size_t field) const { assert(field < file.fieldCount); - return *reinterpret_cast(offset+file.GetOffset(field)); + return *reinterpret_cast(offset + file.GetOffset(field)); } const char* getString(size_t field) const @@ -92,7 +92,7 @@ class DBCFileLoader uint32 GetNumRows() const { return recordCount;} uint32 GetCols() const { return fieldCount; } uint32 GetOffset(size_t id) const { return (fieldsOffset != NULL && id < fieldCount) ? fieldsOffset[id] : 0; } - bool IsLoaded() {return (data!=NULL);} + bool IsLoaded() {return (data != NULL);} char* AutoProduceData(const char* fmt, uint32& count, char**& indexTable); char* AutoProduceStrings(const char* fmt, char* dataTable); static uint32 GetFormatRecordSize(const char* format, int32* index_pos = NULL); diff --git a/src/shared/Database/DBCStore.h b/src/shared/Database/DBCStore.h index 0f2e65802..0d83b0a85 100644 --- a/src/shared/Database/DBCStore.h +++ b/src/shared/Database/DBCStore.h @@ -44,13 +44,13 @@ class DBCStorage fieldCount = dbc.GetCols(); // load raw non-string data - m_dataTable = (T*)dbc.AutoProduceData(fmt,nCount,(char**&)indexTable); + m_dataTable = (T*)dbc.AutoProduceData(fmt, nCount, (char**&)indexTable); // load strings from dbc data - m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); + m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable)); // error in dbc file at loading if NULL - return indexTable!=NULL; + return indexTable != NULL; } bool LoadStringsFrom(char const* fn) @@ -65,7 +65,7 @@ class DBCStorage return false; // load strings from another locale dbc data - m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt,(char*)m_dataTable)); + m_stringPoolList.push_back(dbc.AutoProduceStrings(fmt, (char*)m_dataTable)); return true; } diff --git a/src/shared/Database/Database.cpp b/src/shared/Database/Database.cpp index f6eac8671..27033340a 100644 --- a/src/shared/Database/Database.cpp +++ b/src/shared/Database/Database.cpp @@ -104,10 +104,10 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/) // Enable logging of SQL commands (usually only GM commands) // (See method: PExecuteLog) m_logSQL = sConfig.GetBoolDefault("LogSQL", false); - m_logsDir = sConfig.GetStringDefault("LogsDir",""); + m_logsDir = sConfig.GetStringDefault("LogsDir", ""); if (!m_logsDir.empty()) { - if ((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\')) + if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\')) m_logsDir.append("/"); } @@ -215,9 +215,9 @@ void Database::escape_string(std::string& str) if (str.empty()) return; - char* buf = new char[str.size()*2+1]; + char* buf = new char[str.size() * 2 + 1]; //we don't care what connection to use - escape string will be the same - m_pQueryConnections[0]->escape_string(buf,str.c_str(),str.size()); + m_pQueryConnections[0]->escape_string(buf, str.c_str(), str.size()); str = buf; delete[] buf; } @@ -250,7 +250,7 @@ void Database::Ping() } } -bool Database::PExecuteLog(const char* format,...) +bool Database::PExecuteLog(const char* format, ...) { if (!format) return false; @@ -261,9 +261,9 @@ bool Database::PExecuteLog(const char* format,...) int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap); va_end(ap); - if (res==-1) + if (res == -1) { - sLog.outError("SQL Query truncated (and not execute) for format: %s",format); + sLog.outError("SQL Query truncated (and not execute) for format: %s", format); return false; } @@ -272,12 +272,12 @@ bool Database::PExecuteLog(const char* format,...) time_t curr; tm local; time(&curr); // get current time_t value - local=*(localtime(&curr)); // dereference and assign + local = *(localtime(&curr)); // dereference and assign char fName[128]; - sprintf(fName, "%04d-%02d-%02d_logSQL.sql", local.tm_year+1900, local.tm_mon+1, local.tm_mday); + sprintf(fName, "%04d-%02d-%02d_logSQL.sql", local.tm_year + 1900, local.tm_mon + 1, local.tm_mday); FILE* log_file; - std::string logsDir_fname = m_logsDir+fName; + std::string logsDir_fname = m_logsDir + fName; log_file = fopen(logsDir_fname.c_str(), "a"); if (log_file) { @@ -287,14 +287,14 @@ bool Database::PExecuteLog(const char* format,...) else { // The file could not be opened - sLog.outError("SQL-Logging is disabled - Log file for the SQL commands could not be openend: %s",fName); + sLog.outError("SQL-Logging is disabled - Log file for the SQL commands could not be openend: %s", fName); } } return Execute(szQuery); } -QueryResult* Database::PQuery(const char* format,...) +QueryResult* Database::PQuery(const char* format, ...) { if (!format) return NULL; @@ -304,16 +304,16 @@ QueryResult* Database::PQuery(const char* format,...) int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap); va_end(ap); - if (res==-1) + if (res == -1) { - sLog.outError("SQL Query truncated (and not execute) for format: %s",format); + sLog.outError("SQL Query truncated (and not execute) for format: %s", format); return NULL; } return Query(szQuery); } -QueryNamedResult* Database::PQueryNamed(const char* format,...) +QueryNamedResult* Database::PQueryNamed(const char* format, ...) { if (!format) return NULL; @@ -323,9 +323,9 @@ QueryNamedResult* Database::PQueryNamed(const char* format,...) int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap); va_end(ap); - if (res==-1) + if (res == -1) { - sLog.outError("SQL Query truncated (and not execute) for format: %s",format); + sLog.outError("SQL Query truncated (and not execute) for format: %s", format); return NULL; } @@ -356,7 +356,7 @@ bool Database::Execute(const char* sql) return true; } -bool Database::PExecute(const char* format,...) +bool Database::PExecute(const char* format, ...) { if (!format) return false; @@ -367,16 +367,16 @@ bool Database::PExecute(const char* format,...) int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap); va_end(ap); - if (res==-1) + if (res == -1) { - sLog.outError("SQL Query truncated (and not execute) for format: %s",format); + sLog.outError("SQL Query truncated (and not execute) for format: %s", format); return false; } return Execute(szQuery); } -bool Database::DirectPExecute(const char* format,...) +bool Database::DirectPExecute(const char* format, ...) { if (!format) return false; @@ -387,9 +387,9 @@ bool Database::DirectPExecute(const char* format,...) int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap); va_end(ap); - if (res==-1) + if (res == -1) { - sLog.outError("SQL Query truncated (and not execute) for format: %s",format); + sLog.outError("SQL Query truncated (and not execute) for format: %s", format); return false; } @@ -459,7 +459,7 @@ bool Database::RollbackTransaction() bool Database::CheckRequiredField(char const* table_name, char const* required_name) { // check required field - QueryResult* result = PQuery("SELECT %s FROM %s LIMIT 1",required_name,table_name); + QueryResult* result = PQuery("SELECT %s FROM %s LIMIT 1", required_name, table_name); if (result) { delete result; @@ -479,16 +479,16 @@ bool Database::CheckRequiredField(char const* table_name, char const* required_n else db_name = "UNKNOWN"; - char const* req_sql_update_name = required_name+strlen("required_"); + char const* req_sql_update_name = required_name + strlen("required_"); - QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1",table_name); + QueryNamedResult* result2 = PQueryNamed("SELECT * FROM %s LIMIT 1", table_name); if (result2) { QueryFieldNames const& namesMap = result2->GetFieldNames(); std::string reqName; for (QueryFieldNames::const_iterator itr = namesMap.begin(); itr != namesMap.end(); ++itr) { - if (itr->substr(0,9)=="required_") + if (itr->substr(0, 9) == "required_") { reqName = *itr; break; @@ -497,15 +497,15 @@ bool Database::CheckRequiredField(char const* table_name, char const* required_n delete result2; - std::string cur_sql_update_name = reqName.substr(strlen("required_"),reqName.npos); + std::string cur_sql_update_name = reqName.substr(strlen("required_"), reqName.npos); if (!reqName.empty()) { - sLog.outErrorDb("The table `%s` in your [%s] database indicates that this database is out of date!",table_name,db_name); + sLog.outErrorDb("The table `%s` in your [%s] database indicates that this database is out of date!", table_name, db_name); sLog.outErrorDb(); - sLog.outErrorDb(" [A] You have: --> `%s.sql`",cur_sql_update_name.c_str()); + sLog.outErrorDb(" [A] You have: --> `%s.sql`", cur_sql_update_name.c_str()); sLog.outErrorDb(); - sLog.outErrorDb(" [B] You need: --> `%s.sql`",req_sql_update_name); + sLog.outErrorDb(" [B] You need: --> `%s.sql`", req_sql_update_name); sLog.outErrorDb(); sLog.outErrorDb("You must apply all updates after [A] to [B] to use mangos with this database."); sLog.outErrorDb("These updates are included in the sql/updates folder."); @@ -513,32 +513,32 @@ bool Database::CheckRequiredField(char const* table_name, char const* required_n } else { - sLog.outErrorDb("The table `%s` in your [%s] database is missing its version info.",table_name,db_name); + sLog.outErrorDb("The table `%s` in your [%s] database is missing its version info.", table_name, db_name); sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date."); sLog.outErrorDb(); sLog.outErrorDb("This revision of MaNGOS requires a database updated to:"); - sLog.outErrorDb("`%s.sql`",req_sql_update_name); + sLog.outErrorDb("`%s.sql`", req_sql_update_name); sLog.outErrorDb(); if (!strcmp(db_name, "WORLD")) sLog.outErrorDb("Post this error to your database provider forum or find a solution there."); else - sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name); + sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.", db_name); } } else { - sLog.outErrorDb("The table `%s` in your [%s] database is missing or corrupt.",table_name,db_name); + sLog.outErrorDb("The table `%s` in your [%s] database is missing or corrupt.", table_name, db_name); sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date."); sLog.outErrorDb(); sLog.outErrorDb("This revision of mangos requires a database updated to:"); - sLog.outErrorDb("`%s.sql`",req_sql_update_name); + sLog.outErrorDb("`%s.sql`", req_sql_update_name); sLog.outErrorDb(); if (!strcmp(db_name, "WORLD")) sLog.outErrorDb("Post this error to your database provider forum or find a solution there."); else - sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.",db_name); + sLog.outErrorDb("Reinstall your [%s] database with the included sql file in the sql folder.", db_name); } return false; diff --git a/src/shared/Database/Database.h b/src/shared/Database/Database.h index 38ed54635..da73aaac9 100644 --- a/src/shared/Database/Database.h +++ b/src/shared/Database/Database.h @@ -53,7 +53,7 @@ class MANGOS_DLL_SPEC SqlConnection virtual bool Execute(const char* sql) = 0; //escape string generation - virtual unsigned long escape_string(char* to, const char* from, unsigned long length) { strncpy(to,from,length); return length; } + virtual unsigned long escape_string(char* to, const char* from, unsigned long length) { strncpy(to, from, length); return length; } // nothing do if DB not support transactions virtual bool BeginTransaction() { return true; } @@ -124,8 +124,8 @@ class MANGOS_DLL_SPEC Database return guard->QueryNamed(sql); } - QueryResult* PQuery(const char* format,...) ATTR_PRINTF(2,3); - QueryNamedResult* PQueryNamed(const char* format,...) ATTR_PRINTF(2,3); + QueryResult* PQuery(const char* format, ...) ATTR_PRINTF(2, 3); + QueryNamedResult* PQueryNamed(const char* format, ...) ATTR_PRINTF(2, 3); inline bool DirectExecute(const char* sql) { @@ -136,7 +136,7 @@ class MANGOS_DLL_SPEC Database return guard->Execute(sql); } - bool DirectPExecute(const char* format,...) ATTR_PRINTF(2,3); + bool DirectPExecute(const char* format, ...) ATTR_PRINTF(2, 3); /// Async queries and query holders, implemented in DatabaseImpl.h @@ -158,20 +158,20 @@ class MANGOS_DLL_SPEC Database bool AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* sql); // PQuery / member template - bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format,...) ATTR_PRINTF(4,5); + bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format, ...) ATTR_PRINTF(4, 5); template - bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...) ATTR_PRINTF(5,6); + bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...) ATTR_PRINTF(5, 6); template - bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...) ATTR_PRINTF(6,7); + bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...) ATTR_PRINTF(6, 7); template - bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...) ATTR_PRINTF(7,8); + bool AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...) ATTR_PRINTF(7, 8); // PQuery / static template - bool AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...) ATTR_PRINTF(4,5); + bool AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...) ATTR_PRINTF(4, 5); template - bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...) ATTR_PRINTF(5,6); + bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...) ATTR_PRINTF(5, 6); template - bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...) ATTR_PRINTF(6,7); + bool AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...) ATTR_PRINTF(6, 7); template // QueryHolder bool DelayQueryHolder(Class* object, void (Class::*method)(QueryResult*, SqlQueryHolder*), SqlQueryHolder* holder); @@ -179,10 +179,10 @@ class MANGOS_DLL_SPEC Database bool DelayQueryHolder(Class* object, void (Class::*method)(QueryResult*, SqlQueryHolder*, ParamType1), SqlQueryHolder* holder, ParamType1 param1); bool Execute(const char* sql); - bool PExecute(const char* format,...) ATTR_PRINTF(2,3); + bool PExecute(const char* format, ...) ATTR_PRINTF(2, 3); // Writes SQL commands to a LOG file (see mangosd.conf "LogSQL") - bool PExecuteLog(const char* format,...) ATTR_PRINTF(2,3); + bool PExecuteLog(const char* format, ...) ATTR_PRINTF(2, 3); bool BeginTransaction(); bool CommitTransaction(); diff --git a/src/shared/Database/DatabaseImpl.h b/src/shared/Database/DatabaseImpl.h index 8fc9526f2..1a33116f8 100644 --- a/src/shared/Database/DatabaseImpl.h +++ b/src/shared/Database/DatabaseImpl.h @@ -107,7 +107,7 @@ Database::AsyncQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamT template bool -Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format,...) +Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const char* format, ...) { ASYNC_PQUERY_BODY(format, szQuery) return AsyncQuery(object, method, szQuery); @@ -115,7 +115,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*), const template bool -Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...) +Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...) { ASYNC_PQUERY_BODY(format, szQuery) return AsyncQuery(object, method, param1, szQuery); @@ -123,7 +123,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamTy template bool -Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...) +Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...) { ASYNC_PQUERY_BODY(format, szQuery) return AsyncQuery(object, method, param1, param2, szQuery); @@ -131,7 +131,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamTy template bool -Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...) +Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...) { ASYNC_PQUERY_BODY(format, szQuery) return AsyncQuery(object, method, param1, param2, param3, szQuery); @@ -141,7 +141,7 @@ Database::AsyncPQuery(Class* object, void (Class::*method)(QueryResult*, ParamTy template bool -Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format,...) +Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param1, const char* format, ...) { ASYNC_PQUERY_BODY(format, szQuery) return AsyncQuery(method, param1, szQuery); @@ -149,7 +149,7 @@ Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1), ParamType1 param template bool -Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format,...) +Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), ParamType1 param1, ParamType2 param2, const char* format, ...) { ASYNC_PQUERY_BODY(format, szQuery) return AsyncQuery(method, param1, param2, szQuery); @@ -157,7 +157,7 @@ Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2), Para template bool -Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format,...) +Database::AsyncPQuery(void (*method)(QueryResult*, ParamType1, ParamType2, ParamType3), ParamType1 param1, ParamType2 param2, ParamType3 param3, const char* format, ...) { ASYNC_PQUERY_BODY(format, szQuery) return AsyncQuery(method, param1, param2, param3, szQuery); diff --git a/src/shared/Database/DatabaseMysql.cpp b/src/shared/Database/DatabaseMysql.cpp index 9323da389..5423938ce 100644 --- a/src/shared/Database/DatabaseMysql.cpp +++ b/src/shared/Database/DatabaseMysql.cpp @@ -104,12 +104,12 @@ bool MySQLConnection::Initialize(const char* infoString) if (iter != tokens.end()) database = *iter++; - mysql_options(mysqlInit,MYSQL_SET_CHARSET_NAME,"utf8"); + mysql_options(mysqlInit, MYSQL_SET_CHARSET_NAME, "utf8"); #ifdef WIN32 - if (host==".") // named pipe use option (Windows) + if (host == ".") // named pipe use option (Windows) { unsigned int opt = MYSQL_PROTOCOL_PIPE; - mysql_options(mysqlInit,MYSQL_OPT_PROTOCOL,(char const*)&opt); + mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt); port = 0; unix_socket = 0; } @@ -119,10 +119,10 @@ bool MySQLConnection::Initialize(const char* infoString) unix_socket = 0; } #else - if (host==".") // socket use option (Unix/Linux) + if (host == ".") // socket use option (Unix/Linux) { unsigned int opt = MYSQL_PROTOCOL_SOCKET; - mysql_options(mysqlInit,MYSQL_OPT_PROTOCOL,(char const*)&opt); + mysql_options(mysqlInit, MYSQL_OPT_PROTOCOL, (char const*)&opt); host = "localhost"; port = 0; unix_socket = port_or_socket.c_str(); @@ -140,7 +140,7 @@ bool MySQLConnection::Initialize(const char* infoString) if (!mMysql) { sLog.outError("Could not connect to MySQL database at %s: %s\n", - host.c_str(),mysql_error(mysqlInit)); + host.c_str(), mysql_error(mysqlInit)); mysql_close(mysqlInit); return false; } @@ -189,7 +189,7 @@ bool MySQLConnection::_Query(const char* sql, MYSQL_RES** pResult, MYSQL_FIELD** } else { - DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql); + DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql); } *pResult = mysql_store_result(mMysql); @@ -216,7 +216,7 @@ QueryResult* MySQLConnection::Query(const char* sql) uint64 rowCount = 0; uint32 fieldCount = 0; - if (!_Query(sql,&result,&fields,&rowCount,&fieldCount)) + if (!_Query(sql, &result, &fields, &rowCount, &fieldCount)) return NULL; QueryResultMysql* queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount); @@ -232,7 +232,7 @@ QueryNamedResult* MySQLConnection::QueryNamed(const char* sql) uint64 rowCount = 0; uint32 fieldCount = 0; - if (!_Query(sql,&result,&fields,&rowCount,&fieldCount)) + if (!_Query(sql, &result, &fields, &rowCount, &fieldCount)) return NULL; QueryFieldNames names(fieldCount); @@ -242,7 +242,7 @@ QueryNamedResult* MySQLConnection::QueryNamed(const char* sql) QueryResultMysql* queryResult = new QueryResultMysql(result, fields, rowCount, fieldCount); queryResult->NextRow(); - return new QueryNamedResult(queryResult,names); + return new QueryNamedResult(queryResult, names); } bool MySQLConnection::Execute(const char* sql) @@ -261,7 +261,7 @@ bool MySQLConnection::Execute(const char* sql) } else { - DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql); + DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql); } // end guarded block } diff --git a/src/shared/Database/DatabasePostgre.cpp b/src/shared/Database/DatabasePostgre.cpp index 2bfb7320b..692da3013 100644 --- a/src/shared/Database/DatabasePostgre.cpp +++ b/src/shared/Database/DatabasePostgre.cpp @@ -117,7 +117,7 @@ bool PostgreSQLConnection::_Query(const char* sql, PGresult** pResult, uint64* p } else { - DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql); + DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql); } *pRowCount = PQntuples(*pResult); @@ -142,7 +142,7 @@ QueryResult* PostgreSQLConnection::Query(const char* sql) uint64 rowCount = 0; uint32 fieldCount = 0; - if (!_Query(sql,&result,&rowCount,&fieldCount)) + if (!_Query(sql, &result, &rowCount, &fieldCount)) return NULL; QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount); @@ -160,7 +160,7 @@ QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql) uint64 rowCount = 0; uint32 fieldCount = 0; - if (!_Query(sql,&result,&rowCount,&fieldCount)) + if (!_Query(sql, &result, &rowCount, &fieldCount)) return NULL; QueryFieldNames names(fieldCount); @@ -170,7 +170,7 @@ QueryNamedResult* PostgreSQLConnection::QueryNamed(const char* sql) QueryResultPostgre* queryResult = new QueryResultPostgre(result, rowCount, fieldCount); queryResult->NextRow(); - return new QueryNamedResult(queryResult,names); + return new QueryNamedResult(queryResult, names); } bool PostgreSQLConnection::Execute(const char* sql) @@ -189,7 +189,7 @@ bool PostgreSQLConnection::Execute(const char* sql) } else { - DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s,WorldTimer::getMSTime()), sql); + DEBUG_FILTER_LOG(LOG_FILTER_SQL_TEXT, "[%u ms] SQL: %s", WorldTimer::getMSTimeDiff(_s, WorldTimer::getMSTime()), sql); } PQclear(res); diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index 1ec2378af..36dcf8d22 100644 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -57,7 +57,7 @@ class Field uint64 GetUInt64() const { uint64 value = 0; - if (!mValue || sscanf(mValue,UI64FMTD,&value) == -1) + if (!mValue || sscanf(mValue, UI64FMTD, &value) == -1) return 0; return value; diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index b17de4689..48996c550 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -36,7 +36,7 @@ void SQLStorage::EraseEntry(uint32 id) case FT_STRING: { if (pIndex[id]) - delete [] *(char**)((char*)(pIndex[id])+offset); + delete [] *(char**)((char*)(pIndex[id]) + offset); offset += sizeof(char*); break; @@ -81,7 +81,7 @@ void SQLStorage::Free() { for (uint32 y = 0; y < MaxEntry; ++y) if (pIndex[y]) - delete [] *(char**)((char*)(pIndex[y])+offset); + delete [] *(char**)((char*)(pIndex[y]) + offset); offset += sizeof(char*); break; diff --git a/src/shared/Database/SQLStorage.h b/src/shared/Database/SQLStorage.h index 80f707415..3f8fdb4d4 100644 --- a/src/shared/Database/SQLStorage.h +++ b/src/shared/Database/SQLStorage.h @@ -71,7 +71,7 @@ class SQLStorage void init(const char* _entry_field, const char* sqlname) { entry_field = _entry_field; - table=sqlname; + table = sqlname; data = NULL; pIndex = NULL; iNumFields = strlen(src_format); diff --git a/src/shared/Database/SQLStorageImpl.h b/src/shared/Database/SQLStorageImpl.h index 7743837a0..66bb816c5 100644 --- a/src/shared/Database/SQLStorageImpl.h +++ b/src/shared/Database/SQLStorageImpl.h @@ -84,35 +84,35 @@ void SQLStorageLoaderBase::storeValue(V value, SQLStorage& store, char* p, ui { case FT_LOGIC: subclass->convert(x, value, *((bool*)(&p[offset]))); - offset+=sizeof(bool); + offset += sizeof(bool); break; case FT_BYTE: subclass->convert(x, value, *((char*)(&p[offset]))); - offset+=sizeof(char); + offset += sizeof(char); break; case FT_INT: subclass->convert(x, value, *((uint32*)(&p[offset]))); - offset+=sizeof(uint32); + offset += sizeof(uint32); break; case FT_FLOAT: subclass->convert(x, value, *((float*)(&p[offset]))); - offset+=sizeof(float); + offset += sizeof(float); break; case FT_STRING: subclass->convert_to_str(x, value, *((char**)(&p[offset]))); - offset+=sizeof(char*); + offset += sizeof(char*); break; case FT_NA: subclass->default_fill(x, value, *((int32*)(&p[offset]))); - offset+=sizeof(uint32); + offset += sizeof(uint32); break; case FT_NA_BYTE: subclass->default_fill(x, value, *((char*)(&p[offset]))); - offset+=sizeof(char); + offset += sizeof(char); break; case FT_NA_FLOAT: subclass->default_fill(x, value, *((float*)(&p[offset]))); - offset+=sizeof(float); + offset += sizeof(float); break; case FT_IND: case FT_SORT: @@ -132,7 +132,7 @@ void SQLStorageLoaderBase::storeValue(char const* value, SQLStorage& store, c { case FT_LOGIC: subclass->convert_from_str(x, value, *((bool*)(&p[offset]))); - offset+=sizeof(bool); + offset += sizeof(bool); break; case FT_BYTE: subclass->convert_from_str(x, value, *((char*)(&p[offset]))); @@ -177,7 +177,7 @@ void SQLStorageLoaderBase::Load(SQLStorage& store, bool error_at_empty /*= tr exit(1); // Stop server at loading non exited table or not accessable table } - maxi = (*result)[0].GetUInt32()+1; + maxi = (*result)[0].GetUInt32() + 1; delete result; result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s", store.table); @@ -249,9 +249,9 @@ void SQLStorageLoaderBase::Load(SQLStorage& store, bool error_at_empty /*= tr } char** newIndex = new char*[maxi]; - memset(newIndex, 0, maxi*sizeof(char*)); + memset(newIndex, 0, maxi * sizeof(char*)); - char* _data= new char[store.RecordCount * recordsize]; + char* _data = new char[store.RecordCount * recordsize]; uint32 count = 0; BarGoLink bar(store.RecordCount); do diff --git a/src/shared/Database/SqlOperations.cpp b/src/shared/Database/SqlOperations.cpp index e5300672a..3c2b949a3 100644 --- a/src/shared/Database/SqlOperations.cpp +++ b/src/shared/Database/SqlOperations.cpp @@ -130,7 +130,7 @@ bool SqlQueryHolder::SetQuery(size_t index, const char* sql) if (m_queries[index].first != NULL) { sLog.outError("Attempt assign query to holder index (" SIZEFMTD ") where other query stored (Old: [%s] New: [%s])", - index,m_queries[index].first,sql); + index, m_queries[index].first, sql); return false; } @@ -143,7 +143,7 @@ bool SqlQueryHolder::SetPQuery(size_t index, const char* format, ...) { if (!format) { - sLog.outError("Query (index: " SIZEFMTD ") is empty.",index); + sLog.outError("Query (index: " SIZEFMTD ") is empty.", index); return false; } @@ -153,13 +153,13 @@ bool SqlQueryHolder::SetPQuery(size_t index, const char* format, ...) int res = vsnprintf(szQuery, MAX_QUERY_LEN, format, ap); va_end(ap); - if (res==-1) + if (res == -1) { - sLog.outError("SQL Query truncated (and not execute) for format: %s",format); + sLog.outError("SQL Query truncated (and not execute) for format: %s", format); return false; } - return SetQuery(index,szQuery); + return SetQuery(index, szQuery); } QueryResult* SqlQueryHolder::GetResult(size_t index) diff --git a/src/shared/Database/SqlOperations.h b/src/shared/Database/SqlOperations.h index cd9904671..369d613d8 100644 --- a/src/shared/Database/SqlOperations.h +++ b/src/shared/Database/SqlOperations.h @@ -118,7 +118,7 @@ class SqlQueryHolder SqlQueryHolder() {} ~SqlQueryHolder(); bool SetQuery(size_t index, const char* sql); - bool SetPQuery(size_t index, const char* format, ...) ATTR_PRINTF(3,4); + bool SetPQuery(size_t index, const char* format, ...) ATTR_PRINTF(3, 4); void SetSize(size_t size); QueryResult* GetResult(size_t index); void SetResult(size_t index, QueryResult* result); diff --git a/src/shared/LockedQueue.h b/src/shared/LockedQueue.h index 7a22736b2..b0e33511a 100644 --- a/src/shared/LockedQueue.h +++ b/src/shared/LockedQueue.h @@ -27,7 +27,7 @@ namespace ACE_Based { - template > + template > class LockedQueue { //! Lock access to the queue. diff --git a/src/shared/Log.cpp b/src/shared/Log.cpp index 8d38eb95b..2ccb8ce36 100644 --- a/src/shared/Log.cpp +++ b/src/shared/Log.cpp @@ -61,7 +61,7 @@ enum LogType LogError }; -const int LogType_count = int(LogError) +1; +const int LogType_count = int(LogError) + 1; Log::Log() : raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL), @@ -134,21 +134,21 @@ void Log::SetColor(bool stdout_stream, Color color) enum ANSITextAttr { - TA_NORMAL=0, - TA_BOLD=1, - TA_BLINK=5, - TA_REVERSE=7 + TA_NORMAL = 0, + TA_BOLD = 1, + TA_BLINK = 5, + TA_REVERSE = 7 }; enum ANSIFgTextAttr { - FG_BLACK=30, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, + FG_BLACK = 30, FG_RED, FG_GREEN, FG_BROWN, FG_BLUE, FG_MAGENTA, FG_CYAN, FG_WHITE, FG_YELLOW }; enum ANSIBgTextAttr { - BG_BLACK=40, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, + BG_BLACK = 40, BG_RED, BG_GREEN, BG_BROWN, BG_BLUE, BG_MAGENTA, BG_CYAN, BG_WHITE }; @@ -171,7 +171,7 @@ void Log::SetColor(bool stdout_stream, Color color) FG_WHITE // LWHITE }; - fprintf((stdout_stream? stdout : stderr), "\x1b[%d%sm",UnixColorFG[color],(color>=YELLOW&&color= YELLOW && color < Color_count ? ";1" : "")); #endif } @@ -187,7 +187,7 @@ void Log::ResetColor(bool stdout_stream) void Log::SetLogLevel(char* level) { - int32 newLevel =atoi((char*)level); + int32 newLevel = atoi((char*)level); if (newLevel < LOG_LVL_MINIMAL) newLevel = LOG_LVL_MINIMAL; @@ -201,7 +201,7 @@ void Log::SetLogLevel(char* level) void Log::SetLogFileLevel(char* level) { - int32 newLevel =atoi((char*)level); + int32 newLevel = atoi((char*)level); if (newLevel < LOG_LVL_MINIMAL) newLevel = LOG_LVL_MINIMAL; @@ -216,36 +216,36 @@ void Log::SetLogFileLevel(char* level) void Log::Initialize() { /// Common log files data - m_logsDir = sConfig.GetStringDefault("LogsDir",""); + m_logsDir = sConfig.GetStringDefault("LogsDir", ""); if (!m_logsDir.empty()) { - if ((m_logsDir.at(m_logsDir.length()-1)!='/') && (m_logsDir.at(m_logsDir.length()-1)!='\\')) + if ((m_logsDir.at(m_logsDir.length() - 1) != '/') && (m_logsDir.at(m_logsDir.length() - 1) != '\\')) m_logsDir.append("/"); } m_logsTimestamp = "_" + GetTimestampStr(); /// Open specific log files - logfile = openLogFile("LogFile","LogTimestamp","w"); + logfile = openLogFile("LogFile", "LogTimestamp", "w"); - m_gmlog_per_account = sConfig.GetBoolDefault("GmLogPerAccount",false); + 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 m_gmlog_filename_format = sConfig.GetStringDefault("GMLogFile", ""); if (!m_gmlog_filename_format.empty()) { - bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp",false); + bool m_gmlog_timestamp = sConfig.GetBoolDefault("GmLogTimestamp", false); size_t dot_pos = m_gmlog_filename_format.find_last_of("."); - if (dot_pos!=m_gmlog_filename_format.npos) + 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"); + m_gmlog_filename_format.insert(dot_pos, "_#%u"); } else { @@ -259,10 +259,10 @@ void Log::Initialize() } } - charLogfile = openLogFile("CharLogFile","CharLogTimestamp","a"); - dberLogfile = openLogFile("DBErrorLogFile",NULL,"a"); - raLogfile = openLogFile("RaLogFile",NULL,"a"); - worldLogfile = openLogFile("WorldLogFile","WorldLogTimestamp","a"); + charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a"); + dberLogfile = openLogFile("DBErrorLogFile", NULL, "a"); + raLogfile = openLogFile("RaLogFile", NULL, "a"); + worldLogfile = openLogFile("WorldLogFile", "WorldLogTimestamp", "a"); // Main log file settings m_includeTime = sConfig.GetBoolDefault("LogTime", false); @@ -280,22 +280,22 @@ void Log::Initialize() m_charLog_Dump = sConfig.GetBoolDefault("CharLogDump", false); } -FILE* Log::openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode) +FILE* Log::openLogFile(char const* configFileName, char const* configTimeStampFlag, char const* mode) { - std::string logfn=sConfig.GetStringDefault(configFileName, ""); + std::string logfn = sConfig.GetStringDefault(configFileName, ""); if (logfn.empty()) return NULL; - if (configTimeStampFlag && sConfig.GetBoolDefault(configTimeStampFlag,false)) + 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); + if (dot_pos != logfn.npos) + logfn.insert(dot_pos, m_logsTimestamp); else logfn += m_logsTimestamp; } - return fopen((m_logsDir+logfn).c_str(), mode); + return fopen((m_logsDir + logfn).c_str(), mode); } FILE* Log::openGmlogPerAccount(uint32 account) @@ -304,7 +304,7 @@ FILE* Log::openGmlogPerAccount(uint32 account) return NULL; char namebuf[MANGOS_PATH_MAX]; - snprintf(namebuf,MANGOS_PATH_MAX,m_gmlog_filename_format.c_str(),account); + snprintf(namebuf, MANGOS_PATH_MAX, m_gmlog_filename_format.c_str(), account); return fopen(namebuf, "a"); } @@ -318,7 +318,7 @@ void Log::outTimestamp(FILE* file) // HH hour (2 digits 00-23) // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) - fprintf(file,"%-4d-%02d-%02d %02d:%02d:%02d ",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + fprintf(file, "%-4d-%02d-%02d %02d:%02d:%02d ", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec); } void Log::outTime() @@ -331,7 +331,7 @@ void Log::outTime() // HH hour (2 digits 00-23) // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) - printf("%02d:%02d:%02d ",aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + printf("%02d:%02d:%02d ", aTm->tm_hour, aTm->tm_min, aTm->tm_sec); } std::string Log::GetTimestampStr() @@ -345,7 +345,7 @@ std::string Log::GetTimestampStr() // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) char buf[20]; - snprintf(buf,20,"%04d-%02d-%02d_%02d-%02d-%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + snprintf(buf, 20, "%04d-%02d-%02d_%02d-%02d-%02d", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec); return std::string(buf); } @@ -370,7 +370,7 @@ void Log::outString(const char* str, ...) return; if (m_colored) - SetColor(true,m_colors[LogNormal]); + SetColor(true, m_colors[LogNormal]); if (m_includeTime) outTime(); @@ -407,7 +407,7 @@ void Log::outError(const char* err, ...) return; if (m_colored) - SetColor(false,m_colors[LogError]); + SetColor(false, m_colors[LogError]); if (m_includeTime) outTime(); @@ -468,7 +468,7 @@ void Log::outErrorDb(const char* err, ...) return; if (m_colored) - SetColor(false,m_colors[LogError]); + SetColor(false, m_colors[LogError]); if (m_includeTime) outTime(); @@ -521,7 +521,7 @@ void Log::outBasic(const char* str, ...) if (m_logLevel >= LOG_LVL_BASIC) { if (m_colored) - SetColor(true,m_colors[LogDetails]); + SetColor(true, m_colors[LogDetails]); if (m_includeTime) outTime(); @@ -560,7 +560,7 @@ void Log::outDetail(const char* str, ...) { if (m_colored) - SetColor(true,m_colors[LogDetails]); + SetColor(true, m_colors[LogDetails]); if (m_includeTime) outTime(); @@ -600,7 +600,7 @@ void Log::outDebug(const char* str, ...) if (m_logLevel >= LOG_LVL_DEBUG) { if (m_colored) - SetColor(true,m_colors[LogDebug]); + SetColor(true, m_colors[LogDebug]); if (m_includeTime) outTime(); @@ -640,7 +640,7 @@ void Log::outCommand(uint32 account, const char* str, ...) if (m_logLevel >= LOG_LVL_DETAIL) { if (m_colored) - SetColor(true,m_colors[LogDetails]); + SetColor(true, m_colors[LogDetails]); if (m_includeTime) outTime(); @@ -719,7 +719,7 @@ void Log::outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeNam outTimestamp(worldLogfile); - fprintf(worldLogfile,"\n%s:\nSOCKET: %u\nLENGTH: " SIZEFMTD "\nOPCODE: %s (0x%.4X)\nDATA:\n", + fprintf(worldLogfile, "\n%s:\nSOCKET: %u\nLENGTH: " SIZEFMTD "\nOPCODE: %s (0x%.4X)\nDATA:\n", incoming ? "CLIENT" : "SERVER", socket, packet->size(), opcodeName, opcode); @@ -740,7 +740,7 @@ void Log::outCharDump(const char* str, uint32 account_id, uint32 guid, const cha { if (charLogfile) { - fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n",account_id,guid,name,str); + fprintf(charLogfile, "== START DUMP == (account: %u guid: %u name: %s )\n%s\n== END DUMP ==\n", account_id, guid, name, str); fflush(charLogfile); } } @@ -766,7 +766,7 @@ void Log::outRALog(const char* str, ...) void Log::WaitBeforeContinueIfNeed() { - int mode = sConfig.GetIntDefault("WaitAtStartupError",0); + int mode = sConfig.GetIntDefault("WaitAtStartupError", 0); if (mode < 0) { @@ -777,7 +777,7 @@ void Log::WaitBeforeContinueIfNeed() } else if (mode > 0) { - printf("\nWait %u secs for continue.\n",mode); + printf("\nWait %u secs for continue.\n", mode); BarGoLink bar(mode); for (int i = 0; i < mode; ++i) { @@ -809,7 +809,7 @@ void detail_log(const char* str, ...) char buf[256]; va_list ap; va_start(ap, str); - vsnprintf(buf,256, str, ap); + vsnprintf(buf, 256, str, ap); va_end(ap); sLog.outDetail("%s", buf); @@ -823,7 +823,7 @@ void debug_log(const char* str, ...) char buf[256]; va_list ap; va_start(ap, str); - vsnprintf(buf,256, str, ap); + vsnprintf(buf, 256, str, ap); va_end(ap); DEBUG_LOG("%s", buf); @@ -837,7 +837,7 @@ void error_log(const char* str, ...) char buf[256]; va_list ap; va_start(ap, str); - vsnprintf(buf,256, str, ap); + vsnprintf(buf, 256, str, ap); va_end(ap); sLog.outError("%s", buf); @@ -851,7 +851,7 @@ void error_db_log(const char* str, ...) char buf[256]; va_list ap; va_start(ap, str); - vsnprintf(buf,256, str, ap); + vsnprintf(buf, 256, str, ap); va_end(ap); sLog.outErrorDb("%s", buf); diff --git a/src/shared/Log.h b/src/shared/Log.h index bb6fe5d87..ab59e6a9b 100644 --- a/src/shared/Log.h +++ b/src/shared/Log.h @@ -39,7 +39,7 @@ enum LogFilters LOG_FILTER_TRANSPORT_MOVES = 0x000001, // 0 any related to transport moves LOG_FILTER_CREATURE_MOVES = 0x000002, // 1 creature move by cells LOG_FILTER_VISIBILITY_CHANGES = 0x000004, // 2 update visibility for diff objects and players - LOG_FILTER_ACHIEVEMENT_UPDATES= 0x000008, // 3 achievement update broadcasts + LOG_FILTER_ACHIEVEMENT_UPDATES = 0x000008, // 3 achievement update broadcasts LOG_FILTER_WEATHER = 0x000010, // 4 weather changes LOG_FILTER_PLAYER_STATS = 0x000020, // 5 player save data LOG_FILTER_SQL_TEXT = 0x000040, // 6 raw SQL text send to DB engine @@ -85,7 +85,7 @@ enum Color WHITE }; -const int Color_count = int(WHITE)+1; +const int Color_count = int(WHITE) + 1; class Log : public MaNGOS::Singleton > { @@ -122,29 +122,29 @@ class Log : public MaNGOS::Singleton= 1 - void outBasic(const char* str, ...) ATTR_PRINTF(2,3); + void outBasic(const char* str, ...) ATTR_PRINTF(2, 3); // log level >= 2 - void outDetail(const char* str, ...) ATTR_PRINTF(2,3); + void outDetail(const char* str, ...) ATTR_PRINTF(2, 3); // log level >= 3 - void outDebug(const char* str, ...) ATTR_PRINTF(2,3); + void outDebug(const char* str, ...) ATTR_PRINTF(2, 3); void outErrorDb(); // any log level // any log level - void outErrorDb(const char* str, ...) ATTR_PRINTF(2,3); + void outErrorDb(const char* str, ...) ATTR_PRINTF(2, 3); // any log level - void outChar(const char* str, ...) ATTR_PRINTF(2,3); + void outChar(const char* str, ...) ATTR_PRINTF(2, 3); // any log level void outWorldPacketDump(uint32 socket, uint32 opcode, char const* opcodeName, ByteBuffer const* packet, bool incoming); // any log level void outCharDump(const char* str, uint32 account_id, uint32 guid, const char* name); - void outRALog(const char* str, ...) ATTR_PRINTF(2,3); + void outRALog(const char* str, ...) ATTR_PRINTF(2, 3); uint32 GetLogLevel() const { return m_logLevel; } void SetLogLevel(char* Level); void SetLogFileLevel(char* Level); @@ -161,7 +161,7 @@ class Log : public MaNGOS::Singletontm_year+1900,aTm->tm_mon+1,aTm->tm_mday,aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + snprintf(buf, 20, "%04d-%02d-%02d_%02d-%02d-%02d", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec); return std::string(buf); } @@ -279,7 +279,7 @@ size_t utf8length(std::string& utf8str) { try { - return utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + return utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size()); } catch (std::exception) { @@ -288,20 +288,20 @@ size_t utf8length(std::string& utf8str) } } -void utf8truncate(std::string& utf8str,size_t len) +void utf8truncate(std::string& utf8str, size_t len) { try { - size_t wlen = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + size_t wlen = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size()); if (wlen <= len) return; std::wstring wstr; wstr.resize(wlen); - utf8::utf8to16(utf8str.c_str(),utf8str.c_str()+utf8str.size(),&wstr[0]); + utf8::utf8to16(utf8str.c_str(), utf8str.c_str() + utf8str.size(), &wstr[0]); wstr.resize(len); - char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str[0]); - utf8str.resize(oend-(&utf8str[0])); // remove unused tail + char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str() + wstr.size(), &utf8str[0]); + utf8str.resize(oend - (&utf8str[0])); // remove unused tail } catch (std::exception) { @@ -313,7 +313,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) { try { - size_t len = utf8::distance(utf8str,utf8str+csize); + size_t len = utf8::distance(utf8str, utf8str + csize); if (len > wsize) { if (wsize > 0) @@ -323,7 +323,7 @@ bool Utf8toWStr(char const* utf8str, size_t csize, wchar_t* wstr, size_t& wsize) } wsize = len; - utf8::utf8to16(utf8str,utf8str+csize,wstr); + utf8::utf8to16(utf8str, utf8str + csize, wstr); wstr[len] = L'\0'; } catch (std::exception) @@ -341,11 +341,11 @@ bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr) { try { - size_t len = utf8::distance(utf8str.c_str(),utf8str.c_str()+utf8str.size()); + size_t len = utf8::distance(utf8str.c_str(), utf8str.c_str() + utf8str.size()); 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) { @@ -361,10 +361,10 @@ bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str) try { std::string utf8str2; - utf8str2.resize(size*4); // allocate for most long case + utf8str2.resize(size * 4); // allocate for most long case - char* oend = utf8::utf16to8(wstr,wstr+size,&utf8str2[0]); - utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail + char* oend = utf8::utf16to8(wstr, wstr + size, &utf8str2[0]); + utf8str2.resize(oend - (&utf8str2[0])); // remove unused tail utf8str = utf8str2; } catch (std::exception) @@ -381,10 +381,10 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str) try { std::string utf8str2; - utf8str2.resize(wstr.size()*4); // allocate for most long case + utf8str2.resize(wstr.size() * 4); // allocate for most long case - char* oend = utf8::utf16to8(wstr.c_str(),wstr.c_str()+wstr.size(),&utf8str2[0]); - utf8str2.resize(oend-(&utf8str2[0])); // remove unused tail + char* oend = utf8::utf16to8(wstr.c_str(), wstr.c_str() + wstr.size(), &utf8str2[0]); + utf8str2.resize(oend - (&utf8str2[0])); // remove unused tail utf8str = utf8str2; } catch (std::exception) @@ -406,22 +406,22 @@ std::wstring GetMainPartOfName(std::wstring wname, uint32 declension) // Important: end length must be <= MAX_INTERNAL_PLAYER_NAME-MAX_PLAYER_NAME (3 currently) - static wchar_t const a_End[] = { wchar_t(1), wchar_t(0x0430),wchar_t(0x0000)}; - static wchar_t const o_End[] = { wchar_t(1), wchar_t(0x043E),wchar_t(0x0000)}; - static wchar_t const ya_End[] = { wchar_t(1), wchar_t(0x044F),wchar_t(0x0000)}; - static wchar_t const ie_End[] = { wchar_t(1), wchar_t(0x0435),wchar_t(0x0000)}; - static wchar_t const i_End[] = { wchar_t(1), wchar_t(0x0438),wchar_t(0x0000)}; - static wchar_t const yeru_End[] = { wchar_t(1), wchar_t(0x044B),wchar_t(0x0000)}; - static wchar_t const u_End[] = { wchar_t(1), wchar_t(0x0443),wchar_t(0x0000)}; - static wchar_t const yu_End[] = { wchar_t(1), wchar_t(0x044E),wchar_t(0x0000)}; - static wchar_t const oj_End[] = { wchar_t(2), wchar_t(0x043E),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const ie_j_End[] = { wchar_t(2), wchar_t(0x0435),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const io_j_End[] = { wchar_t(2), wchar_t(0x0451),wchar_t(0x0439),wchar_t(0x0000)}; - static wchar_t const o_m_End[] = { wchar_t(2), wchar_t(0x043E),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const io_m_End[] = { wchar_t(2), wchar_t(0x0451),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const ie_m_End[] = { wchar_t(2), wchar_t(0x0435),wchar_t(0x043C),wchar_t(0x0000)}; - static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C),wchar_t(0x0000)}; - static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439),wchar_t(0x0000)}; + static wchar_t const a_End[] = { wchar_t(1), wchar_t(0x0430), wchar_t(0x0000)}; + static wchar_t const o_End[] = { wchar_t(1), wchar_t(0x043E), wchar_t(0x0000)}; + static wchar_t const ya_End[] = { wchar_t(1), wchar_t(0x044F), wchar_t(0x0000)}; + static wchar_t const ie_End[] = { wchar_t(1), wchar_t(0x0435), wchar_t(0x0000)}; + static wchar_t const i_End[] = { wchar_t(1), wchar_t(0x0438), wchar_t(0x0000)}; + static wchar_t const yeru_End[] = { wchar_t(1), wchar_t(0x044B), wchar_t(0x0000)}; + static wchar_t const u_End[] = { wchar_t(1), wchar_t(0x0443), wchar_t(0x0000)}; + static wchar_t const yu_End[] = { wchar_t(1), wchar_t(0x044E), wchar_t(0x0000)}; + static wchar_t const oj_End[] = { wchar_t(2), wchar_t(0x043E), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const ie_j_End[] = { wchar_t(2), wchar_t(0x0435), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const io_j_End[] = { wchar_t(2), wchar_t(0x0451), wchar_t(0x0439), wchar_t(0x0000)}; + static wchar_t const o_m_End[] = { wchar_t(2), wchar_t(0x043E), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const io_m_End[] = { wchar_t(2), wchar_t(0x0451), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const ie_m_End[] = { wchar_t(2), wchar_t(0x0435), wchar_t(0x043C), wchar_t(0x0000)}; + static wchar_t const soft_End[] = { wchar_t(1), wchar_t(0x044C), wchar_t(0x0000)}; + static wchar_t const j_End[] = { wchar_t(1), wchar_t(0x0439), wchar_t(0x0000)}; static wchar_t const* const dropEnds[6][8] = { @@ -437,8 +437,8 @@ 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); + if (wname.substr(wname.size() - len, len) == *itr) + return wname.substr(0, wname.size() - len); } return wname; @@ -448,11 +448,11 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr) { #if PLATFORM == PLATFORM_WINDOWS std::wstring wstr; - if (!Utf8toWStr(utf8str,wstr)) + if (!Utf8toWStr(utf8str, wstr)) return false; conStr.resize(wstr.size()); - CharToOemBuffW(&wstr[0],&conStr[0],wstr.size()); + CharToOemBuffW(&wstr[0], &conStr[0], wstr.size()); #else // not implemented yet conStr = utf8str; @@ -461,14 +461,14 @@ bool utf8ToConsole(const std::string& utf8str, std::string& conStr) return true; } -bool consoleToUtf8(const std::string& conStr,std::string& utf8str) +bool consoleToUtf8(const std::string& conStr, std::string& utf8str) { #if PLATFORM == PLATFORM_WINDOWS std::wstring wstr; wstr.resize(conStr.size()); - OemToCharBuffW(&conStr[0],&wstr[0],conStr.size()); + OemToCharBuffW(&conStr[0], &wstr[0], conStr.size()); - return WStrToUtf8(wstr,utf8str); + return WStrToUtf8(wstr, utf8str); #else // not implemented yet utf8str = conStr; @@ -480,7 +480,7 @@ bool Utf8FitTo(const std::string& str, std::wstring search) { std::wstring temp; - if (!Utf8toWStr(str,temp)) + if (!Utf8toWStr(str, temp)) return false; // converting to lower case @@ -503,15 +503,15 @@ void utf8printf(FILE* out, const char* str, ...) void vutf8printf(FILE* out, const char* str, va_list* ap) { #if PLATFORM == PLATFORM_WINDOWS - char temp_buf[32*1024]; - wchar_t wtemp_buf[32*1024]; + char temp_buf[32 * 1024]; + wchar_t wtemp_buf[32 * 1024]; - size_t temp_len = vsnprintf(temp_buf, 32*1024, str, *ap); + size_t temp_len = vsnprintf(temp_buf, 32 * 1024, str, *ap); - size_t wtemp_len = 32*1024-1; + size_t wtemp_len = 32 * 1024 - 1; Utf8toWStr(temp_buf, temp_len, wtemp_buf, wtemp_len); - CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len+1); + CharToOemBuffW(&wtemp_buf[0], &temp_buf[0], wtemp_len + 1); fprintf(out, "%s", temp_buf); #else vfprintf(out, str, *ap); @@ -521,16 +521,16 @@ void vutf8printf(FILE* out, const char* str, va_list* ap) void hexEncodeByteArray(uint8* bytes, uint32 arrayLen, std::string& result) { std::ostringstream ss; - for (uint32 i=0; i>((1-j)*4)); + 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; + encodedNibble = 'A' + nibble - 0x0A; ss << encodedNibble; } } diff --git a/src/shared/Util.h b/src/shared/Util.h index fd0a8687a..d00b71122 100644 --- a/src/shared/Util.h +++ b/src/shared/Util.h @@ -101,7 +101,7 @@ inline void ApplyPercentModFloatVar(float& var, float val, bool apply) { if (val == -100.0f) // prevent set var to zero val = -99.99f; - var *= (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val)); + var *= (apply ? (100.0f + val) / 100.0f : 100.0f / (100.0f + val)); } bool Utf8toWStr(const std::string& utf8str, std::wstring& wstr); @@ -117,7 +117,7 @@ bool WStrToUtf8(std::wstring wstr, std::string& utf8str); bool WStrToUtf8(wchar_t* wstr, size_t size, std::string& utf8str); size_t utf8length(std::string& utf8str); // set string to "" if invalid utf8 sequence -void utf8truncate(std::string& utf8str,size_t len); +void utf8truncate(std::string& utf8str, size_t len); inline bool isBasicLatinCharacter(wchar_t wchar) { @@ -186,12 +186,12 @@ inline bool isWhiteSpace(char c) inline bool isNumeric(wchar_t wchar) { - return (wchar >= L'0' && wchar <=L'9'); + return (wchar >= L'0' && wchar <= L'9'); } inline bool isNumeric(char c) { - return (c >= '0' && c <='9'); + return (c >= '0' && c <= '9'); } inline bool isNumericOrSpace(wchar_t wchar) @@ -271,20 +271,20 @@ 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); 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); @@ -299,22 +299,22 @@ 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); if (wchar == 0x0401) // CYRILLIC CAPITAL LETTER IO 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; } @@ -332,7 +332,7 @@ inline void wstrToLower(std::wstring& str) std::wstring GetMainPartOfName(std::wstring wname, uint32 declension); bool utf8ToConsole(const std::string& utf8str, std::string& conStr); -bool consoleToUtf8(const std::string& conStr,std::string& utf8str); +bool consoleToUtf8(const std::string& conStr, std::string& utf8str); bool Utf8FitTo(const std::string& str, std::wstring search); void utf8printf(FILE* out, const char* str, ...); void vutf8printf(FILE* out, const char* str, va_list* ap); diff --git a/src/shared/WheatyExceptionReport.cpp b/src/shared/WheatyExceptionReport.cpp index fb259a950..b73eb57d1 100644 --- a/src/shared/WheatyExceptionReport.cpp +++ b/src/shared/WheatyExceptionReport.cpp @@ -317,10 +317,10 @@ void WheatyExceptionReport::PrintSystemInfo() _tprintf(_T("//=====================================================\r\n")); if (_GetProcessorName(sString, countof(sString))) _tprintf(_T("*** Hardware ***\r\nProcessor: %s\r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"), - sString, SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400); + sString, SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys / 0x400, MemoryStatus.dwAvailPhys / 0x400, MemoryStatus.dwTotalPageFile / 0x400); else _tprintf(_T("*** Hardware ***\r\nProcessor: \r\nNumber Of Processors: %d\r\nPhysical Memory: %d KB (Available: %d KB)\r\nCommit Charge Limit: %d KB\r\n"), - SystemInfo.dwNumberOfProcessors, MemoryStatus.dwTotalPhys/0x400, MemoryStatus.dwAvailPhys/0x400, MemoryStatus.dwTotalPageFile/0x400); + 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); @@ -362,7 +362,7 @@ void WheatyExceptionReport::printTracesForAllThreads() { CONTEXT context; context.ContextFlags = 0xffffffff; - HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION,false, te32.th32ThreadID); + HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, false, te32.th32ThreadID); if (threadHandle && GetThreadContext(threadHandle, &context)) { WriteStackDetails(&context, false, threadHandle); @@ -425,7 +425,7 @@ void WheatyExceptionReport::GenerateExceptionReport( _tprintf(_T("\r\nRegisters:\r\n")); _tprintf(_T("EAX:%08X\r\nEBX:%08X\r\nECX:%08X\r\nEDX:%08X\r\nESI:%08X\r\nEDI:%08X\r\n") - ,pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx, + , pCtx->Eax, pCtx->Ebx, pCtx->Ecx, pCtx->Edx, pCtx->Esi, pCtx->Edi); _tprintf(_T("CS:EIP:%04X:%08X\r\n"), pCtx->SegCs, pCtx->Eip); @@ -440,8 +440,8 @@ void WheatyExceptionReport::GenerateExceptionReport( _tprintf(_T("\r\nRegisters:\r\n")); _tprintf(_T("RAX:%016I64X\r\nRBX:%016I64X\r\nRCX:%016I64X\r\nRDX:%016I64X\r\nRSI:%016I64X\r\nRDI:%016I64X\r\n") _T("R8: %016I64X\r\nR9: %016I64X\r\nR10:%016I64X\r\nR11:%016I64X\r\nR12:%016I64X\r\nR13:%016I64X\r\nR14:%016I64X\r\nR15:%016I64X\r\n") - ,pCtx->Rax, pCtx->Rbx, pCtx->Rcx, pCtx->Rdx, - pCtx->Rsi, pCtx->Rdi ,pCtx->R9,pCtx->R10,pCtx->R11,pCtx->R12,pCtx->R13,pCtx->R14,pCtx->R15); + , pCtx->Rax, pCtx->Rbx, pCtx->Rcx, pCtx->Rdx, + pCtx->Rsi, pCtx->Rdi , pCtx->R9, pCtx->R10, pCtx->R11, pCtx->R12, pCtx->R13, pCtx->R14, pCtx->R15); _tprintf(_T("CS:RIP:%04X:%016I64X\r\n"), pCtx->SegCs, pCtx->Rip); _tprintf(_T("SS:RSP:%04X:%016X RBP:%08X\r\n"), pCtx->SegSs, pCtx->Rsp, pCtx->Rbp); @@ -577,7 +577,7 @@ BOOL WheatyExceptionReport::GetLogicalAddress( // Yes, address is in the section. Calculate section and offset, // and store in the "section" & "offset" params, which were // passed by reference. - section = i+1; + section = i + 1; offset = rva - sectionStart; return TRUE; } @@ -696,7 +696,7 @@ void WheatyExceptionReport::WriteStackDetails( if (SymGetLineFromAddr64(m_hProcess, sf.AddrPC.Offset, &dwLineDisplacement, &lineInfo)) { - _tprintf(_T(" %s line %u"),lineInfo.FileName,lineInfo.LineNumber); + _tprintf(_T(" %s line %u"), lineInfo.FileName, lineInfo.LineNumber); } _tprintf(_T("\r\n")); @@ -793,7 +793,7 @@ bool WheatyExceptionReport::FormatSymbolValue( // Determine if the variable is a user defined type (UDT). IF so, bHandled // will return true. bool bHandled; - pszCurrBuffer = DumpTypeIndex(pszCurrBuffer,pSym->ModBase, pSym->TypeIndex, + pszCurrBuffer = DumpTypeIndex(pszCurrBuffer, pSym->ModBase, pSym->TypeIndex, 0, pVariable, bHandled, pSym->Name); if (!bHandled) @@ -858,7 +858,7 @@ char* WheatyExceptionReport::DumpTypeIndex( } children; children.Count = dwChildrenCount; - children.Start= 0; + children.Start = 0; // Get the array of TypeIds, one for each child type if (!SymGetTypeInfo(m_hProcess, modBase, dwTypeIndex, TI_FINDCHILDREN, @@ -874,7 +874,7 @@ char* WheatyExceptionReport::DumpTypeIndex( for (unsigned i = 0; i < dwChildrenCount; i++) { // Add appropriate indentation level (since this routine is recursive) - for (unsigned j = 0; j <= nestingLevel+1; j++) + for (unsigned j = 0; j <= nestingLevel + 1; j++) pszCurrBuffer += sprintf(pszCurrBuffer, "\t"); // Recurse for each of the child types @@ -883,7 +883,7 @@ char* WheatyExceptionReport::DumpTypeIndex( pszCurrBuffer += sprintf(pszCurrBuffer, rgBaseType[basicType]); pszCurrBuffer = DumpTypeIndex(pszCurrBuffer, modBase, - children.ChildId[i], nestingLevel+1, + children.ChildId[i], nestingLevel + 1, offset, bHandled2, ""/*Name */); // If the child wasn't a UDT, format it appropriately @@ -902,7 +902,7 @@ char* WheatyExceptionReport::DumpTypeIndex( // Get the size of the child member ULONG64 length; - SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH,&length); + SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_LENGTH, &length); // Calculate the address of the member DWORD_PTR dwFinalOffset = offset + dwMemberOffset; @@ -939,7 +939,7 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer, { if (basicType == btFloat) { - pszCurrBuffer += sprintf(pszCurrBuffer," = %f", *(PFLOAT)pAddress); + pszCurrBuffer += sprintf(pszCurrBuffer, " = %f", *(PFLOAT)pAddress); } else if (basicType == btChar) { @@ -953,7 +953,7 @@ char* WheatyExceptionReport::FormatOutputValue(char* pszCurrBuffer, *(PDWORD)pAddress); } else - pszCurrBuffer += sprintf(pszCurrBuffer," = %X", *(PDWORD)pAddress); + pszCurrBuffer += sprintf(pszCurrBuffer, " = %X", *(PDWORD)pAddress); } else if (length == 8) { @@ -983,7 +983,7 @@ WheatyExceptionReport::GetBasicType(DWORD typeIndex, DWORD64 modBase) // Get the real "TypeId" of the child. We need this for the // SymGetTypeInfo( TI_GET_TYPEID ) call below. DWORD typeId; - if (SymGetTypeInfo(m_hProcess,modBase, typeIndex, TI_GET_TYPEID, &typeId)) + if (SymGetTypeInfo(m_hProcess, modBase, typeIndex, TI_GET_TYPEID, &typeId)) { if (SymGetTypeInfo(m_hProcess, modBase, typeId, TI_GET_BASETYPE, &basicType)) diff --git a/src/shared/WheatyExceptionReport.h b/src/shared/WheatyExceptionReport.h index 060fcee3f..8a67eb761 100644 --- a/src/shared/WheatyExceptionReport.h +++ b/src/shared/WheatyExceptionReport.h @@ -94,7 +94,7 @@ class WheatyExceptionReport static void WriteStackDetails(PCONTEXT pContext, bool bWriteVariables, HANDLE pThreadHandle); - static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO,ULONG, PVOID); + static BOOL CALLBACK EnumerateSymbolsCallback(PSYMBOL_INFO, ULONG, PVOID); static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME*, char* pszBuffer, unsigned cbBuffer); diff --git a/src/shared/WorldPacket.h b/src/shared/WorldPacket.h index c51adfe12..350da58ae 100644 --- a/src/shared/WorldPacket.h +++ b/src/shared/WorldPacket.h @@ -31,13 +31,13 @@ class WorldPacket : public ByteBuffer WorldPacket() : ByteBuffer(0), m_opcode(0) { } - explicit WorldPacket(uint16 opcode, size_t res=200) : ByteBuffer(res), m_opcode(opcode) { } + explicit WorldPacket(uint16 opcode, size_t res = 200) : ByteBuffer(res), m_opcode(opcode) { } // copy constructor WorldPacket(const WorldPacket& packet) : ByteBuffer(packet), m_opcode(packet.m_opcode) { } - void Initialize(uint16 opcode, size_t newres=200) + void Initialize(uint16 opcode, size_t newres = 200) { clear(); _storage.reserve(newres); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4db5bbc24..4d6bca02b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12063" +#define REVISION_NR "12063" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index d4b371753..19d78f1d7 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ - #define REVISION_DB_CHARACTERS "required_11785_02_characters_instance" - #define REVISION_DB_MANGOS "required_12012_01_mangos_spell_template" - #define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" +#define REVISION_DB_CHARACTERS "required_11785_02_characters_instance" +#define REVISION_DB_MANGOS "required_12012_01_mangos_spell_template" +#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version" #endif // __REVISION_SQL_H__ diff --git a/src/tools/genrevision/genrevision.cpp b/src/tools/genrevision/genrevision.cpp index eae80e0ff..122f63cd7 100644 --- a/src/tools/genrevision/genrevision.cpp +++ b/src/tools/genrevision/genrevision.cpp @@ -38,21 +38,21 @@ void extractDataFromSvn(FILE* EntriesFile, bool url, RawData& data) char repo_str[200]; char num_str[200]; - fgets(buf,200,EntriesFile); - fgets(buf,200,EntriesFile); - fgets(buf,200,EntriesFile); - fgets(buf,200,EntriesFile); sscanf(buf,"%s",num_str); - fgets(buf,200,EntriesFile); sscanf(buf,"%s",repo_str); - fgets(buf,200,EntriesFile); - fgets(buf,200,EntriesFile); - fgets(buf,200,EntriesFile); - fgets(buf,200,EntriesFile); - fgets(buf,200,EntriesFile); sscanf(buf,"%10sT%8s",data.date_str,data.time_str); + fgets(buf, 200, EntriesFile); + fgets(buf, 200, EntriesFile); + fgets(buf, 200, EntriesFile); + fgets(buf, 200, EntriesFile); sscanf(buf, "%s", num_str); + fgets(buf, 200, EntriesFile); sscanf(buf, "%s", repo_str); + fgets(buf, 200, EntriesFile); + fgets(buf, 200, EntriesFile); + fgets(buf, 200, EntriesFile); + fgets(buf, 200, EntriesFile); + fgets(buf, 200, EntriesFile); sscanf(buf, "%10sT%8s", data.date_str, data.time_str); if (url) - sprintf(data.rev_str,"%s at %s",num_str,repo_str); + sprintf(data.rev_str, "%s at %s", num_str, repo_str); else - strcpy(data.rev_str,num_str); + strcpy(data.rev_str, num_str); } void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& data) @@ -64,9 +64,9 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& char url_str[200]; bool found = false; - while (fgets(buf,200,EntriesFile)) + while (fgets(buf, 200, EntriesFile)) { - if (sscanf(buf,"%s\t\tbranch %s of %s",hash_str,branch_str,url_str)==3) + if (sscanf(buf, "%s\t\tbranch %s of %s", hash_str, branch_str, url_str) == 3) { found = true; break; @@ -75,9 +75,9 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& if (!found) { - strcpy(data.rev_str,"*"); - strcpy(data.date_str,"*"); - strcpy(data.time_str,"*"); + strcpy(data.rev_str, "*"); + strcpy(data.date_str, "*"); + strcpy(data.time_str, "*"); return; } @@ -89,49 +89,49 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& // parse URL like git@github.com:mangos/mangos char url_buf[200]; - int res = sscanf(url_str,"git@%s",url_buf); + int res = sscanf(url_str, "git@%s", url_buf); if (res) { - host_str = strtok(url_buf,":"); - acc_str = strtok(NULL,"/"); - repo_str = strtok(NULL," "); + host_str = strtok(url_buf, ":"); + acc_str = strtok(NULL, "/"); + repo_str = strtok(NULL, " "); } else { - res = sscanf(url_str,"git://%s",url_buf); + res = sscanf(url_str, "git://%s", url_buf); if (res) { - host_str = strtok(url_buf,"/"); - acc_str = strtok(NULL,"/"); - repo_str = strtok(NULL,"."); + host_str = strtok(url_buf, "/"); + acc_str = strtok(NULL, "/"); + repo_str = strtok(NULL, "."); } } // can generate nice link if (res) - sprintf(data.rev_str,"http://%s/%s/%s/commit/%s",host_str,acc_str,repo_str,hash_str); + sprintf(data.rev_str, "http://%s/%s/%s/commit/%s", host_str, acc_str, repo_str, hash_str); // unknonw URL format, use as-is else - sprintf(data.rev_str,"%s at %s",hash_str,url_str); + sprintf(data.rev_str, "%s at %s", hash_str, url_str); } else - strcpy(data.rev_str,hash_str); + strcpy(data.rev_str, hash_str); time_t rev_time = 0; // extracting date/time - FILE* LogFile = fopen((path+".git/logs/HEAD").c_str(), "r"); + FILE* LogFile = fopen((path + ".git/logs/HEAD").c_str(), "r"); if (LogFile) { - while (fgets(buf,200,LogFile)) + while (fgets(buf, 200, LogFile)) { char buf2[200]; char new_hash[200]; int unix_time = 0; - int res2 = sscanf(buf,"%s %s %s %s %i",buf2,new_hash,buf2,buf2,&unix_time); - if (res2!=5) + int res2 = sscanf(buf, "%s %s %s %s %i", buf2, new_hash, buf2, buf2, &unix_time); + if (res2 != 5) continue; - if (strcmp(hash_str,new_hash)) + if (strcmp(hash_str, new_hash)) continue; rev_time = unix_time; @@ -149,19 +149,19 @@ void extractDataFromGit(FILE* EntriesFile, std::string path, bool url, RawData& // HH hour (2 digits 00-23) // MM minutes (2 digits 00-59) // SS seconds (2 digits 00-59) - sprintf(data.date_str,"%04d-%02d-%02d",aTm->tm_year+1900,aTm->tm_mon+1,aTm->tm_mday); - sprintf(data.time_str,"%02d:%02d:%02d",aTm->tm_hour,aTm->tm_min,aTm->tm_sec); + sprintf(data.date_str, "%04d-%02d-%02d", aTm->tm_year + 1900, aTm->tm_mon + 1, aTm->tm_mday); + sprintf(data.time_str, "%02d:%02d:%02d", aTm->tm_hour, aTm->tm_min, aTm->tm_sec); } else { - strcpy(data.date_str,"*"); - strcpy(data.time_str,"*"); + strcpy(data.date_str, "*"); + strcpy(data.time_str, "*"); } } else { - strcpy(data.date_str,"*"); - strcpy(data.time_str,"*"); + strcpy(data.date_str, "*"); + strcpy(data.time_str, "*"); } } @@ -171,7 +171,7 @@ bool extractDataFromSvn(std::string filename, bool url, RawData& data) if (!EntriesFile) return false; - extractDataFromSvn(EntriesFile,url,data); + extractDataFromSvn(EntriesFile, url, data); fclose(EntriesFile); return true; } @@ -182,7 +182,7 @@ bool extractDataFromGit(std::string filename, std::string path, bool url, RawDat if (!EntriesFile) return false; - extractDataFromGit(EntriesFile,path,url,data); + extractDataFromGit(EntriesFile, path, url, data); fclose(EntriesFile); return true; } @@ -194,7 +194,7 @@ std::string generateHeader(char const* rev_str, char const* date_str, char const newData << "#define __REVISION_H__" << std::endl; newData << " #define REVISION_ID \"" << rev_str << "\"" << std::endl; newData << " #define REVISION_DATE \"" << date_str << "\"" << std::endl; - newData << " #define REVISION_TIME \"" << time_str << "\""<< std::endl; + newData << " #define REVISION_TIME \"" << time_str << "\"" << std::endl; newData << "#endif // __REVISION_H__" << std::endl; return newData.str(); } @@ -217,10 +217,10 @@ int main(int argc, char** argv) if (!argv[k] || !*argv[k]) break; - if (argv[k][0]!='-') + if (argv[k][0] != '-') { path = argv[k]; - if (path.size() > 0 && (path[path.size()-1]!='/' || path[path.size()-1]!='\\')) + if (path.size() > 0 && (path[path.size() - 1] != '/' || path[path.size() - 1] != '\\')) path += '/'; break; } @@ -246,7 +246,7 @@ int main(int argc, char** argv) outfile = argv[k]; continue; default: - printf("Unknown option %s",argv[k]); + printf("Unknown option %s", argv[k]); return 1; } } @@ -262,26 +262,26 @@ int main(int argc, char** argv) if (svn_prefered) { /// SVN data - res = extractDataFromSvn(path+".svn/entries",use_url,data); + res = extractDataFromSvn(path + ".svn/entries", use_url, data); if (!res) - res = extractDataFromSvn(path+"_svn/entries",use_url,data); + res = extractDataFromSvn(path + "_svn/entries", use_url, data); // GIT data if (!res) - res = extractDataFromGit(path+".git/FETCH_HEAD",path,use_url,data); + res = extractDataFromGit(path + ".git/FETCH_HEAD", path, use_url, data); } else { // GIT data - res = extractDataFromGit(path+".git/FETCH_HEAD",path,use_url,data); + res = extractDataFromGit(path + ".git/FETCH_HEAD", path, use_url, data); /// SVN data if (!res) - res = extractDataFromSvn(path+".svn/entries",use_url,data); + res = extractDataFromSvn(path + ".svn/entries", use_url, data); if (!res) - res = extractDataFromSvn(path+"_svn/entries",use_url,data); + res = extractDataFromSvn(path + "_svn/entries", use_url, data); } if (res) - newData = generateHeader(data.rev_str,data.date_str,data.time_str); + newData = generateHeader(data.rev_str, data.date_str, data.time_str); else newData = generateHeader("*", "*", "*"); } @@ -289,7 +289,7 @@ int main(int argc, char** argv) /// get existed header data for compare std::string oldData; - if (FILE* HeaderFile = fopen(outfile.c_str(),"rb")) + if (FILE* HeaderFile = fopen(outfile.c_str(), "rb")) { while (!feof(HeaderFile)) { @@ -305,9 +305,9 @@ int main(int argc, char** argv) /// update header only if different data if (newData != oldData) { - if (FILE* OutputFile = fopen(outfile.c_str(),"wb")) + if (FILE* OutputFile = fopen(outfile.c_str(), "wb")) { - fprintf(OutputFile,"%s",newData.c_str()); + fprintf(OutputFile, "%s", newData.c_str()); fclose(OutputFile); } else