Various Cleanups (game S)

This commit is contained in:
Schmoozerd 2012-07-19 21:52:06 +02:00
parent 865f7d7428
commit 08fd085549
18 changed files with 3168 additions and 3146 deletions

View file

@ -236,7 +236,7 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
continue; continue;
} }
for(int i = 0; i < MAX_TEXT_ID; ++i) for (int i = 0; i < MAX_TEXT_ID; ++i)
{ {
if (tmp.textId[i] && (tmp.textId[i] < MIN_DB_SCRIPT_STRING_ID || tmp.textId[i] >= MAX_DB_SCRIPT_STRING_ID)) if (tmp.textId[i] && (tmp.textId[i] < MIN_DB_SCRIPT_STRING_ID || tmp.textId[i] >= MAX_DB_SCRIPT_STRING_ID))
{ {
@ -630,7 +630,8 @@ void ScriptMgr::LoadScripts(ScriptMapMapName& scripts, const char* tablename)
scripts.second[tmp.id].insert(ScriptMap::value_type(tmp.delay, tmp)); scripts.second[tmp.id].insert(ScriptMap::value_type(tmp.delay, tmp));
++count; ++count;
} while(result->NextRow()); }
while (result->NextRow());
delete result; delete result;
@ -643,7 +644,7 @@ void ScriptMgr::LoadGameObjectScripts()
LoadScripts(sGameObjectScripts, "gameobject_scripts"); LoadScripts(sGameObjectScripts, "gameobject_scripts");
// check ids // check ids
for(ScriptMapMap::const_iterator itr = sGameObjectScripts.second.begin(); itr != sGameObjectScripts.second.end(); ++itr) for (ScriptMapMap::const_iterator itr = sGameObjectScripts.second.begin(); itr != sGameObjectScripts.second.end(); ++itr)
{ {
if (!sObjectMgr.GetGOData(itr->first)) if (!sObjectMgr.GetGOData(itr->first))
sLog.outErrorDb("Table `gameobject_scripts` has not existing gameobject (GUID: %u) as script id", itr->first); sLog.outErrorDb("Table `gameobject_scripts` has not existing gameobject (GUID: %u) as script id", itr->first);
@ -667,7 +668,7 @@ void ScriptMgr::LoadQuestEndScripts()
LoadScripts(sQuestEndScripts, "quest_end_scripts"); LoadScripts(sQuestEndScripts, "quest_end_scripts");
// check ids // check ids
for(ScriptMapMap::const_iterator itr = sQuestEndScripts.second.begin(); itr != sQuestEndScripts.second.end(); ++itr) for (ScriptMapMap::const_iterator itr = sQuestEndScripts.second.begin(); itr != sQuestEndScripts.second.end(); ++itr)
{ {
if (!sObjectMgr.GetQuestTemplate(itr->first)) if (!sObjectMgr.GetQuestTemplate(itr->first))
sLog.outErrorDb("Table `quest_end_scripts` has not existing quest (Id: %u) as script id", itr->first); sLog.outErrorDb("Table `quest_end_scripts` has not existing quest (Id: %u) as script id", itr->first);
@ -679,7 +680,7 @@ void ScriptMgr::LoadQuestStartScripts()
LoadScripts(sQuestStartScripts, "quest_start_scripts"); LoadScripts(sQuestStartScripts, "quest_start_scripts");
// check ids // check ids
for(ScriptMapMap::const_iterator itr = sQuestStartScripts.second.begin(); itr != sQuestStartScripts.second.end(); ++itr) for (ScriptMapMap::const_iterator itr = sQuestStartScripts.second.begin(); itr != sQuestStartScripts.second.end(); ++itr)
{ {
if (!sObjectMgr.GetQuestTemplate(itr->first)) if (!sObjectMgr.GetQuestTemplate(itr->first))
sLog.outErrorDb("Table `quest_start_scripts` has not existing quest (Id: %u) as script id", itr->first); sLog.outErrorDb("Table `quest_start_scripts` has not existing quest (Id: %u) as script id", itr->first);
@ -723,7 +724,7 @@ void ScriptMgr::LoadEventScripts()
std::set<uint32> evt_scripts; std::set<uint32> evt_scripts;
// Load all possible script entries from gameobjects // Load all possible script entries from gameobjects
for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i) for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
{ {
if (GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(i)) if (GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(i))
{ {
@ -745,12 +746,12 @@ void ScriptMgr::LoadEventScripts()
} }
// Load all possible script entries from spells // Load all possible script entries from spells
for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
{ {
SpellEntry const* spell = sSpellStore.LookupEntry(i); SpellEntry const* spell = sSpellStore.LookupEntry(i);
if (spell) if (spell)
{ {
for(int j = 0; j < MAX_EFFECT_INDEX; ++j) for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
{ {
if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT) if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT)
{ {
@ -761,9 +762,9 @@ void ScriptMgr::LoadEventScripts()
} }
} }
for(size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx) for (size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
{ {
for(size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx) for (size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
{ {
TaxiPathNodeEntry const& node = sTaxiPathNodesByPath[path_idx][node_idx]; TaxiPathNodeEntry const& node = sTaxiPathNodesByPath[path_idx][node_idx];
@ -776,7 +777,7 @@ void ScriptMgr::LoadEventScripts()
} }
// Then check if all scripts are in above list of possible script entries // Then check if all scripts are in above list of possible script entries
for(ScriptMapMap::const_iterator itr = sEventScripts.second.begin(); itr != sEventScripts.second.end(); ++itr) for (ScriptMapMap::const_iterator itr = sEventScripts.second.begin(); itr != sEventScripts.second.end(); ++itr)
{ {
std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first); std::set<uint32>::const_iterator itr2 = evt_scripts.find(itr->first);
if (itr2 == evt_scripts.end()) if (itr2 == evt_scripts.end())
@ -805,7 +806,7 @@ void ScriptMgr::LoadDbScriptStrings()
std::set<int32> ids; std::set<int32> ids;
for(int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i) for (int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i)
if (sObjectMgr.GetMangosStringLocale(i)) if (sObjectMgr.GetMangosStringLocale(i))
ids.insert(i); ids.insert(i);
@ -820,22 +821,22 @@ void ScriptMgr::LoadDbScriptStrings()
sWaypointMgr.CheckTextsExistance(ids); sWaypointMgr.CheckTextsExistance(ids);
for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr) for (std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr)
sLog.outErrorDb("Table `db_script_string` has unused string id %u", *itr); sLog.outErrorDb("Table `db_script_string` has unused string id %u", *itr);
} }
void ScriptMgr::CheckScriptTexts(ScriptMapMapName const& scripts, std::set<int32>& ids) void ScriptMgr::CheckScriptTexts(ScriptMapMapName const& scripts, std::set<int32>& ids)
{ {
for(ScriptMapMap::const_iterator itrMM = scripts.second.begin(); itrMM != scripts.second.end(); ++itrMM) for (ScriptMapMap::const_iterator itrMM = scripts.second.begin(); itrMM != scripts.second.end(); ++itrMM)
{ {
for(ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM) for (ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM)
{ {
if (itrM->second.command == SCRIPT_COMMAND_TALK) if (itrM->second.command == SCRIPT_COMMAND_TALK)
{ {
for(int i = 0; i < MAX_TEXT_ID; ++i) for (int i = 0; i < MAX_TEXT_ID; ++i)
{ {
if (itrM->second.textId[i] && !sObjectMgr.GetMangosStringLocale(itrM->second.textId[i])) if (itrM->second.textId[i] && !sObjectMgr.GetMangosStringLocale(itrM->second.textId[i]))
sLog.outErrorDb( "Table `db_script_string` is missing string id %u, used in database script table %s id %u.", itrM->second.textId[i], scripts.first, itrMM->first); sLog.outErrorDb("Table `db_script_string` is missing string id %u, used in database script table %s id %u.", itrM->second.textId[i], scripts.first, itrMM->first);
if (ids.find(itrM->second.textId[i]) != ids.end()) if (ids.find(itrM->second.textId[i]) != ids.end())
ids.erase(itrM->second.textId[i]); ids.erase(itrM->second.textId[i]);
@ -1042,7 +1043,7 @@ void ScriptAction::HandleScriptStep()
if (m_script->textId[1]) if (m_script->textId[1])
{ {
int i = 2; int i = 2;
for(; i < MAX_TEXT_ID; ++i) for (; i < MAX_TEXT_ID; ++i)
{ {
if (!m_script->textId[i]) if (!m_script->textId[i])
break; break;
@ -1472,7 +1473,7 @@ void ScriptAction::HandleScriptStep()
// Consider add additional checks for cases where creature should not change movementType // Consider add additional checks for cases where creature should not change movementType
// (pet? in combat? already using same MMgen as script try to apply?) // (pet? in combat? already using same MMgen as script try to apply?)
switch(m_script->movement.movementType) switch (m_script->movement.movementType)
{ {
case IDLE_MOTION_TYPE: case IDLE_MOTION_TYPE:
((Creature*)pSource)->GetMotionMaster()->MoveIdle(); ((Creature*)pSource)->GetMotionMaster()->MoveIdle();
@ -1661,7 +1662,7 @@ void ScriptAction::HandleScriptStep()
void ScriptMgr::LoadAreaTriggerScripts() void ScriptMgr::LoadAreaTriggerScripts()
{ {
m_AreaTriggerScripts.clear(); // need for reload case m_AreaTriggerScripts.clear(); // need for reload case
QueryResult *result = WorldDatabase.Query("SELECT entry, ScriptName FROM scripted_areatrigger"); QueryResult* result = WorldDatabase.Query("SELECT entry, ScriptName FROM scripted_areatrigger");
uint32 count = 0; uint32 count = 0;
@ -1682,10 +1683,10 @@ void ScriptMgr::LoadAreaTriggerScripts()
++count; ++count;
bar.step(); bar.step();
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 triggerId = fields[0].GetUInt32(); uint32 triggerId = fields[0].GetUInt32();
const char *scriptName = fields[1].GetString(); const char* scriptName = fields[1].GetString();
if (!sAreaTriggerStore.LookupEntry(triggerId)) if (!sAreaTriggerStore.LookupEntry(triggerId))
{ {
@ -1694,7 +1695,8 @@ void ScriptMgr::LoadAreaTriggerScripts()
} }
m_AreaTriggerScripts[triggerId] = GetScriptId(scriptName); m_AreaTriggerScripts[triggerId] = GetScriptId(scriptName);
} while(result->NextRow()); }
while (result->NextRow());
delete result; delete result;
@ -1705,7 +1707,7 @@ void ScriptMgr::LoadAreaTriggerScripts()
void ScriptMgr::LoadEventIdScripts() void ScriptMgr::LoadEventIdScripts()
{ {
m_EventIdScripts.clear(); // need for reload case m_EventIdScripts.clear(); // need for reload case
QueryResult *result = WorldDatabase.Query("SELECT id, ScriptName FROM scripted_event_id"); QueryResult* result = WorldDatabase.Query("SELECT id, ScriptName FROM scripted_event_id");
uint32 count = 0; uint32 count = 0;
@ -1747,12 +1749,12 @@ void ScriptMgr::LoadEventIdScripts()
} }
// Load all possible event entries from spells // Load all possible event entries from spells
for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) for (uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
{ {
SpellEntry const* spell = sSpellStore.LookupEntry(i); SpellEntry const* spell = sSpellStore.LookupEntry(i);
if (spell) if (spell)
{ {
for(int j = 0; j < MAX_EFFECT_INDEX; ++j) for (int j = 0; j < MAX_EFFECT_INDEX; ++j)
{ {
if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT) if (spell->Effect[j] == SPELL_EFFECT_SEND_EVENT)
{ {
@ -1764,9 +1766,9 @@ void ScriptMgr::LoadEventIdScripts()
} }
// Load all possible event entries from taxi path nodes // Load all possible event entries from taxi path nodes
for(size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx) for (size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx)
{ {
for(size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx) for (size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx)
{ {
TaxiPathNodeEntry const& node = sTaxiPathNodesByPath[path_idx][node_idx]; TaxiPathNodeEntry const& node = sTaxiPathNodesByPath[path_idx][node_idx];
@ -1783,10 +1785,10 @@ void ScriptMgr::LoadEventIdScripts()
++count; ++count;
bar.step(); bar.step();
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 eventId = fields[0].GetUInt32(); uint32 eventId = fields[0].GetUInt32();
const char *scriptName = fields[1].GetString(); const char* scriptName = fields[1].GetString();
std::set<uint32>::const_iterator itr = evt_scripts.find(eventId); std::set<uint32>::const_iterator itr = evt_scripts.find(eventId);
if (itr == evt_scripts.end()) if (itr == evt_scripts.end())
@ -1794,7 +1796,8 @@ void ScriptMgr::LoadEventIdScripts()
eventId, SPELL_EFFECT_SEND_EVENT); eventId, SPELL_EFFECT_SEND_EVENT);
m_EventIdScripts[eventId] = GetScriptId(scriptName); m_EventIdScripts[eventId] = GetScriptId(scriptName);
} while(result->NextRow()); }
while (result->NextRow());
delete result; delete result;
@ -1805,7 +1808,7 @@ void ScriptMgr::LoadEventIdScripts()
void ScriptMgr::LoadScriptNames() void ScriptMgr::LoadScriptNames()
{ {
m_scriptNames.push_back(""); m_scriptNames.push_back("");
QueryResult *result = WorldDatabase.Query( QueryResult* result = WorldDatabase.Query(
"SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' " "SELECT DISTINCT(ScriptName) FROM creature_template WHERE ScriptName <> '' "
"UNION " "UNION "
"SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' " "SELECT DISTINCT(ScriptName) FROM gameobject_template WHERE ScriptName <> '' "
@ -1837,7 +1840,8 @@ void ScriptMgr::LoadScriptNames()
bar.step(); bar.step();
m_scriptNames.push_back((*result)[0].GetString()); m_scriptNames.push_back((*result)[0].GetString());
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
std::sort(m_scriptNames.begin(), m_scriptNames.end()); std::sort(m_scriptNames.begin(), m_scriptNames.end());
@ -1845,7 +1849,7 @@ void ScriptMgr::LoadScriptNames()
sLog.outString(">> Loaded %d Script Names", count); sLog.outString(">> Loaded %d Script Names", count);
} }
uint32 ScriptMgr::GetScriptId(const char *name) const uint32 ScriptMgr::GetScriptId(const char* name) const
{ {
// use binary search to find the script name in the sorted vector // use binary search to find the script name in the sorted vector
// assume "" is the first element // assume "" is the first element
@ -2033,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) // 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"); GET_SCRIPT_HOOK_PTR(pGetMangosRevStr, "GetMangosRevStr");
@ -2130,7 +2134,7 @@ uint32 GetEventIdScriptId(uint32 eventId)
return sScriptMgr.GetEventIdScriptId(eventId); return sScriptMgr.GetEventIdScriptId(eventId);
} }
uint32 GetScriptId(const char *name) uint32 GetScriptId(const char* name)
{ {
return sScriptMgr.GetScriptId(name); return sScriptMgr.GetScriptId(name);
} }

View file

@ -96,7 +96,8 @@ enum ScriptCommand // resSource, resTar
#define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK #define MAX_TEXT_ID 4 // used for SCRIPT_COMMAND_TALK
enum ScriptInfoDataFlags enum ScriptInfoDataFlags
{ // default: s/b -> t {
// default: s/b -> t
SCRIPT_FLAG_BUDDY_AS_TARGET = 0x01, // s -> b SCRIPT_FLAG_BUDDY_AS_TARGET = 0x01, // s -> b
SCRIPT_FLAG_REVERSE_DIRECTION = 0x02, // t* -> s* (* result after previous flag is evaluated) SCRIPT_FLAG_REVERSE_DIRECTION = 0x02, // t* -> s* (* result after previous flag is evaluated)
SCRIPT_FLAG_SOURCE_TARGETS_SELF = 0x04, // s* -> s* (* result after previous flag is evaluated) SCRIPT_FLAG_SOURCE_TARGETS_SELF = 0x04, // s* -> s* (* result after previous flag is evaluated)
@ -429,7 +430,7 @@ class ScriptMgr
uint32 GetEventIdScriptId(uint32 eventId) const; uint32 GetEventIdScriptId(uint32 eventId) const;
const char* GetScriptName(uint32 id) const { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; } const char* GetScriptName(uint32 id) const { return id < m_scriptNames.size() ? m_scriptNames[id].c_str() : ""; }
uint32 GetScriptId(const char *name) const; uint32 GetScriptId(const char* name) const;
uint32 GetScriptIdsCount() const { return m_scriptNames.size(); } uint32 GetScriptIdsCount() const { return m_scriptNames.size(); }
ScriptLoadResult LoadScriptLibrary(const char* libName); ScriptLoadResult LoadScriptLibrary(const char* libName);
@ -493,37 +494,37 @@ class ScriptMgr
void (MANGOS_IMPORT* m_pOnFreeScriptLibrary)(); void (MANGOS_IMPORT* m_pOnFreeScriptLibrary)();
const char* (MANGOS_IMPORT* m_pGetScriptLibraryVersion)(); const char* (MANGOS_IMPORT* m_pGetScriptLibraryVersion)();
CreatureAI* (MANGOS_IMPORT* m_pGetCreatureAI) (Creature*); CreatureAI* (MANGOS_IMPORT* m_pGetCreatureAI)(Creature*);
InstanceData* (MANGOS_IMPORT* m_pCreateInstanceData) (Map*); InstanceData* (MANGOS_IMPORT* m_pCreateInstanceData)(Map*);
bool (MANGOS_IMPORT* m_pOnGossipHello) (Player*, Creature*); bool (MANGOS_IMPORT* m_pOnGossipHello)(Player*, Creature*);
bool (MANGOS_IMPORT* m_pOnGOGossipHello) (Player*, GameObject*); bool (MANGOS_IMPORT* m_pOnGOGossipHello)(Player*, GameObject*);
bool (MANGOS_IMPORT* m_pOnGossipSelect) (Player*, Creature*, uint32, uint32); bool (MANGOS_IMPORT* m_pOnGossipSelect)(Player*, Creature*, uint32, uint32);
bool (MANGOS_IMPORT* m_pOnGOGossipSelect) (Player*, GameObject*, uint32, uint32); bool (MANGOS_IMPORT* m_pOnGOGossipSelect)(Player*, GameObject*, uint32, uint32);
bool (MANGOS_IMPORT* m_pOnGossipSelectWithCode) (Player*, Creature*, uint32, uint32, const char*); bool (MANGOS_IMPORT* m_pOnGossipSelectWithCode)(Player*, Creature*, uint32, uint32, const char*);
bool (MANGOS_IMPORT* m_pOnGOGossipSelectWithCode) (Player*, GameObject*, uint32, uint32, const char*); bool (MANGOS_IMPORT* m_pOnGOGossipSelectWithCode)(Player*, GameObject*, uint32, uint32, const char*);
bool (MANGOS_IMPORT* m_pOnQuestAccept) (Player*, Creature*, Quest const*); bool (MANGOS_IMPORT* m_pOnQuestAccept)(Player*, Creature*, Quest const*);
bool (MANGOS_IMPORT* m_pOnGOQuestAccept) (Player*, GameObject*, Quest const*); bool (MANGOS_IMPORT* m_pOnGOQuestAccept)(Player*, GameObject*, Quest const*);
bool (MANGOS_IMPORT* m_pOnItemQuestAccept) (Player*, Item*, Quest const*); bool (MANGOS_IMPORT* m_pOnItemQuestAccept)(Player*, Item*, Quest const*);
bool (MANGOS_IMPORT* m_pOnQuestRewarded) (Player*, Creature*, Quest const*); bool (MANGOS_IMPORT* m_pOnQuestRewarded)(Player*, Creature*, Quest const*);
bool (MANGOS_IMPORT* m_pOnGOQuestRewarded) (Player*, GameObject*, Quest const*); bool (MANGOS_IMPORT* m_pOnGOQuestRewarded)(Player*, GameObject*, Quest const*);
uint32 (MANGOS_IMPORT* m_pGetNPCDialogStatus) (Player*, Creature*); uint32(MANGOS_IMPORT* m_pGetNPCDialogStatus)(Player*, Creature*);
uint32 (MANGOS_IMPORT* m_pGetGODialogStatus) (Player*, GameObject*); uint32(MANGOS_IMPORT* m_pGetGODialogStatus)(Player*, GameObject*);
bool (MANGOS_IMPORT* m_pOnGOUse) (Player*, GameObject*); bool (MANGOS_IMPORT* m_pOnGOUse)(Player*, GameObject*);
bool (MANGOS_IMPORT* m_pOnItemUse) (Player*, Item*, SpellCastTargets const&); bool (MANGOS_IMPORT* m_pOnItemUse)(Player*, Item*, SpellCastTargets const&);
bool (MANGOS_IMPORT* m_pOnAreaTrigger) (Player*, AreaTriggerEntry const*); bool (MANGOS_IMPORT* m_pOnAreaTrigger)(Player*, AreaTriggerEntry const*);
bool (MANGOS_IMPORT* m_pOnProcessEvent) (uint32, Object*, Object*, bool); bool (MANGOS_IMPORT* m_pOnProcessEvent)(uint32, Object*, Object*, bool);
bool (MANGOS_IMPORT* m_pOnEffectDummyCreature) (Unit*, uint32, SpellEffectIndex, Creature*); bool (MANGOS_IMPORT* m_pOnEffectDummyCreature)(Unit*, uint32, SpellEffectIndex, Creature*);
bool (MANGOS_IMPORT* m_pOnEffectDummyGO) (Unit*, uint32, SpellEffectIndex, GameObject*); bool (MANGOS_IMPORT* m_pOnEffectDummyGO)(Unit*, uint32, SpellEffectIndex, GameObject*);
bool (MANGOS_IMPORT* m_pOnEffectDummyItem) (Unit*, uint32, SpellEffectIndex, Item*); bool (MANGOS_IMPORT* m_pOnEffectDummyItem)(Unit*, uint32, SpellEffectIndex, Item*);
bool (MANGOS_IMPORT* m_pOnAuraDummy) (Aura const*, bool); bool (MANGOS_IMPORT* m_pOnAuraDummy)(Aura const*, bool);
}; };
#define sScriptMgr MaNGOS::Singleton<ScriptMgr>::Instance() #define sScriptMgr MaNGOS::Singleton<ScriptMgr>::Instance()
MANGOS_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 triggerId); MANGOS_DLL_SPEC uint32 GetAreaTriggerScriptId(uint32 triggerId);
MANGOS_DLL_SPEC uint32 GetEventIdScriptId(uint32 eventId); MANGOS_DLL_SPEC uint32 GetEventIdScriptId(uint32 eventId);
MANGOS_DLL_SPEC uint32 GetScriptId(const char *name); MANGOS_DLL_SPEC uint32 GetScriptId(const char* name);
MANGOS_DLL_SPEC char const* GetScriptName(uint32 id); MANGOS_DLL_SPEC char const* GetScriptName(uint32 id);
MANGOS_DLL_SPEC uint32 GetScriptIdsCount(); MANGOS_DLL_SPEC uint32 GetScriptIdsCount();

View file

@ -172,30 +172,30 @@ enum SpellSchoolMask
{ {
SPELL_SCHOOL_MASK_NONE = 0x00, // not exist SPELL_SCHOOL_MASK_NONE = 0x00, // not exist
SPELL_SCHOOL_MASK_NORMAL = (1 << SPELL_SCHOOL_NORMAL), // PHYSICAL (Armor) SPELL_SCHOOL_MASK_NORMAL = (1 << SPELL_SCHOOL_NORMAL), // PHYSICAL (Armor)
SPELL_SCHOOL_MASK_HOLY = (1 << SPELL_SCHOOL_HOLY ), SPELL_SCHOOL_MASK_HOLY = (1 << SPELL_SCHOOL_HOLY),
SPELL_SCHOOL_MASK_FIRE = (1 << SPELL_SCHOOL_FIRE ), SPELL_SCHOOL_MASK_FIRE = (1 << SPELL_SCHOOL_FIRE),
SPELL_SCHOOL_MASK_NATURE = (1 << SPELL_SCHOOL_NATURE), SPELL_SCHOOL_MASK_NATURE = (1 << SPELL_SCHOOL_NATURE),
SPELL_SCHOOL_MASK_FROST = (1 << SPELL_SCHOOL_FROST ), SPELL_SCHOOL_MASK_FROST = (1 << SPELL_SCHOOL_FROST),
SPELL_SCHOOL_MASK_SHADOW = (1 << SPELL_SCHOOL_SHADOW), SPELL_SCHOOL_MASK_SHADOW = (1 << SPELL_SCHOOL_SHADOW),
SPELL_SCHOOL_MASK_ARCANE = (1 << SPELL_SCHOOL_ARCANE), SPELL_SCHOOL_MASK_ARCANE = (1 << SPELL_SCHOOL_ARCANE),
// unions // unions
// 124, not include normal and holy damage // 124, not include normal and holy damage
SPELL_SCHOOL_MASK_SPELL = ( SPELL_SCHOOL_MASK_FIRE | SPELL_SCHOOL_MASK_SPELL = (SPELL_SCHOOL_MASK_FIRE |
SPELL_SCHOOL_MASK_NATURE | SPELL_SCHOOL_MASK_FROST | SPELL_SCHOOL_MASK_NATURE | SPELL_SCHOOL_MASK_FROST |
SPELL_SCHOOL_MASK_SHADOW | SPELL_SCHOOL_MASK_ARCANE ), SPELL_SCHOOL_MASK_SHADOW | SPELL_SCHOOL_MASK_ARCANE),
// 126 // 126
SPELL_SCHOOL_MASK_MAGIC = ( SPELL_SCHOOL_MASK_HOLY | SPELL_SCHOOL_MASK_SPELL ), SPELL_SCHOOL_MASK_MAGIC = (SPELL_SCHOOL_MASK_HOLY | SPELL_SCHOOL_MASK_SPELL),
// 127 // 127
SPELL_SCHOOL_MASK_ALL = ( SPELL_SCHOOL_MASK_NORMAL | SPELL_SCHOOL_MASK_MAGIC ) SPELL_SCHOOL_MASK_ALL = (SPELL_SCHOOL_MASK_NORMAL | SPELL_SCHOOL_MASK_MAGIC)
}; };
inline SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask) inline SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask)
{ {
for(int i = 0; i < MAX_SPELL_SCHOOL; ++i) for (int i = 0; i < MAX_SPELL_SCHOOL; ++i)
if(mask & (1 << i)) if (mask & (1 << i))
return SpellSchools(i); return SpellSchools(i);
return SPELL_SCHOOL_NORMAL; return SPELL_SCHOOL_NORMAL;
@ -215,7 +215,8 @@ enum ItemQualities
#define MAX_ITEM_QUALITY 8 #define MAX_ITEM_QUALITY 8
const uint32 ItemQualityColors[MAX_ITEM_QUALITY] = { const uint32 ItemQualityColors[MAX_ITEM_QUALITY] =
{
0xff9d9d9d, //GREY 0xff9d9d9d, //GREY
0xffffffff, //WHITE 0xffffffff, //WHITE
0xff1eff00, //GREEN 0xff1eff00, //GREEN
@ -1065,7 +1066,8 @@ enum SpellCastResultCustom
// Spell aura states // Spell aura states
enum AuraState enum AuraState
{ // (C) used in caster aura state (T) used in target aura state {
// (C) used in caster aura state (T) used in target aura state
// (c) used in caster aura state-not (t) used in target aura state-not // (c) used in caster aura state-not (t) used in target aura state-not
AURA_STATE_DEFENSE = 1, // C | AURA_STATE_DEFENSE = 1, // C |
AURA_STATE_HEALTHLESS_20_PERCENT = 2, // CcT | AURA_STATE_HEALTHLESS_20_PERCENT = 2, // CcT |
@ -2224,7 +2226,7 @@ enum QuestSort
inline uint8 ClassByQuestSort(int32 QuestSort) inline uint8 ClassByQuestSort(int32 QuestSort)
{ {
switch(QuestSort) switch (QuestSort)
{ {
case QUEST_SORT_WARLOCK: return CLASS_WARLOCK; case QUEST_SORT_WARLOCK: return CLASS_WARLOCK;
case QUEST_SORT_WARRIOR: return CLASS_WARRIOR; case QUEST_SORT_WARRIOR: return CLASS_WARRIOR;
@ -2400,7 +2402,7 @@ enum SkillType
inline SkillType SkillByLockType(LockType locktype) inline SkillType SkillByLockType(LockType locktype)
{ {
switch(locktype) switch (locktype)
{ {
case LOCKTYPE_PICKLOCK: return SKILL_LOCKPICKING; case LOCKTYPE_PICKLOCK: return SKILL_LOCKPICKING;
case LOCKTYPE_HERBALISM: return SKILL_HERBALISM; case LOCKTYPE_HERBALISM: return SKILL_HERBALISM;

View file

@ -54,12 +54,12 @@ void LoadSkillDiscoveryTable()
uint32 count = 0; uint32 count = 0;
// 0 1 2 3 // 0 1 2 3
QueryResult *result = WorldDatabase.Query("SELECT spellId, reqSpell, reqSkillValue, chance FROM skill_discovery_template"); QueryResult* result = WorldDatabase.Query("SELECT spellId, reqSpell, reqSkillValue, chance FROM skill_discovery_template");
if (!result) if (!result)
{ {
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty." ); sLog.outString(">> Loaded 0 skill discovery definitions. DB table `skill_discovery_template` is empty.");
return; return;
} }
@ -70,7 +70,7 @@ void LoadSkillDiscoveryTable()
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint32 spellId = fields[0].GetUInt32(); uint32 spellId = fields[0].GetUInt32();
@ -113,7 +113,7 @@ void LoadSkillDiscoveryTable()
continue; continue;
} }
SkillDiscoveryStore[reqSkillOrSpell].push_back( SkillDiscoveryEntry(spellId, reqSkillValue, chance) ); SkillDiscoveryStore[reqSkillOrSpell].push_back(SkillDiscoveryEntry(spellId, reqSkillValue, chance));
} }
else if (reqSkillOrSpell == 0) // skill case else if (reqSkillOrSpell == 0) // skill case
{ {
@ -125,8 +125,8 @@ void LoadSkillDiscoveryTable()
continue; continue;
} }
for(SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx) for (SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
SkillDiscoveryStore[-int32(_spell_idx->second->skillId)].push_back( SkillDiscoveryEntry(spellId, reqSkillValue, chance) ); SkillDiscoveryStore[-int32(_spell_idx->second->skillId)].push_back(SkillDiscoveryEntry(spellId, reqSkillValue, chance));
} }
else else
{ {
@ -135,17 +135,18 @@ void LoadSkillDiscoveryTable()
} }
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded %u skill discovery definitions", count ); sLog.outString(">> Loaded %u skill discovery definitions", count);
if (!ssNonDiscoverableEntries.str().empty()) 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 // report about empty data for explicit discovery spells
for(uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id) for (uint32 spell_id = 1; spell_id < sSpellStore.GetNumRows(); ++spell_id)
{ {
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell_id); SpellEntry const* spellEntry = sSpellStore.LookupEntry(spell_id);
if (!spellEntry) if (!spellEntry)
@ -172,7 +173,7 @@ uint32 GetExplicitDiscoverySpell(uint32 spellId, Player* player)
uint32 skillvalue = bounds.first != bounds.second ? player->GetSkillValue(bounds.first->second->skillId) : 0; uint32 skillvalue = bounds.first != bounds.second ? player->GetSkillValue(bounds.first->second->skillId) : 0;
float full_chance = 0; float full_chance = 0;
for(SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter) for (SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)
if (item_iter->reqSkillValue <= skillvalue) if (item_iter->reqSkillValue <= skillvalue)
if (!player->HasSpell(item_iter->spellId)) if (!player->HasSpell(item_iter->spellId))
full_chance += item_iter->chance; full_chance += item_iter->chance;
@ -180,7 +181,7 @@ uint32 GetExplicitDiscoverySpell(uint32 spellId, Player* player)
float rate = full_chance / 100.0f; float rate = full_chance / 100.0f;
float roll = rand_chance_f() * rate; // roll now in range 0..full_chance float roll = rand_chance_f() * rate; // roll now in range 0..full_chance
for(SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter) for (SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)
{ {
if (item_iter->reqSkillValue > skillvalue) if (item_iter->reqSkillValue > skillvalue)
continue; continue;
@ -206,7 +207,7 @@ uint32 GetSkillDiscoverySpell(uint32 skillId, uint32 spellId, Player* player)
if (tab != SkillDiscoveryStore.end()) if (tab != SkillDiscoveryStore.end())
{ {
for(SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter) for (SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)
{ {
if (roll_chance_f(item_iter->chance * sWorld.getConfig(CONFIG_FLOAT_RATE_SKILL_DISCOVERY)) && if (roll_chance_f(item_iter->chance * sWorld.getConfig(CONFIG_FLOAT_RATE_SKILL_DISCOVERY)) &&
item_iter->reqSkillValue <= skillvalue && item_iter->reqSkillValue <= skillvalue &&
@ -224,7 +225,7 @@ uint32 GetSkillDiscoverySpell(uint32 skillId, uint32 spellId, Player* player)
tab = SkillDiscoveryStore.find(-(int32)skillId); tab = SkillDiscoveryStore.find(-(int32)skillId);
if (tab != SkillDiscoveryStore.end()) if (tab != SkillDiscoveryStore.end())
{ {
for(SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter) for (SkillDiscoveryList::const_iterator item_iter = tab->second.begin(); item_iter != tab->second.end(); ++item_iter)
{ {
if (roll_chance_f(item_iter->chance * sWorld.getConfig(CONFIG_FLOAT_RATE_SKILL_DISCOVERY)) && if (roll_chance_f(item_iter->chance * sWorld.getConfig(CONFIG_FLOAT_RATE_SKILL_DISCOVERY)) &&
item_iter->reqSkillValue <= skillvalue && item_iter->reqSkillValue <= skillvalue &&

View file

@ -59,7 +59,7 @@ void LoadSkillExtraItemTable()
SkillExtraItemStore.clear(); // need for reload SkillExtraItemStore.clear(); // need for reload
// 0 1 2 3 // 0 1 2 3
QueryResult *result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template"); QueryResult* result = WorldDatabase.Query("SELECT spellId, requiredSpecialization, additionalCreateChance, additionalMaxNum FROM skill_extra_item_template");
if (result) if (result)
{ {
@ -67,7 +67,7 @@ void LoadSkillExtraItemTable()
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
bar.step(); bar.step();
uint32 spellId = fields[0].GetUInt32(); uint32 spellId = fields[0].GetUInt32();
@ -106,7 +106,8 @@ void LoadSkillExtraItemTable()
skillExtraItemEntry.additionalMaxNum = additionalMaxNum; skillExtraItemEntry.additionalMaxNum = additionalMaxNum;
++count; ++count;
} while (result->NextRow()); }
while (result->NextRow());
delete result; delete result;
@ -116,25 +117,25 @@ void LoadSkillExtraItemTable()
else else
{ {
sLog.outString(); sLog.outString();
sLog.outString( ">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty." ); sLog.outString(">> Loaded 0 spell specialization definitions. DB table `skill_extra_item_template` is empty.");
} }
} }
bool canCreateExtraItems(Player * player, uint32 spellId, float &additionalChance, uint8 &additionalMax) bool canCreateExtraItems(Player* player, uint32 spellId, float& additionalChance, uint8& additionalMax)
{ {
// get the info for the specified spell // get the info for the specified spell
SkillExtraItemMap::const_iterator ret = SkillExtraItemStore.find(spellId); SkillExtraItemMap::const_iterator ret = SkillExtraItemStore.find(spellId);
if(ret==SkillExtraItemStore.end()) if (ret==SkillExtraItemStore.end())
return false; return false;
SkillExtraItemEntry const* specEntry = &ret->second; SkillExtraItemEntry const* specEntry = &ret->second;
// if no entry, then no extra items can be created // if no entry, then no extra items can be created
if(!specEntry) if (!specEntry)
return false; return false;
// the player doesn't have the required specialization, return false // the player doesn't have the required specialization, return false
if(!player->HasSpell(specEntry->requiredSpecialization)) if (!player->HasSpell(specEntry->requiredSpecialization))
return false; return false;
// set the arguments to the appropriate values // set the arguments to the appropriate values

View file

@ -24,7 +24,7 @@
// predef classes used in functions // predef classes used in functions
class Player; class Player;
// returns true and sets the appropriate info if the player can create extra items with the given spellId // returns true and sets the appropriate info if the player can create extra items with the given spellId
bool canCreateExtraItems(Player * player, uint32 spellId, float &additionalChance, uint8 &additionalMax); bool canCreateExtraItems(Player* player, uint32 spellId, float& additionalChance, uint8& additionalMax);
// function to load the extra item creation info from DB // function to load the extra item creation info from DB
void LoadSkillExtraItemTable(); void LoadSkillExtraItemTable();
#endif #endif

View file

@ -25,7 +25,7 @@
#include "WorldSession.h" #include "WorldSession.h"
#include "UpdateMask.h" #include "UpdateMask.h"
void WorldSession::HandleLearnTalentOpcode( WorldPacket & recv_data ) void WorldSession::HandleLearnTalentOpcode(WorldPacket& recv_data)
{ {
uint32 talent_id, requested_rank; uint32 talent_id, requested_rank;
recv_data >> talent_id >> requested_rank; recv_data >> talent_id >> requested_rank;
@ -43,7 +43,7 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket)
uint32 talentId, talentRank; uint32 talentId, talentRank;
for(uint32 i = 0; i < talentsCount; ++i) for (uint32 i = 0; i < talentsCount; ++i)
{ {
recvPacket >> talentId >> talentRank; recvPacket >> talentId >> talentRank;
@ -53,16 +53,16 @@ void WorldSession::HandleLearnPreviewTalents(WorldPacket& recvPacket)
_player->SendTalentsInfoData(false); _player->SendTalentsInfoData(false);
} }
void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data ) void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket& recv_data)
{ {
DETAIL_LOG("MSG_TALENT_WIPE_CONFIRM"); DETAIL_LOG("MSG_TALENT_WIPE_CONFIRM");
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
if (!unit) if (!unit)
{ {
DEBUG_LOG( "WORLD: HandleTalentWipeConfirmOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); DEBUG_LOG("WORLD: HandleTalentWipeConfirmOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
return; return;
} }
@ -72,10 +72,10 @@ void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data )
if (!(_player->resetTalents())) 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 << uint64(0);
data << uint32(0); data << uint32(0);
SendPacket( &data ); SendPacket(&data);
return; return;
} }
@ -83,7 +83,7 @@ void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data )
unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect" unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect"
} }
void WorldSession::HandleUnlearnSkillOpcode(WorldPacket & recv_data) void WorldSession::HandleUnlearnSkillOpcode(WorldPacket& recv_data)
{ {
uint32 skill_id; uint32 skill_id;
recv_data >> skill_id; recv_data >> skill_id;

View file

@ -26,7 +26,7 @@
#include "World.h" #include "World.h"
#include "Util.h" #include "Util.h"
INSTANTIATE_SINGLETON_1( SocialMgr ); INSTANTIATE_SINGLETON_1(SocialMgr);
PlayerSocial::PlayerSocial() PlayerSocial::PlayerSocial()
{ {
@ -40,9 +40,9 @@ PlayerSocial::~PlayerSocial()
uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag) uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag)
{ {
uint32 counter = 0; uint32 counter = 0;
for(PlayerSocialMap::const_iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr) for (PlayerSocialMap::const_iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
{ {
if(itr->second.Flags & flag) if (itr->second.Flags & flag)
++counter; ++counter;
} }
return counter; return counter;
@ -51,23 +51,23 @@ uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag)
bool PlayerSocial::AddToSocialList(ObjectGuid friend_guid, bool ignore) bool PlayerSocial::AddToSocialList(ObjectGuid friend_guid, bool ignore)
{ {
// check client limits // check client limits
if(ignore) if (ignore)
{ {
if(GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED) >= SOCIALMGR_IGNORE_LIMIT) if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_IGNORED) >= SOCIALMGR_IGNORE_LIMIT)
return false; return false;
} }
else else
{ {
if(GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND) >= SOCIALMGR_FRIEND_LIMIT) if (GetNumberOfSocialsWithFlag(SOCIAL_FLAG_FRIEND) >= SOCIALMGR_FRIEND_LIMIT)
return false; return false;
} }
uint32 flag = SOCIAL_FLAG_FRIEND; uint32 flag = SOCIAL_FLAG_FRIEND;
if(ignore) if (ignore)
flag = SOCIAL_FLAG_IGNORED; flag = SOCIAL_FLAG_IGNORED;
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter()); PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter());
if(itr != m_playerSocialMap.end()) if (itr != m_playerSocialMap.end())
{ {
CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags | %u) WHERE guid = '%u' AND friend = '%u'", flag, m_playerLowGuid, friend_guid.GetCounter()); CharacterDatabase.PExecute("UPDATE character_social SET flags = (flags | %u) WHERE guid = '%u' AND friend = '%u'", flag, m_playerLowGuid, friend_guid.GetCounter());
m_playerSocialMap[friend_guid.GetCounter()].Flags |= flag; m_playerSocialMap[friend_guid.GetCounter()].Flags |= flag;
@ -85,15 +85,15 @@ bool PlayerSocial::AddToSocialList(ObjectGuid friend_guid, bool ignore)
void PlayerSocial::RemoveFromSocialList(ObjectGuid friend_guid, bool ignore) void PlayerSocial::RemoveFromSocialList(ObjectGuid friend_guid, bool ignore)
{ {
PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_guid.GetCounter()); PlayerSocialMap::iterator itr = m_playerSocialMap.find(friend_guid.GetCounter());
if(itr == m_playerSocialMap.end()) // not exist if (itr == m_playerSocialMap.end()) // not exist
return; return;
uint32 flag = SOCIAL_FLAG_FRIEND; uint32 flag = SOCIAL_FLAG_FRIEND;
if(ignore) if (ignore)
flag = SOCIAL_FLAG_IGNORED; flag = SOCIAL_FLAG_IGNORED;
itr->second.Flags &= ~flag; itr->second.Flags &= ~flag;
if(itr->second.Flags == 0) if (itr->second.Flags == 0)
{ {
CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' AND friend = '%u'", m_playerLowGuid, friend_guid.GetCounter()); CharacterDatabase.PExecute("DELETE FROM character_social WHERE guid = '%u' AND friend = '%u'", m_playerLowGuid, friend_guid.GetCounter());
m_playerSocialMap.erase(itr); m_playerSocialMap.erase(itr);
@ -107,7 +107,7 @@ void PlayerSocial::RemoveFromSocialList(ObjectGuid friend_guid, bool ignore)
void PlayerSocial::SetFriendNote(ObjectGuid friend_guid, std::string note) void PlayerSocial::SetFriendNote(ObjectGuid friend_guid, std::string note)
{ {
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter()); PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter());
if(itr == m_playerSocialMap.end()) // not exist if (itr == m_playerSocialMap.end()) // not exist
return; return;
utf8truncate(note,48); // DB and client size limitation utf8truncate(note,48); // DB and client size limitation
@ -120,8 +120,8 @@ void PlayerSocial::SetFriendNote(ObjectGuid friend_guid, std::string note)
void PlayerSocial::SendSocialList() void PlayerSocial::SendSocialList()
{ {
Player *plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid)); Player* plr = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, m_playerLowGuid));
if(!plr) if (!plr)
return; return;
uint32 size = m_playerSocialMap.size(); uint32 size = m_playerSocialMap.size();
@ -130,17 +130,17 @@ void PlayerSocial::SendSocialList()
data << uint32(7); // unk flag (0x1, 0x2, 0x4), 0x7 if it include ignore list data << uint32(7); // unk flag (0x1, 0x2, 0x4), 0x7 if it include ignore list
data << uint32(size); // friends count data << uint32(size); // friends count
for(PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr) for (PlayerSocialMap::iterator itr = m_playerSocialMap.begin(); itr != m_playerSocialMap.end(); ++itr)
{ {
sSocialMgr.GetFriendInfo(plr, itr->first, itr->second); sSocialMgr.GetFriendInfo(plr, itr->first, itr->second);
data << ObjectGuid(HIGHGUID_PLAYER, itr->first); // player guid data << ObjectGuid(HIGHGUID_PLAYER, itr->first); // player guid
data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?) data << uint32(itr->second.Flags); // player flag (0x1-friend?, 0x2-ignored?, 0x4-muted?)
data << itr->second.Note; // string note data << itr->second.Note; // string note
if(itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend() if (itr->second.Flags & SOCIAL_FLAG_FRIEND) // if IsFriend()
{ {
data << uint8(itr->second.Status); // online/offline/etc? data << uint8(itr->second.Status); // online/offline/etc?
if(itr->second.Status) // if online if (itr->second.Status) // if online
{ {
data << uint32(itr->second.Area); // player area data << uint32(itr->second.Area); // player area
data << uint32(itr->second.Level); // player level data << uint32(itr->second.Level); // player level
@ -156,7 +156,7 @@ void PlayerSocial::SendSocialList()
bool PlayerSocial::HasFriend(ObjectGuid friend_guid) bool PlayerSocial::HasFriend(ObjectGuid friend_guid)
{ {
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter()); PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(friend_guid.GetCounter());
if(itr != m_playerSocialMap.end()) if (itr != m_playerSocialMap.end())
return itr->second.Flags & SOCIAL_FLAG_FRIEND; return itr->second.Flags & SOCIAL_FLAG_FRIEND;
return false; return false;
} }
@ -164,7 +164,7 @@ bool PlayerSocial::HasFriend(ObjectGuid friend_guid)
bool PlayerSocial::HasIgnore(ObjectGuid ignore_guid) bool PlayerSocial::HasIgnore(ObjectGuid ignore_guid)
{ {
PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(ignore_guid.GetCounter()); PlayerSocialMap::const_iterator itr = m_playerSocialMap.find(ignore_guid.GetCounter());
if(itr != m_playerSocialMap.end()) if (itr != m_playerSocialMap.end())
return itr->second.Flags & SOCIAL_FLAG_IGNORED; return itr->second.Flags & SOCIAL_FLAG_IGNORED;
return false; return false;
} }
@ -179,20 +179,20 @@ SocialMgr::~SocialMgr()
} }
void SocialMgr::GetFriendInfo(Player *player, uint32 friend_lowguid, FriendInfo &friendInfo) void SocialMgr::GetFriendInfo(Player* player, uint32 friend_lowguid, FriendInfo& friendInfo)
{ {
if(!player) if (!player)
return; return;
Player *pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid)); Player* pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friend_lowguid));
Team team = player->GetTeam(); Team team = player->GetTeam();
AccountTypes security = player->GetSession()->GetSecurity(); AccountTypes security = player->GetSession()->GetSecurity();
bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST);
AccountTypes gmLevelInWhoList = AccountTypes (sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST)); AccountTypes gmLevelInWhoList = AccountTypes(sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST));
PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friend_lowguid); PlayerSocialMap::iterator itr = player->GetSocial()->m_playerSocialMap.find(friend_lowguid);
if(itr != player->GetSocial()->m_playerSocialMap.end()) if (itr != player->GetSocial()->m_playerSocialMap.end())
friendInfo.Note = itr->second.Note; friendInfo.Note = itr->second.Note;
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
@ -203,9 +203,9 @@ void SocialMgr::GetFriendInfo(Player *player, uint32 friend_lowguid, FriendInfo
pFriend->IsVisibleGloballyFor(player)) pFriend->IsVisibleGloballyFor(player))
{ {
friendInfo.Status = FRIEND_STATUS_ONLINE; friendInfo.Status = FRIEND_STATUS_ONLINE;
if(pFriend->isAFK()) if (pFriend->isAFK())
friendInfo.Status = FRIEND_STATUS_AFK; friendInfo.Status = FRIEND_STATUS_AFK;
if(pFriend->isDND()) if (pFriend->isDND())
friendInfo.Status = FRIEND_STATUS_DND; friendInfo.Status = FRIEND_STATUS_DND;
friendInfo.Area = pFriend->GetZoneId(); friendInfo.Area = pFriend->GetZoneId();
friendInfo.Level = pFriend->getLevel(); friendInfo.Level = pFriend->getLevel();
@ -220,14 +220,14 @@ void SocialMgr::GetFriendInfo(Player *player, uint32 friend_lowguid, FriendInfo
} }
} }
void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket *data) void SocialMgr::MakeFriendStatusPacket(FriendsResult result, uint32 guid, WorldPacket* data)
{ {
data->Initialize(SMSG_FRIEND_STATUS, 5); data->Initialize(SMSG_FRIEND_STATUS, 5);
*data << uint8(result); *data << uint8(result);
*data << ObjectGuid(HIGHGUID_PLAYER, guid); *data << ObjectGuid(HIGHGUID_PLAYER, guid);
} }
void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, ObjectGuid friend_guid, bool broadcast) void SocialMgr::SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friend_guid, bool broadcast)
{ {
uint32 friend_lowguid = friend_guid.GetCounter(); uint32 friend_lowguid = friend_guid.GetCounter();
@ -236,7 +236,7 @@ void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, ObjectGui
WorldPacket data; WorldPacket data;
MakeFriendStatusPacket(result, friend_lowguid, &data); MakeFriendStatusPacket(result, friend_lowguid, &data);
GetFriendInfo(player, friend_lowguid, fi); GetFriendInfo(player, friend_lowguid, fi);
switch(result) switch (result)
{ {
case FRIEND_ADDED_OFFLINE: case FRIEND_ADDED_OFFLINE:
case FRIEND_ADDED_ONLINE: case FRIEND_ADDED_ONLINE:
@ -246,7 +246,7 @@ void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, ObjectGui
break; break;
} }
switch(result) switch (result)
{ {
case FRIEND_ADDED_ONLINE: case FRIEND_ADDED_ONLINE:
case FRIEND_ONLINE: case FRIEND_ONLINE:
@ -259,15 +259,15 @@ void SocialMgr::SendFriendStatus(Player *player, FriendsResult result, ObjectGui
break; break;
} }
if(broadcast) if (broadcast)
BroadcastToFriendListers(player, &data); BroadcastToFriendListers(player, &data);
else else
player->GetSession()->SendPacket(&data); player->GetSession()->SendPacket(&data);
} }
void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet) void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet)
{ {
if(!player) if (!player)
return; return;
Team team = player->GetTeam(); Team team = player->GetTeam();
@ -276,12 +276,12 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet)
AccountTypes gmLevelInWhoList = AccountTypes(sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST)); AccountTypes gmLevelInWhoList = AccountTypes(sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST));
bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST); bool allowTwoSideWhoList = sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_WHO_LIST);
for(SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr) for (SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr)
{ {
PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(guid); PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(guid);
if(itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND)) if (itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND))
{ {
Player *pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)); Player* pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
// PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters // PLAYER see his team only and PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
// MODERATOR, GAME MASTER, ADMINISTRATOR can see all // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
@ -296,12 +296,12 @@ void SocialMgr::BroadcastToFriendListers(Player *player, WorldPacket *packet)
} }
} }
PlayerSocial *SocialMgr::LoadFromDB(QueryResult *result, ObjectGuid guid) PlayerSocial* SocialMgr::LoadFromDB(QueryResult* result, ObjectGuid guid)
{ {
PlayerSocial *social = &m_socialMap[guid.GetCounter()]; PlayerSocial* social = &m_socialMap[guid.GetCounter()];
social->SetPlayerGuid(guid); social->SetPlayerGuid(guid);
if(!result) if (!result)
return social; return social;
uint32 friend_guid = 0; uint32 friend_guid = 0;
@ -313,25 +313,25 @@ PlayerSocial *SocialMgr::LoadFromDB(QueryResult *result, ObjectGuid guid)
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
friend_guid = fields[0].GetUInt32(); friend_guid = fields[0].GetUInt32();
flags = fields[1].GetUInt32(); flags = fields[1].GetUInt32();
note = fields[2].GetCppString(); note = fields[2].GetCppString();
if((flags & SOCIAL_FLAG_IGNORED) && ignoreCounter >= SOCIALMGR_IGNORE_LIMIT) if ((flags & SOCIAL_FLAG_IGNORED) && ignoreCounter >= SOCIALMGR_IGNORE_LIMIT)
continue; continue;
if((flags & SOCIAL_FLAG_FRIEND) && friendCounter >= SOCIALMGR_FRIEND_LIMIT) if ((flags & SOCIAL_FLAG_FRIEND) && friendCounter >= SOCIALMGR_FRIEND_LIMIT)
continue; continue;
social->m_playerSocialMap[friend_guid] = FriendInfo(flags, note); social->m_playerSocialMap[friend_guid] = FriendInfo(flags, note);
if(flags & SOCIAL_FLAG_IGNORED) if (flags & SOCIAL_FLAG_IGNORED)
ignoreCounter++; ignoreCounter++;
else else
friendCounter++; friendCounter++;
} }
while( result->NextRow() ); while (result->NextRow());
delete result; delete result;
return social; return social;
} }

View file

@ -143,13 +143,13 @@ class SocialMgr
// Misc // Misc
void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); } void RemovePlayerSocial(uint32 guid) { m_socialMap.erase(guid); }
void GetFriendInfo(Player *player, uint32 friendGUID, FriendInfo &friendInfo); void GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo& friendInfo);
// Packet management // Packet management
void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket *data); void MakeFriendStatusPacket(FriendsResult result, uint32 friend_guid, WorldPacket* data);
void SendFriendStatus(Player *player, FriendsResult result, ObjectGuid friend_guid, bool broadcast); void SendFriendStatus(Player* player, FriendsResult result, ObjectGuid friend_guid, bool broadcast);
void BroadcastToFriendListers(Player *player, WorldPacket *packet); void BroadcastToFriendListers(Player* player, WorldPacket* packet);
// Loading // Loading
PlayerSocial *LoadFromDB(QueryResult *result, ObjectGuid guid); PlayerSocial* LoadFromDB(QueryResult* result, ObjectGuid guid);
private: private:
SocialMap m_socialMap; SocialMap m_socialMap;
}; };

File diff suppressed because it is too large Load diff

View file

@ -107,12 +107,12 @@ class SpellCastTargets
SpellCastTargets(); SpellCastTargets();
~SpellCastTargets(); ~SpellCastTargets();
void read( ByteBuffer& data, Unit *caster ); void read(ByteBuffer& data, Unit* caster);
void write( ByteBuffer& data ) const; 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) SpellCastTargets& operator=(const SpellCastTargets& target)
{ {
m_unitTarget = target.m_unitTarget; m_unitTarget = target.m_unitTarget;
m_itemTarget = target.m_itemTarget; m_itemTarget = target.m_itemTarget;
@ -143,14 +143,14 @@ class SpellCastTargets
} }
ObjectGuid getUnitTargetGuid() const { return m_unitTargetGUID; } ObjectGuid getUnitTargetGuid() const { return m_unitTargetGUID; }
Unit *getUnitTarget() const { return m_unitTarget; } Unit* getUnitTarget() const { return m_unitTarget; }
void setUnitTarget(Unit *target); void setUnitTarget(Unit* target);
void setDestination(float x, float y, float z); void setDestination(float x, float y, float z);
void setSource(float x, float y, float z); void setSource(float x, float y, float z);
ObjectGuid getGOTargetGuid() const { return m_GOTargetGUID; } ObjectGuid getGOTargetGuid() const { return m_GOTargetGUID; }
GameObject *getGOTarget() const { return m_GOTarget; } GameObject* getGOTarget() const { return m_GOTarget; }
void setGOTarget(GameObject *target); void setGOTarget(GameObject* target);
ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; } ObjectGuid getCorpseTargetGuid() const { return m_CorpseTargetGUID; }
void setCorpseTarget(Corpse* corpse); void setCorpseTarget(Corpse* corpse);
@ -162,7 +162,7 @@ class SpellCastTargets
void setTradeItemTarget(Player* caster); void setTradeItemTarget(Player* caster);
void updateTradeSlotItem() void updateTradeSlotItem()
{ {
if(m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM)) if (m_itemTarget && (m_targetMask & TARGET_FLAG_TRADE_ITEM))
{ {
m_itemTargetGUID = m_itemTarget->GetObjectGuid(); m_itemTargetGUID = m_itemTarget->GetObjectGuid();
m_itemTargetEntry = m_itemTarget->GetEntry(); m_itemTargetEntry = m_itemTarget->GetEntry();
@ -180,9 +180,9 @@ class SpellCastTargets
uint32 m_targetMask; uint32 m_targetMask;
private: private:
// objects (can be used at spell creating and after Update at casting // objects (can be used at spell creating and after Update at casting
Unit *m_unitTarget; Unit* m_unitTarget;
GameObject *m_GOTarget; GameObject* m_GOTarget;
Item *m_itemTarget; Item* m_itemTarget;
// object GUID/etc, can be used always // object GUID/etc, can be used always
ObjectGuid m_unitTargetGUID; ObjectGuid m_unitTargetGUID;
@ -230,7 +230,7 @@ class Spell
{ {
friend struct MaNGOS::SpellNotifierPlayer; friend struct MaNGOS::SpellNotifierPlayer;
friend struct MaNGOS::SpellNotifierCreatureAndPlayer; friend struct MaNGOS::SpellNotifierCreatureAndPlayer;
friend void Unit::SetCurrentCastedSpell( Spell * pSpell ); friend void Unit::SetCurrentCastedSpell(Spell* pSpell);
public: public:
void EffectEmpty(SpellEffectIndex eff_idx); void EffectEmpty(SpellEffectIndex eff_idx);
@ -322,7 +322,7 @@ class Spell
void EffectDispelMechanic(SpellEffectIndex eff_idx); void EffectDispelMechanic(SpellEffectIndex eff_idx);
void EffectSummonDeadPet(SpellEffectIndex eff_idx); void EffectSummonDeadPet(SpellEffectIndex eff_idx);
void EffectSummonAllTotems(SpellEffectIndex eff_idx); void EffectSummonAllTotems(SpellEffectIndex eff_idx);
void EffectBreakPlayerTargeting (SpellEffectIndex eff_idx); void EffectBreakPlayerTargeting(SpellEffectIndex eff_idx);
void EffectDestroyAllTotems(SpellEffectIndex eff_idx); void EffectDestroyAllTotems(SpellEffectIndex eff_idx);
void EffectDurabilityDamage(SpellEffectIndex eff_idx); void EffectDurabilityDamage(SpellEffectIndex eff_idx);
void EffectSkill(SpellEffectIndex eff_idx); void EffectSkill(SpellEffectIndex eff_idx);
@ -353,7 +353,7 @@ class Spell
void EffectActivateSpec(SpellEffectIndex eff_idx); void EffectActivateSpec(SpellEffectIndex eff_idx);
void EffectCancelAura(SpellEffectIndex eff_idx); void EffectCancelAura(SpellEffectIndex eff_idx);
Spell(Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid(), SpellEntry const* triggeredBy = NULL); Spell(Unit* caster, SpellEntry const* info, bool triggered, ObjectGuid originalCasterGUID = ObjectGuid(), SpellEntry const* triggeredBy = NULL);
~Spell(); ~Spell();
void prepare(SpellCastTargets const* targets, Aura* triggeredByAura = NULL); void prepare(SpellCastTargets const* targets, Aura* triggeredByAura = NULL);
@ -399,16 +399,16 @@ class Spell
typedef std::list<Unit*> UnitList; typedef std::list<Unit*> UnitList;
void FillTargetMap(); void FillTargetMap();
void SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList &targetUnitMap); void SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& targetUnitMap);
void FillAreaTargets(UnitList &targetUnitMap, float radius, SpellNotifyPushType pushType, SpellTargets spellTargets, WorldObject* originalCaster = NULL); void FillAreaTargets(UnitList& targetUnitMap, float radius, SpellNotifyPushType pushType, SpellTargets spellTargets, WorldObject* originalCaster = NULL);
void FillRaidOrPartyTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster); void FillRaidOrPartyTargets(UnitList& targetUnitMap, Unit* member, Unit* center, float radius, bool raid, bool withPets, bool withcaster);
void FillRaidOrPartyManaPriorityTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster); void FillRaidOrPartyManaPriorityTargets(UnitList& targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster);
void FillRaidOrPartyHealthPriorityTargets(UnitList &targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster); void FillRaidOrPartyHealthPriorityTargets(UnitList& targetUnitMap, Unit* member, Unit* center, float radius, uint32 count, bool raid, bool withPets, bool withcaster);
template<typename T> WorldObject* FindCorpseUsing(); template<typename T> WorldObject* FindCorpseUsing();
bool CheckTarget( Unit* target, SpellEffectIndex eff ); bool CheckTarget(Unit* target, SpellEffectIndex eff);
bool CanAutoCast(Unit* target); bool CanAutoCast(Unit* target);
static void MANGOS_DLL_SPEC SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 cast_count, SpellCastResult result); static void MANGOS_DLL_SPEC SendCastResult(Player* caster, SpellEntry const* spellInfo, uint8 cast_count, SpellCastResult result);
@ -423,7 +423,7 @@ class Spell
void SendResurrectRequest(Player* target); void SendResurrectRequest(Player* target);
void SendPlaySpellVisual(uint32 SpellID); 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 HandleThreatSpells();
//void HandleAddAura(Unit* Target); //void HandleAddAura(Unit* Target);
@ -523,7 +523,7 @@ class Spell
uint8 m_delayAtDamageCount; uint8 m_delayAtDamageCount;
bool isDelayableNoMore() bool isDelayableNoMore()
{ {
if(m_delayAtDamageCount >= 2) if (m_delayAtDamageCount >= 2)
return true; return true;
m_delayAtDamageCount++; m_delayAtDamageCount++;
@ -597,7 +597,7 @@ class Spell
struct ItemTargetInfo struct ItemTargetInfo
{ {
Item *item; Item* item;
uint8 effectMask; uint8 effectMask;
}; };
@ -614,13 +614,13 @@ class Spell
void AddGOTarget(GameObject* target, SpellEffectIndex effIndex); void AddGOTarget(GameObject* target, SpellEffectIndex effIndex);
void AddGOTarget(ObjectGuid goGuid, SpellEffectIndex effIndex); void AddGOTarget(ObjectGuid goGuid, SpellEffectIndex effIndex);
void AddItemTarget(Item* target, SpellEffectIndex effIndex); void AddItemTarget(Item* target, SpellEffectIndex effIndex);
void DoAllEffectOnTarget(TargetInfo *target); void DoAllEffectOnTarget(TargetInfo* target);
void HandleDelayedSpellLaunch(TargetInfo *target); void HandleDelayedSpellLaunch(TargetInfo* target);
void InitializeDamageMultipliers(); void InitializeDamageMultipliers();
void ResetEffectDamageAndHeal(); void ResetEffectDamageAndHeal();
void DoSpellHitOnUnit(Unit *unit, uint32 effectMask); void DoSpellHitOnUnit(Unit* unit, uint32 effectMask);
void DoAllEffectOnTarget(GOTargetInfo *target); void DoAllEffectOnTarget(GOTargetInfo* target);
void DoAllEffectOnTarget(ItemTargetInfo *target); void DoAllEffectOnTarget(ItemTargetInfo* target);
bool IsAliveUnitPresentInTargetList(); bool IsAliveUnitPresentInTargetList();
SpellCastResult CanOpenLock(SpellEffectIndex effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue); SpellCastResult CanOpenLock(SpellEffectIndex effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue);
// ------------------------------------------- // -------------------------------------------
@ -679,43 +679,43 @@ namespace MaNGOS
{ {
struct MANGOS_DLL_DECL SpellNotifierPlayer // Currently unused. When put to use this one requires handling for source-location (smilar to below) struct MANGOS_DLL_DECL SpellNotifierPlayer // Currently unused. When put to use this one requires handling for source-location (smilar to below)
{ {
Spell::UnitList &i_data; Spell::UnitList& i_data;
Spell &i_spell; Spell& i_spell;
const uint32& i_index; const uint32& i_index;
float i_radius; float i_radius;
WorldObject* i_originalCaster; WorldObject* i_originalCaster;
SpellNotifierPlayer(Spell &spell, Spell::UnitList &data, const uint32 &i, float radius) SpellNotifierPlayer(Spell& spell, Spell::UnitList& data, const uint32& i, float radius)
: i_data(data), i_spell(spell), i_index(i), i_radius(radius) : i_data(data), i_spell(spell), i_index(i), i_radius(radius)
{ {
i_originalCaster = i_spell.GetAffectiveCasterObject(); i_originalCaster = i_spell.GetAffectiveCasterObject();
} }
void Visit(PlayerMapType &m) void Visit(PlayerMapType& m)
{ {
if(!i_originalCaster) if (!i_originalCaster)
return; 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(); Player* pPlayer = itr->getSource();
if( !pPlayer->isAlive() || pPlayer->IsTaxiFlying()) if (!pPlayer->isAlive() || pPlayer->IsTaxiFlying())
continue; continue;
if( i_originalCaster->IsFriendlyTo(pPlayer) ) if (i_originalCaster->IsFriendlyTo(pPlayer))
continue; 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); i_data.push_back(pPlayer);
} }
} }
template<class SKIP> void Visit(GridRefManager<SKIP> &) {} template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
}; };
struct MANGOS_DLL_DECL SpellNotifierCreatureAndPlayer struct MANGOS_DLL_DECL SpellNotifierCreatureAndPlayer
{ {
Spell::UnitList *i_data; Spell::UnitList* i_data;
Spell &i_spell; Spell& i_spell;
SpellNotifyPushType i_push_type; SpellNotifyPushType i_push_type;
float i_radius; float i_radius;
SpellTargets i_TargetType; SpellTargets i_TargetType;
@ -729,7 +729,7 @@ namespace MaNGOS
float GetCenterX() const { return i_centerX; } float GetCenterX() const { return i_centerX; }
float GetCenterY() const { return i_centerY; } float GetCenterY() const { return i_centerY; }
SpellNotifierCreatureAndPlayer(Spell &spell, Spell::UnitList &data, float radius, SpellNotifyPushType type, SpellNotifierCreatureAndPlayer(Spell& spell, Spell::UnitList& data, float radius, SpellNotifyPushType type,
SpellTargets TargetType = SPELL_TARGETS_NOT_FRIENDLY, WorldObject* originalCaster = NULL) SpellTargets TargetType = SPELL_TARGETS_NOT_FRIENDLY, WorldObject* originalCaster = NULL)
: i_data(&data), i_spell(spell), i_push_type(type), i_radius(radius), i_TargetType(TargetType), : i_data(&data), i_spell(spell), i_push_type(type), i_radius(radius), i_TargetType(TargetType),
i_originalCaster(originalCaster), i_castingObject(i_spell.GetCastingObject()) i_originalCaster(originalCaster), i_castingObject(i_spell.GetCastingObject())
@ -738,7 +738,7 @@ namespace MaNGOS
i_originalCaster = i_spell.GetAffectiveCasterObject(); i_originalCaster = i_spell.GetAffectiveCasterObject();
i_playerControlled = i_originalCaster ? i_originalCaster->IsControlledByPlayer() : false; i_playerControlled = i_originalCaster ? i_originalCaster->IsControlledByPlayer() : false;
switch(i_push_type) switch (i_push_type)
{ {
case PUSH_IN_FRONT: case PUSH_IN_FRONT:
case PUSH_IN_FRONT_90: case PUSH_IN_FRONT_90:
@ -778,14 +778,14 @@ namespace MaNGOS
} }
} }
template<class T> inline void Visit(GridRefManager<T> &m) template<class T> inline void Visit(GridRefManager<T>& m)
{ {
MANGOS_ASSERT(i_data); MANGOS_ASSERT(i_data);
if (!i_originalCaster || !i_castingObject) if (!i_originalCaster || !i_castingObject)
return; return;
for(typename GridRefManager<T>::iterator itr = m.begin(); itr != m.end(); ++itr) for (typename GridRefManager<T>::iterator itr = m.begin(); itr != m.end(); ++itr)
{ {
// there are still more spells which can be casted on dead, but // there are still more spells which can be casted on dead, but
// they are no AOE and don't have such a nice SPELL_ATTR flag // they are no AOE and don't have such a nice SPELL_ATTR flag
@ -797,19 +797,19 @@ namespace MaNGOS
switch (i_TargetType) switch (i_TargetType)
{ {
case SPELL_TARGETS_HOSTILE: case SPELL_TARGETS_HOSTILE:
if (!i_originalCaster->IsHostileTo( itr->getSource() )) if (!i_originalCaster->IsHostileTo(itr->getSource()))
continue; continue;
break; break;
case SPELL_TARGETS_NOT_FRIENDLY: case SPELL_TARGETS_NOT_FRIENDLY:
if (i_originalCaster->IsFriendlyTo( itr->getSource() )) if (i_originalCaster->IsFriendlyTo(itr->getSource()))
continue; continue;
break; break;
case SPELL_TARGETS_NOT_HOSTILE: case SPELL_TARGETS_NOT_HOSTILE:
if (i_originalCaster->IsHostileTo( itr->getSource() )) if (i_originalCaster->IsHostileTo(itr->getSource()))
continue; continue;
break; break;
case SPELL_TARGETS_FRIENDLY: case SPELL_TARGETS_FRIENDLY:
if (!i_originalCaster->IsFriendlyTo( itr->getSource() )) if (!i_originalCaster->IsFriendlyTo(itr->getSource()))
continue; continue;
break; break;
case SPELL_TARGETS_AOE_DAMAGE: case SPELL_TARGETS_AOE_DAMAGE:
@ -819,12 +819,12 @@ namespace MaNGOS
if (i_playerControlled) if (i_playerControlled)
{ {
if (i_originalCaster->IsFriendlyTo( itr->getSource() )) if (i_originalCaster->IsFriendlyTo(itr->getSource()))
continue; continue;
} }
else else
{ {
if (!i_originalCaster->IsHostileTo( itr->getSource() )) if (!i_originalCaster->IsHostileTo(itr->getSource()))
continue; continue;
} }
} }
@ -835,26 +835,26 @@ namespace MaNGOS
} }
// we don't need to check InMap here, it's already done some lines above // we don't need to check InMap here, it's already done some lines above
switch(i_push_type) switch (i_push_type)
{ {
case PUSH_IN_FRONT: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_FRONT_90: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_FRONT_30: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_FRONT_15: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_IN_BACK: 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()); i_data->push_back(itr->getSource());
break; break;
case PUSH_SELF_CENTER: case PUSH_SELF_CENTER:
@ -873,20 +873,20 @@ namespace MaNGOS
} }
} }
#ifdef WIN32 #ifdef WIN32
template<> inline void Visit(CorpseMapType & ) {} template<> inline void Visit(CorpseMapType&) {}
template<> inline void Visit(GameObjectMapType & ) {} template<> inline void Visit(GameObjectMapType&) {}
template<> inline void Visit(DynamicObjectMapType & ) {} template<> inline void Visit(DynamicObjectMapType&) {}
template<> inline void Visit(CameraMapType & ) {} template<> inline void Visit(CameraMapType&) {}
#endif #endif
}; };
#ifndef WIN32 #ifndef WIN32
template<> inline void SpellNotifierCreatureAndPlayer::Visit(CorpseMapType& ) {} template<> inline void SpellNotifierCreatureAndPlayer::Visit(CorpseMapType&) {}
template<> inline void SpellNotifierCreatureAndPlayer::Visit(GameObjectMapType& ) {} template<> inline void SpellNotifierCreatureAndPlayer::Visit(GameObjectMapType&) {}
template<> inline void SpellNotifierCreatureAndPlayer::Visit(DynamicObjectMapType& ) {} template<> inline void SpellNotifierCreatureAndPlayer::Visit(DynamicObjectMapType&) {}
template<> inline void SpellNotifierCreatureAndPlayer::Visit(CameraMapType& ) {} template<> inline void SpellNotifierCreatureAndPlayer::Visit(CameraMapType&) {}
#endif #endif
} }
typedef void(Spell::*pEffect)(SpellEffectIndex eff_idx); typedef void(Spell::*pEffect)(SpellEffectIndex eff_idx);

File diff suppressed because it is too large Load diff

View file

@ -43,10 +43,10 @@ struct ReapplyAffectedPassiveAurasHelper;
class MANGOS_DLL_SPEC SpellAuraHolder class MANGOS_DLL_SPEC SpellAuraHolder
{ {
public: public:
SpellAuraHolder (SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem); SpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem);
Aura* m_auras[MAX_EFFECT_INDEX]; Aura* m_auras[MAX_EFFECT_INDEX];
void AddAura(Aura *aura, SpellEffectIndex index); void AddAura(Aura* aura, SpellEffectIndex index);
void RemoveAura(SpellEffectIndex index); void RemoveAura(SpellEffectIndex index);
void ApplyAuraModifiers(bool apply, bool real = false); void ApplyAuraModifiers(bool apply, bool real = false);
void _AddSpellAuraHolder(); void _AddSpellAuraHolder();
@ -93,11 +93,11 @@ class MANGOS_DLL_SPEC SpellAuraHolder
void SetInUse(bool state) void SetInUse(bool state)
{ {
if(state) if (state)
++m_in_use; ++m_in_use;
else else
{ {
if(m_in_use) if (m_in_use)
--m_in_use; --m_in_use;
} }
} }
@ -206,7 +206,7 @@ typedef void(Aura::*pAuraHandler)(bool Apply, bool Real);
class MANGOS_DLL_SPEC Aura class MANGOS_DLL_SPEC Aura
{ {
friend struct ReapplyAffectedPassiveAurasHelper; friend struct ReapplyAffectedPassiveAurasHelper;
friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem); friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster, Item* castItem);
public: public:
//aura handlers //aura handlers
@ -384,13 +384,13 @@ class MANGOS_DLL_SPEC Aura
int32 GetMiscBValue() const { return m_spellAuraHolder->GetSpellProto()->EffectMiscValueB[m_effIndex]; } int32 GetMiscBValue() const { return m_spellAuraHolder->GetSpellProto()->EffectMiscValueB[m_effIndex]; }
SpellEntry const* GetSpellProto() const { return GetHolder()->GetSpellProto(); } SpellEntry const* GetSpellProto() const { return GetHolder()->GetSpellProto(); }
uint32 GetId() const{ return GetHolder()->GetSpellProto()->Id; } uint32 GetId() const { return GetHolder()->GetSpellProto()->Id; }
ObjectGuid const& GetCastItemGuid() const { return GetHolder()->GetCastItemGuid(); } ObjectGuid const& GetCastItemGuid() const { return GetHolder()->GetCastItemGuid(); }
ObjectGuid const& GetCasterGuid() const { return GetHolder()->GetCasterGuid(); } ObjectGuid const& GetCasterGuid() const { return GetHolder()->GetCasterGuid(); }
Unit* GetCaster() const { return GetHolder()->GetCaster(); } Unit* GetCaster() const { return GetHolder()->GetCaster(); }
Unit* GetTarget() const { return GetHolder()->GetTarget(); } Unit* GetTarget() const { return GetHolder()->GetTarget(); }
SpellEffectIndex GetEffIndex() const{ return m_effIndex; } SpellEffectIndex GetEffIndex() const { return m_effIndex; }
int32 GetBasePoints() const { return m_currentBasePoints; } int32 GetBasePoints() const { return m_currentBasePoints; }
int32 GetAuraMaxDuration() const { return GetHolder()->GetAuraMaxDuration(); } int32 GetAuraMaxDuration() const { return GetHolder()->GetAuraMaxDuration(); }
@ -409,7 +409,7 @@ class MANGOS_DLL_SPEC Aura
m_modifier.m_amount = damage; m_modifier.m_amount = damage;
m_modifier.periodictime = periodicTime; m_modifier.periodictime = periodicTime;
if(uint32 maxticks = GetAuraMaxTicks()) if (uint32 maxticks = GetAuraMaxTicks())
m_periodicTick = maxticks - GetAuraDuration() / m_modifier.periodictime; m_periodicTick = maxticks - GetAuraDuration() / m_modifier.periodictime;
} }
@ -421,11 +421,11 @@ class MANGOS_DLL_SPEC Aura
void SetInUse(bool state) void SetInUse(bool state)
{ {
if(state) if (state)
++m_in_use; ++m_in_use;
else else
{ {
if(m_in_use) if (m_in_use)
--m_in_use; --m_in_use;
} }
} }
@ -444,8 +444,8 @@ class MANGOS_DLL_SPEC Aura
void TriggerSpellWithValue(); void TriggerSpellWithValue();
ClassFamilyMask const& GetAuraSpellClassMask() const { return m_spellAuraHolder->GetSpellProto()->GetEffectSpellClassMask(m_effIndex); } ClassFamilyMask const& GetAuraSpellClassMask() const { return m_spellAuraHolder->GetSpellProto()->GetEffectSpellClassMask(m_effIndex); }
bool isAffectedOnSpell(SpellEntry const *spell) const; bool isAffectedOnSpell(SpellEntry const* spell) const;
bool CanProcFrom(SpellEntry const *spell, uint32 procFlag, uint32 EventProcEx, uint32 procEx, bool active, bool useClassMask) const; bool CanProcFrom(SpellEntry const* spell, uint32 procFlag, uint32 EventProcEx, uint32 procEx, bool active, bool useClassMask) const;
//SpellAuraHolder const* GetHolder() const { return m_spellHolder; } //SpellAuraHolder const* GetHolder() const { return m_spellHolder; }
SpellAuraHolder* GetHolder() { return m_spellAuraHolder; } SpellAuraHolder* GetHolder() { return m_spellAuraHolder; }
@ -455,7 +455,7 @@ class MANGOS_DLL_SPEC Aura
bool HasMechanic(uint32 mechanic) const; bool HasMechanic(uint32 mechanic) const;
protected: protected:
Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster = NULL, Item* castItem = NULL);
// must be called only from Aura::UpdateAura // must be called only from Aura::UpdateAura
virtual void Update(uint32 diff); virtual void Update(uint32 diff);
@ -494,7 +494,7 @@ class MANGOS_DLL_SPEC Aura
class MANGOS_DLL_SPEC AreaAura : public Aura class MANGOS_DLL_SPEC AreaAura : public Aura
{ {
public: public:
AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster = NULL, Item* castItem = NULL);
~AreaAura(); ~AreaAura();
protected: protected:
void Update(uint32 diff); void Update(uint32 diff);
@ -506,7 +506,7 @@ class MANGOS_DLL_SPEC AreaAura : public Aura
class MANGOS_DLL_SPEC PersistentAreaAura : public Aura class MANGOS_DLL_SPEC PersistentAreaAura : public Aura
{ {
public: public:
PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster = NULL, Item* castItem = NULL);
~PersistentAreaAura(); ~PersistentAreaAura();
protected: protected:
void Update(uint32 diff); void Update(uint32 diff);
@ -514,17 +514,17 @@ class MANGOS_DLL_SPEC PersistentAreaAura : public Aura
class MANGOS_DLL_SPEC SingleEnemyTargetAura : public Aura class MANGOS_DLL_SPEC SingleEnemyTargetAura : public Aura
{ {
friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem); friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster, Item* castItem);
public: public:
~SingleEnemyTargetAura(); ~SingleEnemyTargetAura();
Unit* GetTriggerTarget() const; Unit* GetTriggerTarget() const;
protected: protected:
SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster = NULL, Item* castItem = NULL);
ObjectGuid m_castersTargetGuid; ObjectGuid m_castersTargetGuid;
}; };
Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, SpellAuraHolder* holder, Unit* target, Unit* caster = NULL, Item* castItem = NULL);
SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem = NULL); SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit* target, WorldObject* caster, Item* castItem = NULL);
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -54,32 +54,32 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
if (glyphIndex >= MAX_GLYPH_SLOT_INDEX) if (glyphIndex >= MAX_GLYPH_SLOT_INDEX)
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return; return;
} }
Item *pItem = pUser->GetItemByPos(bagIndex, slot); Item* pItem = pUser->GetItemByPos(bagIndex, slot);
if (!pItem) if (!pItem)
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return; return;
} }
if (pItem->GetObjectGuid() != itemGuid) if (pItem->GetObjectGuid() != itemGuid)
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return; return;
} }
DETAIL_LOG("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, cast_count: %u, spellid: %u, Item: %u, glyphIndex: %u, unk_flags: %u, data length = %i", bagIndex, slot, cast_count, spellid, pItem->GetEntry(), glyphIndex, unk_flags, (uint32)recvPacket.size()); DETAIL_LOG("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, cast_count: %u, spellid: %u, Item: %u, glyphIndex: %u, unk_flags: %u, data length = %i", bagIndex, slot, cast_count, spellid, pItem->GetEntry(), glyphIndex, unk_flags, (uint32)recvPacket.size());
ItemPrototype const *proto = pItem->GetProto(); ItemPrototype const* proto = pItem->GetProto();
if (!proto) if (!proto)
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
return; return;
} }
@ -87,7 +87,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
if (proto->InventoryType != INVTYPE_NON_EQUIP && !pItem->IsEquipped()) if (proto->InventoryType != INVTYPE_NON_EQUIP && !pItem->IsEquipped())
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
return; return;
} }
@ -95,7 +95,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError( msg, pItem, NULL ); pUser->SendEquipError(msg, pItem, NULL);
return; return;
} }
@ -103,7 +103,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
if (pItem->IsInTrade()) if (pItem->IsInTrade())
{ {
recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail recvPacket.rpos(recvPacket.wpos()); // prevent spam at not read packet tail
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
return; return;
} }
@ -119,9 +119,9 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
if (pUser->isInCombat()) if (pUser->isInCombat())
{ {
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{ {
if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(proto->Spells[i].SpellId)) if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[i].SpellId))
{ {
if (IsNonCombatSpell(spellInfo)) if (IsNonCombatSpell(spellInfo))
{ {
@ -142,12 +142,12 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
} }
// check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory) // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory)
if( pItem->GetProto()->Bonding == BIND_WHEN_USE || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM ) if (pItem->GetProto()->Bonding == BIND_WHEN_USE || pItem->GetProto()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetProto()->Bonding == BIND_QUEST_ITEM)
{ {
if (!pItem->IsSoulBound()) if (!pItem->IsSoulBound())
{ {
pItem->SetState(ITEM_CHANGED, pUser); pItem->SetState(ITEM_CHANGED, pUser);
pItem->SetBinding( true ); pItem->SetBinding(true);
} }
} }
@ -206,47 +206,47 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
if (!pUser->IsSelfMover()) if (!pUser->IsSelfMover())
return; return;
Item *pItem = pUser->GetItemByPos(bagIndex, slot); Item* pItem = pUser->GetItemByPos(bagIndex, slot);
if(!pItem) if (!pItem)
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return; return;
} }
ItemPrototype const *proto = pItem->GetProto(); ItemPrototype const* proto = pItem->GetProto();
if(!proto) if (!proto)
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
return; return;
} }
// locked item // locked item
uint32 lockId = proto->LockID; uint32 lockId = proto->LockID;
if(lockId && !pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_UNLOCKED)) if (lockId && !pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_UNLOCKED))
{ {
LockEntry const *lockInfo = sLockStore.LookupEntry(lockId); LockEntry const* lockInfo = sLockStore.LookupEntry(lockId);
if (!lockInfo) if (!lockInfo)
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, pItem, NULL);
sLog.outError( "WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", pItem->GetGUIDLow() , lockId); sLog.outError("WORLD::OpenItem: item [guid = %u] has an unknown lockId: %u!", pItem->GetGUIDLow() , lockId);
return; return;
} }
// required picklocking // required picklocking
if(lockInfo->Skill[1] || lockInfo->Skill[0]) if (lockInfo->Skill[1] || lockInfo->Skill[0])
{ {
pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, pItem, NULL ); pUser->SendEquipError(EQUIP_ERR_ITEM_LOCKED, pItem, NULL);
return; return;
} }
} }
if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))// wrapped? if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_DYNFLAG_WRAPPED))// wrapped?
{ {
QueryResult *result = CharacterDatabase.PQuery("SELECT entry, flags FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow()); QueryResult* result = CharacterDatabase.PQuery("SELECT entry, flags FROM character_gifts WHERE item_guid = '%u'", pItem->GetGUIDLow());
if (result) if (result)
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32(); uint32 entry = fields[0].GetUInt32();
uint32 flags = fields[1].GetUInt32(); uint32 flags = fields[1].GetUInt32();
@ -272,7 +272,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
pUser->SendLoot(pItem->GetObjectGuid(),LOOT_CORPSE); pUser->SendLoot(pItem->GetObjectGuid(),LOOT_CORPSE);
} }
void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data ) void WorldSession::HandleGameObjectUseOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
@ -284,8 +284,8 @@ void WorldSession::HandleGameObjectUseOpcode( WorldPacket & recv_data )
if (!_player->IsSelfMover()) if (!_player->IsSelfMover())
return; return;
GameObject *obj = GetPlayer()->GetMap()->GetGameObject(guid); GameObject* obj = GetPlayer()->GetMap()->GetGameObject(guid);
if(!obj) if (!obj)
return; return;
// Additional check preventing exploits (ie loot despawned chests) // Additional check preventing exploits (ie loot despawned chests)
@ -327,7 +327,7 @@ void WorldSession::HandleGameobjectReportUse(WorldPacket& recvPacket)
if (!go) if (!go)
return; return;
if(!go->IsWithinDistInMap(_player,INTERACTION_DISTANCE)) if (!go->IsWithinDistInMap(_player,INTERACTION_DISTANCE))
return; return;
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, go->GetEntry()); _player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, go->GetEntry());
@ -352,9 +352,9 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
DEBUG_LOG("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i", DEBUG_LOG("WORLD: got cast spell packet, spellId - %u, cast_count: %u, unk_flags %u, data length = %i",
spellId, cast_count, unk_flags, (uint32)recvPacket.size()); spellId, cast_count, unk_flags, (uint32)recvPacket.size());
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outError("WORLD: unknown spell id %u", spellId); sLog.outError("WORLD: unknown spell id %u", spellId);
recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet
@ -364,7 +364,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
if (mover->GetTypeId()==TYPEID_PLAYER) if (mover->GetTypeId()==TYPEID_PLAYER)
{ {
// not have spell in spellbook or spell passive and not casted by client // not have spell in spellbook or spell passive and not casted by client
if (!((Player*)mover)->HasActiveSpell (spellId) || IsPassiveSpell(spellInfo)) if (!((Player*)mover)->HasActiveSpell(spellId) || IsPassiveSpell(spellInfo))
{ {
sLog.outError("World: Player %u casts spell %u which he shouldn't have", mover->GetGUIDLow(), spellId); sLog.outError("World: Player %u casts spell %u which he shouldn't have", mover->GetGUIDLow(), spellId);
//cheater? kick? ban? //cheater? kick? ban?
@ -396,7 +396,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
recvPacket >> Unused<float>(); // unk1, coords? recvPacket >> Unused<float>(); // unk1, coords?
recvPacket >> Unused<float>(); // unk1, coords? recvPacket >> Unused<float>(); // unk1, coords?
recvPacket >> unk1; // >> 1 or 0 recvPacket >> unk1; // >> 1 or 0
if(unk1) if (unk1)
{ {
ObjectGuid guid; // guid - unused ObjectGuid guid; // guid - unused
MovementInfo movementInfo; MovementInfo movementInfo;
@ -411,11 +411,11 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
if (Unit* target = targets.getUnitTarget()) if (Unit* target = targets.getUnitTarget())
{ {
// if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message // if rank not found then function return NULL but in explicit cast case original spell can be casted and later failed with appropriate error message
if (SpellEntry const *actualSpellInfo = sSpellMgr.SelectAuraRankForLevel(spellInfo, target->getLevel())) if (SpellEntry const* actualSpellInfo = sSpellMgr.SelectAuraRankForLevel(spellInfo, target->getLevel()))
spellInfo = actualSpellInfo; spellInfo = actualSpellInfo;
} }
Spell *spell = new Spell(mover, spellInfo, false); Spell* spell = new Spell(mover, spellInfo, false);
spell->m_cast_count = cast_count; // set count of casts spell->m_cast_count = cast_count; // set count of casts
spell->prepare(&targets); spell->prepare(&targets);
} }
@ -433,19 +433,19 @@ void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket)
return; return;
//FIXME: hack, ignore unexpected client cancel Deadly Throw cast //FIXME: hack, ignore unexpected client cancel Deadly Throw cast
if(spellId==26679) if (spellId==26679)
return; return;
if(mover->IsNonMeleeSpellCasted(false)) if (mover->IsNonMeleeSpellCasted(false))
mover->InterruptNonMeleeSpells(false,spellId); mover->InterruptNonMeleeSpells(false,spellId);
} }
void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket) void WorldSession::HandleCancelAuraOpcode(WorldPacket& recvPacket)
{ {
uint32 spellId; uint32 spellId;
recvPacket >> spellId; recvPacket >> spellId;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo) if (!spellInfo)
return; return;
@ -462,7 +462,7 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket)
{ {
// except own aura spells // except own aura spells
bool allow = false; bool allow = false;
for(int k = 0; k < MAX_EFFECT_INDEX; ++k) for (int k = 0; k < MAX_EFFECT_INDEX; ++k)
{ {
if (spellInfo->EffectApplyAuraName[k] == SPELL_AURA_MOD_POSSESS || if (spellInfo->EffectApplyAuraName[k] == SPELL_AURA_MOD_POSSESS ||
spellInfo->EffectApplyAuraName[k] == SPELL_AURA_MOD_POSSESS_PET) spellInfo->EffectApplyAuraName[k] == SPELL_AURA_MOD_POSSESS_PET)
@ -473,7 +473,7 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket)
} }
// this also include case when aura not found // this also include case when aura not found
if(!allow) if (!allow)
return; return;
} }
else else
@ -489,7 +489,7 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket)
return; return;
} }
SpellAuraHolder *holder = _player->GetSpellAuraHolder(spellId); SpellAuraHolder* holder = _player->GetSpellAuraHolder(spellId);
// not own area auras can't be cancelled (note: maybe need to check for aura on holder and not general on spell) // not own area auras can't be cancelled (note: maybe need to check for aura on holder and not general on spell)
if (holder && holder->GetCasterGuid() != _player->GetObjectGuid() && HasAreaAuraEffect(holder->GetSpellProto())) if (holder && holder->GetCasterGuid() != _player->GetObjectGuid() && HasAreaAuraEffect(holder->GetSpellProto()))
@ -499,7 +499,7 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket)
_player->RemoveAurasDueToSpellByCancel(spellId); _player->RemoveAurasDueToSpellByCancel(spellId);
} }
void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket) void WorldSession::HandlePetCancelAuraOpcode(WorldPacket& recvPacket)
{ {
ObjectGuid guid; ObjectGuid guid;
uint32 spellId; uint32 spellId;
@ -511,8 +511,8 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket)
if (!_player->IsSelfMover()) if (!_player->IsSelfMover())
return; return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
if(!spellInfo) if (!spellInfo)
{ {
sLog.outError("WORLD: unknown PET spell id %u", spellId); sLog.outError("WORLD: unknown PET spell id %u", spellId);
return; return;
@ -543,19 +543,19 @@ void WorldSession::HandlePetCancelAuraOpcode( WorldPacket& recvPacket)
pet->AddCreatureSpellCooldown(spellId); pet->AddCreatureSpellCooldown(spellId);
} }
void WorldSession::HandleCancelGrowthAuraOpcode( WorldPacket& /*recvPacket*/) void WorldSession::HandleCancelGrowthAuraOpcode(WorldPacket& /*recvPacket*/)
{ {
// nothing do // nothing do
} }
void WorldSession::HandleCancelAutoRepeatSpellOpcode( WorldPacket& /*recvPacket*/) void WorldSession::HandleCancelAutoRepeatSpellOpcode(WorldPacket& /*recvPacket*/)
{ {
// cancel and prepare for deleting // cancel and prepare for deleting
// do not send SMSG_CANCEL_AUTO_REPEAT! client will send this Opcode again (loop) // do not send SMSG_CANCEL_AUTO_REPEAT! client will send this Opcode again (loop)
_player->GetMover()->InterruptSpell(CURRENT_AUTOREPEAT_SPELL, true, false); _player->GetMover()->InterruptSpell(CURRENT_AUTOREPEAT_SPELL, true, false);
} }
void WorldSession::HandleCancelChanneling( WorldPacket & recv_data) void WorldSession::HandleCancelChanneling(WorldPacket& recv_data)
{ {
recv_data.read_skip<uint32>(); // spellid, not used recv_data.read_skip<uint32>(); // spellid, not used
@ -567,7 +567,7 @@ void WorldSession::HandleCancelChanneling( WorldPacket & recv_data)
mover->InterruptSpell(CURRENT_CHANNELED_SPELL); mover->InterruptSpell(CURRENT_CHANNELED_SPELL);
} }
void WorldSession::HandleTotemDestroyed( WorldPacket& recvPacket) void WorldSession::HandleTotemDestroyed(WorldPacket& recvPacket)
{ {
uint8 slotId; uint8 slotId;
@ -584,21 +584,21 @@ void WorldSession::HandleTotemDestroyed( WorldPacket& recvPacket)
totem->UnSummon(); totem->UnSummon();
} }
void WorldSession::HandleSelfResOpcode( WorldPacket & /*recv_data*/ ) void WorldSession::HandleSelfResOpcode(WorldPacket& /*recv_data*/)
{ {
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: CMSG_SELF_RES"); // empty opcode DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: CMSG_SELF_RES"); // empty opcode
if(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL)) if (_player->GetUInt32Value(PLAYER_SELF_RES_SPELL))
{ {
SpellEntry const *spellInfo = sSpellStore.LookupEntry(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL)); SpellEntry const* spellInfo = sSpellStore.LookupEntry(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL));
if(spellInfo) if (spellInfo)
_player->CastSpell(_player, spellInfo, false); _player->CastSpell(_player, spellInfo, false);
_player->SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); _player->SetUInt32Value(PLAYER_SELF_RES_SPELL, 0);
} }
} }
void WorldSession::HandleSpellClick( WorldPacket & recv_data ) void WorldSession::HandleSpellClick(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
@ -606,17 +606,17 @@ void WorldSession::HandleSpellClick( WorldPacket & recv_data )
if (_player->isInCombat()) // client prevent click and set different icon at combat state if (_player->isInCombat()) // client prevent click and set different icon at combat state
return; return;
Creature *unit = _player->GetMap()->GetAnyTypeCreature(guid); Creature* unit = _player->GetMap()->GetAnyTypeCreature(guid);
if (!unit || unit->isInCombat()) // client prevent click and set different icon at combat state if (!unit || unit->isInCombat()) // client prevent click and set different icon at combat state
return; return;
SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(unit->GetEntry()); SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(unit->GetEntry());
for(SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) for (SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
{ {
if (itr->second.IsFitToRequirements(_player)) if (itr->second.IsFitToRequirements(_player))
{ {
Unit *caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit; Unit* caster = (itr->second.castFlags & 0x1) ? (Unit*)_player : (Unit*)unit;
Unit *target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit; Unit* target = (itr->second.castFlags & 0x2) ? (Unit*)_player : (Unit*)unit;
caster->CastSpell(target, itr->second.spellId, true); caster->CastSpell(target, itr->second.spellId, true);
} }

File diff suppressed because it is too large Load diff

View file

@ -76,39 +76,39 @@ enum SpellSpecific
SpellSpecific GetSpellSpecific(uint32 spellId); SpellSpecific GetSpellSpecific(uint32 spellId);
// Different spell properties // Different spell properties
inline float GetSpellRadius(SpellRadiusEntry const *radius) { return (radius ? radius->Radius : 0); } inline float GetSpellRadius(SpellRadiusEntry const* radius) { return (radius ? radius->Radius : 0); }
uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell = NULL); uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell const* spell = NULL);
uint32 GetSpellCastTimeForBonus( SpellEntry const *spellProto, DamageEffectType damagetype ); uint32 GetSpellCastTimeForBonus(SpellEntry const* spellProto, DamageEffectType damagetype);
float CalculateDefaultCoefficient(SpellEntry const *spellProto, DamageEffectType const damagetype); float CalculateDefaultCoefficient(SpellEntry const* spellProto, DamageEffectType const damagetype);
inline float GetSpellMinRange(SpellRangeEntry const *range, bool friendly = false) inline float GetSpellMinRange(SpellRangeEntry const* range, bool friendly = false)
{ {
if(!range) if (!range)
return 0; return 0;
return (friendly ? range->minRangeFriendly : range->minRange); return (friendly ? range->minRangeFriendly : range->minRange);
} }
inline float GetSpellMaxRange(SpellRangeEntry const *range, bool friendly = false) inline float GetSpellMaxRange(SpellRangeEntry const* range, bool friendly = false)
{ {
if(!range) if (!range)
return 0; return 0;
return (friendly ? range->maxRangeFriendly : range->maxRange); return (friendly ? range->maxRangeFriendly : range->maxRange);
} }
inline uint32 GetSpellRecoveryTime(SpellEntry const *spellInfo) { return spellInfo->RecoveryTime > spellInfo->CategoryRecoveryTime ? spellInfo->RecoveryTime : spellInfo->CategoryRecoveryTime; } inline uint32 GetSpellRecoveryTime(SpellEntry const* spellInfo) { return spellInfo->RecoveryTime > spellInfo->CategoryRecoveryTime ? spellInfo->RecoveryTime : spellInfo->CategoryRecoveryTime; }
int32 GetSpellDuration(SpellEntry const *spellInfo); int32 GetSpellDuration(SpellEntry const* spellInfo);
int32 GetSpellMaxDuration(SpellEntry const *spellInfo); int32 GetSpellMaxDuration(SpellEntry const* spellInfo);
int32 CalculateSpellDuration(SpellEntry const *spellInfo, Unit const* caster = NULL); int32 CalculateSpellDuration(SpellEntry const* spellInfo, Unit const* caster = NULL);
uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo); uint16 GetSpellAuraMaxTicks(SpellEntry const* spellInfo);
uint16 GetSpellAuraMaxTicks(uint32 spellId); uint16 GetSpellAuraMaxTicks(uint32 spellId);
WeaponAttackType GetWeaponAttackType(SpellEntry const *spellInfo); WeaponAttackType GetWeaponAttackType(SpellEntry const* spellInfo);
inline bool IsSpellHaveEffect(SpellEntry const *spellInfo, SpellEffects effect) inline bool IsSpellHaveEffect(SpellEntry const* spellInfo, SpellEffects effect)
{ {
for(int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
if(SpellEffects(spellInfo->Effect[i])==effect) if (SpellEffects(spellInfo->Effect[i])==effect)
return true; return true;
return false; return false;
} }
inline bool IsAuraApplyEffect(SpellEntry const *spellInfo, SpellEffectIndex effecIdx) inline bool IsAuraApplyEffect(SpellEntry const* spellInfo, SpellEffectIndex effecIdx)
{ {
switch (spellInfo->Effect[effecIdx]) switch (spellInfo->Effect[effecIdx])
{ {
@ -124,9 +124,9 @@ inline bool IsAuraApplyEffect(SpellEntry const *spellInfo, SpellEffectIndex effe
return false; return false;
} }
inline bool IsSpellAppliesAura(SpellEntry const *spellInfo, uint32 effectMask = ((1 << EFFECT_INDEX_0) | (1 << EFFECT_INDEX_1) | (1 << EFFECT_INDEX_2))) inline bool IsSpellAppliesAura(SpellEntry const* spellInfo, uint32 effectMask = ((1 << EFFECT_INDEX_0) | (1 << EFFECT_INDEX_1) | (1 << EFFECT_INDEX_2)))
{ {
for(int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
if (effectMask & (1 << i)) if (effectMask & (1 << i))
if (IsAuraApplyEffect(spellInfo, SpellEffectIndex(i))) if (IsAuraApplyEffect(spellInfo, SpellEffectIndex(i)))
return true; return true;
@ -134,7 +134,7 @@ inline bool IsSpellAppliesAura(SpellEntry const *spellInfo, uint32 effectMask =
return false; return false;
} }
inline bool IsEffectHandledOnDelayedSpellLaunch(SpellEntry const *spellInfo, SpellEffectIndex effecIdx) inline bool IsEffectHandledOnDelayedSpellLaunch(SpellEntry const* spellInfo, SpellEffectIndex effecIdx)
{ {
switch (spellInfo->Effect[effecIdx]) switch (spellInfo->Effect[effecIdx])
{ {
@ -149,7 +149,7 @@ inline bool IsEffectHandledOnDelayedSpellLaunch(SpellEntry const *spellInfo, Spe
} }
} }
inline bool IsPeriodicRegenerateEffect(SpellEntry const *spellInfo, SpellEffectIndex effecIdx) inline bool IsPeriodicRegenerateEffect(SpellEntry const* spellInfo, SpellEffectIndex effecIdx)
{ {
switch (AuraType(spellInfo->EffectApplyAuraName[effecIdx])) switch (AuraType(spellInfo->EffectApplyAuraName[effecIdx]))
{ {
@ -162,27 +162,27 @@ inline bool IsPeriodicRegenerateEffect(SpellEntry const *spellInfo, SpellEffectI
} }
} }
bool IsCastEndProcModifierAura(SpellEntry const *spellInfo, SpellEffectIndex effecIdx, SpellEntry const *procSpell); bool IsCastEndProcModifierAura(SpellEntry const* spellInfo, SpellEffectIndex effecIdx, SpellEntry const* procSpell);
inline bool IsSpellHaveAura(SpellEntry const *spellInfo, AuraType aura) inline bool IsSpellHaveAura(SpellEntry const* spellInfo, AuraType aura)
{ {
for(int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
if(AuraType(spellInfo->EffectApplyAuraName[i])==aura) if (AuraType(spellInfo->EffectApplyAuraName[i])==aura)
return true; return true;
return false; return false;
} }
inline bool IsSpellLastAuraEffect(SpellEntry const *spellInfo, SpellEffectIndex effecIdx) 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]) if (spellInfo->EffectApplyAuraName[i])
return false; return false;
return true; return true;
} }
bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 spellId_2); bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 spellId_2);
inline bool IsSealSpell(SpellEntry const *spellInfo) inline bool IsSealSpell(SpellEntry const* spellInfo)
{ {
//Collection of all the seal family flags. No other paladin spell has any of those. //Collection of all the seal family flags. No other paladin spell has any of those.
return spellInfo->IsFitToFamily(SPELLFAMILY_PALADIN, UI64LIT(0x26000C000A000000)) && return spellInfo->IsFitToFamily(SPELLFAMILY_PALADIN, UI64LIT(0x26000C000A000000)) &&
@ -190,13 +190,13 @@ inline bool IsSealSpell(SpellEntry const *spellInfo)
spellInfo->EffectImplicitTargetA[EFFECT_INDEX_0] == TARGET_SELF; spellInfo->EffectImplicitTargetA[EFFECT_INDEX_0] == TARGET_SELF;
} }
inline bool IsElementalShield(SpellEntry const *spellInfo) inline bool IsElementalShield(SpellEntry const* spellInfo)
{ {
// family flags 10 (Lightning), 42 (Earth), 37 (Water), proc shield from T2 8 pieces bonus // family flags 10 (Lightning), 42 (Earth), 37 (Water), proc shield from T2 8 pieces bonus
return (spellInfo->SpellFamilyFlags & UI64LIT(0x42000000400)) || spellInfo->Id == 23552; return (spellInfo->SpellFamilyFlags & UI64LIT(0x42000000400)) || spellInfo->Id == 23552;
} }
inline bool IsExplicitDiscoverySpell(SpellEntry const *spellInfo) inline bool IsExplicitDiscoverySpell(SpellEntry const* spellInfo)
{ {
return (((spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_RANDOM_ITEM return (((spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_RANDOM_ITEM
|| spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_ITEM_2) || spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_ITEM_2)
@ -204,7 +204,7 @@ inline bool IsExplicitDiscoverySpell(SpellEntry const *spellInfo)
|| spellInfo->Id == 64323); // Book of Glyph Mastery (Effect0==SPELL_EFFECT_SCRIPT_EFFECT without any other data) || spellInfo->Id == 64323); // Book of Glyph Mastery (Effect0==SPELL_EFFECT_SCRIPT_EFFECT without any other data)
} }
inline bool IsLootCraftingSpell(SpellEntry const *spellInfo) inline bool IsLootCraftingSpell(SpellEntry const* spellInfo)
{ {
return (spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_CREATE_RANDOM_ITEM || 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 // different random cards from Inscription (121==Virtuoso Inking Set category) r without explicit item
@ -224,7 +224,7 @@ bool IsPassiveSpell(SpellEntry const* spellProto);
inline bool IsPassiveSpellStackableWithRanks(SpellEntry const* spellProto) inline bool IsPassiveSpellStackableWithRanks(SpellEntry const* spellProto)
{ {
if(!IsPassiveSpell(spellProto)) if (!IsPassiveSpell(spellProto))
return false; return false;
return !IsSpellHaveEffect(spellProto,SPELL_EFFECT_APPLY_AURA); return !IsSpellHaveEffect(spellProto,SPELL_EFFECT_APPLY_AURA);
@ -242,35 +242,35 @@ inline bool IsSpellRemoveAllMovementAndControlLossEffects(SpellEntry const* spel
(SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED|SPELL_ATTR_EX5_USABLE_WHILE_FEARED|SPELL_ATTR_EX5_USABLE_WHILE_STUNNED))*/; (SPELL_ATTR_EX5_USABLE_WHILE_CONFUSED|SPELL_ATTR_EX5_USABLE_WHILE_FEARED|SPELL_ATTR_EX5_USABLE_WHILE_STUNNED))*/;
} }
inline bool IsDeathOnlySpell(SpellEntry const *spellInfo) inline bool IsDeathOnlySpell(SpellEntry const* spellInfo)
{ {
return spellInfo->HasAttribute(SPELL_ATTR_EX3_CAST_ON_DEAD) || spellInfo->Id == 2584; return spellInfo->HasAttribute(SPELL_ATTR_EX3_CAST_ON_DEAD) || spellInfo->Id == 2584;
} }
inline bool IsDeathPersistentSpell(SpellEntry const *spellInfo) inline bool IsDeathPersistentSpell(SpellEntry const* spellInfo)
{ {
return spellInfo->HasAttribute(SPELL_ATTR_EX3_DEATH_PERSISTENT); return spellInfo->HasAttribute(SPELL_ATTR_EX3_DEATH_PERSISTENT);
} }
inline bool IsNonCombatSpell(SpellEntry const *spellInfo) inline bool IsNonCombatSpell(SpellEntry const* spellInfo)
{ {
return spellInfo->HasAttribute(SPELL_ATTR_CANT_USED_IN_COMBAT); return spellInfo->HasAttribute(SPELL_ATTR_CANT_USED_IN_COMBAT);
} }
bool IsPositiveSpell(uint32 spellId); bool IsPositiveSpell(uint32 spellId);
bool IsPositiveSpell(SpellEntry const *spellproto); bool IsPositiveSpell(SpellEntry const* spellproto);
bool IsPositiveEffect(SpellEntry const *spellInfo, SpellEffectIndex effIndex); bool IsPositiveEffect(SpellEntry const* spellInfo, SpellEffectIndex effIndex);
bool IsPositiveTarget(uint32 targetA, uint32 targetB); bool IsPositiveTarget(uint32 targetA, uint32 targetB);
bool IsExplicitPositiveTarget(uint32 targetA); bool IsExplicitPositiveTarget(uint32 targetA);
bool IsExplicitNegativeTarget(uint32 targetA); bool IsExplicitNegativeTarget(uint32 targetA);
bool IsSingleTargetSpell(SpellEntry const *spellInfo); bool IsSingleTargetSpell(SpellEntry const* spellInfo);
bool IsSingleTargetSpells(SpellEntry const *spellInfo1, SpellEntry const *spellInfo2); bool IsSingleTargetSpells(SpellEntry const* spellInfo1, SpellEntry const* spellInfo2);
inline bool IsCasterSourceTarget(uint32 target) inline bool IsCasterSourceTarget(uint32 target)
{ {
switch (target ) switch (target)
{ {
case TARGET_SELF: case TARGET_SELF:
case TARGET_PET: case TARGET_PET:
@ -300,25 +300,25 @@ inline bool IsCasterSourceTarget(uint32 target)
inline bool IsSpellWithCasterSourceTargetsOnly(SpellEntry const* spellInfo) inline bool IsSpellWithCasterSourceTargetsOnly(SpellEntry const* spellInfo)
{ {
for(int i = 0; i < MAX_EFFECT_INDEX; ++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
uint32 targetA = spellInfo->EffectImplicitTargetA[i]; uint32 targetA = spellInfo->EffectImplicitTargetA[i];
if(targetA && !IsCasterSourceTarget(targetA)) if (targetA && !IsCasterSourceTarget(targetA))
return false; return false;
uint32 targetB = spellInfo->EffectImplicitTargetB[i]; uint32 targetB = spellInfo->EffectImplicitTargetB[i];
if(targetB && !IsCasterSourceTarget(targetB)) if (targetB && !IsCasterSourceTarget(targetB))
return false; return false;
if(!targetA && !targetB) if (!targetA && !targetB)
return false; return false;
} }
return true; return true;
} }
inline bool IsPointEffectTarget( Targets target ) inline bool IsPointEffectTarget(Targets target)
{ {
switch (target ) switch (target)
{ {
case TARGET_INNKEEPER_COORDINATES: case TARGET_INNKEEPER_COORDINATES:
case TARGET_TABLE_X_Y_Z_COORDINATES: case TARGET_TABLE_X_Y_Z_COORDINATES:
@ -342,9 +342,9 @@ inline bool IsPointEffectTarget( Targets target )
return false; return false;
} }
inline bool IsAreaEffectPossitiveTarget( Targets target ) inline bool IsAreaEffectPossitiveTarget(Targets target)
{ {
switch (target ) switch (target)
{ {
case TARGET_ALL_PARTY_AROUND_CASTER: case TARGET_ALL_PARTY_AROUND_CASTER:
case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER: case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER:
@ -361,9 +361,9 @@ inline bool IsAreaEffectPossitiveTarget( Targets target )
return false; return false;
} }
inline bool IsAreaEffectTarget( Targets target ) inline bool IsAreaEffectTarget(Targets target)
{ {
switch (target ) switch (target)
{ {
case TARGET_AREAEFFECT_INSTANT: case TARGET_AREAEFFECT_INSTANT:
case TARGET_AREAEFFECT_CUSTOM: case TARGET_AREAEFFECT_CUSTOM:
@ -388,20 +388,20 @@ inline bool IsAreaEffectTarget( Targets target )
return false; return false;
} }
inline bool IsAreaOfEffectSpell(SpellEntry const *spellInfo) inline bool IsAreaOfEffectSpell(SpellEntry const* spellInfo)
{ {
if(IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_0])) || IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetB[EFFECT_INDEX_0]))) if (IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_0])) || IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetB[EFFECT_INDEX_0])))
return true; return true;
if(IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_1])) || IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetB[EFFECT_INDEX_1]))) if (IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_1])) || IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetB[EFFECT_INDEX_1])))
return true; return true;
if(IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_2])) || IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetB[EFFECT_INDEX_2]))) if (IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetA[EFFECT_INDEX_2])) || IsAreaEffectTarget(Targets(spellInfo->EffectImplicitTargetB[EFFECT_INDEX_2])))
return true; return true;
return false; return false;
} }
inline bool IsAreaAuraEffect(uint32 effect) inline bool IsAreaAuraEffect(uint32 effect)
{ {
if( effect == SPELL_EFFECT_APPLY_AREA_AURA_PARTY || if (effect == SPELL_EFFECT_APPLY_AREA_AURA_PARTY ||
effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID || effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID ||
effect == SPELL_EFFECT_APPLY_AREA_AURA_FRIEND || effect == SPELL_EFFECT_APPLY_AREA_AURA_FRIEND ||
effect == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY || effect == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY ||
@ -411,7 +411,7 @@ inline bool IsAreaAuraEffect(uint32 effect)
return false; return false;
} }
inline bool HasAreaAuraEffect(SpellEntry const *spellInfo) inline bool HasAreaAuraEffect(SpellEntry const* spellInfo)
{ {
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
if (IsAreaAuraEffect(spellInfo->Effect[i])) if (IsAreaAuraEffect(spellInfo->Effect[i]))
@ -419,11 +419,11 @@ inline bool HasAreaAuraEffect(SpellEntry const *spellInfo)
return false; return false;
} }
inline bool HasAuraWithTriggerEffect(SpellEntry const *spellInfo) inline bool HasAuraWithTriggerEffect(SpellEntry const* spellInfo)
{ {
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
switch(spellInfo->Effect[i]) switch (spellInfo->Effect[i])
{ {
case SPELL_AURA_PERIODIC_TRIGGER_SPELL: case SPELL_AURA_PERIODIC_TRIGGER_SPELL:
case SPELL_AURA_PROC_TRIGGER_SPELL: case SPELL_AURA_PROC_TRIGGER_SPELL:
@ -435,7 +435,7 @@ inline bool HasAuraWithTriggerEffect(SpellEntry const *spellInfo)
return false; return false;
} }
inline bool IsDispelSpell(SpellEntry const *spellInfo) inline bool IsDispelSpell(SpellEntry const* spellInfo)
{ {
return IsSpellHaveEffect(spellInfo, SPELL_EFFECT_DISPEL); return IsSpellHaveEffect(spellInfo, SPELL_EFFECT_DISPEL);
} }
@ -455,7 +455,7 @@ inline bool IsSpellRequiresRangedAP(SpellEntry const* spellInfo)
return (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->DmgClass != SPELL_DAMAGE_CLASS_MELEE); return (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->DmgClass != SPELL_DAMAGE_CLASS_MELEE);
} }
SpellCastResult GetErrorAtShapeshiftedCast (SpellEntry const *spellInfo, uint32 form); SpellCastResult GetErrorAtShapeshiftedCast(SpellEntry const* spellInfo, uint32 form);
inline bool IsChanneledSpell(SpellEntry const* spellInfo) inline bool IsChanneledSpell(SpellEntry const* spellInfo)
{ {
@ -717,12 +717,12 @@ class PetAura
uint32 GetAura(uint32 petEntry) const uint32 GetAura(uint32 petEntry) const
{ {
std::map<uint32, uint32>::const_iterator itr = auras.find(petEntry); std::map<uint32, uint32>::const_iterator itr = auras.find(petEntry);
if(itr != auras.end()) if (itr != auras.end())
return itr->second; return itr->second;
else else
{ {
std::map<uint32, uint32>::const_iterator itr2 = auras.find(0); std::map<uint32, uint32>::const_iterator itr2 = auras.find(0);
if(itr2 != auras.end()) if (itr2 != auras.end())
return itr2->second; return itr2->second;
else else
return 0; return 0;
@ -859,7 +859,7 @@ class SpellMgr
uint32 GetSpellElixirMask(uint32 spellid) const uint32 GetSpellElixirMask(uint32 spellid) const
{ {
SpellElixirMap::const_iterator itr = mSpellElixirs.find(spellid); SpellElixirMap::const_iterator itr = mSpellElixirs.find(spellid);
if(itr==mSpellElixirs.end()) if (itr==mSpellElixirs.end())
return 0x0; return 0x0;
return itr->second; return itr->second;
@ -868,13 +868,13 @@ class SpellMgr
SpellSpecific GetSpellElixirSpecific(uint32 spellid) const SpellSpecific GetSpellElixirSpecific(uint32 spellid) const
{ {
uint32 mask = GetSpellElixirMask(spellid); uint32 mask = GetSpellElixirMask(spellid);
if((mask & ELIXIR_FLASK_MASK)==ELIXIR_FLASK_MASK) if ((mask & ELIXIR_FLASK_MASK)==ELIXIR_FLASK_MASK)
return SPELL_FLASK_ELIXIR; return SPELL_FLASK_ELIXIR;
else if(mask & ELIXIR_BATTLE_MASK) else if (mask & ELIXIR_BATTLE_MASK)
return SPELL_BATTLE_ELIXIR; return SPELL_BATTLE_ELIXIR;
else if(mask & ELIXIR_GUARDIAN_MASK) else if (mask & ELIXIR_GUARDIAN_MASK)
return SPELL_GUARDIAN_ELIXIR; return SPELL_GUARDIAN_ELIXIR;
else if(mask & ELIXIR_WELL_FED) else if (mask & ELIXIR_WELL_FED)
return SPELL_WELL_FED; return SPELL_WELL_FED;
else else
return SPELL_NORMAL; return SPELL_NORMAL;
@ -889,12 +889,12 @@ class SpellMgr
return NULL; return NULL;
} }
float GetSpellThreatMultiplier(SpellEntry const *spellInfo) const float GetSpellThreatMultiplier(SpellEntry const* spellInfo) const
{ {
if (!spellInfo) if (!spellInfo)
return 1.0f; return 1.0f;
if (SpellThreatEntry const *entry = GetSpellThreatEntry(spellInfo->Id)) if (SpellThreatEntry const* entry = GetSpellThreatEntry(spellInfo->Id))
return entry->multiplier; return entry->multiplier;
return 1.0f; return 1.0f;
@ -904,7 +904,7 @@ class SpellMgr
SpellProcEventEntry const* GetSpellProcEvent(uint32 spellId) const SpellProcEventEntry const* GetSpellProcEvent(uint32 spellId) const
{ {
SpellProcEventMap::const_iterator itr = mSpellProcEventMap.find(spellId); SpellProcEventMap::const_iterator itr = mSpellProcEventMap.find(spellId);
if( itr != mSpellProcEventMap.end( ) ) if (itr != mSpellProcEventMap.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
@ -913,20 +913,20 @@ class SpellMgr
float GetItemEnchantProcChance(uint32 spellid) const float GetItemEnchantProcChance(uint32 spellid) const
{ {
SpellProcItemEnchantMap::const_iterator itr = mSpellProcItemEnchantMap.find(spellid); SpellProcItemEnchantMap::const_iterator itr = mSpellProcItemEnchantMap.find(spellid);
if(itr==mSpellProcItemEnchantMap.end()) if (itr==mSpellProcItemEnchantMap.end())
return 0.0f; return 0.0f;
return itr->second; return itr->second;
} }
static bool IsSpellProcEventCanTriggeredBy( SpellProcEventEntry const * spellProcEvent, uint32 EventProcFlag, SpellEntry const * procSpell, uint32 procFlags, uint32 procExtra); static bool IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellProcEvent, uint32 EventProcFlag, SpellEntry const* procSpell, uint32 procFlags, uint32 procExtra);
// Spell bonus data // Spell bonus data
SpellBonusEntry const* GetSpellBonusData(uint32 spellId) const SpellBonusEntry const* GetSpellBonusData(uint32 spellId) const
{ {
// Lookup data // Lookup data
SpellBonusMap::const_iterator itr = mSpellBonusMap.find(spellId); SpellBonusMap::const_iterator itr = mSpellBonusMap.find(spellId);
if( itr != mSpellBonusMap.end( ) ) if (itr != mSpellBonusMap.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
@ -935,8 +935,8 @@ class SpellMgr
// Spell target coordinates // Spell target coordinates
SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id) const SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id) const
{ {
SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find( spell_id ); SpellTargetPositionMap::const_iterator itr = mSpellTargetPositions.find(spell_id);
if( itr != mSpellTargetPositions.end( ) ) if (itr != mSpellTargetPositions.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
@ -945,7 +945,7 @@ class SpellMgr
SpellChainNode const* GetSpellChainNode(uint32 spell_id) const SpellChainNode const* GetSpellChainNode(uint32 spell_id) const
{ {
SpellChainMap::const_iterator itr = mSpellChains.find(spell_id); SpellChainMap::const_iterator itr = mSpellChains.find(spell_id);
if(itr == mSpellChains.end()) if (itr == mSpellChains.end())
return NULL; return NULL;
return &itr->second; return &itr->second;
@ -953,7 +953,7 @@ class SpellMgr
uint32 GetFirstSpellInChain(uint32 spell_id) const uint32 GetFirstSpellInChain(uint32 spell_id) const
{ {
if(SpellChainNode const* node = GetSpellChainNode(spell_id)) if (SpellChainNode const* node = GetSpellChainNode(spell_id))
return node->first; return node->first;
return spell_id; return spell_id;
@ -961,7 +961,7 @@ class SpellMgr
uint32 GetPrevSpellInChain(uint32 spell_id) const uint32 GetPrevSpellInChain(uint32 spell_id) const
{ {
if(SpellChainNode const* node = GetSpellChainNode(spell_id)) if (SpellChainNode const* node = GetSpellChainNode(spell_id))
return node->prev; return node->prev;
return 0; return 0;
@ -973,7 +973,7 @@ class SpellMgr
void doForHighRanks(uint32 spellid, Worker& worker) void doForHighRanks(uint32 spellid, Worker& worker)
{ {
SpellChainMapNext const& nextMap = GetSpellChainNext(); SpellChainMapNext const& nextMap = GetSpellChainNext();
for(SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr) for (SpellChainMapNext::const_iterator itr = nextMap.lower_bound(spellid); itr != nextMap.upper_bound(spellid); ++itr)
{ {
worker(itr->second); worker(itr->second);
doForHighRanks(itr->second,worker); doForHighRanks(itr->second,worker);
@ -984,7 +984,7 @@ class SpellMgr
// Use IsHighRankOfSpell instead // Use IsHighRankOfSpell instead
uint8 GetSpellRank(uint32 spell_id) const uint8 GetSpellRank(uint32 spell_id) const
{ {
if(SpellChainNode const* node = GetSpellChainNode(spell_id)) if (SpellChainNode const* node = GetSpellChainNode(spell_id))
return node->rank; return node->rank;
return 0; return 0;
@ -997,21 +997,21 @@ class SpellMgr
uint32 rank2 = GetSpellRank(spell2); uint32 rank2 = GetSpellRank(spell2);
// not ordered correctly by rank value // not ordered correctly by rank value
if(itr == mSpellChains.end() || !rank2 || itr->second.rank <= rank2) if (itr == mSpellChains.end() || !rank2 || itr->second.rank <= rank2)
return false; return false;
// check present in same rank chain // check present in same rank chain
for(; itr != mSpellChains.end(); itr = mSpellChains.find(itr->second.prev)) for (; itr != mSpellChains.end(); itr = mSpellChains.find(itr->second.prev))
if(itr->second.prev==spell2) if (itr->second.prev==spell2)
return true; return true;
return false; 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 IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const;
bool canStackSpellRanksInSpellBook(SpellEntry const *spellInfo) const; bool canStackSpellRanksInSpellBook(SpellEntry const* spellInfo) const;
bool IsRankedSpellNonStackableInSpellBook(SpellEntry const *spellInfo) const bool IsRankedSpellNonStackableInSpellBook(SpellEntry const* spellInfo) const
{ {
return !canStackSpellRanksInSpellBook(spellInfo) && GetSpellRank(spellInfo->Id) != 0; return !canStackSpellRanksInSpellBook(spellInfo) && GetSpellRank(spellInfo->Id) != 0;
} }
@ -1022,7 +1022,7 @@ class SpellMgr
SpellLearnSkillNode const* GetSpellLearnSkill(uint32 spell_id) const SpellLearnSkillNode const* GetSpellLearnSkill(uint32 spell_id) const
{ {
SpellLearnSkillMap::const_iterator itr = mSpellLearnSkills.find(spell_id); SpellLearnSkillMap::const_iterator itr = mSpellLearnSkills.find(spell_id);
if(itr != mSpellLearnSkills.end()) if (itr != mSpellLearnSkills.end())
return &itr->second; return &itr->second;
else else
return NULL; return NULL;
@ -1041,7 +1041,7 @@ class SpellMgr
bool IsSpellLearnToSpell(uint32 spell_id1,uint32 spell_id2) const bool IsSpellLearnToSpell(uint32 spell_id1,uint32 spell_id2) const
{ {
SpellLearnSpellMapBounds bounds = GetSpellLearnSpellMapBounds(spell_id1); SpellLearnSpellMapBounds bounds = GetSpellLearnSpellMapBounds(spell_id1);
for(SpellLearnSpellMap::const_iterator i = bounds.first; i != bounds.second; ++i) 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 true;
return false; return false;
@ -1063,7 +1063,7 @@ class SpellMgr
} }
// Spell correctness for client using // Spell correctness for client using
static bool IsSpellValid(SpellEntry const * spellInfo, Player* pl = NULL, bool msg = true); static bool IsSpellValid(SpellEntry const* spellInfo, Player* pl = NULL, bool msg = true);
SkillLineAbilityMapBounds GetSkillLineAbilityMapBounds(uint32 spell_id) const SkillLineAbilityMapBounds GetSkillLineAbilityMapBounds(uint32 spell_id) const
{ {
@ -1078,7 +1078,7 @@ class SpellMgr
PetAura const* GetPetAura(uint32 spell_id, SpellEffectIndex eff) 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()) if (itr != mSpellPetAuraMap.end())
return &itr->second; return &itr->second;
else else
return NULL; return NULL;
@ -1087,7 +1087,7 @@ class SpellMgr
PetLevelupSpellSet const* GetPetLevelupSpellList(uint32 petFamily) const PetLevelupSpellSet const* GetPetLevelupSpellList(uint32 petFamily) const
{ {
PetLevelupSpellMap::const_iterator itr = mPetLevelupSpellMap.find(petFamily); PetLevelupSpellMap::const_iterator itr = mPetLevelupSpellMap.find(petFamily);
if(itr != mPetLevelupSpellMap.end()) if (itr != mPetLevelupSpellMap.end())
return &itr->second; return &itr->second;
else else
return NULL; return NULL;
@ -1097,12 +1097,12 @@ class SpellMgr
PetDefaultSpellsEntry const* GetPetDefaultSpellsEntry(int32 id) const PetDefaultSpellsEntry const* GetPetDefaultSpellsEntry(int32 id) const
{ {
PetDefaultSpellsMap::const_iterator itr = mPetDefaultSpellsMap.find(id); PetDefaultSpellsMap::const_iterator itr = mPetDefaultSpellsMap.find(id);
if(itr != mPetDefaultSpellsMap.end()) if (itr != mPetDefaultSpellsMap.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
SpellCastResult GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL); SpellCastResult GetSpellAllowedInLocationError(SpellEntry const* spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL);
SpellAreaMapBounds GetSpellAreaMapBounds(uint32 spell_id) const SpellAreaMapBounds GetSpellAreaMapBounds(uint32 spell_id) const
{ {

View file

@ -31,7 +31,7 @@
bool Player::UpdateStats(Stats stat) bool Player::UpdateStats(Stats stat)
{ {
if(stat > STAT_SPIRIT) if (stat > STAT_SPIRIT)
return false; return false;
// value = ((base_value * base_pct) + total_value) * total_pct // value = ((base_value * base_pct) + total_value) * total_pct
@ -39,14 +39,14 @@ bool Player::UpdateStats(Stats stat)
SetStat(stat, int32(value)); SetStat(stat, int32(value));
if(stat == STAT_STAMINA || stat == STAT_INTELLECT) if (stat == STAT_STAMINA || stat == STAT_INTELLECT)
{ {
Pet *pet = GetPet(); Pet* pet = GetPet();
if(pet) if (pet)
pet->UpdateStats(stat); pet->UpdateStats(stat);
} }
switch(stat) switch (stat)
{ {
case STAT_STRENGTH: case STAT_STRENGTH:
UpdateShieldBlockValue(); UpdateShieldBlockValue();
@ -79,7 +79,7 @@ bool Player::UpdateStats(Stats stat)
// Update ratings in exist SPELL_AURA_MOD_RATING_FROM_STAT and only depends from stat // Update ratings in exist SPELL_AURA_MOD_RATING_FROM_STAT and only depends from stat
uint32 mask = 0; uint32 mask = 0;
AuraList const& modRatingFromStat = GetAurasByType(SPELL_AURA_MOD_RATING_FROM_STAT); AuraList const& modRatingFromStat = GetAurasByType(SPELL_AURA_MOD_RATING_FROM_STAT);
for(AuraList::const_iterator i = modRatingFromStat.begin();i != modRatingFromStat.end(); ++i) for (AuraList::const_iterator i = modRatingFromStat.begin(); i != modRatingFromStat.end(); ++i)
if (Stats((*i)->GetMiscBValue()) == stat) if (Stats((*i)->GetMiscBValue()) == stat)
mask |= (*i)->GetMiscValue(); mask |= (*i)->GetMiscValue();
if (mask) if (mask)
@ -97,7 +97,7 @@ void Player::ApplySpellPowerBonus(int32 amount, bool apply)
// For speed just update for client // For speed just update for client
ApplyModUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, amount, apply); ApplyModUInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, amount, apply);
for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) 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);;
} }
@ -108,7 +108,7 @@ void Player::UpdateSpellDamageAndHealingBonus()
// Get healing bonus for all schools // Get healing bonus for all schools
SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL)); SetStatInt32Value(PLAYER_FIELD_MOD_HEALING_DONE_POS, SpellBaseHealingBonusDone(SPELL_SCHOOL_MASK_ALL));
// Get damage bonus for all schools // Get damage bonus for all schools
for(int i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i) 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)));
} }
@ -125,7 +125,7 @@ bool Player::UpdateAllStats()
UpdateAttackPowerAndDamage(true); UpdateAttackPowerAndDamage(true);
UpdateMaxHealth(); UpdateMaxHealth();
for(int i = POWER_MANA; i < MAX_POWERS; ++i) for (int i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i)); UpdateMaxPower(Powers(i));
UpdateAllRatings(); UpdateAllRatings();
@ -146,13 +146,13 @@ bool Player::UpdateAllStats()
void Player::UpdateResistances(uint32 school) void Player::UpdateResistances(uint32 school)
{ {
if(school > SPELL_SCHOOL_NORMAL) if (school > SPELL_SCHOOL_NORMAL)
{ {
float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school));
SetResistance(SpellSchools(school), int32(value)); SetResistance(SpellSchools(school), int32(value));
Pet *pet = GetPet(); Pet* pet = GetPet();
if(pet) if (pet)
pet->UpdateResistances(school); pet->UpdateResistances(school);
} }
else else
@ -171,10 +171,10 @@ void Player::UpdateArmor()
//add dynamic flat mods //add dynamic flat mods
AuraList const& mResbyIntellect = GetAurasByType(SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT); AuraList const& mResbyIntellect = GetAurasByType(SPELL_AURA_MOD_RESISTANCE_OF_STAT_PERCENT);
for(AuraList::const_iterator i = mResbyIntellect.begin();i != mResbyIntellect.end(); ++i) for (AuraList::const_iterator i = mResbyIntellect.begin(); i != mResbyIntellect.end(); ++i)
{ {
Modifier* mod = (*i)->GetModifier(); Modifier* mod = (*i)->GetModifier();
if(mod->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL) if (mod->m_miscvalue & SPELL_SCHOOL_MASK_NORMAL)
value += int32(GetStat(Stats((*i)->GetMiscBValue())) * mod->m_amount / 100.0f); value += int32(GetStat(Stats((*i)->GetMiscBValue())) * mod->m_amount / 100.0f);
} }
@ -182,8 +182,8 @@ void Player::UpdateArmor()
SetArmor(int32(value)); SetArmor(int32(value));
Pet *pet = GetPet(); Pet* pet = GetPet();
if(pet) if (pet)
pet->UpdateArmor(); pet->UpdateArmor();
UpdateAttackPowerAndDamage(); // armor dependent auras update for SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR UpdateAttackPowerAndDamage(); // armor dependent auras update for SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR
@ -244,7 +244,7 @@ void Player::ApplyFeralAPBonus(int32 amount, bool apply)
UpdateAttackPowerAndDamage(); UpdateAttackPowerAndDamage();
} }
void Player::UpdateAttackPowerAndDamage(bool ranged ) void Player::UpdateAttackPowerAndDamage(bool ranged)
{ {
float val2 = 0.0f; float val2 = 0.0f;
float level = float(getLevel()); float level = float(getLevel());
@ -255,19 +255,19 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS; uint16 index_mod = UNIT_FIELD_ATTACK_POWER_MODS;
uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER; uint16 index_mult = UNIT_FIELD_ATTACK_POWER_MULTIPLIER;
if(ranged) if (ranged)
{ {
index = UNIT_FIELD_RANGED_ATTACK_POWER; index = UNIT_FIELD_RANGED_ATTACK_POWER;
index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS; index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER; index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
switch(getClass()) switch (getClass())
{ {
case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f; break; 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_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: case CLASS_DRUID:
switch(GetShapeshiftForm()) switch (GetShapeshiftForm())
{ {
case FORM_CAT: case FORM_CAT:
case FORM_BEAR: case FORM_BEAR:
@ -282,7 +282,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
} }
else else
{ {
switch(getClass()) switch (getClass())
{ {
case CLASS_WARRIOR: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 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_PALADIN: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
@ -296,7 +296,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
//Check if Predatory Strikes is skilled //Check if Predatory Strikes is skilled
float mLevelBonus = 0.0f; float mLevelBonus = 0.0f;
float mBonusWeaponAtt = 0.0f; float mBonusWeaponAtt = 0.0f;
switch(form) switch (form)
{ {
case FORM_CAT: case FORM_CAT:
case FORM_BEAR: case FORM_BEAR:
@ -304,9 +304,9 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
case FORM_MOONKIN: case FORM_MOONKIN:
{ {
Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY); Unit::AuraList const& mDummy = GetAurasByType(SPELL_AURA_DUMMY);
for(Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr) for (Unit::AuraList::const_iterator itr = mDummy.begin(); itr != mDummy.end(); ++itr)
{ {
if((*itr)->GetSpellProto()->SpellIconID != 1563) if ((*itr)->GetSpellProto()->SpellIconID != 1563)
continue; continue;
// Predatory Strikes (effect 0) // Predatory Strikes (effect 0)
@ -324,7 +324,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
default: break; default: break;
} }
switch(form) switch (form)
{ {
case FORM_CAT: 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;
@ -350,23 +350,23 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE); float attPowerMod = GetModifierValue(unitMod, TOTAL_VALUE);
//add dynamic flat mods //add dynamic flat mods
if( ranged ) 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); AuraList const& mRAPbyStat = GetAurasByType(SPELL_AURA_MOD_RANGED_ATTACK_POWER_OF_STAT_PERCENT);
for(AuraList::const_iterator i = mRAPbyStat.begin();i != mRAPbyStat.end(); ++i) for (AuraList::const_iterator i = mRAPbyStat.begin(); i != mRAPbyStat.end(); ++i)
attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f); attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f);
} }
} }
else else
{ {
AuraList const& mAPbyStat = GetAurasByType(SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT); AuraList const& mAPbyStat = GetAurasByType(SPELL_AURA_MOD_ATTACK_POWER_OF_STAT_PERCENT);
for(AuraList::const_iterator i = mAPbyStat.begin();i != mAPbyStat.end(); ++i) for (AuraList::const_iterator i = mAPbyStat.begin(); i != mAPbyStat.end(); ++i)
attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f); attPowerMod += int32(GetStat(Stats((*i)->GetModifier()->m_miscvalue)) * (*i)->GetModifier()->m_amount / 100.0f);
AuraList const& mAPbyArmor = GetAurasByType(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR); AuraList const& mAPbyArmor = GetAurasByType(SPELL_AURA_MOD_ATTACK_POWER_OF_ARMOR);
for(AuraList::const_iterator iter = mAPbyArmor.begin(); iter != mAPbyArmor.end(); ++iter) for (AuraList::const_iterator iter = mAPbyArmor.begin(); iter != mAPbyArmor.end(); ++iter)
// always: ((*i)->GetModifier()->m_miscvalue == 1 == SPELL_SCHOOL_MASK_NORMAL) // always: ((*i)->GetModifier()->m_miscvalue == 1 == SPELL_SCHOOL_MASK_NORMAL)
attPowerMod += int32(GetArmor() / (*iter)->GetModifier()->m_amount); attPowerMod += int32(GetArmor() / (*iter)->GetModifier()->m_amount);
} }
@ -378,18 +378,18 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field SetFloatValue(index_mult, attPowerMultiplier); //UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
//automatically update weapon damage after attack power modification //automatically update weapon damage after attack power modification
if(ranged) if (ranged)
{ {
UpdateDamagePhysical(RANGED_ATTACK); UpdateDamagePhysical(RANGED_ATTACK);
Pet *pet = GetPet(); //update pet's AP Pet* pet = GetPet(); //update pet's AP
if(pet) if (pet)
pet->UpdateAttackPowerAndDamage(); pet->UpdateAttackPowerAndDamage();
} }
else else
{ {
UpdateDamagePhysical(BASE_ATTACK); UpdateDamagePhysical(BASE_ATTACK);
if(CanDualWield() && haveOffhandWeapon()) //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon if (CanDualWield() && haveOffhandWeapon()) //allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
UpdateDamagePhysical(OFF_ATTACK); UpdateDamagePhysical(OFF_ATTACK);
} }
} }
@ -404,7 +404,7 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, fl
UnitMods unitMod; UnitMods unitMod;
UnitMods attPower; UnitMods attPower;
switch(attType) switch (attType)
{ {
case BASE_ATTACK: case BASE_ATTACK:
default: default:
@ -462,7 +462,7 @@ void Player::UpdateDamagePhysical(WeaponAttackType attType)
CalculateMinMaxDamage(attType,false,mindamage,maxdamage); CalculateMinMaxDamage(attType,false,mindamage,maxdamage);
switch(attType) switch (attType)
{ {
case BASE_ATTACK: case BASE_ATTACK:
default: default:
@ -491,7 +491,7 @@ void Player::UpdateBlockPercentage()
{ {
// No block // No block
float value = 0.0f; float value = 0.0f;
if(CanBlock()) if (CanBlock())
{ {
// Base value // Base value
value = 5.0f; value = 5.0f;
@ -512,7 +512,7 @@ void Player::UpdateCritPercentage(WeaponAttackType attType)
uint16 index; uint16 index;
CombatRating cr; CombatRating cr;
switch(attType) switch (attType)
{ {
case OFF_ATTACK: case OFF_ATTACK:
modGroup = OFFHAND_CRIT_PERCENTAGE; modGroup = OFFHAND_CRIT_PERCENTAGE;
@ -644,7 +644,7 @@ void Player::UpdateDodgePercentage()
void Player::UpdateSpellCritChance(uint32 school) void Player::UpdateSpellCritChance(uint32 school)
{ {
// For normal school set zero crit chance // For normal school set zero crit chance
if(school == SPELL_SCHOOL_NORMAL) if (school == SPELL_SCHOOL_NORMAL)
{ {
SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1, 0.0f); SetFloatValue(PLAYER_SPELL_CRIT_PERCENTAGE1, 0.0f);
return; return;
@ -692,28 +692,28 @@ void Player::UpdateAllSpellCritChances()
void Player::UpdateExpertise(WeaponAttackType attack) void Player::UpdateExpertise(WeaponAttackType attack)
{ {
if(attack==RANGED_ATTACK) if (attack==RANGED_ATTACK)
return; return;
int32 expertise = int32(GetRatingBonusValue(CR_EXPERTISE)); int32 expertise = int32(GetRatingBonusValue(CR_EXPERTISE));
Item *weapon = GetWeaponForAttack(attack); Item* weapon = GetWeaponForAttack(attack);
AuraList const& expAuras = GetAurasByType(SPELL_AURA_MOD_EXPERTISE); AuraList const& expAuras = GetAurasByType(SPELL_AURA_MOD_EXPERTISE);
for(AuraList::const_iterator itr = expAuras.begin(); itr != expAuras.end(); ++itr) for (AuraList::const_iterator itr = expAuras.begin(); itr != expAuras.end(); ++itr)
{ {
// item neutral spell // item neutral spell
if((*itr)->GetSpellProto()->EquippedItemClass == -1) if ((*itr)->GetSpellProto()->EquippedItemClass == -1)
expertise += (*itr)->GetModifier()->m_amount; expertise += (*itr)->GetModifier()->m_amount;
// item dependent spell // item dependent spell
else if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) else if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
expertise += (*itr)->GetModifier()->m_amount; expertise += (*itr)->GetModifier()->m_amount;
} }
if(expertise < 0) if (expertise < 0)
expertise = 0; expertise = 0;
switch(attack) switch (attack)
{ {
case BASE_ATTACK: SetUInt32Value(PLAYER_EXPERTISE, expertise); break; case BASE_ATTACK: SetUInt32Value(PLAYER_EXPERTISE, expertise); break;
case OFF_ATTACK: SetUInt32Value(PLAYER_OFFHAND_EXPERTISE, expertise); break; case OFF_ATTACK: SetUInt32Value(PLAYER_OFFHAND_EXPERTISE, expertise); break;
@ -726,20 +726,20 @@ void Player::UpdateArmorPenetration()
m_armorPenetrationPct = GetRatingBonusValue(CR_ARMOR_PENETRATION); m_armorPenetrationPct = GetRatingBonusValue(CR_ARMOR_PENETRATION);
AuraList const& armorAuras = GetAurasByType(SPELL_AURA_MOD_TARGET_ARMOR_PCT); AuraList const& armorAuras = GetAurasByType(SPELL_AURA_MOD_TARGET_ARMOR_PCT);
for(AuraList::const_iterator itr = armorAuras.begin(); itr != armorAuras.end(); ++itr) for (AuraList::const_iterator itr = armorAuras.begin(); itr != armorAuras.end(); ++itr)
{ {
// affects all weapons // affects all weapons
if((*itr)->GetSpellProto()->EquippedItemClass == -1) if ((*itr)->GetSpellProto()->EquippedItemClass == -1)
{ {
m_armorPenetrationPct += (*itr)->GetModifier()->m_amount; m_armorPenetrationPct += (*itr)->GetModifier()->m_amount;
continue; continue;
} }
// dependent on weapon class // dependent on weapon class
for(uint8 i = 0; i < MAX_ATTACK; ++i) for (uint8 i = 0; i < MAX_ATTACK; ++i)
{ {
Item *weapon = GetWeaponForAttack(WeaponAttackType(i)); Item* weapon = GetWeaponForAttack(WeaponAttackType(i));
if(weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto())) if (weapon && weapon->IsFitToSpellRequirements((*itr)->GetSpellProto()))
{ {
m_armorPenetrationPct += (*itr)->GetModifier()->m_amount; m_armorPenetrationPct += (*itr)->GetModifier()->m_amount;
break; break;
@ -767,7 +767,7 @@ void Player::UpdateManaRegen()
// Get bonus from SPELL_AURA_MOD_MANA_REGEN_FROM_STAT aura // Get bonus from SPELL_AURA_MOD_MANA_REGEN_FROM_STAT aura
AuraList const& regenAura = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_FROM_STAT); AuraList const& regenAura = GetAurasByType(SPELL_AURA_MOD_MANA_REGEN_FROM_STAT);
for(AuraList::const_iterator i = regenAura.begin();i != regenAura.end(); ++i) for (AuraList::const_iterator i = regenAura.begin(); i != regenAura.end(); ++i)
{ {
Modifier* mod = (*i)->GetModifier(); Modifier* mod = (*i)->GetModifier();
power_regen_mp5 += GetStat(Stats(mod->m_miscvalue)) * mod->m_amount / 500.0f; power_regen_mp5 += GetStat(Stats(mod->m_miscvalue)) * mod->m_amount / 500.0f;
@ -822,10 +822,10 @@ bool Creature::UpdateAllStats()
UpdateMaxHealth(); UpdateMaxHealth();
UpdateAttackPowerAndDamage(); UpdateAttackPowerAndDamage();
for(int i = POWER_MANA; i < MAX_POWERS; ++i) for (int i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i)); UpdateMaxPower(Powers(i));
for(int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
UpdateResistances(i); UpdateResistances(i);
return true; return true;
@ -833,7 +833,7 @@ bool Creature::UpdateAllStats()
void Creature::UpdateResistances(uint32 school) void Creature::UpdateResistances(uint32 school)
{ {
if(school > SPELL_SCHOOL_NORMAL) if (school > SPELL_SCHOOL_NORMAL)
{ {
float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school));
SetResistance(SpellSchools(school), int32(value)); SetResistance(SpellSchools(school), int32(value));
@ -926,28 +926,28 @@ void Creature::UpdateDamagePhysical(WeaponAttackType attType)
bool Pet::UpdateStats(Stats stat) bool Pet::UpdateStats(Stats stat)
{ {
if(stat > STAT_SPIRIT) if (stat > STAT_SPIRIT)
return false; return false;
// value = ((base_value * base_pct) + total_value) * total_pct // value = ((base_value * base_pct) + total_value) * total_pct
float value = GetTotalStatValue(stat); float value = GetTotalStatValue(stat);
Unit *owner = GetOwner(); Unit* owner = GetOwner();
if ( stat == STAT_STAMINA ) if (stat == STAT_STAMINA)
{ {
if(owner) if (owner)
value += float(owner->GetStat(stat)) * 0.3f; value += float(owner->GetStat(stat)) * 0.3f;
} }
//warlock's and mage's pets gain 30% of owner's intellect //warlock's and mage's pets gain 30% of owner's intellect
else if ( stat == STAT_INTELLECT && getPetType() == SUMMON_PET ) else if (stat == STAT_INTELLECT && getPetType() == SUMMON_PET)
{ {
if(owner && (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE) ) if (owner && (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE))
value += float(owner->GetStat(stat)) * 0.3f; value += float(owner->GetStat(stat)) * 0.3f;
} }
SetStat(stat, int32(value)); SetStat(stat, int32(value));
switch(stat) switch (stat)
{ {
case STAT_STRENGTH: UpdateAttackPowerAndDamage(); break; case STAT_STRENGTH: UpdateAttackPowerAndDamage(); break;
case STAT_AGILITY: UpdateArmor(); break; case STAT_AGILITY: UpdateArmor(); break;
@ -966,7 +966,7 @@ bool Pet::UpdateAllStats()
for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) for (int i = STAT_STRENGTH; i < MAX_STATS; ++i)
UpdateStats(Stats(i)); UpdateStats(Stats(i));
for(int i = POWER_MANA; i < MAX_POWERS; ++i) for (int i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i)); UpdateMaxPower(Powers(i));
for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
@ -977,13 +977,13 @@ bool Pet::UpdateAllStats()
void Pet::UpdateResistances(uint32 school) void Pet::UpdateResistances(uint32 school)
{ {
if(school > SPELL_SCHOOL_NORMAL) if (school > SPELL_SCHOOL_NORMAL)
{ {
float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school)); float value = GetTotalAuraModValue(UnitMods(UNIT_MOD_RESISTANCE_START + school));
Unit *owner = GetOwner(); Unit* owner = GetOwner();
// hunter and warlock pets gain 40% of owner's resistance // hunter and warlock pets gain 40% of owner's resistance
if(owner && (getPetType() == HUNTER_PET || (getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK))) if (owner && (getPetType() == HUNTER_PET || (getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK)))
value += float(owner->GetResistance(SpellSchools(school))) * 0.4f; value += float(owner->GetResistance(SpellSchools(school))) * 0.4f;
SetResistance(SpellSchools(school), int32(value)); SetResistance(SpellSchools(school), int32(value));
@ -998,9 +998,9 @@ void Pet::UpdateArmor()
float bonus_armor = 0.0f; float bonus_armor = 0.0f;
UnitMods unitMod = UNIT_MOD_ARMOR; UnitMods unitMod = UNIT_MOD_ARMOR;
Unit *owner = GetOwner(); Unit* owner = GetOwner();
// hunter and warlock pets gain 35% of owner's armor value // hunter and warlock pets gain 35% of owner's armor value
if(owner && (getPetType() == HUNTER_PET || (getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK))) if (owner && (getPetType() == HUNTER_PET || (getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK)))
bonus_armor = 0.35f * float(owner->GetArmor()); bonus_armor = 0.35f * float(owner->GetArmor());
value = GetModifierValue(unitMod, BASE_VALUE); value = GetModifierValue(unitMod, BASE_VALUE);
@ -1041,44 +1041,44 @@ void Pet::UpdateMaxPower(Powers power)
void Pet::UpdateAttackPowerAndDamage(bool ranged) void Pet::UpdateAttackPowerAndDamage(bool ranged)
{ {
if(ranged) if (ranged)
return; return;
float val = 0.0f; float val = 0.0f;
float bonusAP = 0.0f; float bonusAP = 0.0f;
UnitMods unitMod = UNIT_MOD_ATTACK_POWER; UnitMods unitMod = UNIT_MOD_ATTACK_POWER;
if(GetEntry() == 416) // imp's attack power if (GetEntry() == 416) // imp's attack power
val = GetStat(STAT_STRENGTH) - 10.0f; val = GetStat(STAT_STRENGTH) - 10.0f;
else else
val = 2 * GetStat(STAT_STRENGTH) - 20.0f; val = 2 * GetStat(STAT_STRENGTH) - 20.0f;
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if( owner && owner->GetTypeId()==TYPEID_PLAYER) if (owner && owner->GetTypeId()==TYPEID_PLAYER)
{ {
if(getPetType() == HUNTER_PET) //hunter pets benefit from owner's attack power if (getPetType() == HUNTER_PET) //hunter pets benefit from owner's attack power
{ {
bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f; bonusAP = owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.22f;
SetBonusDamage( int32(owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.1287f)); SetBonusDamage(int32(owner->GetTotalAttackPowerValue(RANGED_ATTACK) * 0.1287f));
} }
//demons benefit from warlocks shadow or fire damage //demons benefit from warlocks shadow or fire damage
else if(getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK) else if (getPetType() == SUMMON_PET && owner->getClass() == CLASS_WARLOCK)
{ {
int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE); int32 fire = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FIRE);
int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW); int32 shadow = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_SHADOW);
int32 maximum = (fire > shadow) ? fire : shadow; int32 maximum = (fire > shadow) ? fire : shadow;
if(maximum < 0) if (maximum < 0)
maximum = 0; maximum = 0;
SetBonusDamage( int32(maximum * 0.15f)); SetBonusDamage(int32(maximum * 0.15f));
bonusAP = maximum * 0.57f; bonusAP = maximum * 0.57f;
} }
//water elementals benefit from mage's frost damage //water elementals benefit from mage's frost damage
else if(getPetType() == SUMMON_PET && owner->getClass() == CLASS_MAGE) else if (getPetType() == SUMMON_PET && owner->getClass() == CLASS_MAGE)
{ {
int32 frost = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST); int32 frost = int32(owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST)) - owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_NEG + SPELL_SCHOOL_FROST);
if(frost < 0) if (frost < 0)
frost = 0; frost = 0;
SetBonusDamage( int32(frost * 0.4f)); SetBonusDamage(int32(frost * 0.4f));
} }
} }
@ -1102,7 +1102,7 @@ void Pet::UpdateAttackPowerAndDamage(bool ranged)
void Pet::UpdateDamagePhysical(WeaponAttackType attType) void Pet::UpdateDamagePhysical(WeaponAttackType attType)
{ {
if(attType > BASE_ATTACK) if (attType > BASE_ATTACK)
return; return;
UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND;
@ -1123,7 +1123,7 @@ void Pet::UpdateDamagePhysical(WeaponAttackType attType)
// Pet's base damage changes depending on happiness // Pet's base damage changes depending on happiness
if (getPetType() == HUNTER_PET && attType == BASE_ATTACK) if (getPetType() == HUNTER_PET && attType == BASE_ATTACK)
{ {
switch(GetHappinessState()) switch (GetHappinessState())
{ {
case HAPPY: case HAPPY:
// 125% of normal damage // 125% of normal damage