diff options
Diffstat (limited to 'src')
30 files changed, 1067 insertions, 1110 deletions
diff --git a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp index 3e61cd8ec20..892a7765cd1 100644 --- a/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp +++ b/src/bindings/scripts/scripts/eastern_kingdoms/karazhan/boss_prince_malchezaar.cpp @@ -188,7 +188,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI InfernalCleanup(); positions.clear(); - for (uint8 i =0; i < 5; ++i) + for (uint8 i = 0; i < 5; ++i) enfeeble_targets[i] = 0; for (uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i) @@ -202,8 +202,8 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI Cleave_Timer = 8000; InfernalTimer = 45000; InfernalCleanupTimer = 47000; - AxesTargetSwitchTimer = 7500 + rand()%12500; - SunderArmorTimer = 5000 + rand()%5000; + AxesTargetSwitchTimer = urand(7500,20000); + SunderArmorTimer = urand(5000,10000); phase = 1; if (pInstance) @@ -242,21 +242,20 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI void InfernalCleanup() { //Infernal Cleanup - for (std::vector<uint64>::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr) - { - Unit *pInfernal = Unit::GetUnit(*m_creature, *itr); - if (pInfernal && pInfernal->isAlive()) - { - pInfernal->SetVisibility(VISIBILITY_OFF); - pInfernal->setDeathState(JUST_DIED); - } - } + for (std::vector<uint64>::iterator itr = infernals.begin(); itr != infernals.end(); ++itr) + if (Unit *pInfernal = Unit::GetUnit(*m_creature, *itr)) + if (pInfernal->isAlive()) + { + pInfernal->SetVisibility(VISIBILITY_OFF); + pInfernal->setDeathState(JUST_DIED); + } + infernals.clear(); } void AxesCleanup() { - for (uint8 i=0; i<2; ++i) + for (uint8 i = 0; i < 2; ++i) { Unit *axe = Unit::GetUnit(*m_creature, axes[i]); if (axe && axe->isAlive()) @@ -291,23 +290,18 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI //begin + 1, so we don't target the one with the highest threat std::list<HostilReference *>::iterator itr = t_list.begin(); std::advance(itr, 1); - for (; itr!= t_list.end(); ++itr) //store the threat list in a different container - { - Unit *pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()); - //only on alive players - if (pTarget && pTarget->isAlive() && pTarget->GetTypeId() == TYPEID_PLAYER) - targets.push_back(pTarget); - } + for (; itr != t_list.end(); ++itr) //store the threat list in a different container + if (Unit *pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid())) + if (pTarget->isAlive() && pTarget->GetTypeId() == TYPEID_PLAYER) + targets.push_back(pTarget); //cut down to size if we have more than 5 targets - while(targets.size() > 5) + while (targets.size() > 5) targets.erase(targets.begin()+rand()%targets.size()); - int i = 0; - for (std::vector<Unit *>::iterator iter = targets.begin(); iter!= targets.end(); ++iter, ++i) - { - Unit *pTarget = *iter; - if (pTarget) + uint32 i = 0; + for (std::vector<Unit *>::iterator iter = targets.begin(); iter != targets.end(); ++iter, ++i) + if (Unit *pTarget = *iter) { enfeeble_targets[i] = pTarget->GetGUID(); enfeeble_health[i] = pTarget->GetHealth(); @@ -315,8 +309,6 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI pTarget->CastSpell(pTarget, SPELL_ENFEEBLE, true, 0, 0, m_creature->GetGUID()); pTarget->SetHealth(1); } - } - } void EnfeebleResetHealth() @@ -367,17 +359,16 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI if (!UpdateVictim()) return; - if (EnfeebleResetTimer) - if (EnfeebleResetTimer <= diff) //Let's not forget to reset that + if (EnfeebleResetTimer && EnfeebleResetTimer <= diff) // Let's not forget to reset that { EnfeebleResetHealth(); - EnfeebleResetTimer=0; + EnfeebleResetTimer = 0; } else EnfeebleResetTimer -= diff; - if (m_creature->hasUnitState(UNIT_STAT_STUNNED)) //While shifting to phase 2 malchezaar stuns himself + if (m_creature->hasUnitState(UNIT_STAT_STUNNED)) // While shifting to phase 2 malchezaar stuns himself return; - if (m_creature->GetUInt64Value(UNIT_FIELD_TARGET)!=m_creature->getVictim()->GetGUID()) + if (m_creature->GetUInt64Value(UNIT_FIELD_TARGET) != m_creature->getVictim()->GetGUID()) m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID()); if (phase == 1) @@ -481,11 +472,10 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI { if (Unit *axe = Unit::GetUnit(*m_creature, axes[i])) { - float threat = 1000000.0f; if (axe->getVictim()) DoModifyThreatPercent(axe->getVictim(), -100); if (pTarget) - axe->AddThreat(pTarget, threat); + axe->AddThreat(pTarget, 1000000.0f); //axe->getThreatManager().tauntFadeOut(axe->getVictim()); //axe->getThreatManager().tauntApply(pTarget); } @@ -505,13 +495,13 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI if (InfernalTimer <= diff) { SummonInfernal(diff); - InfernalTimer = phase == 3 ? 14500 : 44500; //15 secs in phase 3, 45 otherwise + InfernalTimer = phase == 3 ? 14500 : 44500; // 15 secs in phase 3, 45 otherwise } else InfernalTimer -= diff; if (ShadowNovaTimer <= diff) { DoCast(m_creature->getVictim(), SPELL_SHADOWNOVA); - ShadowNovaTimer = phase == 3 ? 31000 : 4294967295; + ShadowNovaTimer = phase == 3 ? 31000 : uint32(-1); } else ShadowNovaTimer -= diff; if (phase != 2) @@ -521,7 +511,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI Unit *pTarget = NULL; if (phase == 1) pTarget = m_creature->getVictim(); // the tank - else // anyone but the tank + else // anyone but the tank pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); if (pTarget) diff --git a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp index bbdc55321b8..58115b7e0fc 100644 --- a/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp +++ b/src/bindings/scripts/scripts/northrend/azjol_nerub/ahnkahet/boss_amanitar.cpp @@ -125,7 +125,8 @@ struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI void UpdateAI(const uint32 diff) { //Return since we have no target - if (!UpdateVictim()) return; + if (!UpdateVictim()) + return; if (spawntimer <= diff) { @@ -136,20 +137,20 @@ struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI if (roottimer <= diff) { if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - m_creature->CastSpell(pTarget, SPELL_ENTANGLING_ROOTS, false); + DoCast(pTarget, SPELL_ENTANGLING_ROOTS); roottimer = urand(15000,30000); } if (bashtimer <= diff) { - m_creature->CastSpell(m_creature->getVictim(), SPELL_BASH, false); + DoCastVictim(SPELL_BASH); bashtimer = urand(15000,30000); } else bashtimer -= diff; if (bolttimer <= diff) { if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true)) - m_creature->CastSpell(pTarget, SPELL_VENOM_BOLT_VOLLEY, false); + DoCast(pTarget, SPELL_VENOM_BOLT_VOLLEY); bolttimer = urand(15000,30000); } else bolttimer -= diff; @@ -169,9 +170,10 @@ struct MANGOS_DLL_DECL mob_amanitar_mushroomsAI : public Scripted_NoMovementAI void Reset() { - m_creature->CastSpell(m_creature, SPELL_PUTRID_MUSHROOM, true); // Hack, to make the mushrooms visible, can't find orig. spell... + DoCast(m_creature, SPELL_PUTRID_MUSHROOM, true); // Hack, to make the mushrooms visible, can't find orig. spell... - if (m_creature->GetEntry() == NPC_POISONOUS_MUSHROOM) m_creature->CastSpell(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AURA, true); + if (m_creature->GetEntry() == NPC_POISONOUS_MUSHROOM) + DoCast(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AURA, true); auratimer = 0; deathtimer = 30000; @@ -198,8 +200,8 @@ struct MANGOS_DLL_DECL mob_amanitar_mushroomsAI : public Scripted_NoMovementAI { if (auratimer <= diff) { - m_creature->CastSpell(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AREA, true); - m_creature->CastSpell(m_creature, POISONOUS_MUSHROOM_SPELL_POISON_CLOUD, false); + DoCast(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AREA, true); + DoCast(m_creature, POISONOUS_MUSHROOM_SPELL_POISON_CLOUD, false); auratimer = 7000; } else auratimer -= diff; } diff --git a/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp b/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp index 70d8912d1d5..9b71a8063d5 100644 --- a/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp +++ b/src/bindings/scripts/scripts/northrend/naxxramas/boss_maexxna.cpp @@ -31,9 +31,9 @@ #define MAX_POS_WRAP 3 const float PosWrap[MAX_POS_WRAP][3] = { - {3546.796, -3869.082, 296.450+20}, - {3531.271, -3847.424, 299.450+20}, - {3497.067, -3843.384, 302.384+20}, + {3546.796, -3869.082, 296.450}, + {3531.271, -3847.424, 299.450}, + {3497.067, -3843.384, 302.384}, }; enum Events @@ -74,12 +74,12 @@ struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI switch(eventId) { case EVENT_WRAP: - for (uint32 i = 0; i < HEROIC(1,2); ++i) + for (uint8 i = 0; i < HEROIC(1,2); ++i) { if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true, -SPELL_WEB_WRAP)) { pTarget->RemoveAura(SPELL_WEB_SPRAY); - uint32 pos = rand()%MAX_POS_WRAP; + uint8 pos = rand()%MAX_POS_WRAP; pTarget->GetMotionMaster()->MoveJump(PosWrap[pos][0], PosWrap[pos][1], PosWrap[pos][2], 20, 20); if (Creature *wrap = DoSummon(MOB_WEB_WRAP, pTarget, 0, 60000)) { @@ -104,8 +104,8 @@ struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI return; case EVENT_SUMMON: { - uint32 amount = 8+rand()%2; - for (uint32 i = 0; i < amount; ++i) + uint8 amount = urand(8,10); + for (uint8 i = 0; i < amount; ++i) DoSummon(MOB_SPIDERLING, me); events.ScheduleEvent(EVENT_SUMMON, 40000); break; diff --git a/src/bindings/scripts/scripts/world/npc_professions.cpp b/src/bindings/scripts/scripts/world/npc_professions.cpp index 08822f58ecd..ad4cd3bd1f2 100644 --- a/src/bindings/scripts/scripts/world/npc_professions.cpp +++ b/src/bindings/scripts/scripts/world/npc_professions.cpp @@ -195,7 +195,7 @@ int32 DoHighUnlearnCost(Player* pPlayer) //tailor, alchemy int32 DoMedUnlearnCost(Player* pPlayer) //blacksmith, leatherwork { - uint32 level = pPlayer->getLevel(); + uint8 level = pPlayer->getLevel(); if (level < 51) return 250000; else if (level < 66) @@ -206,7 +206,7 @@ int32 DoMedUnlearnCost(Player* pPlayer) //blacksmith, leath int32 DoLowUnlearnCost(Player* pPlayer) //blacksmith { - uint32 level = pPlayer->getLevel(); + uint8 level = pPlayer->getLevel(); if (level < 66) return 50000; else @@ -224,14 +224,14 @@ bool EquippedOk(Player* pPlayer, uint32 spellId) if (!spell) return false; - for (uint8 i=0; i<3; ++i) + for (uint8 i = 0; i < 3; ++i) { uint32 reqSpell = spell->EffectTriggerSpell[i]; if (!reqSpell) continue; Item* pItem; - for (uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++) + for (uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; ++j) { pItem = pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, j); if (pItem) diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 402c198221e..93820044bac 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -593,7 +593,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player, } void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player, - std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable, + std::wstring const& wsearchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount) { diff --git a/src/game/AuctionHouseMgr.h b/src/game/AuctionHouseMgr.h index 0e3ead4f608..c42d268f0c9 100644 --- a/src/game/AuctionHouseMgr.h +++ b/src/game/AuctionHouseMgr.h @@ -108,7 +108,7 @@ class AuctionHouseObject void BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount); void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount); void BuildListAuctionItems(WorldPacket& data, Player* player, - std::wstring const& searchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable, + std::wstring const& searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint32 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32& count, uint32& totalcount); diff --git a/src/game/BattleGroundAV.cpp b/src/game/BattleGroundAV.cpp index abcc2e72d14..ad41eb83d5c 100644 --- a/src/game/BattleGroundAV.cpp +++ b/src/game/BattleGroundAV.cpp @@ -247,38 +247,38 @@ void BattleGroundAV::UpdateScore(uint16 team, int16 points ) } } -Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type ) +Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type) { - uint32 level; - bool isStatic=false; + uint8 level; + bool isStatic = false; Creature* creature = NULL; assert(type <= AV_CPLACE_MAX + AV_STATICCPLACE_MAX); - if(type>=AV_CPLACE_MAX) //static + if (type >= AV_CPLACE_MAX) //static { - type-=AV_CPLACE_MAX; - cinfoid=int(BG_AV_StaticCreaturePos[type][4]); + type -= AV_CPLACE_MAX; + cinfoid=uint16(BG_AV_StaticCreaturePos[type][4]); creature = AddCreature(BG_AV_StaticCreatureInfo[cinfoid][0],(type+AV_CPLACE_MAX),BG_AV_StaticCreatureInfo[cinfoid][1],BG_AV_StaticCreaturePos[type][0],BG_AV_StaticCreaturePos[type][1],BG_AV_StaticCreaturePos[type][2],BG_AV_StaticCreaturePos[type][3]); - level = ( BG_AV_StaticCreatureInfo[cinfoid][2] == BG_AV_StaticCreatureInfo[cinfoid][3] ) ? BG_AV_StaticCreatureInfo[cinfoid][2] : urand(BG_AV_StaticCreatureInfo[cinfoid][2],BG_AV_StaticCreatureInfo[cinfoid][3]); - isStatic=true; + level = (BG_AV_StaticCreatureInfo[cinfoid][2] == BG_AV_StaticCreatureInfo[cinfoid][3]) ? BG_AV_StaticCreatureInfo[cinfoid][2] : urand(BG_AV_StaticCreatureInfo[cinfoid][2],BG_AV_StaticCreatureInfo[cinfoid][3]); + isStatic = true; } else { creature = AddCreature(BG_AV_CreatureInfo[cinfoid][0],type,BG_AV_CreatureInfo[cinfoid][1],BG_AV_CreaturePos[type][0],BG_AV_CreaturePos[type][1],BG_AV_CreaturePos[type][2],BG_AV_CreaturePos[type][3]); - level = ( BG_AV_CreatureInfo[cinfoid][2] == BG_AV_CreatureInfo[cinfoid][3] ) ? BG_AV_CreatureInfo[cinfoid][2] : urand(BG_AV_CreatureInfo[cinfoid][2],BG_AV_CreatureInfo[cinfoid][3]); + level = (BG_AV_CreatureInfo[cinfoid][2] == BG_AV_CreatureInfo[cinfoid][3]) ? BG_AV_CreatureInfo[cinfoid][2] : urand(BG_AV_CreatureInfo[cinfoid][2],BG_AV_CreatureInfo[cinfoid][3]); } - if(!creature) + if (!creature) return NULL; - if(creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_A_CAPTAIN][0] || creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN][0]) + if (creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_A_CAPTAIN][0] || creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN][0]) creature->SetRespawnDelay(RESPAWN_ONE_DAY); // TODO: look if this can be done by database + also add this for the wingcommanders - if((isStatic && cinfoid>=10 && cinfoid<=14) || (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid<=AV_NPC_A_GRAVEDEFENSE3) || - (cinfoid>=AV_NPC_H_GRAVEDEFENSE0 && cinfoid<=AV_NPC_H_GRAVEDEFENSE3)))) + if ((isStatic && cinfoid>=10 && cinfoid<=14) || (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid<=AV_NPC_A_GRAVEDEFENSE3) || + (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3)))) { if(!isStatic && ((cinfoid>=AV_NPC_A_GRAVEDEFENSE0 && cinfoid<=AV_NPC_A_GRAVEDEFENSE3) - || (cinfoid>=AV_NPC_H_GRAVEDEFENSE0 && cinfoid<=AV_NPC_H_GRAVEDEFENSE3))) + || (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3))) { CreatureData &data = objmgr.NewOrExistCreatureData(creature->GetDBTableGUIDLow()); - data.spawndist = 5; + data.spawndist = 5; } //else spawndist will be 15, so creatures move maximum=10 //creature->SetDefaultMovementType(RANDOM_MOTION_TYPE); @@ -289,8 +289,8 @@ Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type ) //just copied this code from a gm-command } - if(level != 0) - level += m_MaxLevel-60; //maybe we can do this more generic for custom level-range.. actually it's blizzlike + if (level != 0) + level += m_MaxLevel - 60; //maybe we can do this more generic for custom level-range.. actually it's blizzlike creature->SetLevel(level); return creature; } diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index dbfe024f371..39921239678 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1390,9 +1390,9 @@ void Creature::SelectLevel(const CreatureInfo *cinfo) uint32 rank = isPet()? 0 : cinfo->rank; // level - uint32 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel); - uint32 maxlevel = std::max(cinfo->maxlevel, cinfo->minlevel); - uint32 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel); + uint8 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel); + uint8 maxlevel = std::max(cinfo->maxlevel, cinfo->minlevel); + uint8 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel); SetLevel(level); float rellevel = maxlevel == minlevel ? 0 : (float(level - minlevel))/(maxlevel - minlevel); @@ -2510,12 +2510,12 @@ void Creature::AllLootRemovedFromCorpse() } } -uint32 Creature::getLevelForTarget( Unit const* target ) const +uint8 Creature::getLevelForTarget(Unit const* target) const { if(!isWorldBoss()) return Unit::getLevelForTarget(target); - uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF); + uint16 level = target->getLevel()+sWorld.getConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF); if(level < 1) return 1; if(level > 255) diff --git a/src/game/Creature.h b/src/game/Creature.h index 2ee2a3997d7..5945f441946 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -530,7 +530,7 @@ class TRINITY_DLL_SPEC Creature : public Unit return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS; } - uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support + uint8 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support bool IsInEvadeMode() const { return hasUnitState(UNIT_STAT_EVADE); } diff --git a/src/game/CreatureAIImpl.h b/src/game/CreatureAIImpl.h index 1048968ce82..9f61216e489 100644 --- a/src/game/CreatureAIImpl.h +++ b/src/game/CreatureAIImpl.h @@ -29,14 +29,14 @@ template<class T> inline const T& RAND(const T& v1, const T& v2) { - return (rand()%2) ? v1 : v2; + return (urand(0,1)) ? v1 : v2; } template<class T> inline const T& RAND(const T& v1, const T& v2, const T& v3) { - switch(rand()%3) + switch (urand(0,2)) { default: case 0: return v1; @@ -49,7 +49,7 @@ template<class T> inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4) { - switch(rand()%4) + switch (urand(0,3)) { default: case 0: return v1; @@ -63,7 +63,7 @@ template<class T> inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5) { - switch(rand()%5) + switch (urand(0,4)) { default: case 0: return v1; @@ -78,7 +78,7 @@ template<class T> inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6) { - switch(rand()%6) + switch (urand(0,5)) { default: case 0: return v1; @@ -94,7 +94,7 @@ template<class T> inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7) { - switch(rand()%7) + switch (urand(0,6)) { default: case 0: return v1; @@ -111,7 +111,7 @@ template<class T> inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8) { - switch(rand()%8) + switch (urand(0,7)) { default: case 0: return v1; @@ -130,7 +130,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9) { - switch(rand()%9) + switch (urand(0,8)) { default: case 0: return v1; @@ -150,7 +150,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10) { - switch(rand()%10) + switch (urand(0,9)) { default: case 0: return v1; @@ -171,7 +171,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10, const T& v11) { - switch(rand()%11) + switch (urand(0,10)) { default: case 0: return v1; @@ -193,7 +193,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10, const T& v11, const T& v12) { - switch(rand()%12) + switch (urand(0,11)) { default: case 0: return v1; @@ -216,7 +216,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10, const T& v11, const T& v12, const T& v13) { - switch(rand()%13) + switch (urand(0,12)) { default: case 0: return v1; @@ -240,7 +240,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14) { - switch(rand()%14) + switch (urand(0,13)) { default: case 0: return v1; @@ -265,7 +265,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15) { - switch(rand()%15) + switch (urand(0,14)) { default: case 0: return v1; @@ -291,7 +291,7 @@ inline const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8, const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15, const T& v16) { - switch(rand()%16) + switch (urand(0,15)) { default: case 0: return v1; @@ -328,19 +328,19 @@ class EventMap : private std::map<uint32, uint32> void SetPhase(uint32 phase) { - if(phase && phase < 9) + if (phase && phase < 9) m_phase = (1 << (phase + 24)); } void ScheduleEvent(uint32 eventId, uint32 time, uint32 gcd = 0, uint32 phase = 0) { time += m_time; - if(gcd && gcd < 9) + if (gcd && gcd < 9) eventId |= (1 << (gcd + 16)); - if(phase && phase < 9) + if (phase && phase < 9) eventId |= (1 << (phase + 24)); iterator itr = find(time); - while(itr != end()) + while (itr != end()) { ++time; itr = find(time); @@ -356,13 +356,13 @@ class EventMap : private std::map<uint32, uint32> void RepeatEvent(uint32 time) { - if(empty()) + if (empty()) return; uint32 eventId = begin()->second; erase(begin()); time += m_time; iterator itr = find(time); - while(itr != end()) + while (itr != end()) { ++time; itr = find(time); @@ -377,11 +377,11 @@ class EventMap : private std::map<uint32, uint32> uint32 ExecuteEvent() { - while(!empty()) + while (!empty()) { - if(begin()->first > m_time) + if (begin()->first > m_time) return 0; - else if(m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase)) + else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase)) erase(begin()); else { @@ -395,16 +395,14 @@ class EventMap : private std::map<uint32, uint32> uint32 GetEvent() { - while(!empty()) + while (!empty()) { - if(begin()->first > m_time) + if (begin()->first > m_time) return 0; - else if(m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase)) + else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase)) erase(begin()); else - { return (begin()->second & 0x0000FFFF); - } } return 0; } @@ -413,11 +411,11 @@ class EventMap : private std::map<uint32, uint32> { time += m_time; gcd = (1 << (gcd + 16)); - for (iterator itr = begin(); itr != end(); ) + for (iterator itr = begin(); itr != end();) { - if(itr->first >= time) + if (itr->first >= time) break; - if(itr->second & gcd) + if (itr->second & gcd) { ScheduleEvent(time, itr->second); erase(itr++); @@ -429,9 +427,9 @@ class EventMap : private std::map<uint32, uint32> void CancelEvent(uint32 eventId) { - for (iterator itr = begin(); itr != end(); ) + for (iterator itr = begin(); itr != end();) { - if(eventId == (itr->second & 0x0000FFFF)) + if (eventId == (itr->second & 0x0000FFFF)) erase(itr++); else ++itr; @@ -440,9 +438,9 @@ class EventMap : private std::map<uint32, uint32> void CancelEventsByGCD(uint32 gcd) { - for (iterator itr = begin(); itr != end(); ) + for (iterator itr = begin(); itr != end();) { - if(itr->second & gcd) + if (itr->second & gcd) erase(itr++); else ++itr; @@ -484,7 +482,7 @@ TRINITY_DLL_SPEC AISpellInfoType * GetAISpellInfo(uint32 i); inline void CreatureAI::SetGazeOn(Unit *target) { - if(me->canAttack(target)) + if (me->canAttack(target)) { AttackStart(target); me->SetReactState(REACT_PASSIVE); @@ -493,34 +491,34 @@ inline void CreatureAI::SetGazeOn(Unit *target) inline bool CreatureAI::UpdateVictimWithGaze() { - if(!me->isInCombat()) + if (!me->isInCombat()) return false; - if(me->HasReactState(REACT_PASSIVE)) + if (me->HasReactState(REACT_PASSIVE)) { - if(me->getVictim()) + if (me->getVictim()) return true; else me->SetReactState(REACT_AGGRESSIVE); } - if(Unit *victim = me->SelectVictim()) + if (Unit *victim = me->SelectVictim()) AttackStart(victim); return me->getVictim(); } inline bool CreatureAI::UpdateCombatState() { - if(!me->isInCombat()) + if (!me->isInCombat()) return false; - if(!me->HasReactState(REACT_PASSIVE)) + if (!me->HasReactState(REACT_PASSIVE)) { - if(Unit *victim = me->SelectVictim()) + if (Unit *victim = me->SelectVictim()) AttackStart(victim); return me->getVictim(); } - else if(me->getThreatManager().isThreatListEmpty()) + else if (me->getThreatManager().isThreatListEmpty()) { EnterEvadeMode(); return false; @@ -531,16 +529,16 @@ inline bool CreatureAI::UpdateCombatState() inline bool CreatureAI::UpdateVictim() { - if(!me->isInCombat()) + if (!me->isInCombat()) return false; - if(!me->HasReactState(REACT_PASSIVE)) + if (!me->HasReactState(REACT_PASSIVE)) { if(Unit *victim = me->SelectVictim()) AttackStart(victim); return me->getVictim(); } - else if(me->getThreatManager().isThreatListEmpty()) + else if (me->getThreatManager().isThreatListEmpty()) { EnterEvadeMode(); return false; @@ -552,9 +550,9 @@ inline bool CreatureAI::UpdateVictim() /* inline bool CreatureAI::UpdateVictim() { - if(!me->isInCombat()) + if (!me->isInCombat()) return false; - if(Unit *victim = me->SelectVictim()) + if (Unit *victim = me->SelectVictim()) AttackStart(victim); return me->getVictim(); } @@ -562,7 +560,7 @@ inline bool CreatureAI::UpdateVictim() inline bool CreatureAI::_EnterEvadeMode() { - if(!me->isAlive()) + if (!me->isAlive()) return false; // sometimes bosses stuck in combat? @@ -573,7 +571,7 @@ inline bool CreatureAI::_EnterEvadeMode() me->SetLootRecipient(NULL); me->ResetPlayerDamageReq(); - if(me->IsInEvadeMode()) + if (me->IsInEvadeMode()) return false; return true; @@ -581,7 +579,7 @@ inline bool CreatureAI::_EnterEvadeMode() inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered) { - if(!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered)) + if (!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered)) return; me->CastSpell(victim, spellId, triggered); @@ -594,7 +592,7 @@ inline void UnitAI::DoCastVictim(uint32 spellId, bool triggered) inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered) { - if(!triggered && me->hasUnitState(UNIT_STAT_CASTING)) + if (!triggered && me->hasUnitState(UNIT_STAT_CASTING)) return; me->CastSpell((Unit*)NULL, spellId, triggered); diff --git a/src/game/Formulas.h b/src/game/Formulas.h index 2ec175f95be..41e75905df2 100644 --- a/src/game/Formulas.h +++ b/src/game/Formulas.h @@ -27,61 +27,61 @@ namespace Trinity { namespace Honor { - inline uint32 hk_honor_at_level(uint32 level, uint32 count=1) + inline uint32 hk_honor_at_level(uint8 level, uint32 count = 1) { - return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f ))); + return uint32(ceil(count*(-0.53177f + 0.59357f * exp((level + 23.54042f) / 26.07859f)))); } } namespace XP { enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY }; - inline uint32 GetGrayLevel(uint32 pl_level) + inline uint8 GetGrayLevel(uint8 pl_level) { - if( pl_level <= 5 ) + if (pl_level <= 5) return 0; - else if( pl_level <= 39 ) + else if (pl_level <= 39) return pl_level - 5 - pl_level/10; - else if( pl_level <= 59 ) + else if (pl_level <= 59) return pl_level - 1 - pl_level/5; else return pl_level - 9; } - inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level) + inline XPColorChar GetColorCode(uint8 pl_level, uint8 mob_level) { - if( mob_level >= pl_level + 5 ) + if (mob_level >= pl_level + 5) return RED; - else if( mob_level >= pl_level + 3 ) + else if (mob_level >= pl_level + 3) return ORANGE; - else if( mob_level >= pl_level - 2 ) + else if (mob_level >= pl_level - 2) return YELLOW; - else if( mob_level > GetGrayLevel(pl_level) ) + else if (mob_level > GetGrayLevel(pl_level)) return GREEN; else return GRAY; } - inline uint32 GetZeroDifference(uint32 pl_level) + inline uint8 GetZeroDifference(uint8 pl_level) { - if( pl_level < 8 ) return 5; - if( pl_level < 10 ) return 6; - if( pl_level < 12 ) return 7; - if( pl_level < 16 ) return 8; - if( pl_level < 20 ) return 9; - if( pl_level < 30 ) return 11; - if( pl_level < 40 ) return 12; - if( pl_level < 45 ) return 13; - if( pl_level < 50 ) return 14; - if( pl_level < 55 ) return 15; - if( pl_level < 60 ) return 16; + if (pl_level < 8) return 5; + if (pl_level < 10) return 6; + if (pl_level < 12) return 7; + if (pl_level < 16) return 8; + if (pl_level < 20) return 9; + if (pl_level < 30) return 11; + if (pl_level < 40) return 12; + if (pl_level < 45) return 13; + if (pl_level < 50) return 14; + if (pl_level < 55) return 15; + if (pl_level < 60) return 16; return 17; } - inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content) + inline uint32 BaseGain(uint8 pl_level, uint8 mob_level, ContentLevels content) { uint32 nBaseExp; - switch(content) + switch (content) { case CONTENT_1_60: nBaseExp = 45; break; case CONTENT_61_70: nBaseExp = 235; break; @@ -91,19 +91,19 @@ namespace Trinity nBaseExp = 45; break; } - if( mob_level >= pl_level ) + if (mob_level >= pl_level) { - uint32 nLevelDiff = mob_level - pl_level; + uint8 nLevelDiff = mob_level - pl_level; if (nLevelDiff > 4) nLevelDiff = 4; return ((pl_level*5 + nBaseExp) * (20 + nLevelDiff)/10 + 1)/2; } else { - uint32 gray_level = GetGrayLevel(pl_level); - if( mob_level > gray_level ) + uint8 gray_level = GetGrayLevel(pl_level); + if (mob_level > gray_level) { - uint32 ZD = GetZeroDifference(pl_level); + uint8 ZD = GetZeroDifference(pl_level); return (pl_level*5 + nBaseExp) * (ZD + mob_level - pl_level)/ZD; } return 0; @@ -112,31 +112,31 @@ namespace Trinity inline uint32 Gain(Player *pl, Unit *u) { - if(u->GetTypeId()==TYPEID_UNIT && ( + if (u->GetTypeId()==TYPEID_UNIT && ( ((Creature*)u)->isTotem() || ((Creature*)u)->isPet() || (((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) )) return 0; - uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(),u->GetZoneId())); - if( xp_gain == 0 ) + uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(),u->GetZoneId())); + if (xp_gain == 0) return 0; - if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isElite()) + if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite()) xp_gain *= 2; - return (uint32)(xp_gain*sWorld.getRate(RATE_XP_KILL)); + return uint32(xp_gain*sWorld.getRate(RATE_XP_KILL)); } inline float xp_in_group_rate(uint32 count, bool isRaid) { - if(isRaid) + if (isRaid) { // FIX ME: must apply decrease modifiers dependent from raid size return 1.0f; } else { - switch(count) + switch (count) { case 0: case 1: diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index fa66576feb1..8a2bf6f521d 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -1291,12 +1291,12 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_FLAGSTAND: // 24 { - if(user->GetTypeId() != TYPEID_PLAYER) + if (user->GetTypeId() != TYPEID_PLAYER) return; Player* player = (Player*)user; - if( player->CanUseBattleGroundObject() ) + if (player->CanUseBattleGroundObject()) { // in battleground check BattleGround *bg = player->GetBattleGround(); @@ -1316,16 +1316,16 @@ void GameObject::Use(Unit* user) } case GAMEOBJECT_TYPE_FLAGDROP: // 26 { - if(user->GetTypeId() != TYPEID_PLAYER) + if (user->GetTypeId() != TYPEID_PLAYER) return; Player* player = (Player*)user; - if( player->CanUseBattleGroundObject() ) + if (player->CanUseBattleGroundObject()) { // in battleground check BattleGround *bg = player->GetBattleGround(); - if(!bg) + if (!bg) return; // BG flag dropped // WS: @@ -1334,7 +1334,7 @@ void GameObject::Use(Unit* user) // EotS: // 184142 - Netherstorm Flag GameObjectInfo const* info = GetGOInfo(); - if(info) + if (info) { switch(info->id) { @@ -1362,10 +1362,10 @@ void GameObject::Use(Unit* user) case GAMEOBJECT_TYPE_BARBER_CHAIR: //32 { GameObjectInfo const* info = GetGOInfo(); - if(!info) + if (!info) return; - if(user->GetTypeId() != TYPEID_PLAYER) + if (user->GetTypeId() != TYPEID_PLAYER) return; Player* player = (Player*)user; @@ -1384,11 +1384,11 @@ void GameObject::Use(Unit* user) break; } - if(!spellId) + if (!spellId) return; SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellId ); - if(!spellInfo) + if (!spellInfo) { if(user->GetTypeId() != TYPEID_PLAYER || !sOutdoorPvPMgr.HandleCustomSpell((Player*)user,spellId,this)) sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u )", spellId,GetEntry(),GetGoType()); @@ -1402,7 +1402,7 @@ void GameObject::Use(Unit* user) // spell target is user of GO SpellCastTargets targets; - targets.setUnitTarget( user ); + targets.setUnitTarget(user); spell->prepare(&targets); } @@ -1410,7 +1410,7 @@ void GameObject::Use(Unit* user) void GameObject::CastSpell(Unit* target, uint32 spellId) { SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); - if(!spellInfo) + if (!spellInfo) return; bool self = false; @@ -1462,7 +1462,7 @@ void GameObject::SendCustomAnim() bool GameObject::IsInRange(float x, float y, float z, float radius) const { GameObjectDisplayInfoEntry const * info = sGameObjectDisplayInfoStore.LookupEntry(GetUInt32Value(GAMEOBJECT_DISPLAYID)); - if(!info) + if (!info) return IsWithinDist3d(x, y, z, radius); float sinA = sin(GetOrientation()); @@ -1482,15 +1482,15 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const void GameObject::TakenDamage(uint32 damage) { - if(!m_goValue->building.health) + if (!m_goValue->building.health) return; - if(m_goValue->building.health > damage) + if (m_goValue->building.health > damage) m_goValue->building.health -= damage; else m_goValue->building.health = 0; - if(HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed + if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed { if(!m_goValue->building.health) { @@ -1503,11 +1503,11 @@ void GameObject::TakenDamage(uint32 damage) } else // from intact to damaged { - if(m_goValue->building.health <= m_goInfo->building.damagedNumHits) + if (m_goValue->building.health <= m_goInfo->building.damagedNumHits) { - if(!m_goInfo->building.destroyedDisplayId) + if (!m_goInfo->building.destroyedDisplayId) m_goValue->building.health = 0; - else if(!m_goValue->building.health) + else if (!m_goValue->building.health) m_goValue->building.health = 1; SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); @@ -1535,14 +1535,9 @@ void GameObject::EventInform(uint32 eventId) const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const { if (loc_idx >= 0) - { - GameObjectLocale const *cl = objmgr.GetGameObjectLocale(GetEntry()); - if (cl) - { + if (GameObjectLocale const *cl = objmgr.GetGameObjectLocale(GetEntry())) if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty()) return cl->Name[loc_idx].c_str(); - } - } return GetName(); } @@ -1567,7 +1562,7 @@ void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3 m_rotation = rotation; - if(rotation2==0.0f && rotation3==0.0f) + if(rotation2 == 0.0f && rotation3 == 0.0f) { rotation2 = f_rot1; rotation3 = f_rot2; diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 232b711bcf9..03f182de7e8 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -100,7 +100,7 @@ struct GameObjectInfo uint32 eventId; //6 lootedEvent uint32 linkedTrapId; //7 uint32 questId; //8 not used currently but store quest required for GO activation for player - uint32 level; //9 + uint8 level; //9 uint32 losOK; //10 uint32 leaveLoot; //11 uint32 notInCombat; //12 @@ -124,7 +124,7 @@ struct GameObjectInfo struct { uint32 lockId; //0 -> Lock.dbc - uint32 level; //1 + uint8 level; //1 uint32 radius; //2 radius for trap activation uint32 spellId; //3 uint32 charges; //4 need respawn (if > 0) diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp index aaea53e5c7a..8db145bb5e1 100644 --- a/src/game/InstanceData.cpp +++ b/src/game/InstanceData.cpp @@ -29,7 +29,7 @@ void InstanceData::SaveToDB() { std::string data = GetSaveData(); - if(data.empty()) + if (data.empty()) return; CharacterDatabase.escape_string(data); CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%d'", data.c_str(), instance->GetInstanceId()); @@ -37,9 +37,9 @@ void InstanceData::SaveToDB() void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go) { - if(!go) + if (!go) go = instance->GetGameObject(GUID); - if(go) + if (go) go->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY); else debug_log("TSCR: InstanceData: HandleGameObject failed"); @@ -48,7 +48,7 @@ void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go) bool InstanceData::IsEncounterInProgress() const { for (std::vector<BossInfo>::const_iterator itr = bosses.begin(); itr != bosses.end(); ++itr) - if(itr->state == IN_PROGRESS) + if (itr->state == IN_PROGRESS) return true; return false; @@ -58,7 +58,7 @@ void InstanceData::LoadMinionData(const MinionData *data) { while(data->entry) { - if(data->bossId < bosses.size()) + if (data->bossId < bosses.size()) minions.insert(std::make_pair(data->entry, MinionInfo(&bosses[data->bossId]))); ++data; @@ -70,7 +70,7 @@ void InstanceData::LoadDoorData(const DoorData *data) { while(data->entry) { - if(data->bossId < bosses.size()) + if (data->bossId < bosses.size()) doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type, BoundaryType(data->boundary)))); ++data; @@ -80,18 +80,18 @@ void InstanceData::LoadDoorData(const DoorData *data) void InstanceData::UpdateMinionState(Creature *minion, EncounterState state) { - switch(state) + switch (state) { case NOT_STARTED: - if(!minion->isAlive()) + if (!minion->isAlive()) minion->Respawn(); - else if(minion->isInCombat()) + else if (minion->isInCombat()) minion->AI()->EnterEvadeMode(); break; case IN_PROGRESS: - if(!minion->isAlive()) + if (!minion->isAlive()) minion->Respawn(); - else if(!minion->getVictim()) + else if (!minion->getVictim()) minion->AI()->DoZoneInCombat(); break; } @@ -101,23 +101,23 @@ void InstanceData::UpdateDoorState(GameObject *door) { DoorInfoMap::iterator lower = doors.lower_bound(door->GetEntry()); DoorInfoMap::iterator upper = doors.upper_bound(door->GetEntry()); - if(lower == upper) + if (lower == upper) return; bool open = true; for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr) { - if(itr->second.type == DOOR_TYPE_ROOM) + if (itr->second.type == DOOR_TYPE_ROOM) { - if(itr->second.bossInfo->state == IN_PROGRESS) + if (itr->second.bossInfo->state == IN_PROGRESS) { open = false; break; } } - else if(itr->second.type == DOOR_TYPE_PASSAGE) + else if (itr->second.type == DOOR_TYPE_PASSAGE) { - if(itr->second.bossInfo->state != DONE) + if (itr->second.bossInfo->state != DONE) { open = false; break; @@ -133,15 +133,15 @@ void InstanceData::AddDoor(GameObject *door, bool add) { DoorInfoMap::iterator lower = doors.lower_bound(door->GetEntry()); DoorInfoMap::iterator upper = doors.upper_bound(door->GetEntry()); - if(lower == upper) + if (lower == upper) return; for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr) { - if(add) + if (add) { itr->second.bossInfo->door[itr->second.type].insert(door); - switch(itr->second.boundary) + switch (itr->second.boundary) { default: case BOUNDARY_NONE: @@ -168,17 +168,17 @@ void InstanceData::AddDoor(GameObject *door, bool add) itr->second.bossInfo->door[itr->second.type].erase(door); } - if(add) + if (add) UpdateDoorState(door); } void InstanceData::AddMinion(Creature *minion, bool add) { MinionInfoMap::iterator itr = minions.find(minion->GetEntry()); - if(itr == minions.end()) + if (itr == minions.end()) return; - if(add) + if (add) itr->second.bossInfo->minion.insert(minion); else itr->second.bossInfo->minion.erase(minion); @@ -186,10 +186,10 @@ void InstanceData::AddMinion(Creature *minion, bool add) bool InstanceData::SetBossState(uint32 id, EncounterState state) { - if(id < bosses.size()) + if (id < bosses.size()) { BossInfo *bossInfo = &bosses[id]; - if(bossInfo->state == TO_BE_DECIDED) // loading + if (bossInfo->state == TO_BE_DECIDED) // loading { bossInfo->state = state; //sLog.outError("Inialize boss %u state as %u.", id, (uint32)state); @@ -197,10 +197,10 @@ bool InstanceData::SetBossState(uint32 id, EncounterState state) } else { - if(bossInfo->state == state) + if (bossInfo->state == state) return false; - if(state == DONE) + if (state == DONE) for (MinionSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i) if((*i)->isWorldBoss() && (*i)->isAlive()) return false; @@ -223,14 +223,15 @@ bool InstanceData::SetBossState(uint32 id, EncounterState state) std::string InstanceData::LoadBossState(const char * data) { - if(!data) return NULL; + if(!data) + return NULL; std::istringstream loadStream(data); uint32 buff; uint32 bossId = 0; for (std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i, ++bossId) { loadStream >> buff; - if(buff < TO_BE_DECIDED) + if (buff < TO_BE_DECIDED) SetBossState(bossId, (EncounterState)buff); } return loadStream.str(); @@ -270,8 +271,8 @@ void InstanceData::DoRespawnGameObject(uint64 uiGuid, uint32 uiTimeToDespawn) if (GameObject* pGo = instance->GetGameObject(uiGuid)) { //not expect any of these should ever be handled - if (pGo->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || pGo->GetGoType()==GAMEOBJECT_TYPE_DOOR || - pGo->GetGoType()==GAMEOBJECT_TYPE_BUTTON || pGo->GetGoType()==GAMEOBJECT_TYPE_TRAP) + if (pGo->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE || pGo->GetGoType()==GAMEOBJECT_TYPE_DOOR || + pGo->GetGoType() == GAMEOBJECT_TYPE_BUTTON || pGo->GetGoType()==GAMEOBJECT_TYPE_TRAP) return; if (pGo->isSpawned()) @@ -288,16 +289,13 @@ void InstanceData::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData) if (!lPlayers.isEmpty()) { for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr) - { - if (Player* pPlayer = itr->getSource()) + if (Player *pPlayer = itr->getSource()) pPlayer->SendUpdateWorldState(uiStateId, uiStateData); - } } else debug_log("TSCR: DoUpdateWorldState attempt send data but no players in map."); } -/* Not used anywhere yet, not sure if they're needed: // Send Notify to all players in instance void InstanceData::DoSendNotifyToInstance(const char *format, ...) { @@ -306,10 +304,11 @@ void InstanceData::DoSendNotifyToInstance(const char *format, ...) if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (i->getSource() && i->getSource()->GetSession()) - i->getSource()->GetSession()->SendNotification(format); + if (Player *pPlayer = i->getSource()) + if (WorldSession *pSession = pPlayer->GetSession()) + pSession->SendNotification(format); } -*/ + // Complete Achievement for all players in instance void InstanceData::DoCompleteAchievement(uint32 achievement) { @@ -318,8 +317,8 @@ void InstanceData::DoCompleteAchievement(uint32 achievement) if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (i->getSource()) - i->getSource()->CompletedAchievement(AE); + if (Player *pPlayer = i->getSource()) + pPlayer->CompletedAchievement(AE); } // Remove Auras due to Spell on all players in instance @@ -329,6 +328,6 @@ void InstanceData::DoRemoveAurasDueToSpellOnPlayers(uint32 spell) if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (i->getSource()) - i->getSource()->RemoveAurasDueToSpell(spell); + if (Player* pPlayer = i->getSource()) + pPlayer->RemoveAurasDueToSpell(spell); } diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h index a277907a30a..ccc389d8cc2 100644 --- a/src/game/InstanceData.h +++ b/src/game/InstanceData.h @@ -152,10 +152,8 @@ class TRINITY_DLL_SPEC InstanceData : public ZoneScript //sends world state update to all players in instance void DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData); - /* Not used anywhere yet, not sure if they're needed: // Send Notify to all players in instance void DoSendNotifyToInstance(const char *format,...); - */ // Complete Achievement for all players in instance void DoCompleteAchievement(uint32 achievement); diff --git a/src/game/ItemPrototype.h b/src/game/ItemPrototype.h index a6daf47cb48..490953766cd 100644 --- a/src/game/ItemPrototype.h +++ b/src/game/ItemPrototype.h @@ -522,7 +522,7 @@ struct ItemPrototype uint32 AllowableClass; uint32 AllowableRace; uint32 ItemLevel; - uint32 RequiredLevel; + uint8 RequiredLevel; uint32 RequiredSkill; // id from SkillLine.dbc uint32 RequiredSkillRank; uint32 RequiredSpell; // id from Spell.dbc diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 51677bb11ac..2a82fc3cb97 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1743,7 +1743,7 @@ bool ChatHandler::HandleNpcTameCommand(const char* /*args*/) pet->SetReactState(REACT_DEFENSIVE); // calculate proper level - uint32 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel(); + uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel(); // prepare visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); @@ -2139,7 +2139,7 @@ bool ChatHandler::HandlePInfoCommand(const char* args) uint32 accId = 0; uint32 money = 0; uint32 total_player_time = 0; - uint32 level = 0; + uint8 level = 0; uint32 latency = 0; uint8 race; uint8 Class; diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index e568deae695..a062ff87d55 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -152,7 +152,8 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) uint32 clientcount = 0; - uint32 level_min, level_max, racemask, classmask, zones_count, str_count; + uint8 level_min, level_max; + uint32 racemask, classmask, zones_count, str_count; uint32 zoneids[10]; // 10 is client limit std::string player_name, guild_name; @@ -166,7 +167,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) recv_data >> classmask; // class mask recv_data >> zones_count; // zones count, client limit=10 (2.0.10) - if(zones_count > 10) + if (zones_count > 10) return; // can't be received from real client or broken packet for (uint32 i = 0; i < zones_count; ++i) @@ -179,7 +180,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) recv_data >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10) - if(str_count > 4) + if (str_count > 4) return; // can't be received from real client or broken packet sLog.outDebug("Minlvl %u, maxlvl %u, name %s, guild %s, racemask %u, classmask %u, zones %u, strings %u", level_min, level_max, player_name.c_str(), guild_name.c_str(), racemask, classmask, zones_count, str_count); @@ -190,7 +191,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) std::string temp; recv_data >> temp; // user entered string, it used as universal search pattern(guild+player name)? - if(!Utf8toWStr(temp,str[i])) + if (!Utf8toWStr(temp,str[i])) continue; wstrToLower(str[i]); @@ -200,14 +201,14 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) std::wstring wplayer_name; std::wstring wguild_name; - if(!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name))) + if (!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name))) return; wstrToLower(wplayer_name); wstrToLower(wguild_name); // client send in case not set max level value 100 but mangos support 255 max level, // update it to show GMs with characters after 100 level - if(level_max >= MAX_LEVEL) + if (level_max >= MAX_LEVEL) level_max = STRONG_MAX_LEVEL; uint32 team = _player->GetTeam(); @@ -243,7 +244,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data ) continue; // check if target's level is in level range - uint32 lvl = itr->second->getLevel(); + uint8 lvl = itr->second->getLevel(); if (lvl < level_min || lvl > level_max) continue; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 43a59c3aa61..0cb124e4a8b 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -1914,7 +1914,7 @@ void ObjectMgr::LoadItemPrototypes() { ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype >(i); ItemEntry const *dbcitem = sItemStore.LookupEntry(i); - if(!proto) + if (!proto) { /* to many errors, and possible not all items really used in game if (dbcitem) @@ -1923,9 +1923,9 @@ void ObjectMgr::LoadItemPrototypes() continue; } - if(dbcitem) + if (dbcitem) { - if(proto->Class != dbcitem->Class) + if (proto->Class != dbcitem->Class) { sLog.outErrorDb("Item (Entry: %u) not correct class %u, must be %u (still using DB value).",i,proto->Class,dbcitem->Class); // It safe let use Class from DB @@ -1939,71 +1939,69 @@ void ObjectMgr::LoadItemPrototypes() } */ - if(proto->Unk0 != dbcitem->Unk0) + if (proto->Unk0 != dbcitem->Unk0) { sLog.outErrorDb("Item (Entry: %u) not correct %i Unk0, must be %i (still using DB value).",i,proto->Unk0,dbcitem->Unk0); // It safe let use Unk0 from DB } - if(proto->Material != dbcitem->Material) + if (proto->Material != dbcitem->Material) { sLog.outErrorDb("Item (Entry: %u) not correct %i material, must be %i (still using DB value).",i,proto->Material,dbcitem->Material); // It safe let use Material from DB } - if(proto->InventoryType != dbcitem->InventoryType) + if (proto->InventoryType != dbcitem->InventoryType) { sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType); // It safe let use InventoryType from DB } - if(proto->DisplayInfoID != dbcitem->DisplayId) + if (proto->DisplayInfoID != dbcitem->DisplayId) { sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId); const_cast<ItemPrototype*>(proto)->DisplayInfoID = dbcitem->DisplayId; } - if(proto->Sheath != dbcitem->Sheath) + if (proto->Sheath != dbcitem->Sheath) { sLog.outErrorDb("Item (Entry: %u) not correct %u sheath, must be %u (using it).",i,proto->Sheath,dbcitem->Sheath); const_cast<ItemPrototype*>(proto)->Sheath = dbcitem->Sheath; } } else - { sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existed items).",i); - } - if(proto->Class >= MAX_ITEM_CLASS) + if (proto->Class >= MAX_ITEM_CLASS) { sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class); const_cast<ItemPrototype*>(proto)->Class = ITEM_CLASS_MISC; } - if(proto->SubClass >= MaxItemSubclassValues[proto->Class]) + if (proto->SubClass >= MaxItemSubclassValues[proto->Class]) { sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class); const_cast<ItemPrototype*>(proto)->SubClass = 0;// exist for all item classes } - if(proto->Quality >= MAX_ITEM_QUALITY) + if (proto->Quality >= MAX_ITEM_QUALITY) { sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality); const_cast<ItemPrototype*>(proto)->Quality = ITEM_QUALITY_NORMAL; } - if(proto->BuyCount <= 0) + if (proto->BuyCount <= 0) { sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount); const_cast<ItemPrototype*>(proto)->BuyCount = 1; } - if(proto->InventoryType >= MAX_INVTYPE) + if (proto->InventoryType >= MAX_INVTYPE) { sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType); const_cast<ItemPrototype*>(proto)->InventoryType = INVTYPE_NON_EQUIP; } - if(proto->RequiredSkill >= MAX_SKILL_TYPE) + if (proto->RequiredSkill >= MAX_SKILL_TYPE) { sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill); const_cast<ItemPrototype*>(proto)->RequiredSkill = 0; @@ -2011,20 +2009,18 @@ void ObjectMgr::LoadItemPrototypes() { // can be used in equip slot, as page read use in inventory, or spell casting at use - bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText; - if(!req) - { - for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) + bool req = proto->InventoryType != INVTYPE_NON_EQUIP || proto->PageText; + if (!req) + for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if(proto->Spells[j].SpellId) + if (proto->Spells[j].SpellId) { req = true; break; } } - } - - if(req) + + if (req) { if(!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE)) sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped or use.",i,proto->AllowableClass); @@ -2034,71 +2030,71 @@ void ObjectMgr::LoadItemPrototypes() } } - if(proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) + if (proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) { sLog.outErrorDb("Item (Entry: %u) have wrong (non-existed) spell in RequiredSpell (%u)",i,proto->RequiredSpell); const_cast<ItemPrototype*>(proto)->RequiredSpell = 0; } - if(proto->RequiredReputationRank >= MAX_REPUTATION_RANK) + if (proto->RequiredReputationRank >= MAX_REPUTATION_RANK) sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",i,proto->RequiredReputationRank); - if(proto->RequiredReputationFaction) + if (proto->RequiredReputationFaction) { - if(!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) + if (!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction); const_cast<ItemPrototype*>(proto)->RequiredReputationFaction = 0; } - if(proto->RequiredReputationRank == MIN_REPUTATION_RANK) + if (proto->RequiredReputationRank == MIN_REPUTATION_RANK) sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.",i); } - if(proto->MaxCount < -1) + if (proto->MaxCount < -1) { sLog.outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.",i,proto->MaxCount); const_cast<ItemPrototype*>(proto)->MaxCount = -1; } - if(proto->Stackable == 0) + if (proto->Stackable == 0) { sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.",i,proto->Stackable); const_cast<ItemPrototype*>(proto)->Stackable = 1; } - else if(proto->Stackable < -1) + else if (proto->Stackable < -1) { sLog.outErrorDb("Item (Entry: %u) has too large negative in stackable (%i), replace by value (-1) no stacking limits.",i,proto->Stackable); const_cast<ItemPrototype*>(proto)->Stackable = -1; } - else if(proto->Stackable > 1000) + else if (proto->Stackable > 1000) { sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (1000).",i,proto->Stackable); const_cast<ItemPrototype*>(proto)->Stackable = 1000; } - if(proto->ContainerSlots > MAX_BAG_SIZE) + if (proto->ContainerSlots > MAX_BAG_SIZE) { sLog.outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).",i,proto->ContainerSlots,MAX_BAG_SIZE); const_cast<ItemPrototype*>(proto)->ContainerSlots = MAX_BAG_SIZE; } - if(proto->StatsCount > MAX_ITEM_PROTO_STATS) + if (proto->StatsCount > MAX_ITEM_PROTO_STATS) { sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS); const_cast<ItemPrototype*>(proto)->StatsCount = MAX_ITEM_PROTO_STATS; } - for (int j = 0; j < MAX_ITEM_PROTO_STATS; ++j) + for (uint8 j = 0; j < MAX_ITEM_PROTO_STATS; ++j) { // for ItemStatValue != 0 - if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) + if (proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) { sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); const_cast<ItemPrototype*>(proto)->ItemStat[j].ItemStatType = 0; } - switch(proto->ItemStat[j].ItemStatType) + switch (proto->ItemStat[j].ItemStatType) { case ITEM_MOD_SPELL_HEALING_DONE: case ITEM_MOD_SPELL_DAMAGE_DONE: @@ -2109,7 +2105,7 @@ void ObjectMgr::LoadItemPrototypes() } } - for (int j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j) + for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j) { if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL) { @@ -2119,10 +2115,10 @@ void ObjectMgr::LoadItemPrototypes() } // special format - if((proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET)) + if ((proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET)) { // spell_1 - if(proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + if (proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",i,0+1,proto->Spells[0].SpellTrigger); const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; @@ -2132,14 +2128,14 @@ void ObjectMgr::LoadItemPrototypes() } // spell_2 have learning spell - if(proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) + if (proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) { sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",i,1+1,proto->Spells[1].SpellTrigger); const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; const_cast<ItemPrototype*>(proto)->Spells[1].SpellId = 0; const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - else if(!proto->Spells[1].SpellId) + else if (!proto->Spells[1].SpellId) { sLog.outErrorDb("Item (Entry: %u) not has expected spell in spellid_%d in special learning format.",i,1+1); const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; @@ -2148,7 +2144,7 @@ void ObjectMgr::LoadItemPrototypes() else { SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId); - if(!spellInfo) + if (!spellInfo) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; @@ -2156,7 +2152,7 @@ void ObjectMgr::LoadItemPrototypes() const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } // allowed only in special format - else if((proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN_PET)) + else if ((proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId == SPELL_ID_GENERIC_LEARN_PET)) { sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0; @@ -2166,15 +2162,15 @@ void ObjectMgr::LoadItemPrototypes() } // spell_3*,spell_4*,spell_5* is empty - for (int j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j) + for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if(proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + if (proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; const_cast<ItemPrototype*>(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - else if(proto->Spells[j].SpellId != 0) + else if (proto->Spells[j].SpellId != 0) { sLog.outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%u) for learning special format",i,j+1,proto->Spells[j].SpellId); const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; @@ -2184,9 +2180,9 @@ void ObjectMgr::LoadItemPrototypes() // normal spell list else { - for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) + for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if(proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID) + if (proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID) { sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; @@ -2196,13 +2192,13 @@ void ObjectMgr::LoadItemPrototypes() if(proto->Spells[j].SpellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId); - if(!spellInfo) + if (!spellInfo) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; } // allowed only in special format - else if((proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN_PET)) + else if ((proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN_PET)) { sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0; @@ -2211,66 +2207,66 @@ void ObjectMgr::LoadItemPrototypes() } } - if(proto->Bonding >= MAX_BIND_TYPE) + if (proto->Bonding >= MAX_BIND_TYPE) sLog.outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)",i,proto->Bonding); - if(proto->PageText && !sPageTextStore.LookupEntry<PageText>(proto->PageText)) + if (proto->PageText && !sPageTextStore.LookupEntry<PageText>(proto->PageText)) sLog.outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i,proto->PageText); - if(proto->LockID && !sLockStore.LookupEntry(proto->LockID)) + if (proto->LockID && !sLockStore.LookupEntry(proto->LockID)) sLog.outErrorDb("Item (Entry: %u) has wrong LockID (%u)",i,proto->LockID); - if(proto->Sheath >= MAX_SHEATHETYPE) + if (proto->Sheath >= MAX_SHEATHETYPE) { sLog.outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",i,proto->Sheath); const_cast<ItemPrototype*>(proto)->Sheath = SHEATHETYPE_NONE; } - if(proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty))) + if (proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty))) { sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",i,proto->RandomProperty); const_cast<ItemPrototype*>(proto)->RandomProperty = 0; } - if(proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix))) + if (proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix))) { sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",i,proto->RandomSuffix); const_cast<ItemPrototype*>(proto)->RandomSuffix = 0; } - if(proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet)) + if (proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet)) { sLog.outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)",i,proto->ItemSet); const_cast<ItemPrototype*>(proto)->ItemSet = 0; } - if(proto->Area && !GetAreaEntryByAreaID(proto->Area)) + if (proto->Area && !GetAreaEntryByAreaID(proto->Area)) sLog.outErrorDb("Item (Entry: %u) has wrong Area (%u)",i,proto->Area); - if(proto->Map && !sMapStore.LookupEntry(proto->Map)) + if (proto->Map && !sMapStore.LookupEntry(proto->Map)) sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)",i,proto->Map); - if(proto->BagFamily) + if (proto->BagFamily) { // check bits for (uint32 j = 0; j < sizeof(proto->BagFamily)*8; ++j) { uint32 mask = 1 << j; - if((proto->BagFamily & mask)==0) + if ((proto->BagFamily & mask)==0) continue; ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1); - if(!bf) + if (!bf) { sLog.outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit",i); const_cast<ItemPrototype*>(proto)->BagFamily &= ~mask; continue; } - if(BAG_FAMILY_MASK_CURRENCY_TOKENS & mask) + if (BAG_FAMILY_MASK_CURRENCY_TOKENS & mask) { CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(proto->ItemId); - if(!ctEntry) + if (!ctEntry) { sLog.outErrorDb("Item (Entry: %u) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit",i); const_cast<ItemPrototype*>(proto)->BagFamily &= ~mask; @@ -2279,34 +2275,34 @@ void ObjectMgr::LoadItemPrototypes() } } - if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory)) + if (proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory)) sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory); - for (int j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j) + for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j) { - if(proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color) + if (proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color) { sLog.outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)",i,j+1,proto->Socket[j].Color); const_cast<ItemPrototype*>(proto)->Socket[j].Color = 0; } } - if(proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties)) + if (proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties)) sLog.outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",i,proto->GemProperties); - if(proto->FoodType >= MAX_PET_DIET) + if (proto->FoodType >= MAX_PET_DIET) { sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType); const_cast<ItemPrototype*>(proto)->FoodType = 0; } - if(proto->ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(proto->ItemLimitCategory)) + if (proto->ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(proto->ItemLimitCategory)) { sLog.outErrorDb("Item (Entry: %u) has wrong LimitCategory value (%u)",i,proto->ItemLimitCategory); const_cast<ItemPrototype*>(proto)->ItemLimitCategory = 0; } - if(proto->HolidayId && !sHolidaysStore.LookupEntry(proto->HolidayId)) + if (proto->HolidayId && !sHolidaysStore.LookupEntry(proto->HolidayId)) { sLog.outErrorDb("Item (Entry: %u) has wrong HolidayId value (%u)", i, proto->HolidayId); const_cast<ItemPrototype*>(proto)->HolidayId = 0; @@ -2508,7 +2504,7 @@ void ObjectMgr::LoadPetLevelInfo() } // fill level gaps - for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) { if(pInfo[level].health == 0) { @@ -2519,7 +2515,7 @@ void ObjectMgr::LoadPetLevelInfo() } } -PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) const +PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint8 level) const { if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); @@ -2842,7 +2838,7 @@ void ObjectMgr::LoadPlayerInfo() continue; } - uint32 current_level = fields[1].GetUInt32(); + uint8 current_level = fields[1].GetUInt8(); if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) { if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum @@ -2893,7 +2889,7 @@ void ObjectMgr::LoadPlayerInfo() } // fill level gaps - for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) { if(pClassInfo->levelInfo[level].basehealth == 0) { @@ -3011,7 +3007,7 @@ void ObjectMgr::LoadPlayerInfo() } // fill level gaps - for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) { if(pInfo->levelInfo[level].stats[0] == 0) { @@ -3025,7 +3021,7 @@ void ObjectMgr::LoadPlayerInfo() // Loading xp per level data { mPlayerXPperLevel.resize(sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)); - for (uint32 level = 0; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + for (uint8 level = 0; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) mPlayerXPperLevel[level] = 0; // 0 1 @@ -3077,9 +3073,9 @@ void ObjectMgr::LoadPlayerInfo() } // fill level gaps - for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) + for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level) { - if( mPlayerXPperLevel[level] == 0) + if (mPlayerXPperLevel[level] == 0) { sLog.outErrorDb("Level %i does not have XP for level data. Using data of level [%i] + 100.",level+1, level); mPlayerXPperLevel[level] = mPlayerXPperLevel[level-1]+100; @@ -3087,29 +3083,29 @@ void ObjectMgr::LoadPlayerInfo() } } -void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const +void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassLevelInfo* info) const { - if(level < 1 || class_ >= MAX_CLASSES) + if (level < 1 || class_ >= MAX_CLASSES) return; PlayerClassInfo const* pInfo = &playerClassInfo[class_]; - if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + if (level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); *info = pInfo->levelInfo[level-1]; } -void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const +void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const { - if(level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) + if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) return; PlayerInfo const* pInfo = &playerInfo[race][class_]; - if(pInfo->displayId_m==0 || pInfo->displayId_f==0) + if (pInfo->displayId_m==0 || pInfo->displayId_f==0) return; - if(level <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) + if (level <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) *info = pInfo->levelInfo[level-1]; else BuildPlayerLevelInfo(race,class_,level,info); @@ -3198,10 +3194,10 @@ void ObjectMgr::LoadGuilds() QueryResult *result = CharacterDatabase.Query( "SELECT guildid FROM guild" ); - if( !result ) + if (!result) { - barGoLink bar( 1 ); + barGoLink bar(1); bar.step(); @@ -3210,7 +3206,7 @@ void ObjectMgr::LoadGuilds() return; } - barGoLink bar( result->GetRowCount() ); + barGoLink bar(result->GetRowCount()); do { @@ -3220,7 +3216,7 @@ void ObjectMgr::LoadGuilds() ++count; newguild = new Guild; - if(!newguild->LoadGuildFromDB(fields[0].GetUInt32())) + if (!newguild->LoadGuildFromDB(fields[0].GetUInt32())) { newguild->Disband(); delete newguild; @@ -3228,7 +3224,7 @@ void ObjectMgr::LoadGuilds() } AddGuild(newguild); - }while( result->NextRow() ); + }while (result->NextRow()); delete result; @@ -6380,25 +6376,25 @@ void ObjectMgr::LoadExplorationBaseXP() uint32 count = 0; QueryResult *result = WorldDatabase.Query("SELECT level,basexp FROM exploration_basexp"); - if( !result ) + if (!result) { - barGoLink bar( 1 ); + barGoLink bar(1); bar.step(); sLog.outString(); - sLog.outString( ">> Loaded %u BaseXP definitions", count ); + sLog.outString(">> Loaded %u BaseXP definitions", count); return; } - barGoLink bar( result->GetRowCount() ); + barGoLink bar(result->GetRowCount()); do { bar.step(); Field *fields = result->Fetch(); - uint32 level = fields[0].GetUInt32(); + uint8 level = fields[0].GetUInt8(); uint32 basexp = fields[1].GetUInt32(); mBaseXPTable[level] = basexp; ++count; @@ -6411,12 +6407,12 @@ void ObjectMgr::LoadExplorationBaseXP() sLog.outString( ">> Loaded %u BaseXP definitions", count ); } -uint32 ObjectMgr::GetBaseXP(uint32 level) +uint32 ObjectMgr::GetBaseXP(uint8 level) { return mBaseXPTable[level] ? mBaseXPTable[level] : 0; } -uint32 ObjectMgr::GetXPForLevel(uint32 level) +uint32 ObjectMgr::GetXPForLevel(uint8 level) { if (level < mPlayerXPperLevel.size()) return mPlayerXPperLevel[level]; @@ -6428,9 +6424,9 @@ void ObjectMgr::LoadPetNames() uint32 count = 0; QueryResult *result = WorldDatabase.Query("SELECT word,entry,half FROM pet_name_generation"); - if( !result ) + if (!result) { - barGoLink bar( 1 ); + barGoLink bar(1); bar.step(); @@ -6439,7 +6435,7 @@ void ObjectMgr::LoadPetNames() return; } - barGoLink bar( result->GetRowCount() ); + barGoLink bar(result->GetRowCount()); do { @@ -6449,7 +6445,7 @@ void ObjectMgr::LoadPetNames() std::string word = fields[0].GetString(); uint32 entry = fields[1].GetUInt32(); bool half = fields[2].GetBool(); - if(half) + if (half) PetHalfName1[entry].push_back(word); else PetHalfName0[entry].push_back(word); @@ -6465,14 +6461,14 @@ void ObjectMgr::LoadPetNames() void ObjectMgr::LoadPetNumber() { QueryResult* result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet"); - if(result) + if (result) { Field *fields = result->Fetch(); m_hiPetNumber = fields[0].GetUInt32()+1; delete result; } - barGoLink bar( 1 ); + barGoLink bar(1); bar.step(); sLog.outString(); @@ -6484,11 +6480,11 @@ std::string ObjectMgr::GeneratePetName(uint32 entry) std::vector<std::string> & list0 = PetHalfName0[entry]; std::vector<std::string> & list1 = PetHalfName1[entry]; - if(list0.empty() || list1.empty()) + if (list0.empty() || list1.empty()) { CreatureInfo const *cinfo = GetCreatureTemplate(entry); char* petname = GetPetName(cinfo->family, sWorld.GetDefaultDbcLocale()); - if(!petname) + if (!petname) petname = cinfo->Name; return std::string(petname); } @@ -6504,21 +6500,21 @@ uint32 ObjectMgr::GeneratePetNumber() void ObjectMgr::LoadCorpses() { uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 10 + // 0 1 2 3 4 5 6 7 8 10 QueryResult *result = CharacterDatabase.Query("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0"); - if( !result ) + if(!result) { - barGoLink bar( 1 ); + barGoLink bar(1); bar.step(); sLog.outString(); - sLog.outString( ">> Loaded %u corpses", count ); + sLog.outString(">> Loaded %u corpses", count); return; } - barGoLink bar( result->GetRowCount() ); + barGoLink bar(result->GetRowCount()); do { @@ -6529,7 +6525,7 @@ void ObjectMgr::LoadCorpses() uint32 guid = fields[result->GetFieldCount()-1].GetUInt32(); Corpse *corpse = new Corpse; - if(!corpse->LoadFromDB(guid,fields)) + if (!corpse->LoadFromDB(guid,fields)) { delete corpse; continue; @@ -6543,7 +6539,7 @@ void ObjectMgr::LoadCorpses() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u corpses", count ); + sLog.outString(">> Loaded %u corpses", count); } void ObjectMgr::LoadReputationOnKill() @@ -6587,26 +6583,26 @@ void ObjectMgr::LoadReputationOnKill() repOnKill.repvalue2 = fields[8].GetInt32(); repOnKill.team_dependent = fields[9].GetUInt8(); - if(!GetCreatureTemplate(creature_id)) + if (!GetCreatureTemplate(creature_id)) { sLog.outErrorDb("Table `creature_onkill_reputation` have data for not existed creature entry (%u), skipped",creature_id); continue; } - if(repOnKill.repfaction1) + if (repOnKill.repfaction1) { FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1); - if(!factionEntry1) + if (!factionEntry1) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction1); continue; } } - if(repOnKill.repfaction2) + if (repOnKill.repfaction2) { FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2); - if(!factionEntry2) + if (!factionEntry2) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction2); continue; @@ -6628,7 +6624,7 @@ void ObjectMgr::LoadPointsOfInterest() { uint32 count = 0; - // 0 1 2 3 4 5 + // 0 1 2 3 4 5 6 QueryResult *result = WorldDatabase.Query("SELECT entry, x, y, icon, flags, data, icon_name FROM points_of_interest"); if(!result) @@ -6659,7 +6655,7 @@ void ObjectMgr::LoadPointsOfInterest() POI.data = fields[5].GetUInt32(); POI.icon_name = fields[6].GetCppString(); - if(!MaNGOS::IsValidMapCoord(POI.x,POI.y)) + if (!MaNGOS::IsValidMapCoord(POI.x,POI.y)) { sLog.outErrorDb("Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.",point_id,POI.x,POI.y); continue; diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index ca47ff52ac1..6f6ca30cdeb 100644 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -415,14 +415,14 @@ class ObjectMgr return sInstanceTemplate.LookupEntry<InstanceTemplate>(map); } - PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const; + PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint8 level) const; PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const { if(class_ >= MAX_CLASSES) return NULL; return &playerClassInfo[class_]; } - void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const; + void GetPlayerClassLevelInfo(uint32 class_,uint8 level, PlayerClassLevelInfo* info) const; PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const { @@ -432,7 +432,7 @@ class ObjectMgr if(info->displayId_m==0 || info->displayId_f==0) return NULL; return info; } - void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const; + void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const; uint64 GetPlayerGUIDByName(std::string name) const; bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const; @@ -606,8 +606,8 @@ class ObjectMgr void LoadGMTickets(); std::string GeneratePetName(uint32 entry); - uint32 GetBaseXP(uint32 level); - uint32 GetXPForLevel(uint32 level); + uint32 GetBaseXP(uint8 level); + uint32 GetXPForLevel(uint8 level); int32 GetFishingBaseSkillLevel(uint32 entry) const { diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index b5995120a9e..775c0ee8df5 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -702,7 +702,7 @@ void Pet::GivePetXP(uint32 xp) if(!isAlive()) return; - uint32 level = getLevel(); + uint8 level = getLevel(); // XP to money conversion processed in Player::RewardQuest if(level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)) @@ -732,9 +732,9 @@ void Pet::GivePetXP(uint32 xp) SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP); } -void Pet::GivePetLevel(uint32 level) +void Pet::GivePetLevel(uint8 level) { - if(!level) + if (!level) return; InitStatsForLevel(level); @@ -798,7 +798,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) } // TODO: Move stat mods code to pet passive auras -bool Guardian::InitStatsForLevel(uint32 petlevel) +bool Guardian::InitStatsForLevel(uint8 petlevel) { CreatureInfo const *cinfo = GetCreatureInfo(); assert(cinfo); @@ -849,7 +849,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) //resistance int32 createResistance[MAX_SPELL_SCHOOL] = {0,0,0,0,0,0,0}; - if(cinfo && petType != HUNTER_PET) + if (cinfo && petType != HUNTER_PET) { createResistance[SPELL_SCHOOL_HOLY] = cinfo->resistance1; createResistance[SPELL_SCHOOL_FIRE] = cinfo->resistance2; @@ -863,13 +863,13 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) //health, mana, armor and resistance PetLevelInfo const* pInfo = objmgr.GetPetLevelInfo(creature_ID, petlevel); - if(pInfo) // exist in DB + if (pInfo) // exist in DB { SetCreateHealth(pInfo->health); - if(petType != HUNTER_PET) //hunter pet use focus + if (petType != HUNTER_PET) //hunter pet use focus SetCreateMana(pInfo->mana); - if(pInfo->armor > 0) + if (pInfo->armor > 0) SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor)); for (uint8 stat = 0; stat < MAX_STATS; ++stat) @@ -889,7 +889,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) } m_bonusdamage = 0; - switch(petType) + switch (petType) { case SUMMON_PET: { @@ -919,7 +919,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) } default: { - switch(GetEntry()) + switch (GetEntry()) { case 510: // mage Water Elemental { @@ -932,7 +932,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) } case 1964: //force of nature { - if(!pInfo) + if (!pInfo) SetCreateHealth(30 + 30*petlevel); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2))); @@ -940,7 +940,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) } case 15352: //earth elemental 36213 { - if(!pInfo) + if (!pInfo) SetCreateHealth(100 + 120*petlevel); SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4))); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4))); @@ -948,7 +948,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) } case 15438: //fire elemental { - if(!pInfo) + if (!pInfo) { SetCreateHealth(40*petlevel); SetCreateMana(28 + 10*petlevel); @@ -959,8 +959,8 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) } case 31216: // Mirror Image { - SetBonusDamage( int32(m_owner->SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FROST) * 0.33f)); - if(!pInfo) + SetBonusDamage(int32(m_owner->SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FROST) * 0.33f)); + if (!pInfo) { SetCreateMana(28 + 30*petlevel); SetCreateHealth(28 + 10*petlevel); @@ -970,7 +970,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) case 27829: // Ebon Gargoyle { SetBonusDamage( int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.4f)); - if(!pInfo) + if (!pInfo) { SetCreateMana(28 + 10*petlevel); SetCreateHealth(28 + 30*petlevel); @@ -979,7 +979,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel) } default: { - if(!pInfo) + if (!pInfo) { SetCreateMana(28 + 10*petlevel); SetCreateHealth(28 + 30*petlevel); @@ -1010,11 +1010,11 @@ bool Pet::HaveInDiet(ItemPrototype const* item) const return false; CreatureInfo const* cInfo = GetCreatureInfo(); - if(!cInfo) + if (!cInfo) return false; CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family); - if(!cFamily) + if (!cFamily) return false; uint32 diet = cFamily->petFoodMask; @@ -1077,14 +1077,12 @@ void Pet::_LoadSpellCooldowns() sLog.outDebug("Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time-curTime)); } - while( result->NextRow() ); + while (result->NextRow()); delete result; if(!m_CreatureSpellCooldowns.empty() && GetOwner()) - { ((Player*)GetOwner())->GetSession()->SendPacket(&data); - } } } @@ -1097,7 +1095,7 @@ void Pet::_SaveSpellCooldowns() // remove oudated and save active for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end(); ) { - if(itr->second <= curTime) + if (itr->second <= curTime) m_CreatureSpellCooldowns.erase(itr++); else { @@ -1111,7 +1109,7 @@ void Pet::_LoadSpells() { QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active FROM pet_spell WHERE guid = '%u'",m_charmInfo->GetPetNumber()); - if(result) + if (result) { do { @@ -1119,7 +1117,7 @@ void Pet::_LoadSpells() addSpell(fields[0].GetUInt32(), ActiveStates(fields[1].GetUInt8()), PETSPELL_UNCHANGED); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -1135,7 +1133,7 @@ void Pet::_SaveSpells() if (itr->second.type == PETSPELL_FAMILY) continue; - switch(itr->second.state) + switch (itr->second.state) { case PETSPELL_REMOVED: CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u' and spell = '%u'", m_charmInfo->GetPetNumber(), itr->first); @@ -1160,9 +1158,9 @@ void Pet::_LoadAuras(uint32 timediff) { sLog.outDebug("Loading auras for pet %u",GetGUIDLow()); - QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2 ,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); + QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_mask,stackcount,amount0,amount1,amount2,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber()); - if(result) + if (result) { do { @@ -1170,14 +1168,14 @@ void Pet::_LoadAuras(uint32 timediff) Field *fields = result->Fetch(); uint64 caster_guid = fields[0].GetUInt64(); uint32 spellid = fields[1].GetUInt32(); - uint32 effmask = fields[2].GetUInt32(); - uint32 stackcount = fields[3].GetUInt32(); - damage[0] = int32(fields[4].GetUInt32()); - damage[1] = int32(fields[5].GetUInt32()); - damage[2] = int32(fields[6].GetUInt32()); - int32 maxduration = (int32)fields[7].GetUInt32(); - int32 remaintime = (int32)fields[8].GetUInt32(); - int32 remaincharges = (int32)fields[9].GetUInt32(); + uint8 effmask = fields[2].GetUInt8(); + uint8 stackcount = fields[3].GetUInt8(); + damage[0] = fields[4].GetInt32(); + damage[1] = fields[5].GetInt32(); + damage[2] = fields[6].GetInt32(); + int32 maxduration = fields[7].GetInt32(); + int32 remaintime = fields[8].GetInt32(); + uint8 remaincharges = fields[9].GetUInt8(); SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); if(!spellproto) @@ -1214,7 +1212,7 @@ void Pet::_LoadAuras(uint32 timediff) AddAura(aura); sLog.outDetail("Added aura spellid %u, effectmask %u", spellproto->Id, effmask); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -1227,7 +1225,7 @@ void Pet::_SaveAuras() AuraMap const& auras = GetAuras(); for (AuraMap::const_iterator itr = auras.begin(); itr !=auras.end() ; ++itr) { - if(!itr->second->CanBeSaved()) + if (!itr->second->CanBeSaved()) continue; int32 amounts[MAX_SPELL_EFFECTS]; @@ -1239,11 +1237,11 @@ void Pet::_SaveAuras() amounts[i] = 0; } - CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%u')", - m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(), itr->second->GetId(), (uint32)itr->second->GetEffectMask(), - (int32)itr->second->GetStackAmount(), amounts[0], amounts[1], amounts[2] - ,itr->second->GetAuraMaxDuration(), itr->second->GetAuraDuration(), (uint32)itr->second->GetAuraCharges()); + CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0,amount1,amount2,maxduration,remaintime,remaincharges) " + "VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%u')", + m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(), itr->second->GetId(), itr->second->GetEffectMask(), + itr->second->GetStackAmount(), amounts[0], amounts[1], amounts[2], + itr->second->GetAuraMaxDuration(), itr->second->GetAuraDuration(),itr->second->GetAuraCharges()); } } @@ -1253,7 +1251,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel if (!spellInfo) { // do pet spell book cleanup - if(state == PETSPELL_UNCHANGED) // spell load case + if (state == PETSPELL_UNCHANGED) // spell load case { sLog.outError("Pet::addSpell: Non-existed in SpellStore spell #%u request, deleting for all pets in `pet_spell`.",spell_id); CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'",spell_id); @@ -1277,9 +1275,9 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel // can be in case spell loading but learned at some previous spell loading itr->second.state = PETSPELL_UNCHANGED; - if(active == ACT_ENABLED) + if (active == ACT_ENABLED) ToggleAutocast(spell_id, true); - else if(active == ACT_DISABLED) + else if (active == ACT_DISABLED) ToggleAutocast(spell_id, false); return false; @@ -1294,9 +1292,9 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel newspell.state = state; newspell.type = type; - if(active == ACT_DECIDE) //active was not used before, so we save it's autocast/passive state here + if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here { - if(IsAutocastableSpell(spell_id)) + if (IsAutocastableSpell(spell_id)) newspell.active = ACT_DISABLED; else newspell.active = ACT_PASSIVE; @@ -1305,19 +1303,19 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel newspell.active = active; // talent: unlearn all other talent ranks (high and low) - if(TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) + if (TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) { - if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) + if (TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id )) { - for (uint8 i=0; i < MAX_TALENT_RANK; ++i) + for (uint8 i = 0; i < MAX_TALENT_RANK; ++i) { // skip learning spell and no rank spell case uint32 rankSpellId = talentInfo->RankID[i]; - if(!rankSpellId || rankSpellId==spell_id) + if (!rankSpellId || rankSpellId==spell_id) continue; // skip unknown ranks - if(!HasSpell(rankSpellId)) + if (!HasSpell(rankSpellId)) continue; removeSpell(rankSpellId,false,false); } @@ -1327,16 +1325,16 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel { for (PetSpellMap::const_iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2) { - if(itr2->second.state == PETSPELL_REMOVED) continue; + if (itr2->second.state == PETSPELL_REMOVED) continue; - if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) ) + if (spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) ) { // replace by new high rank - if(spellmgr.IsHighRankOfSpell(spell_id,itr2->first)) + if (spellmgr.IsHighRankOfSpell(spell_id,itr2->first)) { newspell.active = itr2->second.active; - if(newspell.active == ACT_ENABLED) + if (newspell.active == ACT_ENABLED) ToggleAutocast(itr2->first, false); oldspell_id = itr2->first; @@ -1344,7 +1342,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel break; } // ignore new lesser rank - else if(spellmgr.IsHighRankOfSpell(itr2->first,spell_id)) + else if (spellmgr.IsHighRankOfSpell(itr2->first,spell_id)) return false; } } @@ -1364,7 +1362,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel if (talentCost) { int32 free_points = GetMaxTalentPointsForLevel(getLevel()); - m_usedTalentCount+=talentCost; + m_usedTalentCount += talentCost; // update free talent points free_points-=m_usedTalentCount; SetFreeTalentPoints(free_points > 0 ? free_points : 0); @@ -1378,7 +1376,7 @@ bool Pet::learnSpell(uint32 spell_id) if (!addSpell(spell_id)) return false; - if(!m_loading) + if (!m_loading) { WorldPacket data(SMSG_PET_LEARNED_SPELL, 4); data << uint32(spell_id); @@ -1390,15 +1388,15 @@ bool Pet::learnSpell(uint32 spell_id) void Pet::InitLevelupSpellsForLevel() { - uint32 level = getLevel(); + uint8 level = getLevel(); - if(PetLevelupSpellSet const *levelupSpells = GetCreatureInfo()->family ? spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL) + if (PetLevelupSpellSet const *levelupSpells = GetCreatureInfo()->family ? spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL) { // PetLevelupSpellSet ordered by levels, process in reversed order for (PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr) { // will called first if level down - if(itr->first > level) + if (itr->first > level) unlearnSpell(itr->second,true); // will learn prev rank if any // will called if level up else @@ -1414,11 +1412,11 @@ void Pet::InitLevelupSpellsForLevel() for (uint8 i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i) { SpellEntry const* spellEntry = sSpellStore.LookupEntry(defSpells->spellid[i]); - if(!spellEntry) + if (!spellEntry) continue; // will called first if level down - if(spellEntry->spellLevel > level) + if (spellEntry->spellLevel > level) unlearnSpell(spellEntry->Id,true); // will called if level up else @@ -1429,9 +1427,9 @@ void Pet::InitLevelupSpellsForLevel() bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab) { - if(removeSpell(spell_id,learn_prev,clear_ab)) + if (removeSpell(spell_id,learn_prev,clear_ab)) { - if(!m_loading) + if (!m_loading) { WorldPacket data(SMSG_PET_REMOVED_SPELL, 4); data << uint32(spell_id); @@ -1448,10 +1446,10 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) if (itr == m_spells.end()) return false; - if(itr->second.state == PETSPELL_REMOVED) + if (itr->second.state == PETSPELL_REMOVED) return false; - if(itr->second.state == PETSPELL_NEW) + if (itr->second.state == PETSPELL_NEW) m_spells.erase(itr); else itr->second.state = PETSPELL_REMOVED; @@ -1462,7 +1460,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) if (talentCost > 0) { if (m_usedTalentCount > talentCost) - m_usedTalentCount-=talentCost; + m_usedTalentCount -= talentCost; else m_usedTalentCount = 0; // update free talent points @@ -1481,7 +1479,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) // if remove last rank or non-ranked then update action bar at server and client if need if (clear_ab && !learn_prev && m_charmInfo->RemoveSpellFromActionBar(spell_id)) { - if(!m_loading) + if (!m_loading) { // need update action bar for last removed rank if (Unit* owner = GetOwner()) @@ -1496,12 +1494,12 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab) void Pet::CleanupActionBar() { for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i) - if(UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i)) - if(ab->GetAction() && ab->IsActionBarForSpell()) + if (UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i)) + if (ab->GetAction() && ab->IsActionBarForSpell()) { - if(!HasSpell(ab->GetAction())) + if (!HasSpell(ab->GetAction())) m_charmInfo->SetActionBar(i, 0, ACT_PASSIVE); - else if(ab->GetType() == ACT_ENABLED) + else if (ab->GetType() == ACT_ENABLED) ToggleAutocast(ab->GetAction(), true); } } @@ -1524,20 +1522,20 @@ bool Pet::resetTalents(bool no_cost) return false; // not need after this call - if(((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) + if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true); CreatureInfo const * ci = GetCreatureInfo(); - if(!ci) + if (!ci) return false; // Check pet talent type CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family); - if(!pet_family || pet_family->petTalentType < 0) + if (!pet_family || pet_family->petTalentType < 0) return false; Player *player = (Player *)owner; - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level); if (m_usedTalentCount == 0) @@ -1548,13 +1546,13 @@ bool Pet::resetTalents(bool no_cost) uint32 cost = 0; - if(!no_cost) + if (!no_cost) { cost = resetTalentsCost(); if (player->GetMoney() < cost) { - player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); + player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0); return false; } } @@ -1563,22 +1561,23 @@ bool Pet::resetTalents(bool no_cost) { TalentEntry const *talentInfo = sTalentStore.LookupEntry(i); - if (!talentInfo) continue; + if (!talentInfo) + continue; TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab ); - if(!talentTabInfo) + if (!talentTabInfo) continue; // unlearn only talents for pets family talent type - if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) + if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask)) continue; - for (int j = 0; j < MAX_TALENT_RANK; j++) + for (uint8 j = 0; j < MAX_TALENT_RANK; ++j) { for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ) { - if(itr->second.state == PETSPELL_REMOVED) + if (itr->second.state == PETSPELL_REMOVED) { ++itr; continue; @@ -1601,14 +1600,14 @@ bool Pet::resetTalents(bool no_cost) SetFreeTalentPoints(talentPointsForLevel); - if(!no_cost) + if (!no_cost) { player->ModifyMoney(-(int32)cost); m_resetTalentsCost = cost; m_resetTalentsTime = time(NULL); } - if(!m_loading) + if (!m_loading) player->PetSpellInitialize(); return true; } @@ -1616,11 +1615,11 @@ bool Pet::resetTalents(bool no_cost) void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) { // not need after this call - if(((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) + if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS)) ((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true); // reset for online - if(online_pet) + if (online_pet) online_pet->resetTalents(true); // now need only reset for offline pets (all pets except online case) @@ -1631,7 +1630,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) owner->GetGUIDLow(),except_petnumber); // no offline pets - if(!resultPets) + if (!resultPets) return; QueryResult *result = CharacterDatabase.PQuery( @@ -1639,7 +1638,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) "WHERE character_pet.owner = '%u' AND character_pet.id = pet_spell.guid AND character_pet.id <> %u", owner->GetGUIDLow(),except_petnumber); - if(!result) + if (!result) { delete resultPets; return; @@ -1662,7 +1661,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) need_comma = true; } - while( resultPets->NextRow() ); + while (resultPets->NextRow()); delete resultPets; @@ -1675,21 +1674,21 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) uint32 spell = fields[0].GetUInt32(); - if(!GetTalentSpellCost(spell)) + if (!GetTalentSpellCost(spell)) continue; - if(need_execute) + if (need_execute) ss << ","; ss << spell; need_execute = true; } - while( result->NextRow() ); + while (result->NextRow()); delete result; - if(!need_execute) + if (!need_execute) return; ss << ")"; @@ -1699,21 +1698,19 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/) void Pet::InitTalentForLevel() { - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level); // Reset talents in case low level (on level down) or wrong points for level (hunter can unlearn TP increase talent) if(talentPointsForLevel == 0 || m_usedTalentCount > talentPointsForLevel) - { - // Remove all talent points - resetTalents(true); - } + resetTalents(true); // Remove all talent points + SetFreeTalentPoints(talentPointsForLevel - m_usedTalentCount); Unit *owner = GetOwner(); if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - if(!m_loading) + if (!m_loading) ((Player*)owner)->SendTalentsInfoData(true); } @@ -1722,20 +1719,20 @@ uint32 Pet::resetTalentsCost() const uint32 days = (sWorld.GetGameTime() - m_resetTalentsTime)/DAY; // The first time reset costs 10 silver; after 1 day cost is reset to 10 silver - if(m_resetTalentsCost < 10*SILVER || days > 0) + if (m_resetTalentsCost < 10*SILVER || days > 0) return 10*SILVER; // then 50 silver - else if(m_resetTalentsCost < 50*SILVER) + else if (m_resetTalentsCost < 50*SILVER) return 50*SILVER; // then 1 gold - else if(m_resetTalentsCost < 1*GOLD) + else if (m_resetTalentsCost < 1*GOLD) return 1*GOLD; // then increasing at a rate of 1 gold; cap 10 gold else return (m_resetTalentsCost + 1*GOLD > 10*GOLD ? 10*GOLD : m_resetTalentsCost + 1*GOLD); } -uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) +uint8 Pet::GetMaxTalentPointsForLevel(uint8 level) { uint8 points = (level >= 20) ? ((level - 16) / 4) : 0; // Mod points from owner SPELL_AURA_MOD_PET_TALENT_POINTS @@ -1746,16 +1743,16 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) void Pet::ToggleAutocast(uint32 spellid, bool apply) { - if(!IsAutocastableSpell(spellid)) + if (!IsAutocastableSpell(spellid)) return; PetSpellMap::iterator itr = m_spells.find(spellid); - if(itr == m_spells.end()) + if (itr == m_spells.end()) return; uint32 i; - if(apply) + if (apply) { for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i) ; // just search @@ -1764,10 +1761,10 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) { m_autospells.push_back(spellid); - if(itr->second.active != ACT_ENABLED) + if (itr->second.active != ACT_ENABLED) { itr->second.active = ACT_ENABLED; - if(itr->second.state != PETSPELL_NEW) + if (itr->second.state != PETSPELL_NEW) itr->second.state = PETSPELL_CHANGED; } } @@ -1775,7 +1772,7 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) else { AutoSpellList::iterator itr2 = m_autospells.begin(); - for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, itr2++) + for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, ++itr2) ; // just search if (i < m_autospells.size()) @@ -1793,10 +1790,10 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply) bool Pet::IsPermanentPetFor(Player* owner) { - switch(getPetType()) + switch (getPetType()) { case SUMMON_PET: - switch(owner->getClass()) + switch (owner->getClass()) { case CLASS_WARLOCK: return GetCreatureInfo()->type == CREATURE_TYPE_DEMON; @@ -1823,7 +1820,7 @@ bool Pet::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint3 m_DBTableGuid = guidlow; m_originalEntry = Entry; - if(!InitEntry(Entry)) + if (!InitEntry(Entry)) return false; SetSheath(SHEATH_STATE_MELEE); @@ -1834,22 +1831,22 @@ bool Pet::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint3 bool Pet::HasSpell(uint32 spell) const { PetSpellMap::const_iterator itr = m_spells.find(spell); - return (itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED ); + return itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED; } // Get all passive spells in our skill line void Pet::LearnPetPassives() { CreatureInfo const* cInfo = GetCreatureInfo(); - if(!cInfo) + if (!cInfo) return; CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family); - if(!cFamily) + if (!cFamily) return; PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID); - if(petStore != sPetFamilySpellsStore.end()) + if (petStore != sPetFamilySpellsStore.end()) { // For general hunter pets skill 270 // Passive 01~10, Passive 00 (20782, not used), Ferocious Inspiration (34457) @@ -1862,10 +1859,10 @@ void Pet::LearnPetPassives() void Pet::CastPetAuras(bool current) { Unit* owner = GetOwner(); - if(!owner || owner->GetTypeId() != TYPEID_PLAYER) + if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - if(!IsPermanentPetFor((Player*)owner)) + if (!IsPermanentPetFor((Player*)owner)) return; for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); ) @@ -1873,7 +1870,7 @@ void Pet::CastPetAuras(bool current) PetAura const* pa = *itr; ++itr; - if(!current && pa->IsRemovedOnChangePet()) + if (!current && pa->IsRemovedOnChangePet()) owner->RemovePetAura(pa); else CastPetAura(pa); @@ -1883,10 +1880,10 @@ void Pet::CastPetAuras(bool current) void Pet::CastPetAura(PetAura const* aura) { uint32 auraId = aura->GetAura(GetEntry()); - if(!auraId) + if (!auraId) return; - if(auraId == 35696) // Demonic Knowledge + if (auraId == 35696) // Demonic Knowledge { int32 basePoints = int32(aura->GetDamage() * (GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT)) / 100); CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true); @@ -1899,7 +1896,7 @@ void Pet::learnSpellHighRank(uint32 spellid) { learnSpell(spellid); - if(uint32 next = spellmgr.GetNextSpellInChain(spellid)) + if (uint32 next = spellmgr.GetNextSpellInChain(spellid)) learnSpellHighRank(next); } @@ -1909,7 +1906,7 @@ void Pet::SynchronizeLevelWithOwner() if (!owner || owner->GetTypeId() != TYPEID_PLAYER) return; - switch(getPetType()) + switch (getPetType()) { // always same level case SUMMON_PET: @@ -1917,7 +1914,7 @@ void Pet::SynchronizeLevelWithOwner() break; // can't be greater owner level case HUNTER_PET: - if(getLevel() > owner->getLevel()) + if (getLevel() > owner->getLevel()) { GivePetLevel(owner->getLevel()); SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(owner->getLevel())/4); diff --git a/src/game/Pet.h b/src/game/Pet.h index 7f3684bbd59..0028b5038f9 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -162,7 +162,7 @@ class Pet : public Guardian void LooseHappiness(); HappinessState GetHappinessState(); void GivePetXP(uint32 xp); - void GivePetLevel(uint32 level); + void GivePetLevel(uint8 level); void SynchronizeLevelWithOwner(); bool HaveInDiet(ItemPrototype const* item) const; uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel); @@ -213,7 +213,7 @@ class Pet : public Guardian uint32 resetTalentsCost() const; void InitTalentForLevel(); - uint8 GetMaxTalentPointsForLevel(uint32 level); + uint8 GetMaxTalentPointsForLevel(uint8 level); uint8 GetFreeTalentPoints() { return GetByteValue(UNIT_FIELD_BYTES_1, 1); } void SetFreeTalentPoints(uint8 points) { SetByteValue(UNIT_FIELD_BYTES_1, 1, points); } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 93a3dcd45bf..86c23316b22 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -133,7 +133,7 @@ PlayerTaxi::PlayerTaxi() memset(m_taximask, 0, sizeof(m_taximask)); } -void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level) +void PlayerTaxi::InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level) { // class specific initial known nodes switch(chrClass) @@ -2449,7 +2449,7 @@ void Player::GiveXP(uint32 xp, Unit* victim) if(!isAlive()) return; - uint32 level = getLevel(); + uint8 level = getLevel(); // Favored experience increase START uint32 zone = GetZoneId(); @@ -2487,7 +2487,7 @@ void Player::GiveXP(uint32 xp, Unit* victim) // Update player to next level // Current player experience not update (must be update by caller) -void Player::GiveLevel(uint32 level) +void Player::GiveLevel(uint8 level) { if (level == getLevel()) return; @@ -2563,9 +2563,9 @@ void Player::GiveLevel(uint32 level) void Player::InitTalentForLevel() { - uint32 level = getLevel(); + uint8 level = getLevel(); // talents base at level diff ( talents = level - 9 but some can be used already) - if(level < 10) + if (level < 10) { // Remove all talent points if(m_usedTalentCount > 0) // Free any used talents @@ -4997,17 +4997,18 @@ uint32 Player::GetShieldBlockValue() const float Player::GetMeleeCritFromAgility() { - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) + level = GT_MAX_LEVEL; GtChanceToMeleeCritBaseEntry const *critBase = sGtChanceToMeleeCritBaseStore.LookupEntry(pclass-1); GtChanceToMeleeCritEntry const *critRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (critBase==NULL || critRatio==NULL) + if (critBase == NULL || critRatio == NULL) return 0.0f; - float crit=critBase->base + GetStat(STAT_AGILITY)*critRatio->ratio; + float crit = critBase->base + GetStat(STAT_AGILITY)*critRatio->ratio; return crit*100.0f; } @@ -5042,14 +5043,15 @@ float Player::GetDodgeFromAgility() 1.7f // Druid }; - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) + level = GT_MAX_LEVEL; // Dodge per agility for most classes equal crit per agility (but for some classes need apply some multiplier) GtChanceToMeleeCritEntry const *dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (dodgeRatio==NULL || pclass > MAX_CLASSES) + if (dodgeRatio == NULL || pclass > MAX_CLASSES) return 0.0f; float dodge=dodge_base[pclass-1] + GetStat(STAT_AGILITY) * dodgeRatio->ratio * crit_to_dodge[pclass-1]; @@ -5058,14 +5060,15 @@ float Player::GetDodgeFromAgility() float Player::GetSpellCritFromIntellect() { - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) + level = GT_MAX_LEVEL; GtChanceToSpellCritBaseEntry const *critBase = sGtChanceToSpellCritBaseStore.LookupEntry(pclass-1); GtChanceToSpellCritEntry const *critRatio = sGtChanceToSpellCritStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (critBase==NULL || critRatio==NULL) + if (critBase == NULL || critRatio == NULL) return 0.0f; float crit=critBase->base + GetStat(STAT_INTELLECT)*critRatio->ratio; @@ -5074,9 +5077,10 @@ float Player::GetSpellCritFromIntellect() float Player::GetRatingCoefficient(CombatRating cr) const { - uint32 level = getLevel(); + uint8 level = getLevel(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) + level = GT_MAX_LEVEL; GtCombatRatingsEntry const *Rating = sGtCombatRatingsStore.LookupEntry(cr*GT_MAX_LEVEL+level-1); if (Rating == NULL) @@ -5138,20 +5142,22 @@ float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const float Player::OCTRegenHPPerSpirit() { - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) + level = GT_MAX_LEVEL; GtOCTRegenHPEntry const *baseRatio = sGtOCTRegenHPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); GtRegenHPPerSptEntry const *moreRatio = sGtRegenHPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (baseRatio==NULL || moreRatio==NULL) + if (baseRatio == NULL || moreRatio == NULL) return 0.0f; // Formula from PaperDollFrame script float spirit = GetStat(STAT_SPIRIT); float baseSpirit = spirit; - if (baseSpirit>50) baseSpirit = 50; + if (baseSpirit > 50) + baseSpirit = 50; float moreSpirit = spirit - baseSpirit; float regen = baseSpirit * baseRatio->ratio + moreSpirit * moreRatio->ratio; return regen; @@ -5159,14 +5165,15 @@ float Player::OCTRegenHPPerSpirit() float Player::OCTRegenMPPerSpirit() { - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 pclass = getClass(); - if (level>GT_MAX_LEVEL) level = GT_MAX_LEVEL; + if (level > GT_MAX_LEVEL) + level = GT_MAX_LEVEL; // GtOCTRegenMPEntry const *baseRatio = sGtOCTRegenMPStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); GtRegenMPPerSptEntry const *moreRatio = sGtRegenMPPerSptStore.LookupEntry((pclass-1)*GT_MAX_LEVEL + level-1); - if (moreRatio==NULL) + if (moreRatio == NULL) return 0.0f; // Formula get from PaperDollFrame script @@ -5513,35 +5520,33 @@ void Player::UpdateWeaponSkill (WeaponAttackType attType) void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool defence) { - uint32 plevel = getLevel(); // if defense than pVictim == attacker - uint32 greylevel = Trinity::XP::GetGrayLevel(plevel); - uint32 moblevel = pVictim->getLevelForTarget(this); + uint8 plevel = getLevel(); // if defense than pVictim == attacker + uint8 greylevel = Trinity::XP::GetGrayLevel(plevel); + uint8 moblevel = pVictim->getLevelForTarget(this); if(moblevel < greylevel) return; if (moblevel > plevel + 5) moblevel = plevel + 5; - uint32 lvldif = moblevel - greylevel; - if(lvldif < 3) + uint8 lvldif = moblevel - greylevel; + if (lvldif < 3) lvldif = 3; uint32 skilldif = 5 * plevel - (defence ? GetBaseDefenseSkillValue() : GetBaseWeaponSkillValue(attType)); - if(skilldif <= 0) + if (skilldif <= 0) return; float chance = float(3 * lvldif * skilldif) / plevel; - if(!defence) - { - if(getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE) + if (!defence) + if (getClass() == CLASS_WARRIOR || getClass() == CLASS_ROGUE) chance += chance * 0.02f * GetStat(STAT_INTELLECT); - } chance = chance < 1.0f ? 1.0f : chance; //minimum chance to increase skill is 1% - if(roll_chance_f(chance)) + if (roll_chance_f(chance)) { - if(defence) + if (defence) UpdateDefense(); else UpdateWeaponSkill(attType); @@ -5552,19 +5557,19 @@ void Player::UpdateCombatSkills(Unit *pVictim, WeaponAttackType attType, bool de void Player::ModifySkillBonus(uint32 skillid,int32 val, bool talent) { - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skillid) - { - uint32 bonus_val = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); - int16 temp_bonus = SKILL_TEMP_BONUS(bonus_val); - int16 perm_bonus = SKILL_PERM_BONUS(bonus_val); + { + uint32 bonus_val = GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i)); + int16 temp_bonus = SKILL_TEMP_BONUS(bonus_val); + int16 perm_bonus = SKILL_PERM_BONUS(bonus_val); - if(talent) // permanent bonus stored in high part - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus,perm_bonus+val)); - else // temporary/item bonus stored in low part - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus+val,perm_bonus)); - return; - } + if(talent) // permanent bonus stored in high part + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus,perm_bonus+val)); + else // temporary/item bonus stored in low part + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),MAKE_SKILL_BONUS(temp_bonus+val,perm_bonus)); + return; + } } void Player::UpdateSkillsForLevel() @@ -5574,69 +5579,70 @@ void Player::UpdateSkillsForLevel() bool alwaysMaxSkill = sWorld.getConfig(CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL); - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) - { - uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; + { + uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(pskill); - if(!pSkill) - continue; + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(pskill); + if (!pSkill) + continue; - if(GetSkillRangeType(pSkill,false) != SKILL_RANGE_LEVEL) - continue; + if (GetSkillRangeType(pSkill,false) != SKILL_RANGE_LEVEL) + continue; - uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); - uint32 max = SKILL_MAX(data); - uint32 val = SKILL_VALUE(data); + uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); + uint32 max = SKILL_MAX(data); + uint32 val = SKILL_VALUE(data); - /// update only level dependent max skill values - if(max!=1) - { - /// miximize skill always - if(alwaysMaxSkill) - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(maxSkill,maxSkill)); - /// update max skill value if current max skill not maximized - else if(max != maxconfskill) - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,maxSkill)); + /// update only level dependent max skill values + if (max != 1) + { + /// miximize skill always + if (alwaysMaxSkill) + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(maxSkill,maxSkill)); + /// update max skill value if current max skill not maximized + else if (max != maxconfskill) + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(val,maxSkill)); + } } - } } void Player::UpdateSkillsToMaxSkillsForLevel() { - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if (GetUInt32Value(PLAYER_SKILL_INDEX(i))) - { - uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; - if( IsProfessionOrRidingSkill(pskill)) - continue; - uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); + { + uint32 pskill = GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF; + if (IsProfessionOrRidingSkill(pskill)) + continue; + uint32 data = GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i)); - uint32 max = SKILL_MAX(data); + uint32 max = SKILL_MAX(data); - if(max > 1) - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(max,max)); + if (max > 1) + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(max,max)); - if(pskill == SKILL_DEFENSE) - UpdateDefenseBonusesMod(); - } + if (pskill == SKILL_DEFENSE) + UpdateDefenseBonusesMod(); + } } // This functions sets a skill line value (and adds if doesn't exist yet) // To "remove" a skill line, set it's values to zero void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) { - if(!id) + if (!id) return; - uint16 i=0; - for (; i < PLAYER_MAX_SKILLS; i++) - if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == id) break; + uint16 i = 0; + for (; i < PLAYER_MAX_SKILLS; ++i) + if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == id) + break; - if(i<PLAYER_MAX_SKILLS) //has skill + if (i < PLAYER_MAX_SKILLS) //has skill { - if(currVal) + if (currVal) { SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal)); learnSkillRewardedSpells(id, currVal); @@ -5651,73 +5657,72 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal) SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); // remove all spells that related to this skill - for (uint32 j=0; j<sSkillLineAbilityStore.GetNumRows(); ++j) + for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) if(SkillLineAbilityEntry const *pAbility = sSkillLineAbilityStore.LookupEntry(j)) - if (pAbility->skillId==id) + if (pAbility->skillId == id) removeSpell(spellmgr.GetFirstSpellInChain(pAbility->spellId)); } } - else if(currVal) //add + else if (currVal) //add { - for (i=0; i < PLAYER_MAX_SKILLS; i++) + for (i = 0; i < PLAYER_MAX_SKILLS; ++i) if (!GetUInt32Value(PLAYER_SKILL_INDEX(i))) - { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(id); - if(!pSkill) { - sLog.outError("Skill not found in SkillLineStore: skill #%u", id); + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(id); + if (!pSkill) + { + sLog.outError("Skill not found in SkillLineStore: skill #%u", id); + return; + } + // enable unlearn button for primary professions only + if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION) + SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1)); + else + SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0)); + SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal)); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,id); + GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL,id); + + // apply skill bonuses + SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); + + // temporary bonuses + AuraEffectList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); + for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j) + if ((*j)->GetMiscValue() == int32(id)) + (*j)->ApplyModifier(true); + + // permanent bonuses + AuraEffectList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT); + for (AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j) + if ((*j)->GetMiscValue() == int32(id)) + (*j)->ApplyModifier(true); + + // Learn all spells for skill + learnSkillRewardedSpells(id, currVal); return; } - // enable unlearn button for primary professions only - if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION) - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1)); - else - SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0)); - SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal)); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,id); - GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL,id); - - // apply skill bonuses - SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0); - - // temporary bonuses - AuraEffectList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL); - for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j) - if ((*j)->GetMiscValue() == int32(id)) - (*j)->ApplyModifier(true); - - // permanent bonuses - AuraEffectList const& mModSkillTalent = GetAurasByType(SPELL_AURA_MOD_SKILL_TALENT); - for (AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j) - if ((*j)->GetMiscValue() == int32(id)) - (*j)->ApplyModifier(true); - - // Learn all spells for skill - learnSkillRewardedSpells(id, currVal); - return; } - } } bool Player::HasSkill(uint32 skill) const { - if(!skill)return false; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { + if (!skill) + return false; + + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { return true; - } - } + return false; } uint16 Player::GetSkillValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) { if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) { @@ -5734,8 +5739,10 @@ uint16 Player::GetSkillValue(uint32 skill) const uint16 Player::GetMaxSkillValue(uint32 skill) const { - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + if (!skill) + return 0; + + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) { if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) { @@ -5752,21 +5759,22 @@ uint16 Player::GetMaxSkillValue(uint32 skill) const uint16 Player::GetPureMaxSkillValue(uint32 skill) const { - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { + if (!skill) + return 0; + + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { return SKILL_MAX(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i))); - } - } + return 0; } uint16 Player::GetBaseSkillValue(uint32 skill) const { - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) + if (!skill) + return 0; + + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) { if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) { @@ -5780,45 +5788,36 @@ uint16 Player::GetBaseSkillValue(uint32 skill) const uint16 Player::GetPureSkillValue(uint32 skill) const { - if(!skill)return 0; - for (uint16 i=0; i < PLAYER_MAX_SKILLS; i++) - { + if (!skill) + return 0; + + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { return SKILL_VALUE(GetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i))); - } - } + return 0; } int16 Player::GetSkillPermBonusValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; - for (uint8 i = 0; i < PLAYER_MAX_SKILLS; i++) - { + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { return SKILL_PERM_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i))); - } - } return 0; } int16 Player::GetSkillTempBonusValue(uint32 skill) const { - if(!skill) + if (!skill) return 0; - for (uint8 i = 0; i < PLAYER_MAX_SKILLS; i++) - { + for (uint16 i = 0; i < PLAYER_MAX_SKILLS; ++i) if ((GetUInt32Value(PLAYER_SKILL_INDEX(i)) & 0x0000FFFF) == skill) - { return SKILL_TEMP_BONUS(GetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i))); - } - } return 0; } @@ -5829,17 +5828,17 @@ void Player::SendActionButtons(uint32 state) const WorldPacket data(SMSG_ACTION_BUTTONS, 1+(MAX_ACTION_BUTTONS*4)); data << uint8(state); // can be 0, 1, 2 - for (int button = 0; button < MAX_ACTION_BUTTONS; ++button) + for (uint16 button = 0; button < MAX_ACTION_BUTTONS; ++button) { ActionButtonList::const_iterator itr = m_actionButtons.find(button); - if(itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED) + if (itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED) data << uint32(itr->second.packedData); else data << uint32(0); } - GetSession()->SendPacket( &data ); - sLog.outDetail( "Action Buttons for '%u' spec '%u' Sent", GetGUIDLow(), m_activeSpec ); + GetSession()->SendPacket(&data); + sLog.outDetail("Action Buttons for '%u' spec '%u' Sent", GetGUIDLow(), m_activeSpec); } ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) @@ -5856,23 +5855,23 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) return NULL; } - switch(type) + switch (type) { case ACTION_BUTTON_SPELL: - if(!sSpellStore.LookupEntry(action)) + if (!sSpellStore.LookupEntry(action)) { sLog.outError( "Action %u not added into button %u for player %s: spell not exist", action, button, GetName() ); return NULL; } - if(!HasSpell(action)) + if (!HasSpell(action)) { sLog.outError( "Action %u not added into button %u for player %s: player don't known this spell", action, button, GetName() ); return NULL; } break; case ACTION_BUTTON_ITEM: - if(!objmgr.GetItemPrototype(action)) + if (!objmgr.GetItemPrototype(action)) { sLog.outError( "Action %u not added into button %u for player %s: item not exist", action, button, GetName() ); return NULL; @@ -5888,14 +5887,14 @@ ActionButton* Player::addActionButton(uint8 button, uint32 action, uint8 type) // set data and update to CHANGED if not NEW ab.SetActionAndType(action,ActionButtonType(type)); - sLog.outDetail( "Player '%u' Added Action '%u' (type %u) to Button '%u'", GetGUIDLow(), action, uint32(type), button ); + sLog.outDetail("Player '%u' Added Action '%u' (type %u) to Button '%u'", GetGUIDLow(), action, type, button); return &ab; } void Player::removeActionButton(uint8 button) { ActionButtonList::iterator buttonItr = m_actionButtons.find(button); - if (buttonItr==m_actionButtons.end()) + if (buttonItr == m_actionButtons.end()) return; if (!buttonItr->second.canRemoveByClient) @@ -5908,13 +5907,13 @@ void Player::removeActionButton(uint8 button) else buttonItr->second.uState = ACTIONBUTTON_DELETED; // saved, will deleted at next save - sLog.outDetail( "Action Button '%u' Removed from Player '%u'", button, GetGUIDLow() ); + sLog.outDetail("Action Button '%u' Removed from Player '%u'", button, GetGUIDLow()); } bool Player::SetPosition(float x, float y, float z, float orientation, bool teleport) { // prevent crash when a bad coord is sent by the client - if(!Trinity::IsValidMapCoord(x,y,z,orientation)) + if (!Trinity::IsValidMapCoord(x,y,z,orientation)) { sLog.outDebug("Player::SetPosition(%f, %f, %f, %f, %d) .. bad coordinates for player %d!",x,y,z,orientation,teleport,GetGUIDLow()); return false; @@ -5929,10 +5928,10 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele bool turn = (GetOrientation() != orientation); bool move2d = (teleport || GetPositionX() != x || GetPositionY() != y); - if(turn) + if (turn) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TURNING); - if(move2d || GetPositionZ() != z) + if (move2d || GetPositionZ() != z) { RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOVE); @@ -5943,7 +5942,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele GetPosition(x, y, z); // group update - if(move2d && GetGroup()) + if (move2d && GetGroup()) SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION); // code block for underwater state update @@ -5952,9 +5951,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele CheckExploreSystem(); } else if(turn) - { SetOrientation(orientation); - } return true; } @@ -5970,7 +5967,7 @@ void Player::SaveRecallPosition() void Player::SendMessageToSet(WorldPacket *data, bool self) { - if(self) + if (self) GetSession()->SendPacket(data); // we use World::GetMaxVisibleDistance() because i cannot see why not use a distance @@ -5981,7 +5978,7 @@ void Player::SendMessageToSet(WorldPacket *data, bool self) void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) { - if(self) + if (self) GetSession()->SendPacket(data); Trinity::MessageDistDeliverer notifier(this, data, dist); @@ -5990,7 +5987,7 @@ void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only) { - if(self) + if (self) GetSession()->SendPacket(data); Trinity::MessageDistDeliverer notifier(this, data, dist, own_team_only); @@ -6572,12 +6569,12 @@ uint32 Player::GetZoneIdFromDB(uint64 guid) uint32 Player::GetLevelFromDB(uint64 guid) { - QueryResult *result = CharacterDatabase.PQuery( "SELECT level FROM characters WHERE guid='%u'", GUID_LOPART(guid) ); + QueryResult *result = CharacterDatabase.PQuery("SELECT level FROM characters WHERE guid='%u'", GUID_LOPART(guid)); if (!result) return 0; Field* fields = result->Fetch(); - uint32 level = fields[0].GetUInt32(); + uint8 level = fields[0].GetUInt8(); delete result; return level; @@ -11997,15 +11994,16 @@ void Player::RemoveItemFromBuyBackSlot( uint32 slot, bool del ) if (pItem) { pItem->RemoveFromWorld(); - if(del) pItem->SetState(ITEM_REMOVED, this); + if(del) + pItem->SetState(ITEM_REMOVED, this); } m_items[slot] = NULL; uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value( PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0 ); - SetUInt32Value( PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0 ); + SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0); + SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); + SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); // if current backslot is filled set to now free slot if(m_items[m_currentBuybackSlot]) @@ -12027,7 +12025,7 @@ void Player::SendEquipError( uint8 msg, Item* pItem, Item *pItem2 ) if (msg == EQUIP_ERR_CANT_EQUIP_LEVEL_I) { - uint32 level = 0; + uint8 level = 0; if (pItem) if (ItemPrototype const* proto = pItem->GetProto()) @@ -15049,12 +15047,12 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) time_t logoutTime = time_t(fields[23].GetUInt64()); // since last logout (in seconds) - uint64 time_diff = uint64(now - logoutTime); + uint32 time_diff = uint32(now - logoutTime); //uint64 is excessive for a time_diff in seconds.. uint32 allows for 136~ year difference. // set value, including drunk invisibility detection // calculate sobering. after 15 minutes logged out, the player will be sober again float soberFactor; - if(time_diff > 15*MINUTE) + if (time_diff > 15*MINUTE) soberFactor = 0; else soberFactor = 1-time_diff/(15.0f*MINUTE); @@ -15067,7 +15065,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) //speed collect rest bonus in offline, in logout, in tavern, city (section/in hour) float bubble1 = 0.125; - if(time_diff > 0) + if (time_diff > 0) { float bubble = fields[24].GetUInt32() > 0 ? bubble1*sWorld.getRate(RATE_REST_OFFLINE_IN_TAVERN_OR_CITY) @@ -15086,15 +15084,15 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // reserve some flags uint32 old_safe_flags = GetUInt32Value(PLAYER_FLAGS) & ( PLAYER_FLAGS_HIDE_CLOAK | PLAYER_FLAGS_HIDE_HELM ); - if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM) ) + if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM)) SetUInt32Value(PLAYER_FLAGS, 0 | old_safe_flags); - m_taxi.LoadTaxiMask( fields[18].GetString() ); // must be before InitTaxiNodesForLevel + m_taxi.LoadTaxiMask(fields[18].GetString()); // must be before InitTaxiNodesForLevel uint32 extraflags = fields[32].GetUInt32(); m_stableSlots = fields[33].GetUInt32(); - if(m_stableSlots > MAX_PET_STABLES) + if (m_stableSlots > MAX_PET_STABLES) { sLog.outError("Player can have not more %u stable slots, but have in DB %u",MAX_PET_STABLES,uint32(m_stableSlots)); m_stableSlots = MAX_PET_STABLES; @@ -15108,7 +15106,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) UpdateHonorFields(); m_deathExpireTime = (time_t)fields[37].GetUInt64(); - if(m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP) + if (m_deathExpireTime > now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP) m_deathExpireTime = now+MAX_DEATH_COUNT*DEATH_EXPIRE_STEP-1; // clear channel spell data (if saved at channel spell casting) @@ -15141,7 +15139,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // remember loaded power/health values to restore after stats initialization and modifier applying uint32 savedHealth = GetHealth(); uint32 savedPower[MAX_POWERS]; - for (uint32 i = 0; i < MAX_POWERS; ++i) + for (uint8 i = 0; i < MAX_POWERS; ++i) savedPower[i] = GetPower(Powers(i)); // reset stats before loading any modifiers @@ -15155,8 +15153,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) //mails are loaded only when needed ;-) - when player in game click on mailbox. //_LoadMail(); - m_specsCount = fields[42].GetUInt32(); - m_activeSpec = fields[43].GetUInt32(); + m_specsCount = fields[42].GetUInt8(); + m_activeSpec = fields[43].GetUInt8(); delete result; // sanity check @@ -15174,7 +15172,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) _LoadAuras(holder->GetResult(PLAYER_LOGIN_QUERY_LOADAURAS), time_diff); _LoadGlyphAuras(); // add ghost flag (must be after aura load: PLAYER_FLAGS_GHOST set in aura) - if( HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST) ) + if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) m_deathState = DEAD; // after spell load, learn rewarded spell if need also @@ -15202,11 +15200,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES // note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded - if(uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) - { + if (uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) if(!HasTitle(curTitle)) SetUInt32Value(PLAYER_CHOSEN_TITLE, 0); - } // has to be called after last Relocate() in Player::LoadFromDB SetFallInformation(0, GetPositionZ()); @@ -15215,7 +15211,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // Spell code allow apply any auras to dead character in load time in aura/spell/item loading // Do now before stats re-calculation cleanup for ghost state unexpected auras - if(!isAlive()) + if (!isAlive()) RemoveAllAurasOnDeath(); //apply all stat bonuses from items and auras @@ -15224,16 +15220,16 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // restore remembered power/health values (but not more max values) SetHealth(savedHealth > GetMaxHealth() ? GetMaxHealth() : savedHealth); - for (uint32 i = 0; i < MAX_POWERS; ++i) + for (uint8 i = 0; i < MAX_POWERS; ++i) SetPower(Powers(i),savedPower[i] > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedPower[i]); sLog.outDebug("The value of player %s after load item and aura is: ", m_name.c_str()); outDebugValues(); // GM state - if(GetSession()->GetSecurity() > SEC_PLAYER) + if (GetSession()->GetSecurity() > SEC_PLAYER) { - switch(sWorld.getConfig(CONFIG_GM_LOGIN_STATE)) + switch (sWorld.getConfig(CONFIG_GM_LOGIN_STATE)) { default: case 0: break; // disable @@ -15244,7 +15240,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) break; } - switch(sWorld.getConfig(CONFIG_GM_VISIBLE_STATE)) + switch (sWorld.getConfig(CONFIG_GM_VISIBLE_STATE)) { default: case 0: SetGMVisible(false); break; // invisible @@ -15266,7 +15262,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) break; }*/ - switch(sWorld.getConfig(CONFIG_GM_CHAT)) + switch (sWorld.getConfig(CONFIG_GM_CHAT)) { default: case 0: break; // disable @@ -15277,7 +15273,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) break; } - switch(sWorld.getConfig(CONFIG_GM_WISPERING_TO)) + switch (sWorld.getConfig(CONFIG_GM_WISPERING_TO)) { default: case 0: break; // disable @@ -15301,17 +15297,17 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) bool Player::isAllowedToLoot(Creature* creature) { - if(creature->isDead() && !creature->IsDamageEnoughForLootingAndReward()) + if (creature->isDead() && !creature->IsDamageEnoughForLootingAndReward()) return false; - if(Player* recipient = creature->GetLootRecipient()) + if (Player* recipient = creature->GetLootRecipient()) { if (recipient == this) return true; - if( Group* otherGroup = recipient->GetGroup()) + if (Group* otherGroup = recipient->GetGroup()) { Group* thisGroup = GetGroup(); - if(!thisGroup) + if (!thisGroup) return false; return thisGroup == otherGroup; } @@ -15324,7 +15320,7 @@ bool Player::isAllowedToLoot(Creature* creature) void Player::_LoadActions(QueryResult *result, bool startup) { - if(result) + if (result) { do { @@ -15348,7 +15344,7 @@ void Player::_LoadActions(QueryResult *result, bool startup) m_actionButtons[button].uState = ACTIONBUTTON_DELETED; } } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -15360,7 +15356,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) //QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_mask,stackcount,amount0,amount1,amount2,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'",GetGUIDLow()); - if(result) + if (result) { do { @@ -15368,17 +15364,17 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) Field *fields = result->Fetch(); uint64 caster_guid = fields[0].GetUInt64(); uint32 spellid = fields[1].GetUInt32(); - uint32 effmask = fields[2].GetUInt32(); - uint32 stackcount = fields[3].GetUInt32(); - damage[0] = int32(fields[4].GetUInt32()); - damage[1] = int32(fields[5].GetUInt32()); - damage[2] = int32(fields[6].GetUInt32()); - int32 maxduration = (int32)fields[7].GetUInt32(); - int32 remaintime = (int32)fields[8].GetUInt32(); - int32 remaincharges = (int32)fields[9].GetUInt32(); + uint8 effmask = fields[2].GetUInt8(); + uint8 stackcount = fields[3].GetUInt8(); + damage[0] = fields[4].GetInt32(); + damage[1] = fields[5].GetInt32(); + damage[2] = fields[6].GetInt32(); + int32 maxduration = fields[7].GetInt32(); + int32 remaintime = fields[8].GetInt32(); + uint8 remaincharges = fields[9].GetUInt8(); SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid); - if(!spellproto) + if (!spellproto) { sLog.outError("Unknown aura (spellid %u), ignore.",spellid); continue; @@ -15394,7 +15390,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) } // prevent wrong values of remaincharges - if(spellproto->procCharges) + if (spellproto->procCharges) { if(remaincharges <= 0 || remaincharges > spellproto->procCharges) remaincharges = spellproto->procCharges; @@ -15404,7 +15400,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) Aura* aura = new Aura(spellproto, effmask, this, this, this); aura->SetLoadedState(caster_guid,maxduration,remaintime,remaincharges, stackcount, &damage[0]); - if(!aura->CanBeSaved()) + if (!aura->CanBeSaved()) { delete aura; continue; @@ -15412,7 +15408,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) AddAura(aura); sLog.outDetail("Added aura spellid %u, effectmask %u", spellproto->Id, effmask); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -15431,7 +15427,7 @@ void Player::_LoadGlyphAuras() { if (GlyphSlotEntry const *gs = sGlyphSlotStore.LookupEntry(GetGlyphSlot(i))) { - if(gp->TypeFlags == gs->TypeFlags) + if (gp->TypeFlags == gs->TypeFlags) { CastSpell(this, gp->SpellId, true); continue; @@ -15453,21 +15449,15 @@ void Player::_LoadGlyphAuras() void Player::LoadCorpse() { - if( isAlive() ) - { + if (isAlive()) ObjectAccessor::Instance().ConvertCorpseForPlayer(GetGUID()); - } else { - if(Corpse *corpse = GetCorpse()) - { + if (Corpse *corpse = GetCorpse()) ApplyModFlag(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTE_RELEASE_TIMER, corpse && !sMapStore.LookupEntry(corpse->GetMapId())->Instanceable() ); - } else - { //Prevent Dead Player login without corpse ResurrectPlayer(0.5f); - } } } @@ -15498,7 +15488,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) ItemPrototype const * proto = objmgr.GetItemPrototype(item_id); - if(!proto) + if (!proto) { CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item_guid); @@ -15508,7 +15498,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) Item *item = NewItemOrBag(proto); - if(!item->LoadFromDB(item_guid, GetGUID(), result)) + if (!item->LoadFromDB(item_guid, GetGUID(), result)) { sLog.outError( "Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id ); CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); @@ -15518,7 +15508,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) } // not allow have in alive state item limited to another map/zone - if(isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone) ) + if (isAlive() && item->IsLimitedToAnotherMapOrZone(GetMapId(),zone)) { CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); item->FSetState(ITEM_REMOVED); @@ -15527,7 +15517,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) } // "Conjured items disappear if you are logged out for more than 15 minutes" - if ((timediff > 15*60) && (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED))) + if (timediff > 15*MINUTE && item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_CONJURED)) { CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid); item->FSetState(ITEM_REMOVED); @@ -15540,38 +15530,38 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) if (!bag_guid) { // the item is not in a bag - item->SetContainer( NULL ); + item->SetContainer(NULL); item->SetSlot(slot); - if( IsInventoryPos( INVENTORY_SLOT_BAG_0, slot ) ) + if (IsInventoryPos(INVENTORY_SLOT_BAG_0, slot)) { ItemPosCountVec dest; - if( CanStoreItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false ) == EQUIP_ERR_OK ) + if (CanStoreItem(INVENTORY_SLOT_BAG_0, slot, dest, item, false) == EQUIP_ERR_OK) item = StoreItem(dest, item, true); else success = false; } - else if( IsEquipmentPos( INVENTORY_SLOT_BAG_0, slot ) ) + else if (IsEquipmentPos(INVENTORY_SLOT_BAG_0, slot)) { uint16 dest; - if( CanEquipItem( slot, dest, item, false, false ) == EQUIP_ERR_OK ) + if (CanEquipItem(slot, dest, item, false, false) == EQUIP_ERR_OK) QuickEquipItem(dest, item); else success = false; } - else if( IsBankPos( INVENTORY_SLOT_BAG_0, slot ) ) + else if (IsBankPos(INVENTORY_SLOT_BAG_0, slot)) { ItemPosCountVec dest; - if( CanBankItem( INVENTORY_SLOT_BAG_0, slot, dest, item, false, false ) == EQUIP_ERR_OK ) + if (CanBankItem(INVENTORY_SLOT_BAG_0, slot, dest, item, false, false) == EQUIP_ERR_OK) item = BankItem(dest, item, true); else success = false; } - if(success) + if (success) { // store bags that may contain items in them - if(item->IsBag() && IsBagPos(item->GetPos())) + if (item->IsBag() && IsBagPos(item->GetPos())) bagMap[item_guid] = (Bag*)item; } } @@ -15580,12 +15570,12 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) item->SetSlot(NULL_SLOT); // the item is in a bag, find the bag std::map<uint64, Bag*>::iterator itr = bagMap.find(bag_guid); - if(itr != bagMap.end()) + if (itr != bagMap.end()) { ItemPosCountVec dest; uint8 result = CanStoreItem(itr->second->GetSlot(), slot, dest, item); - if(result == EQUIP_ERR_OK) - itr->second->StoreItem(slot, item, true ); + if (result == EQUIP_ERR_OK) + itr->second->StoreItem(slot, item, true); else { sLog.outError("Player::_LoadInventory: Player %s has item (GUID: %u Entry: %u) can't be loaded to inventory (Bag GUID: %u Slot: %u) by reason %u.", GetName(),item_guid, item_id, bag_guid, slot, result); @@ -15611,7 +15601,7 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff) m_itemUpdateQueueBlocked = false; // send by mail problematic items - while(!problematicItems.empty()) + while (!problematicItems.empty()) { // fill mail MailItemsInfo mi; // item list preparing @@ -15638,7 +15628,7 @@ void Player::_LoadMailedItems(Mail *mail) { // data needs to be at first place for Item::LoadFromDB QueryResult* result = CharacterDatabase.PQuery("SELECT data, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail->messageID); - if(!result) + if (!result) return; do @@ -15651,7 +15641,7 @@ void Player::_LoadMailedItems(Mail *mail) ItemPrototype const *proto = objmgr.GetItemPrototype(item_template); - if(!proto) + if (!proto) { sLog.outError( "Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template,mail->messageID); CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); @@ -15661,7 +15651,7 @@ void Player::_LoadMailedItems(Mail *mail) Item *item = NewItemOrBag(proto); - if(!item->LoadFromDB(item_guid_low, 0, result)) + if (!item->LoadFromDB(item_guid_low, 0, result)) { sLog.outError( "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low); CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low); @@ -15702,7 +15692,7 @@ void Player::_LoadMail() m_mail.clear(); //mails are in right order 0 1 2 3 4 5 6 7 8 9 10 11 12 13 QueryResult *result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow()); - if(result) + if (result) { do { @@ -15723,7 +15713,7 @@ void Player::_LoadMail() m->stationery = fields[12].GetUInt8(); m->mailTemplateId = fields[13].GetInt16(); - if(m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId)) + if (m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId)) { sLog.outError( "Player::_LoadMail - Mail (%u) have not existed MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId); m->mailTemplateId = 0; @@ -15735,7 +15725,7 @@ void Player::_LoadMail() _LoadMailedItems(m); m_mail.push_back(m); - } while( result->NextRow() ); + } while (result->NextRow()); delete result; } m_mailsLoaded = true; @@ -15745,10 +15735,10 @@ void Player::LoadPet() { //fixme: the pet should still be loaded if the player is not in world // just not added to the map - if(IsInWorld()) + if (IsInWorld()) { Pet *pet = new Pet(this); - if(!pet->LoadPetFromDB(this,0,0,true)) + if (!pet->LoadPetFromDB(this,0,0,true)) delete pet; } } @@ -15757,12 +15747,12 @@ void Player::_LoadQuestStatus(QueryResult *result) { mQuestStatus.clear(); - uint32 slot = 0; + uint16 slot = 0; //// 0 1 2 3 4 5 6 7 8 9 10 11 12 //QueryResult *result = CharacterDatabase.PQuery("SELECT quest, status, rewarded, explored, timer, mobcount1, mobcount2, mobcount3, mobcount4, itemcount1, itemcount2, itemcount3, itemcount4 FROM character_queststatus WHERE guid = '%u'", GetGUIDLow()); - if(result) + if (result) { do { @@ -15771,13 +15761,13 @@ void Player::_LoadQuestStatus(QueryResult *result) uint32 quest_id = fields[0].GetUInt32(); // used to be new, no delete? Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); - if( pQuest ) + if (pQuest) { // find or create QuestStatusData& questStatusData = mQuestStatus[quest_id]; uint32 qstatus = fields[1].GetUInt32(); - if(qstatus < MAX_QUEST_STATUS) + if (qstatus < MAX_QUEST_STATUS) questStatusData.m_status = QuestStatus(qstatus); else { @@ -15790,9 +15780,9 @@ void Player::_LoadQuestStatus(QueryResult *result) time_t quest_time = time_t(fields[4].GetUInt64()); - if( pQuest->HasFlag( QUEST_TRINITY_FLAGS_TIMED ) && !GetQuestRewardStatus(quest_id) && questStatusData.m_status != QUEST_STATUS_NONE ) + if (pQuest->HasFlag(QUEST_TRINITY_FLAGS_TIMED) && !GetQuestRewardStatus(quest_id) && questStatusData.m_status != QUEST_STATUS_NONE) { - AddTimedQuest( quest_id ); + AddTimedQuest(quest_id); if (quest_time <= sWorld.GetGameTime()) questStatusData.m_timer = 1; @@ -15829,21 +15819,21 @@ void Player::_LoadQuestStatus(QueryResult *result) SetQuestSlotState(slot, QUEST_STATE_FAIL); for (uint8 idx = 0; idx < QUEST_OBJECTIVES_COUNT; ++idx) - if(questStatusData.m_creatureOrGOcount[idx]) + if (questStatusData.m_creatureOrGOcount[idx]) SetQuestSlotCounter(slot, idx, questStatusData.m_creatureOrGOcount[idx]); ++slot; } - if(questStatusData.m_rewarded) + if (questStatusData.m_rewarded) { // learn rewarded spell if unknown learnQuestRewardedSpells(pQuest); // set rewarded title if any - if(pQuest->GetCharTitleId()) + if (pQuest->GetCharTitleId()) { - if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) + if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) SetTitle(titleEntry); } @@ -15854,13 +15844,13 @@ void Player::_LoadQuestStatus(QueryResult *result) sLog.outDebug("Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.m_status, quest_id, GetGUIDLow()); } } - while( result->NextRow() ); + while (result->NextRow()); delete result; } // clear quest log tail - for (uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i ) + for (uint16 i = slot; i < MAX_QUEST_LOG_SIZE; ++i) SetQuestSlot(i, 0); } @@ -15871,13 +15861,13 @@ void Player::_LoadDailyQuestStatus(QueryResult *result) //QueryResult *result = CharacterDatabase.PQuery("SELECT quest,time FROM character_queststatus_daily WHERE guid = '%u'", GetGUIDLow()); - if(result) + if (result) { uint32 quest_daily_idx = 0; do { - if(quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query + if (quest_daily_idx >= PLAYER_MAX_DAILY_QUESTS) // max amount with exist data in query { sLog.outError("Player (GUID: %u) have more 25 daily quest records in `charcter_queststatus_daily`",GetGUIDLow()); break; @@ -15891,7 +15881,7 @@ void Player::_LoadDailyQuestStatus(QueryResult *result) m_lastDailyQuestTime = (time_t)fields[1].GetUInt64(); Quest const* pQuest = objmgr.GetQuestTemplate(quest_id); - if( !pQuest ) + if (!pQuest) continue; SetUInt32Value(PLAYER_FIELD_DAILY_QUESTS_1+quest_daily_idx,quest_id); @@ -15899,7 +15889,7 @@ void Player::_LoadDailyQuestStatus(QueryResult *result) sLog.outDebug("Daily quest {%u} cooldown for player (GUID: %u)", quest_id, GetGUIDLow()); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -15911,7 +15901,7 @@ void Player::_LoadSpells(QueryResult *result) { //QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'",GetGUIDLow()); - if(result) + if (result) { do { @@ -15919,7 +15909,7 @@ void Player::_LoadSpells(QueryResult *result) addSpell(fields[0].GetUInt32(), fields[1].GetBool(), false, false, fields[2].GetBool()); } - while( result->NextRow() ); + while (result->NextRow()); delete result; } @@ -15928,33 +15918,30 @@ void Player::_LoadSpells(QueryResult *result) void Player::_LoadGroup(QueryResult *result) { //QueryResult *result = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", GetGUIDLow()); - if(result) + if (result) { uint64 leaderGuid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER); delete result; - Group* group = objmgr.GetGroupByLeader(leaderGuid); - if(group) + if (Group* group = objmgr.GetGroupByLeader(leaderGuid)) { uint8 subgroup = group->GetMemberGroup(GetGUID()); SetGroup(group, subgroup); - if(getLevel() >= LEVELREQUIREMENT_HEROIC) - { + if (getLevel() >= LEVELREQUIREMENT_HEROIC) // the group leader may change the instance difficulty while the player is offline SetDifficulty(group->GetDifficulty()); - } } } } void Player::_LoadBoundInstances(QueryResult *result) { - for (uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + for (uint8 i = 0; i < TOTAL_DIFFICULTIES; ++i) m_boundInstances[i].clear(); Group *group = GetGroup(); //QueryResult *result = CharacterDatabase.PQuery("SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); - if(result) + if (result) { do { @@ -15969,14 +15956,14 @@ void Player::_LoadBoundInstances(QueryResult *result) // and in that case it is not used MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); - if(!mapEntry || !mapEntry->IsDungeon()) + if (!mapEntry || !mapEntry->IsDungeon()) { sLog.outError("_LoadBoundInstances: player %s(%d) has bind to not existed or not dungeon map %d", GetName(), GetGUIDLow(), mapId); CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND instance = '%d'", GetGUIDLow(), instanceId); continue; } - if(!perm && group) + if (!perm && group) { sLog.outError("_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d,%d,%d", GetName(), GetGUIDLow(), GUID_LOPART(group->GetLeaderGUID()), mapId, instanceId, difficulty); CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND instance = '%d'", GetGUIDLow(), instanceId); @@ -15984,9 +15971,9 @@ void Player::_LoadBoundInstances(QueryResult *result) } // since non permanent binds are always solo bind, they can always be reset - InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapId, instanceId, difficulty, resetTime, !perm, true); - if(save) BindToInstance(save, perm, true); - } while(result->NextRow()); + if (InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapId, instanceId, difficulty, resetTime, !perm, true)) + BindToInstance(save, perm, true); + } while (result->NextRow()); delete result; } } @@ -15995,10 +15982,10 @@ InstancePlayerBind* Player::GetBoundInstance(uint32 mapid, uint8 difficulty) { // some instances only have one difficulty const MapEntry* entry = sMapStore.LookupEntry(mapid); - if(!entry || !entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL; + if (!entry || !entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL; BoundInstancesMap::iterator itr = m_boundInstances[difficulty].find(mapid); - if(itr != m_boundInstances[difficulty].end()) + if (itr != m_boundInstances[difficulty].end()) return &itr->second; else return NULL; @@ -16008,12 +15995,11 @@ InstanceSave * Player::GetInstanceSave(uint32 mapid) { InstancePlayerBind *pBind = GetBoundInstance(mapid, GetDifficulty()); InstanceSave *pSave = pBind ? pBind->save : NULL; - if(!pBind || !pBind->perm) - { + if (!pBind || !pBind->perm) if(Group *group = GetGroup()) if(InstanceGroupBind *groupBind = group->GetBoundInstance(mapid, GetDifficulty())) pSave = groupBind->save; - } + return pSave; } @@ -16025,7 +16011,7 @@ void Player::UnbindInstance(uint32 mapid, uint8 difficulty, bool unload) void Player::UnbindInstance(BoundInstancesMap::iterator &itr, uint8 difficulty, bool unload) { - if(itr != m_boundInstances[difficulty].end()) + if (itr != m_boundInstances[difficulty].end()) { if(!unload) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%u' AND instance = '%u'", GetGUIDLow(), itr->second.save->GetInstanceId()); itr->second.save->RemovePlayer(this); // save can become invalid @@ -16038,26 +16024,31 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave *save, bool permanent, b if(save) { InstancePlayerBind& bind = m_boundInstances[save->GetDifficulty()][save->GetMapId()]; - if(bind.save) + if (bind.save) { // update the save when the group kills a boss - if(permanent != bind.perm || save != bind.save) - if(!load) CharacterDatabase.PExecute("UPDATE character_instance SET instance = '%u', permanent = '%u' WHERE guid = '%u' AND instance = '%u'", save->GetInstanceId(), permanent, GetGUIDLow(), bind.save->GetInstanceId()); + if (permanent != bind.perm || save != bind.save) + if (!load) + CharacterDatabase.PExecute("UPDATE character_instance SET instance = '%u', permanent = '%u' WHERE guid = '%u' AND instance = '%u'", save->GetInstanceId(), permanent, GetGUIDLow(), bind.save->GetInstanceId()); } else - if(!load) CharacterDatabase.PExecute("INSERT INTO character_instance (guid, instance, permanent) VALUES ('%u', '%u', '%u')", GetGUIDLow(), save->GetInstanceId(), permanent); + if (!load) + CharacterDatabase.PExecute("INSERT INTO character_instance (guid, instance, permanent) VALUES ('%u', '%u', '%u')", GetGUIDLow(), save->GetInstanceId(), permanent); - if(bind.save != save) + if (bind.save != save) { - if(bind.save) bind.save->RemovePlayer(this); + if(bind.save) + bind.save->RemovePlayer(this); save->AddPlayer(this); } - if(permanent) save->SetCanReset(false); + if (permanent) + save->SetCanReset(false); bind.save = save; bind.perm = permanent; - if(!load) sLog.outDebug("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); + if (!load) + sLog.outDebug("Player::BindToInstance: %s(%d) is now bound to map %d, instance %d, difficulty %d", GetName(), GetGUIDLow(), save->GetMapId(), save->GetInstanceId(), save->GetDifficulty()); return &bind; } else @@ -16103,11 +16094,11 @@ void Player::SendSavedInstances() bool hasBeenSaved = false; WorldPacket data; - for (uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + for (uint8 i = 0; i < TOTAL_DIFFICULTIES; ++i) { for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) { - if(itr->second.perm) // only permanent binds are sent + if (itr->second.perm) // only permanent binds are sent { hasBeenSaved = true; break; @@ -16120,14 +16111,14 @@ void Player::SendSavedInstances() data << uint32(hasBeenSaved); GetSession()->SendPacket(&data); - if(!hasBeenSaved) + if (!hasBeenSaved) return; - for (uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + for (uint8 i = 0; i < TOTAL_DIFFICULTIES; ++i) { for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) { - if(itr->second.perm) + if (itr->second.perm) { data.Initialize(SMSG_UPDATE_LAST_INSTANCE); data << uint32(itr->second.save->GetMapId()); @@ -16143,22 +16134,28 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, uint64 player bool has_binds = false; bool has_solo = false; - if(player) { player_guid = player->GetGUID(); if(!group) group = player->GetGroup(); } + if(player) + { + player_guid = player->GetGUID(); + if (!group) + group = player->GetGroup(); + } assert(player_guid); // copy all binds to the group, when changing leader it's assumed the character // will not have any solo binds - if(player) + if (player) { - for (uint8 i = 0; i < TOTAL_DIFFICULTIES; i++) + for (uint8 i = 0; i < TOTAL_DIFFICULTIES; ++i) { - for (BoundInstancesMap::iterator itr = player->m_boundInstances[i].begin(); itr != player->m_boundInstances[i].end(); ) + for (BoundInstancesMap::iterator itr = player->m_boundInstances[i].begin(); itr != player->m_boundInstances[i].end();) { has_binds = true; - if(group) group->BindToInstance(itr->second.save, itr->second.perm, true); + if (group) + group->BindToInstance(itr->second.save, itr->second.perm, true); // permanent binds are not removed - if(!itr->second.perm) + if (!itr->second.perm) { player->UnbindInstance(itr, i, true); // increments itr has_solo = true; @@ -16170,32 +16167,34 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, uint64 player } // if the player's not online we don't know what binds it has - if(!player || !group || has_binds) CharacterDatabase.PExecute("INSERT INTO group_instance SELECT guid, instance, permanent FROM character_instance WHERE guid = '%u'", GUID_LOPART(player_guid)); + if(!player || !group || has_binds) + CharacterDatabase.PExecute("INSERT INTO group_instance SELECT guid, instance, permanent FROM character_instance WHERE guid = '%u'", GUID_LOPART(player_guid)); // the following should not get executed when changing leaders - if(!player || has_solo) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND permanent = 0", GUID_LOPART(player_guid)); + if(!player || has_solo) + CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND permanent = 0", GUID_LOPART(player_guid)); } bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report) { - if(!isGameMaster() && ar) + if (!isGameMaster() && ar) { - uint32 LevelMin = 0; - uint32 LevelMax = 0; + uint8 LevelMin = 0; + uint8 LevelMax = 0; - if(!sWorld.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL)) + if (!sWorld.getConfig(CONFIG_INSTANCE_IGNORE_LEVEL)) { - if(ar->levelMin && getLevel() < ar->levelMin) + if (ar->levelMin && getLevel() < ar->levelMin) LevelMin = ar->levelMin; - if(ar->heroicLevelMin && GetDifficulty() == DIFFICULTY_HEROIC && getLevel() < ar->heroicLevelMin) + if (ar->heroicLevelMin && GetDifficulty() == DIFFICULTY_HEROIC && getLevel() < ar->heroicLevelMin) LevelMin = ar->heroicLevelMin; - if(ar->levelMax && getLevel() > ar->levelMax) + if (ar->levelMax && getLevel() > ar->levelMax) LevelMax = ar->levelMax; } uint32 missingItem = 0; - if(ar->item) + if (ar->item) { - if(!HasItemCount(ar->item, 1) && + if (!HasItemCount(ar->item, 1) && (!ar->item2 || !HasItemCount(ar->item2, 1))) missingItem = ar->item; } @@ -16204,18 +16203,18 @@ bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report uint32 missingKey = 0; uint32 missingHeroicQuest = 0; - if(GetDifficulty() == DIFFICULTY_HEROIC) + if (GetDifficulty() == DIFFICULTY_HEROIC) { - if(ar->heroicKey) + if (ar->heroicKey) { - if(!HasItemCount(ar->heroicKey, 1) && + if (!HasItemCount(ar->heroicKey, 1) && (!ar->heroicKey2 || !HasItemCount(ar->heroicKey2, 1))) missingKey = ar->heroicKey; } - else if(ar->heroicKey2 && !HasItemCount(ar->heroicKey2, 1)) + else if (ar->heroicKey2 && !HasItemCount(ar->heroicKey2, 1)) missingKey = ar->heroicKey2; - if(ar->heroicQuest && !GetQuestRewardStatus(ar->heroicQuest)) + if (ar->heroicQuest && !GetQuestRewardStatus(ar->heroicQuest)) missingHeroicQuest = ar->heroicQuest; } @@ -16223,19 +16222,19 @@ bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report if(ar->quest && !GetQuestRewardStatus(ar->quest)) missingQuest = ar->quest; - if(LevelMin || LevelMax || missingItem || missingKey || missingQuest || missingHeroicQuest) + if (LevelMin || LevelMax || missingItem || missingKey || missingQuest || missingHeroicQuest) { - if(report) + if (report) { - if(missingItem) + if (missingItem) GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), LevelMin, objmgr.GetItemPrototype(missingItem)->Name1); - else if(missingKey) + else if (missingKey) SendTransferAborted(target_map, TRANSFER_ABORT_DIFFICULTY); - else if(missingHeroicQuest) + else if (missingHeroicQuest) GetSession()->SendAreaTriggerMessage(ar->heroicQuestFailedText.c_str()); - else if(missingQuest) + else if (missingQuest) GetSession()->SendAreaTriggerMessage(ar->questFailedText.c_str()); - else if(LevelMin) + else if (LevelMin) GetSession()->SendAreaTriggerMessage(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED), LevelMin); } return false; @@ -16247,7 +16246,7 @@ bool Player::Satisfy(AccessRequirement const *ar, uint32 target_map, bool report bool Player::_LoadHomeBind(QueryResult *result) { PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(), getClass()); - if(!info) + if (!info) { sLog.outError("Player have incorrect race/class pair. Can't be loaded."); return false; @@ -16270,14 +16269,12 @@ bool Player::_LoadHomeBind(QueryResult *result) // accept saved data only for valid position (and non instanceable), and accessable if( MapManager::IsValidMapCoord(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ) && !bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion()) - { ok = true; - } else CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'", GetGUIDLow()); } - if(!ok) + if (!ok) { m_homebindMapId = info->mapId; m_homebindZoneId = info->zoneId; @@ -16304,7 +16301,7 @@ void Player::SaveToDB() m_nextSave = sWorld.getConfig(CONFIG_INTERVAL_SAVE); //lets allow only players in world to be saved - if(IsBeingTeleportedFar()) + if (IsBeingTeleportedFar()) { ScheduleDelayedOperation(DELAYED_SAVE_PLAYER); return; @@ -16343,7 +16340,7 @@ void Player::SaveToDB() << GetUInt32Value(PLAYER_BYTES_2) << ", " << GetUInt32Value(PLAYER_FLAGS) << ", "; - if(!IsBeingTeleported()) + if (!IsBeingTeleported()) { ss << GetMapId() << ", " << (uint32)GetInstanceId() << ", " @@ -16365,10 +16362,8 @@ void Player::SaveToDB() } uint16 i; - for (i = 0; i < m_valuesCount; i++ ) - { + for (i = 0; i < m_valuesCount; ++i) ss << GetUInt32Value(i) << " "; - } ss << "', "; @@ -16420,7 +16415,7 @@ void Player::SaveToDB() CharacterDatabase.Execute( ss.str().c_str() ); - if(m_mailsUpdated) //save mails only when needed + if (m_mailsUpdated) //save mails only when needed _SaveMail(); _SaveBGData(); @@ -16441,7 +16436,7 @@ void Player::SaveToDB() CharacterDatabase.CommitTransaction(); // save pet (hunter pet level and experience and all type pets health/mana). - if(Pet* pet = GetPet()) + if (Pet* pet = GetPet()) pet->SavePetToDB(PET_SAVE_AS_CURRENT); } @@ -16493,23 +16488,23 @@ void Player::_SaveAuras() AuraMap const& auras = GetAuras(); for (AuraMap::const_iterator itr = auras.begin(); itr !=auras.end() ; ++itr) { - if(!itr->second->CanBeSaved()) + if (!itr->second->CanBeSaved()) continue; int32 amounts[MAX_SPELL_EFFECTS]; - for (uint8 i=0; i<MAX_SPELL_EFFECTS; ++i) + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (AuraEffect * partAura = itr->second->GetPartAura(i)) - amounts[i]=partAura->GetAmount(); + amounts[i] = partAura->GetAmount(); else - amounts[i]=0; + amounts[i] = 0; } - CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2,maxduration,remaintime,remaincharges) " - "VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", - GetGUIDLow(), itr->second->GetCasterGUID(),(uint32)itr->second->GetId(), (uint32)itr->second->GetEffectMask(), - (int32)itr->second->GetStackAmount(), (int32)amounts[0], (int32)amounts[1], (int32)amounts[2] - ,int(itr->second->GetAuraMaxDuration()),int(itr->second->GetAuraDuration()),int(itr->second->GetAuraCharges())); + CharacterDatabase.PExecute("INSERT INTO character_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0,amount1,amount2,maxduration,remaintime,remaincharges) " + "VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%u')", + GetGUIDLow(), itr->second->GetCasterGUID(), itr->second->GetId(), itr->second->GetEffectMask(), + itr->second->GetStackAmount(), amounts[0], amounts[1], amounts[2], + itr->second->GetAuraMaxDuration(),itr->second->GetAuraDuration(),itr->second->GetAuraCharges()); } } @@ -16517,10 +16512,11 @@ void Player::_SaveInventory() { // force items in buyback slots to new state // and remove those that aren't already - for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; i++) + for (uint8 i = BUYBACK_SLOT_START; i < BUYBACK_SLOT_END; ++i) { Item *item = m_items[i]; - if (!item || item->GetState() == ITEM_NEW) continue; + if (!item || item->GetState() == ITEM_NEW) + continue; CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item->GetGUIDLow()); CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", item->GetGUIDLow()); m_items[i]->FSetState(ITEM_NEW); @@ -16528,16 +16524,15 @@ void Player::_SaveInventory() // update enchantment durations for (EnchantDurationList::iterator itr = m_enchantDuration.begin(); itr != m_enchantDuration.end(); ++itr) - { itr->item->SetEnchantmentDuration(itr->slot,itr->leftduration); - } // if no changes - if (m_itemUpdateQueue.empty()) return; + if (m_itemUpdateQueue.empty()) + return; // do not save if the update queue is corrupt bool error = false; - for (size_t i = 0; i < m_itemUpdateQueue.size(); i++) + for (size_t i = 0; i < m_itemUpdateQueue.size(); ++i) { Item *item = m_itemUpdateQueue[i]; if(!item || item->GetState() == ITEM_REMOVED) continue; @@ -19756,12 +19751,12 @@ bool Player::GetBGAccessByLevel(BattleGroundTypeId bgTypeId) const BGQueueIdBasedOnLevel Player::GetBattleGroundQueueIdFromLevel(BattleGroundTypeId bgTypeId) const { //returned to hardcoded version of this function, because there is no way to code it dynamic - uint32 level = getLevel(); - if( bgTypeId == BATTLEGROUND_AV ) + uint8 level = getLevel(); + if (bgTypeId == BATTLEGROUND_AV) level--; uint32 queue_id = (level / 10) - 1; // for ranges 0 - 19, 20 - 29, 30 - 39, 40 - 49, 50 - 59, 60 - 69, 70 -79, 80 - if( queue_id >= MAX_BATTLEGROUND_QUEUES ) + if (queue_id >= MAX_BATTLEGROUND_QUEUES) { sLog.outError("BattleGround: too high queue_id %u this shouldn't happen", queue_id); return QUEUE_ID_MAX_LEVEL_80; @@ -19772,11 +19767,11 @@ BGQueueIdBasedOnLevel Player::GetBattleGroundQueueIdFromLevel(BattleGroundTypeId float Player::GetReputationPriceDiscount( Creature const* pCreature ) const { FactionTemplateEntry const* vendor_faction = pCreature->getFactionTemplateEntry(); - if(!vendor_faction || !vendor_faction->faction) + if (!vendor_faction || !vendor_faction->faction) return 1.0f; ReputationRank rank = GetReputationRank(vendor_faction->faction); - if(rank <= REP_NEUTRAL) + if (rank <= REP_NEUTRAL) return 1.0f; return 1.0f - 0.05f* (rank - REP_NEUTRAL); @@ -19809,14 +19804,14 @@ bool Player::IsSpellFitByClassAndRace( uint32 spell_id ) const bool Player::HasQuestForGO(int32 GOId) const { - for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i ) + for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) { uint32 questid = GetQuestSlotQuestId(i); - if ( questid == 0 ) + if (questid == 0) continue; QuestStatusMap::const_iterator qs_itr = mQuestStatus.find(questid); - if(qs_itr == mQuestStatus.end()) + if (qs_itr == mQuestStatus.end()) continue; QuestStatusData const& qs = qs_itr->second; @@ -19824,18 +19819,18 @@ bool Player::HasQuestForGO(int32 GOId) const if (qs.m_status == QUEST_STATUS_INCOMPLETE) { Quest const* qinfo = objmgr.GetQuestTemplate(questid); - if(!qinfo) + if (!qinfo) continue; - if(GetGroup() && GetGroup()->isRaidGroup() && qinfo->GetType() != QUEST_TYPE_RAID) + if (GetGroup() && GetGroup()->isRaidGroup() && qinfo->GetType() != QUEST_TYPE_RAID) continue; - for (int j = 0; j < QUEST_OBJECTIVES_COUNT; j++) + for (uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { - if (qinfo->ReqCreatureOrGOId[j]>=0) //skip non GO case + if (qinfo->ReqCreatureOrGOId[j] >= 0) //skip non GO case continue; - if((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) + if ((-1)*GOId == qinfo->ReqCreatureOrGOId[j] && qs.m_creatureOrGOcount[j] < qinfo->ReqCreatureOrGOCount[j]) return true; } } @@ -19845,23 +19840,22 @@ bool Player::HasQuestForGO(int32 GOId) const void Player::UpdateForQuestWorldObjects() { - if(m_clientGUIDs.empty()) + if (m_clientGUIDs.empty()) return; UpdateData udata; WorldPacket packet; for (ClientGUIDs::iterator itr=m_clientGUIDs.begin(); itr!=m_clientGUIDs.end(); ++itr) { - if(IS_GAMEOBJECT_GUID(*itr)) + if (IS_GAMEOBJECT_GUID(*itr)) { - GameObject *obj = HashMapHolder<GameObject>::Find(*itr); - if(obj) + if (GameObject *obj = HashMapHolder<GameObject>::Find(*itr)) obj->BuildValuesUpdateBlockForPlayer(&udata,this); } - else if(IS_CRE_OR_VEH_GUID(*itr)) + else if (IS_CRE_OR_VEH_GUID(*itr)) { Creature *obj = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr); - if(!obj) + if (!obj) continue; // check if this unit requires quest specific flags @@ -19870,13 +19864,11 @@ void Player::UpdateForQuestWorldObjects() SpellClickInfoMapBounds clickPair = objmgr.GetSpellClickInfoMapBounds(obj->GetEntry()); for (SpellClickInfoMap::const_iterator _itr = clickPair.first; _itr != clickPair.second; ++_itr) - { if(_itr->second.questStart || _itr->second.questEnd) { obj->BuildCreateUpdateBlockForPlayer(&udata,this); break; } - } } } udata.BuildPacket(&packet); @@ -19885,18 +19877,18 @@ void Player::UpdateForQuestWorldObjects() void Player::SummonIfPossible(bool agree) { - if(!agree) + if (!agree) { m_summon_expire = 0; return; } // expire and auto declined - if(m_summon_expire < time(NULL)) + if (m_summon_expire < time(NULL)) return; // stop taxi flight at summon - if(isInFlight()) + if (isInFlight()) { GetMotionMaster()->MovementExpired(); CleanupAfterTaxiFlight(); @@ -19904,7 +19896,7 @@ void Player::SummonIfPossible(bool agree) // drop flag at summon // this code can be reached only when GM is summoning player who carries flag, because player should be immune to summoning spells when he carries flag - if(BattleGround *bg = GetBattleGround()) + if (BattleGround *bg = GetBattleGround()) bg->EventPlayerDroppedFlag(this); m_summon_expire = 0; @@ -19914,11 +19906,11 @@ void Player::SummonIfPossible(bool agree) TeleportTo(m_summon_mapid, m_summon_x, m_summon_y, m_summon_z,GetOrientation()); } -void Player::RemoveItemDurations( Item *item ) +void Player::RemoveItemDurations(Item *item) { for (ItemDurationList::iterator itr = m_itemDuration.begin(); itr != m_itemDuration.end(); ++itr) { - if(*itr==item) + if(*itr == item) { m_itemDuration.erase(itr); break; @@ -19926,9 +19918,9 @@ void Player::RemoveItemDurations( Item *item ) } } -void Player::AddItemDurations( Item *item ) +void Player::AddItemDurations(Item *item) { - if(item->GetUInt32Value(ITEM_FIELD_DURATION)) + if (item->GetUInt32Value(ITEM_FIELD_DURATION)) { m_itemDuration.push_back(item); item->SendTimeUpdate(this); @@ -19938,7 +19930,7 @@ void Player::AddItemDurations( Item *item ) void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/) { Item *offItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND); - if(!offItem) + if (!offItem) return; // need unequip offhand for 2h-weapon without TitanGrip (in any from hands) @@ -19946,11 +19938,11 @@ void Player::AutoUnequipOffhandIfNeed(bool force /*= false*/) return; ItemPosCountVec off_dest; - uint8 off_msg = CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ); - if( off_msg == EQUIP_ERR_OK ) + uint8 off_msg = CanStoreItem(NULL_BAG, NULL_SLOT, off_dest, offItem, false); + if (off_msg == EQUIP_ERR_OK) { RemoveItem(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND, true); - StoreItem( off_dest, offItem, true ); + StoreItem(off_dest, offItem, true); } else { @@ -19974,18 +19966,18 @@ OutdoorPvP * Player::GetOutdoorPvP() const bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem) { - if(spellInfo->EquippedItemClass < 0) + if (spellInfo->EquippedItemClass < 0) return true; // scan other equipped items for same requirements (mostly 2 daggers/etc) // for optimize check 2 used cases only - switch(spellInfo->EquippedItemClass) + switch (spellInfo->EquippedItemClass) { case ITEM_CLASS_WEAPON: { for (uint8 i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if(item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; break; } @@ -19994,17 +19986,17 @@ bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item cons // tabard not have dependent spells for (uint8 i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, i )) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if(item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // shields can be equipped to offhand slot if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if(item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; // ranged slot can have some armor subclasses if(Item *item = GetUseableItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_RANGED)) - if(item!=ignoreItem && item->IsFitToSpellRequirements(spellInfo)) + if(item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; break; @@ -20077,9 +20069,9 @@ uint32 Player::GetResurrectionSpellId() for (AuraEffectList::const_iterator itr = dummyAuras.begin(); itr != dummyAuras.end(); ++itr) { // Soulstone Resurrection // prio: 3 (max, non death persistent) - if( prio < 2 && (*itr)->GetSpellProto()->SpellVisual[0] == 99 && (*itr)->GetSpellProto()->SpellIconID == 92 ) + if (prio < 2 && (*itr)->GetSpellProto()->SpellVisual[0] == 99 && (*itr)->GetSpellProto()->SpellIconID == 92 ) { - switch((*itr)->GetId()) + switch ((*itr)->GetId()) { case 20707: spell_id = 3026; break; // rank 1 case 20762: spell_id = 20758; break; // rank 2 @@ -20096,7 +20088,7 @@ uint32 Player::GetResurrectionSpellId() prio = 3; } // Twisting Nether // prio: 2 (max) - else if((*itr)->GetId()==23701 && roll_chance_i(10)) + else if ((*itr)->GetId()==23701 && roll_chance_i(10)) { prio = 2; spell_id = 23700; @@ -20104,7 +20096,7 @@ uint32 Player::GetResurrectionSpellId() } // Reincarnation (passive spell) // prio: 1 // Glyph of Renewed Life - if(prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasAura(58059) || HasItemCount(17030,1))) + if (prio < 1 && HasSpell(20608) && !HasSpellCooldown(21169) && (HasAura(58059) || HasItemCount(17030,1))) spell_id = 21169; return spell_id; @@ -20113,11 +20105,11 @@ uint32 Player::GetResurrectionSpellId() // Used in triggers for check "Only to targets that grant experience or honor" req bool Player::isHonorOrXPTarget(Unit* pVictim) { - uint32 v_level = pVictim->getLevel(); - uint32 k_grey = Trinity::XP::GetGrayLevel(getLevel()); + uint8 v_level = pVictim->getLevel(); + uint8 k_grey = Trinity::XP::GetGrayLevel(getLevel()); // Victim level less gray level - if(v_level<=k_grey) + if(v_level <= k_grey) return false; if(pVictim->GetTypeId() == TYPEID_UNIT) @@ -20702,7 +20694,7 @@ bool Player::CanCaptureTowerPoint() uint32 Player::GetBarberShopCost(uint8 newhairstyle, uint8 newhaircolor, uint8 newfacialhair) { - uint32 level = getLevel(); + uint8 level = getLevel(); if(level > GT_MAX_LEVEL) level = GT_MAX_LEVEL; // max level in this dbc @@ -20740,7 +20732,7 @@ void Player::InitGlyphsForLevel() if(gs->Order) SetGlyphSlot(gs->Order - 1, gs->Id); - uint32 level = getLevel(); + uint8 level = getLevel(); uint32 value = 0; // 0x3F = 0x01 | 0x02 | 0x04 | 0x08 | 0x10 | 0x20 for 80 level @@ -21031,30 +21023,30 @@ void Player::_LoadSkills() } // special settings - if(getClass()==CLASS_DEATH_KNIGHT) + if (getClass() == CLASS_DEATH_KNIGHT) { - uint32 base_level = std::min(getLevel(),sWorld.getConfig (CONFIG_START_HEROIC_PLAYER_LEVEL)); - if(base_level < 1) + uint8 base_level = std::min(getLevel(),uint8(sWorld.getConfig(CONFIG_START_HEROIC_PLAYER_LEVEL))); + if (base_level < 1) base_level = 1; - uint32 base_skill = (base_level-1)*5; // 270 at starting level 55 - if(base_skill < 1) + uint8 base_skill = (base_level-1)*5; // 270 at starting level 55 + if (base_skill < 1) base_skill = 1; // skill mast be known and then > 0 in any case - if(GetPureSkillValue (SKILL_FIRST_AID) < base_skill) + if (GetPureSkillValue(SKILL_FIRST_AID) < base_skill) SetSkill(SKILL_FIRST_AID,base_skill, base_skill); - if(GetPureSkillValue (SKILL_AXES) < base_skill) + if (GetPureSkillValue(SKILL_AXES) < base_skill) SetSkill(SKILL_AXES, base_skill,base_skill); - if(GetPureSkillValue (SKILL_DEFENSE) < base_skill) + if (GetPureSkillValue(SKILL_DEFENSE) < base_skill) SetSkill(SKILL_DEFENSE, base_skill,base_skill); - if(GetPureSkillValue (SKILL_POLEARMS) < base_skill) + if (GetPureSkillValue(SKILL_POLEARMS) < base_skill) SetSkill(SKILL_POLEARMS, base_skill,base_skill); - if(GetPureSkillValue (SKILL_SWORDS) < base_skill) + if (GetPureSkillValue(SKILL_SWORDS) < base_skill) SetSkill(SKILL_SWORDS, base_skill,base_skill); - if(GetPureSkillValue (SKILL_2H_AXES) < base_skill) + if (GetPureSkillValue(SKILL_2H_AXES) < base_skill) SetSkill(SKILL_2H_AXES, base_skill,base_skill); - if(GetPureSkillValue (SKILL_2H_SWORDS) < base_skill) + if (GetPureSkillValue(SKILL_2H_SWORDS) < base_skill) SetSkill(SKILL_2H_SWORDS, base_skill,base_skill); - if(GetPureSkillValue (SKILL_UNARMED) < base_skill) + if (GetPureSkillValue(SKILL_UNARMED) < base_skill) SetSkill(SKILL_UNARMED, base_skill,base_skill); } } @@ -21062,17 +21054,17 @@ void Player::_LoadSkills() uint32 Player::GetPhaseMaskForSpawn() const { uint32 phase = PHASEMASK_NORMAL; - if(!isGameMaster()) + if (!isGameMaster()) phase = GetPhaseMask(); else { AuraEffectList const& phases = GetAurasByType(SPELL_AURA_PHASE); - if(!phases.empty()) + if (!phases.empty()) phase = phases.front()->GetMiscValue(); } // some aura phases include 1 normal map in addition to phase itself - if(uint32 n_phase = phase & ~PHASEMASK_NORMAL) + if (uint32 n_phase = phase & ~PHASEMASK_NORMAL) return n_phase; return PHASEMASK_NORMAL; @@ -21083,28 +21075,28 @@ uint8 Player::CanEquipUniqueItem(Item* pItem, uint8 eslot, uint32 limit_count) c ItemPrototype const* pProto = pItem->GetProto(); // proto based limitations - if(uint8 res = CanEquipUniqueItem(pProto,eslot,limit_count)) + if (uint8 res = CanEquipUniqueItem(pProto,eslot,limit_count)) return res; // check unique-equipped on gems for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+3; ++enchant_slot) { uint32 enchant_id = pItem->GetEnchantmentId(EnchantmentSlot(enchant_slot)); - if(!enchant_id) + if (!enchant_id) continue; SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!enchantEntry) + if (!enchantEntry) continue; ItemPrototype const* pGem = objmgr.GetItemPrototype(enchantEntry->GemID); - if(!pGem) + if (!pGem) continue; // include for check equip another gems with same limit category for not equipped item (and then not counted) uint32 gem_limit_count = !pItem->IsEquipped() && pGem->ItemLimitCategory ? pItem->GetGemCountWithLimitCategory(pGem->ItemLimitCategory) : 1; - if(uint8 res = CanEquipUniqueItem(pGem, eslot,gem_limit_count)) + if (uint8 res = CanEquipUniqueItem(pGem, eslot,gem_limit_count)) return res; } @@ -21117,7 +21109,7 @@ uint8 Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_s if (itemProto->Flags & ITEM_FLAGS_UNIQUE_EQUIPPED) { // there is an equip limit on this item - if(HasItemOrGemWithIdEquipped(itemProto->ItemId,1,except_slot)) + if (HasItemOrGemWithIdEquipped(itemProto->ItemId,1,except_slot)) return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; } @@ -21125,14 +21117,14 @@ uint8 Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_s if (itemProto->ItemLimitCategory) { ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(itemProto->ItemLimitCategory); - if(!limitEntry) + if (!limitEntry) return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; - if(limit_count > limitEntry->maxCount) + if (limit_count > limitEntry->maxCount) return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; // attempt add too many limit category items (gems) // there is an equip limit on this item - if(HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory,limitEntry->maxCount-limit_count+1,except_slot)) + if (HasItemOrGemWithLimitCategoryEquipped(itemProto->ItemLimitCategory,limitEntry->maxCount-limit_count+1,except_slot)) return EQUIP_ERR_ITEM_UNIQUE_EQUIPABLE; } @@ -21156,7 +21148,7 @@ void Player::HandleFall(MovementInfo const& movementInfo) float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f; - if(damageperc >0 ) + if (damageperc > 0) { uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL)); diff --git a/src/game/Player.h b/src/game/Player.h index 3b7b8143a74..8c0212f3ded 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -847,7 +847,7 @@ class TRINITY_DLL_SPEC PlayerTaxi PlayerTaxi(); ~PlayerTaxi() {} // Nodes - void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level); + void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level); void LoadTaxiMask(const char* data); bool IsTaximaskNodeKnown(uint32 nodeidx) const @@ -1010,7 +1010,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } void GiveXP(uint32 xp, Unit* victim); - void GiveLevel(uint32 level); + void GiveLevel(uint8 level); void InitStatsForLevel(bool reapplyMods = false); @@ -2347,8 +2347,8 @@ Spell * m_spellModTakingSpell; PlayerTalentMap *m_talents[MAX_TALENT_SPECS]; uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use - uint32 m_activeSpec; - uint32 m_specsCount; + uint8 m_activeSpec; + uint8 m_specsCount; uint32 m_Glyphs[MAX_TALENT_SPECS][MAX_GLYPH_SLOT_INDEX]; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 4d947f41bde..c55001a2d84 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -3533,49 +3533,47 @@ void Spell::EffectProficiency(uint32 /*i*/) void Spell::EffectSummonType(uint32 i) { uint32 entry = m_spellInfo->EffectMiscValue[i]; - if(!entry) + if (!entry) return; SummonPropertiesEntry const *properties = sSummonPropertiesStore.LookupEntry(m_spellInfo->EffectMiscValueB[i]); - if(!properties) + if (!properties) { sLog.outError("EffectSummonType: Unhandled summon type %u", m_spellInfo->EffectMiscValueB[i]); return; } - if(!m_originalCaster) + if (!m_originalCaster) return; int32 duration = GetSpellDuration(m_spellInfo); - if(Player* modOwner = m_originalCaster->GetSpellModOwner()) + if (Player* modOwner = m_originalCaster->GetSpellModOwner()) modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration); Position pos; GetSummonPosition(i, pos); /*//totem must be at same Z in case swimming caster and etc. - if( fabs( z - m_caster->GetPositionZ() ) > 5 ) + if (fabs(z - m_caster->GetPositionZ()) > 5) z = m_caster->GetPositionZ(); - uint32 level = m_caster->getLevel(); + uint8 level = m_caster->getLevel(); // level of creature summoned using engineering item based at engineering skill level - if(m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem) + if (m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem) { ItemPrototype const *proto = m_CastItem->GetProto(); - if(proto && proto->RequiredSkill == SKILL_ENGINERING) + if (proto && proto->RequiredSkill == SKILL_ENGINERING) { uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING); - if(skill202) - { + if (skill202) level = skill202/5; - } } }*/ TempSummon *summon = NULL; - switch(properties->Category) + switch (properties->Category) { default: if (properties->Flags & 512) @@ -3583,7 +3581,7 @@ void Spell::EffectSummonType(uint32 i) SummonGuardian(i, entry, properties); break; } - switch(properties->Type) + switch (properties->Type) { case SUMMON_TYPE_PET: case SUMMON_TYPE_GUARDIAN: @@ -3598,10 +3596,10 @@ void Spell::EffectSummonType(uint32 i) case SUMMON_TYPE_TOTEM: { summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster); - if(!summon || !summon->isTotem()) + if (!summon || !summon->isTotem()) return; - if(damage) // if not spell info, DB values used + if (damage) // if not spell info, DB values used { summon->SetMaxHealth(damage); summon->SetHealth(damage); @@ -3609,7 +3607,7 @@ void Spell::EffectSummonType(uint32 i) //summon->SetUInt32Value(UNIT_CREATED_BY_SPELL,m_spellInfo->Id); - if(m_originalCaster->GetTypeId() == TYPEID_PLAYER + if (m_originalCaster->GetTypeId() == TYPEID_PLAYER && properties->Slot >= SUMMON_SLOT_TOTEM && properties->Slot < MAX_TOTEM_SLOT) { @@ -3626,7 +3624,7 @@ void Spell::EffectSummonType(uint32 i) case SUMMON_TYPE_MINIPET: { summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster); - if(!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION)) + if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION)) return; //summon->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as summon... @@ -3639,7 +3637,7 @@ void Spell::EffectSummonType(uint32 i) std::string name = m_originalCaster->GetName(); name.append(petTypeSuffix[3]); - summon->SetName( name ); + summon->SetName(name); break; } default: @@ -3681,30 +3679,28 @@ void Spell::EffectSummonType(uint32 i) float x, y, z; m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_caster); - if(!summon || !summon->IsVehicle()) + if (!summon || !summon->IsVehicle()) return; - if(damage) + if (damage) m_caster->CastSpell(summon, damage, true); m_caster->EnterVehicle(summon->GetVehicleKit()); break; } } - if(summon) - { + if (summon) summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - } } void Spell::EffectLearnSpell(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) { - if(m_caster->GetTypeId() == TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) EffectLearnPetSpell(i); return; @@ -3712,10 +3708,10 @@ void Spell::EffectLearnSpell(uint32 i) Player *player = (Player*)unitTarget; - uint32 spellToLearn = ((m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) || (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN_PET)) ? damage : m_spellInfo->EffectTriggerSpell[i]; + uint32 spellToLearn = (m_spellInfo->Id == SPELL_ID_GENERIC_LEARN || m_spellInfo->Id == SPELL_ID_GENERIC_LEARN_PET) ? damage : m_spellInfo->EffectTriggerSpell[i]; player->learnSpell(spellToLearn,false); - sLog.outDebug( "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow() ); + sLog.outDebug("Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow()); } typedef std::list< std::pair<uint32, uint64> > DispelList; @@ -3728,7 +3724,7 @@ void Spell::EffectDispel(uint32 i) // Create dispel mask by dispel type uint32 dispel_type = m_spellInfo->EffectMiscValue[i]; - uint32 dispelMask = GetDispellMask( DispelType(dispel_type) ); + uint32 dispelMask = GetDispellMask( DispelType(dispel_type)); Unit::AuraMap const& auras = unitTarget->GetAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) { @@ -3817,7 +3813,7 @@ void Spell::EffectDispel(uint32 i) void Spell::EffectDualWield(uint32 /*i*/) { unitTarget->SetCanDualWield(true); - if(unitTarget->GetTypeId() == TYPEID_UNIT) + if (unitTarget->GetTypeId() == TYPEID_UNIT) ((Creature*)unitTarget)->UpdateDamagePhysical(OFF_ATTACK); } @@ -3834,12 +3830,12 @@ void Spell::EffectDistract(uint32 /*i*/) return; // target must be OK to do this - if( unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING ) ) + if (unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING)) return; float angle = unitTarget->GetAngle(&m_targets.m_dstPos); - if ( unitTarget->GetTypeId() == TYPEID_PLAYER ) + if (unitTarget->GetTypeId() == TYPEID_PLAYER) { // For players just turn them ((Player*)unitTarget)->SetPosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false); @@ -3856,15 +3852,15 @@ void Spell::EffectDistract(uint32 /*i*/) void Spell::EffectPickPocket(uint32 /*i*/) { - if( m_caster->GetTypeId() != TYPEID_PLAYER ) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; // victim must be creature and attackable - if( !unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget) ) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget)) return; // victim have to be alive and humanoid or undead - if( unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) + if (unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0) { int32 chance = 10 + int32(m_caster->getLevel()) - int32(unitTarget->getLevel()); @@ -3909,10 +3905,10 @@ void Spell::EffectAddFarsight(uint32 i) void Spell::EffectTeleUnitsFaceCaster(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(unitTarget->isInFlight()) + if (unitTarget->isInFlight()) return; float dis = m_caster->GetSpellRadiusForTarget(unitTarget, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); @@ -3925,10 +3921,10 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i) void Spell::EffectLearnSkill(uint32 i) { - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; - if(damage < 0) + if (damage < 0) return; uint32 skillid = m_spellInfo->EffectMiscValue[i]; @@ -3938,11 +3934,11 @@ void Spell::EffectLearnSkill(uint32 i) void Spell::EffectAddHonor(uint32 /*i*/) { - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; // not scale value for item based reward (/10 value expected) - if(m_CastItem) + if (m_CastItem) { ((Player*)unitTarget)->RewardHonor(NULL, 1, damage/10); sLog.outError("SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(),((Player*)unitTarget)->GetGUIDLow()); @@ -3950,7 +3946,7 @@ void Spell::EffectAddHonor(uint32 /*i*/) } // do not allow to add too many honor for player (50 * 21) = 1040 at level 70, or (50 * 31) = 1550 at level 80 - if( damage <= 50) + if (damage <= 50) { uint32 honor_reward = MaNGOS::Honor::hk_honor_at_level(unitTarget->getLevel(), damage); ((Player*)unitTarget)->RewardHonor(NULL, 1, honor_reward); @@ -3966,7 +3962,7 @@ void Spell::EffectAddHonor(uint32 /*i*/) void Spell::EffectTradeSkill(uint32 /*i*/) { - if(unitTarget->GetTypeId() != TYPEID_PLAYER) + if (unitTarget->GetTypeId() != TYPEID_PLAYER) return; // uint32 skillid = m_spellInfo->EffectMiscValue[i]; // uint16 skillmax = ((Player*)unitTarget)->(skillid); @@ -3975,7 +3971,7 @@ void Spell::EffectTradeSkill(uint32 /*i*/) void Spell::EffectEnchantItemPerm(uint32 effect_idx) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; if (!itemTarget) return; @@ -3986,7 +3982,7 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx) if (itemTarget->IsWeaponVellum() || itemTarget->IsArmorVellum()) { // destroy one vellum from stack - uint32 count=1; + uint32 count = 1; p_caster->DestroyItemCount(itemTarget,count,true); unitTarget=p_caster; // and add a scroll @@ -4010,7 +4006,7 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx) // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); - if(!item_owner) + if (!item_owner) return; if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) @@ -4033,7 +4029,7 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx) void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; if (!itemTarget) return; @@ -4069,10 +4065,10 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); - if(!item_owner) + if (!item_owner) return; - if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) { sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(),p_caster->GetSession()->GetAccountId(), @@ -4091,18 +4087,18 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx) void Spell::EffectEnchantItemTmp(uint32 i) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player* p_caster = (Player*)m_caster; - if(!itemTarget) + if (!itemTarget) return; uint32 enchant_id = m_spellInfo->EffectMiscValue[i]; // Shaman Rockbiter Weapon - if(i==0 && m_spellInfo->Effect[1]==SPELL_EFFECT_DUMMY) + if (i == 0 && m_spellInfo->Effect[1] == SPELL_EFFECT_DUMMY) { int32 enchnting_damage = CalculateDamage(1, NULL);//+1; @@ -4110,7 +4106,7 @@ void Spell::EffectEnchantItemTmp(uint32 i) // with already applied percent bonus from Elemental Weapons talent // Note: damage calculated (correctly) with rounding int32(float(v)) but // RW enchantments applied damage int32(float(v)+0.5), this create 0..1 difference sometime - switch(enchnting_damage) + switch (enchnting_damage) { // Rank 1 case 2: enchant_id = 29; break; // 0% [ 7% == 2, 14% == 2, 20% == 2] @@ -4162,7 +4158,7 @@ void Spell::EffectEnchantItemTmp(uint32 i) } SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); - if(!pEnchant) + if (!pEnchant) { sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",m_spellInfo->Id,i,enchant_id); return; @@ -4172,26 +4168,26 @@ void Spell::EffectEnchantItemTmp(uint32 i) uint32 duration; // rogue family enchantments exception by duration - if(m_spellInfo->Id == 38615) + if (m_spellInfo->Id == 38615) duration = 1800; // 30 mins // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints) - else if(m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE) + else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE) duration = 3600; // 1 hour // shaman family enchantments - else if(m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN) + else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN) duration = 1800; // 30 mins // other cases with this SpellVisual already selected - else if(m_spellInfo->SpellVisual[0] == 215) + else if (m_spellInfo->SpellVisual[0] == 215) duration = 1800; // 30 mins // some fishing pole bonuses - else if(m_spellInfo->SpellVisual[0] == 563) + else if (m_spellInfo->SpellVisual[0] == 563) duration = 600; // 10 mins // shaman rockbiter enchantments - else if(m_spellInfo->SpellVisual[0] == 0) + else if (m_spellInfo->SpellVisual[0] == 0) duration = 1800; // 30 mins - else if(m_spellInfo->Id == 29702) + else if (m_spellInfo->Id == 29702) duration = 300; // 5 mins - else if(m_spellInfo->Id == 37360) + else if (m_spellInfo->Id == 37360) duration = 300; // 5 mins // default case else @@ -4199,10 +4195,10 @@ void Spell::EffectEnchantItemTmp(uint32 i) // item can be in trade slot and have owner diff. from caster Player* item_owner = itemTarget->GetOwner(); - if(!item_owner) + if (!item_owner) return; - if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) + if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) ) { sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)", p_caster->GetName(), p_caster->GetSession()->GetAccountId(), @@ -4221,21 +4217,21 @@ void Spell::EffectEnchantItemTmp(uint32 i) void Spell::EffectTameCreature(uint32 /*i*/) { - if(m_caster->GetPetGUID()) + if (m_caster->GetPetGUID()) return; - if(!unitTarget) + if (!unitTarget) return; - if(unitTarget->GetTypeId() != TYPEID_UNIT) + if (unitTarget->GetTypeId() != TYPEID_UNIT) return; Creature* creatureTarget = (Creature*)unitTarget; - if(creatureTarget->isPet()) + if (creatureTarget->isPet()) return; - if(m_caster->getClass() != CLASS_HUNTER) + if (m_caster->getClass() != CLASS_HUNTER) return; // cast finish successfully @@ -4243,13 +4239,13 @@ void Spell::EffectTameCreature(uint32 /*i*/) finish(); Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget,m_spellInfo->Id); - if(!pet) // in versy specific state like near world end/etc. + if (!pet) // in very specific state like near world end/etc. return; // "kill" original creature creatureTarget->ForcedDespawn(); - uint32 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel(); + uint8 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel(); // prepare visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1); @@ -4265,7 +4261,7 @@ void Spell::EffectTameCreature(uint32 /*i*/) pet->InitTalentForLevel(); - if(m_caster->GetTypeId() == TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) { pet->SavePetToDB(PET_SAVE_AS_CURRENT); ((Player*)m_caster)->PetSpellInitialize(); @@ -4275,7 +4271,7 @@ void Spell::EffectTameCreature(uint32 /*i*/) void Spell::EffectSummonPet(uint32 i) { Player *owner = NULL; - if(m_originalCaster) + if (m_originalCaster) { if(m_originalCaster->GetTypeId() == TYPEID_PLAYER) owner = (Player*)m_originalCaster; @@ -4285,7 +4281,7 @@ void Spell::EffectSummonPet(uint32 i) uint32 petentry = m_spellInfo->EffectMiscValue[i]; - if(!owner) + if (!owner) { SummonPropertiesEntry const *properties = sSummonPropertiesStore.LookupEntry(67); if(properties) @@ -4296,12 +4292,12 @@ void Spell::EffectSummonPet(uint32 i) Pet *OldSummon = owner->GetPet(); // if pet requested type already exist - if( OldSummon ) + if (OldSummon) { - if(petentry == 0 || OldSummon->GetEntry() == petentry) + if (petentry == 0 || OldSummon->GetEntry() == petentry) { // pet in corpse state can't be summoned - if( OldSummon->isDead() ) + if (OldSummon->isDead()) return; assert(OldSummon->GetMap() == owner->GetMap()); @@ -4316,14 +4312,13 @@ void Spell::EffectSummonPet(uint32 i) //OldSummon->SetMap(owner->GetMap()); //owner->GetMap()->Add((Creature*)OldSummon); - if(owner->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) - { + if (owner->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) ((Player*)owner)->PetSpellInitialize(); - } + return; } - if(owner->GetTypeId() == TYPEID_PLAYER) + if (owner->GetTypeId() == TYPEID_PLAYER) ((Player*)owner)->RemovePet(OldSummon,(OldSummon->getPetType()==HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT),false); else return; @@ -4332,12 +4327,12 @@ void Spell::EffectSummonPet(uint32 i) float x, y, z; owner->GetClosePoint(x, y, z, owner->GetObjectSize()); Pet* pet = owner->SummonPet(petentry, x, y, z, owner->GetOrientation(), SUMMON_PET, 0); - if(!pet) + if (!pet) return; - if(m_caster->GetTypeId() == TYPEID_UNIT) + if (m_caster->GetTypeId() == TYPEID_UNIT) { - if ( ((Creature*)m_caster)->isTotem() ) + if (((Creature*)m_caster)->isTotem()) pet->SetReactState(REACT_AGGRESSIVE); else pet->SetReactState(REACT_DEFENSIVE); @@ -4347,25 +4342,25 @@ void Spell::EffectSummonPet(uint32 i) // generate new name for summon pet std::string new_name=objmgr.GeneratePetName(petentry); - if(!new_name.empty()) + if (!new_name.empty()) pet->SetName(new_name); } void Spell::EffectLearnPetSpell(uint32 i) { - if(m_caster->GetTypeId() != TYPEID_PLAYER) + if (m_caster->GetTypeId() != TYPEID_PLAYER) return; Player *_player = (Player*)m_caster; Pet *pet = _player->GetPet(); - if(!pet) + if (!pet) return; - if(!pet->isAlive()) + if (!pet->isAlive()) return; SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]); - if(!learn_spellproto) + if (!learn_spellproto) return; pet->learnSpell(learn_spellproto->Id); @@ -4389,20 +4384,20 @@ void Spell::EffectTaunt(uint32 /*i*/) } // Also use this effect to set the taunter's threat to the taunted creature's highest value - if(unitTarget->getThreatManager().getCurrentVictim()) + if (unitTarget->getThreatManager().getCurrentVictim()) { float myThreat = unitTarget->getThreatManager().getThreat(m_caster); float itsThreat = unitTarget->getThreatManager().getCurrentVictim()->getThreat(); - if(itsThreat > myThreat) + if (itsThreat > myThreat) unitTarget->getThreatManager().addThreat(m_caster, itsThreat - myThreat); } //Set aggro victim to caster - if( !unitTarget->getThreatManager().getOnlineContainer().empty() ) - if(HostilReference* forcedVictim = unitTarget->getThreatManager().getOnlineContainer().getReferenceByTarget(m_caster)) + if (!unitTarget->getThreatManager().getOnlineContainer().empty()) + if (HostilReference* forcedVictim = unitTarget->getThreatManager().getOnlineContainer().getReferenceByTarget(m_caster)) unitTarget->getThreatManager().setCurrentVictim(forcedVictim); - if(((Creature*)unitTarget)->IsAIEnabled && !((Creature*)unitTarget)->HasReactState(REACT_PASSIVE)) + if (((Creature*)unitTarget)->IsAIEnabled && !((Creature*)unitTarget)->HasReactState(REACT_PASSIVE)) ((Creature*)unitTarget)->AI()->AttackStart(m_caster); } @@ -4412,23 +4407,23 @@ void Spell::EffectWeaponDmg(uint32 i) void Spell::SpellDamageWeaponDmg(uint32 i) { - if(!unitTarget) + if (!unitTarget) return; - if(!unitTarget->isAlive()) + if (!unitTarget->isAlive()) return; // multiple weapon dmg effect workaround // execute only the last weapon damage // and handle all effects at once - for (int j = i+1; j < 3; ++j) + for (uint32 j = i + 1; j < 3; ++j) { - switch(m_spellInfo->Effect[j]) + switch (m_spellInfo->Effect[j]) { case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: case SPELL_EFFECT_NORMALIZED_WEAPON_DMG: case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE: - return; // we must calculate only at last weapon effect + return; // we must calculate only at last weapon effect break; } } @@ -4438,12 +4433,12 @@ void Spell::SpellDamageWeaponDmg(uint32 i) int32 fixed_bonus = 0; int32 spell_bonus = 0; // bonus specific for spell - switch(m_spellInfo->SpellFamilyName) + switch (m_spellInfo->SpellFamilyName) { case SPELLFAMILY_WARRIOR: { // Devastate bonus and sunder armor refresh - if(m_spellInfo->SpellFamilyFlags[1] & 0x40) + if (m_spellInfo->SpellFamilyFlags[1] & 0x40) { if (m_caster->GetTypeId() != TYPEID_PLAYER) return; @@ -4457,7 +4452,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) stack = aur->GetStackAmount(); } - for (uint8 j = 0; j < 3; j++) + for (uint8 j = 0; j < 3; ++j) { if(m_spellInfo->Effect[j] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG) { @@ -4473,7 +4468,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr) { // only highest rank is shown in spell book, so simply check if shown in spell book - if(!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED) + if (!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED) continue; SpellEntry const *spellProto = sSpellStore.LookupEntry(itr->first); @@ -4495,7 +4490,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) // Glyph of Devastate if (AuraEffect * aurEff = m_caster->GetAuraEffect(58388, 0)) count += aurEff->GetAmount(); - for (; count>0; count--) + for (; count > 0; --count) m_caster->CastSpell(unitTarget, spellInfo, true); if (stack) spell_bonus += stack * CalculateDamage(2, unitTarget); @@ -4505,26 +4500,26 @@ void Spell::SpellDamageWeaponDmg(uint32 i) case SPELLFAMILY_ROGUE: { // Hemorrhage - if(m_spellInfo->SpellFamilyFlags[0] & 0x2000000) + if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000) { - if(m_caster->GetTypeId() == TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) ((Player*)m_caster)->AddComboPoints(unitTarget, 1, this); } // Fan of Knives - else if(m_spellInfo->SpellFamilyFlags[1] & 0x40000) + else if (m_spellInfo->SpellFamilyFlags[1] & 0x40000) { // 50% more damage with daggers - if(m_caster->GetTypeId() == TYPEID_PLAYER) + if (m_caster->GetTypeId() == TYPEID_PLAYER) if (Item* item = ((Player*)m_caster)->GetWeaponForAttack(m_attackType, true)) if (item->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER) totalDamagePercentMod *= 1.5f; } // Mutilate (for each hand) - else if(m_spellInfo->SpellFamilyFlags[1] & 0x6) + else if (m_spellInfo->SpellFamilyFlags[1] & 0x6) { bool found = false; // fast check - if(unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON, m_spellInfo, m_caster)) + if (unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON, m_spellInfo, m_caster)) found = true; // full aura scan else @@ -4532,7 +4527,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i) Unit::AuraMap const& auras = unitTarget->GetAuras(); for (Unit::AuraMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr) { - if(itr->second->GetSpellProto()->Dispel == DISPEL_POISON) + if (itr->second->GetSpellProto()->Dispel == DISPEL_POISON) { found = true; break; @@ -4548,30 +4543,30 @@ void Spell::SpellDamageWeaponDmg(uint32 i) case SPELLFAMILY_PALADIN: { // Seal of Command - receive benefit from Spell Damage and Healing - if(m_spellInfo->SpellFamilyFlags[0] & 0x2000000) + if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000) { spell_bonus += int32(0.23f*m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo))); spell_bonus += int32(0.29f*m_caster->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo), unitTarget)); } // Seal of Command Unleashed - else if(m_spellInfo->Id==20467) + else if (m_spellInfo->Id==20467) { spell_bonus += int32(0.16f*m_caster->GetTotalAttackPowerValue(BASE_ATTACK)); spell_bonus += int32(0.25f*m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo))); } break; // Judgement of Blood/of the Martyr backlash damage (33%) - if(m_spellInfo->SpellFamilyFlags[0] & 0x0000000800000000LL && m_spellInfo->SpellIconID==153) + if (m_spellInfo->SpellFamilyFlags[0] & 0x0000000800000000LL && m_spellInfo->SpellIconID==153) { int32 damagePoint = m_damage * 33 / 100; - if(m_spellInfo->Id == 31898) + if (m_spellInfo->Id == 31898) m_caster->CastCustomSpell(m_caster, 32220, &damagePoint, NULL, NULL, true); else m_caster->CastCustomSpell(m_caster, 53725, &damagePoint, NULL, NULL, true); } // Seal of Blood/of the Martyr backlash damage (10%) - else if(m_spellInfo->SpellIconID==2293) + else if (m_spellInfo->SpellIconID==2293) { int32 damagePoint = m_damage * 10 / 100; if(m_spellInfo->Id == 31893) @@ -7234,10 +7229,10 @@ void Spell::EffectRedirectThreat(uint32 /*i*/) void Spell::EffectWMODamage(uint32 /*i*/) { - if(gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) + if (gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) { Unit *caster = m_originalCaster; - if(!caster) + if (!caster) return; FactionTemplateEntry const *casterft, *goft; @@ -7251,40 +7246,33 @@ void Spell::EffectWMODamage(uint32 /*i*/) void Spell::EffectWMORepair(uint32 /*i*/) { - if(gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) + if (gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING) gameObjTarget->Rebuild(); } void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *properties) { Unit *caster = m_originalCaster; - if(!caster) + if (!caster) return; - if(caster->isTotem()) + if (caster->isTotem()) caster = ((Totem*)caster)->GetOwner(); // in another case summon new - uint32 level = caster->getLevel(); + uint8 level = caster->getLevel(); // level of pet summoned using engineering item based at engineering skill level - if(m_CastItem && caster->GetTypeId() == TYPEID_PLAYER) - { - ItemPrototype const *proto = m_CastItem->GetProto(); - if(proto && proto->RequiredSkill == SKILL_ENGINERING) - { - uint16 skill202 = ((Player*)caster)->GetSkillValue(SKILL_ENGINERING); - if(skill202) - { - level = skill202/5; - } - } - } + if (m_CastItem && caster->GetTypeId() == TYPEID_PLAYER) + if (ItemPrototype const *proto = m_CastItem->GetProto()) + if (proto->RequiredSkill == SKILL_ENGINERING) + if (uint16 skill202 = ((Player*)caster)->GetSkillValue(SKILL_ENGINERING)) + level = skill202/5; //float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i])); float radius = 5.0f; int32 amount = damage > 0 ? damage : 1; - switch(m_spellInfo->Id) + switch (m_spellInfo->Id) { case 1122: // Inferno amount = 1; @@ -7303,13 +7291,13 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const * GetSummonPosition(i, pos, radius, count); TempSummon *summon = map->SummonCreature(entry, pos, properties, duration, caster); - if(!summon) + if (!summon) return; - if(summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) + if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN)) ((Guardian*)summon)->InitStatsForLevel(level); summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); - if(summon->HasUnitTypeMask(UNIT_MASK_MINION) && m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) + if (summon->HasUnitTypeMask(UNIT_MASK_MINION) && m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION) ((Minion*)summon)->SetFollowAngle(m_caster->GetAngle(summon)); summon->AI()->EnterEvadeMode(); @@ -7329,7 +7317,7 @@ void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 coun else { //This is a workaround. Do not have time to write much about it - switch(m_spellInfo->EffectImplicitTargetA[i]) + switch (m_spellInfo->EffectImplicitTargetA[i]) { case TARGET_MINION: case TARGET_DEST_CASTER_RANDOM: @@ -7365,7 +7353,7 @@ void Spell::EffectRenamePet(uint32 /*eff_idx*/) void Spell::EffectPlayMusic(uint32 i) { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; uint32 soundid = m_spellInfo->EffectMiscValue[i]; @@ -7383,7 +7371,7 @@ void Spell::EffectPlayMusic(uint32 i) void Spell::EffectSpecCount(uint32 /*eff_idx*/) { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; ((Player*)unitTarget)->UpdateSpecCount(damage); @@ -7391,7 +7379,7 @@ void Spell::EffectSpecCount(uint32 /*eff_idx*/) void Spell::EffectActivateSpec(uint32 /*eff_idx*/) { - if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) + if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; ((Player*)unitTarget)->ActivateSpec(damage-1); // damage is 1 or 2, spec is 0 or 1 diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp index 7a57f62d416..8eb38ed830b 100644 --- a/src/game/StatSystem.cpp +++ b/src/game/StatSystem.cpp @@ -443,19 +443,20 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo if (IsInFeralForm()) //check if player is druid and in cat or bear forms { - uint32 lvl = getLevel(); - if ( lvl > 60 ) lvl = 60; + uint8 lvl = getLevel(); + if (lvl > 60) + lvl = 60; - weapon_mindamage = lvl*0.85*att_speed; - weapon_maxdamage = lvl*1.25*att_speed; + weapon_mindamage = lvl*0.85f*att_speed; + weapon_maxdamage = lvl*1.25f*att_speed; } else if(!CanUseAttackType(attType)) //check if player not in form but still can't use (disarm case) { //cannot use ranged/off attack, set values to 0 if (attType != BASE_ATTACK) { - min_damage=0; - max_damage=0; + min_damage = 0; + max_damage = 0; return; } weapon_mindamage = BASE_MINDAMAGE; @@ -478,7 +479,7 @@ void Player::UpdateDamagePhysical(WeaponAttackType attType) CalculateMinMaxDamage(attType, false, true, mindamage, maxdamage); - switch(attType) + switch (attType) { case BASE_ATTACK: default: diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h index e67a5573ce2..4d3c773ac55 100644 --- a/src/game/TemporarySummon.h +++ b/src/game/TemporarySummon.h @@ -67,7 +67,7 @@ class Guardian : public Minion public: Guardian(SummonPropertiesEntry const *properties, Unit *owner); void InitStats(uint32 duration); - bool InitStatsForLevel(uint32 level); + bool InitStatsForLevel(uint8 level); void InitSummon(); bool UpdateStats(Stats stat); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index bb1ceed76b6..a16a74431ec 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -12026,12 +12026,12 @@ float Unit::GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange typ return m_weaponDamage[attType][type]; } -void Unit::SetLevel(uint32 lvl) +void Unit::SetLevel(uint8 lvl) { SetUInt32Value(UNIT_FIELD_LEVEL, lvl); // group update - if ((GetTypeId() == TYPEID_PLAYER) && ((Player*)this)->GetGroup()) + if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetGroup()) ((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL); } @@ -13513,7 +13513,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id) if(GetTypeId() == TYPEID_PLAYER) pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); - uint32 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel(); + uint8 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel(); if(!pet->InitStatsForLevel(level)) { diff --git a/src/game/Unit.h b/src/game/Unit.h index 6e6e4de94d6..7053b81ac5b 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1167,9 +1167,9 @@ class TRINITY_DLL_SPEC Unit : public WorldObject bool isTotem() const { return m_unitTypeMask & UNIT_MASK_TOTEM; } bool IsVehicle() const { return m_unitTypeMask & UNIT_MASK_VEHICLE; } - uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); } - virtual uint32 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); } - void SetLevel(uint32 lvl); + uint8 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); } + virtual uint8 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); } + void SetLevel(uint8 lvl); uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); } uint32 getRaceMask() const { return 1 << (getRace()-1); } uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); } diff --git a/src/game/World.h b/src/game/World.h index a5de315ad7a..cbfc5a9a36d 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -518,7 +518,7 @@ class World /// Get the maximum skill level a player can reach uint16 GetConfigMaxSkillValue() const { - uint32 lvl = getConfig(CONFIG_MAX_PLAYER_LEVEL); + uint8 lvl = getConfig(CONFIG_MAX_PLAYER_LEVEL); return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl*5; } |