Core/SpellMgr: Minor cleanup in code

This commit is contained in:
Spp-
2011-06-28 13:53:48 +02:00
parent 82f0152478
commit 3bf0029208
+14 -29
View File
@@ -35,7 +35,7 @@ SpellSelectTargetTypes SpellTargetType[TOTAL_SPELL_TARGETS];
SpellMgr::SpellMgr()
{
for (int i = 0; i < TOTAL_SPELL_EFFECTS; ++i)
for (uint8 i = 0; i < TOTAL_SPELL_EFFECTS; ++i)
{
switch (i)
{
@@ -99,7 +99,7 @@ SpellMgr::SpellMgr()
}
}
for (int i = 0; i < TOTAL_SPELL_TARGETS; ++i)
for (uint8 i = 0; i < TOTAL_SPELL_TARGETS; ++i)
{
switch (i)
{
@@ -322,8 +322,8 @@ uint32 GetSpellCastTime(SpellEntry const* spellInfo, Spell* spell)
int32 castTime = spellCastTimeEntry->CastTime;
if (spell && spell->GetCaster())
spell->GetCaster()->ModSpellCastTime(spellInfo, castTime, spell);
if (Unit *caster = (spell ? spell->GetCaster() : NULL))
caster->ModSpellCastTime(spellInfo, castTime, spell);
if (spellInfo->Attributes & SPELL_ATTR0_REQ_AMMO && (!spell || !(spell->IsAutoRepeat())))
castTime += 500;
@@ -1187,7 +1187,7 @@ void SpellMgr::LoadSpellTargetPositions()
}
bool found = false;
for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->EffectImplicitTargetA[i] == TARGET_DST_DB || spellInfo->EffectImplicitTargetB[i] == TARGET_DST_DB)
{
@@ -1420,7 +1420,7 @@ bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellPr
// spellFamilyName is Ok need check for spellFamilyMask if present
if (spellProcEvent->spellFamilyMask)
{
if ((spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags) == 0)
if (!(spellProcEvent->spellFamilyMask & procSpell->SpellFamilyFlags))
return false;
hasFamilyMask = true;
// Some spells are not considered as active even with have spellfamilyflags
@@ -1661,8 +1661,6 @@ void SpellMgr::LoadSpellGroups()
QueryResult result = WorldDatabase.Query("SELECT id, spell_id FROM spell_group");
if (!result)
{
sLog->outString();
sLog->outString(">> Loaded %u spell group definitions", count);
return;
@@ -1746,7 +1744,6 @@ void SpellMgr::LoadSpellGroupStackRules()
QueryResult result = WorldDatabase.Query("SELECT group_id, stack_rule FROM spell_group_stack_rules");
if (!result)
{
sLog->outString(">> Loaded 0 spell group stack rules");
sLog->outString();
return;
@@ -1793,8 +1790,6 @@ void SpellMgr::LoadSpellThreats()
QueryResult result = WorldDatabase.Query("SELECT entry, Threat FROM spell_threat");
if (!result)
{
sLog->outString(">> Loaded %u aggro generating spells", count);
sLog->outString();
return;
@@ -1844,7 +1839,7 @@ bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo)
return false;
// All stance spells. if any better way, change it.
for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
switch (spellInfo->SpellFamilyName)
{
@@ -2036,9 +2031,7 @@ int32 SpellMgr::CalculateSpellEffectBaseAmount(int32 value, SpellEntry const* sp
float SpellMgr::CalculateSpellEffectValueMultiplier(SpellEntry const* spellEntry, uint8 effIndex, Unit* caster, Spell* spell)
{
float multiplier = spellEntry->EffectValueMultiplier[effIndex];
if (caster)
if (Player* modOwner = caster->GetSpellModOwner())
if (Player* modOwner = (caster ? caster->GetSpellModOwner() : NULL))
modOwner->ApplySpellMod(spellEntry->Id, SPELLMOD_VALUE_MULTIPLIER, multiplier, spell);
return multiplier;
}
@@ -2046,9 +2039,7 @@ float SpellMgr::CalculateSpellEffectValueMultiplier(SpellEntry const* spellEntry
float SpellMgr::CalculateSpellEffectDamageMultiplier(SpellEntry const* spellEntry, uint8 effIndex, Unit* caster, Spell* spell)
{
float multiplier = spellEntry->EffectDamageMultiplier[effIndex];
if (caster)
if (Player* modOwner = caster->GetSpellModOwner())
if (Player* modOwner = (caster ? caster->GetSpellModOwner() : NULL))
modOwner->ApplySpellMod(spellEntry->Id, SPELLMOD_DAMAGE_MULTIPLIER, multiplier, spell);
return multiplier;
}
@@ -2060,7 +2051,7 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell
return spellInfo;
bool needRankSelection = false;
for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (IsPositiveEffect(spellInfo->Id, i) && (
spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA ||
@@ -2142,7 +2133,6 @@ void SpellMgr::LoadSpellLearnSpells()
QueryResult result = WorldDatabase.Query("SELECT entry, SpellID, Active FROM spell_learn_spell");
if (!result)
{
sLog->outString(">> Loaded 0 spell learn spells");
sLog->outString();
sLog->outErrorDb("`spell_learn_spell` table is empty!");
@@ -2207,7 +2197,7 @@ void SpellMgr::LoadSpellLearnSpells()
continue;
// talent or passive spells or skill-step spells auto-casted and not need dependent learning,
// pet teaching spells don't must be dependent learning (casted)
// pet teaching spells must not be dependent learning (casted)
// other required explicit dependent learning
dbc_node.autoLearned = entry->EffectImplicitTargetA[i] == TARGET_UNIT_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(spell) || IsSpellHaveEffect(entry, SPELL_EFFECT_SKILL_STEP);
@@ -2312,7 +2302,6 @@ void SpellMgr::LoadPetLevelupSpellMap()
for (uint32 i = 0; i < sCreatureFamilyStore.GetNumRows(); ++i)
{
CreatureFamilyEntry const *creatureFamily = sCreatureFamilyStore.LookupEntry(i);
if (!creatureFamily) // not exist
continue;
@@ -3289,13 +3278,13 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32
return false;
break;
}
case SPELL_OIL_REFINERY: // Oil Refinery - Isle of Conquest.
case SPELL_QUARRY: // Quarry - Isle of Conquest.
case 68719: // Oil Refinery - Isle of Conquest.
case 68720: // Quarry - Isle of Conquest.
{
if (player->GetBattlegroundTypeId() != BATTLEGROUND_IC || !player->GetBattleground())
return false;
uint8 nodeType = spellId == SPELL_OIL_REFINERY ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY;
uint8 nodeType = spellId == 68719 ? NODE_TYPE_REFINERY : NODE_TYPE_QUARRY;
uint8 nodeState = player->GetTeamId() == TEAM_ALLIANCE ? NODE_STATE_CONTROLLED_A : NODE_STATE_CONTROLLED_H;
BattlegroundIC* pIC = static_cast<BattlegroundIC*>(player->GetBattleground());
@@ -3460,7 +3449,6 @@ void SpellMgr::LoadSpellEnchantProcData()
QueryResult result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data");
if (!result)
{
sLog->outString(">> Loaded %u spell enchant proc event conditions", count);
sLog->outString();
return;
@@ -3505,7 +3493,6 @@ void SpellMgr::LoadSpellRequired()
if (!result)
{
sLog->outString(">> Loaded 0 spell required records");
sLog->outString();
sLog->outErrorDb("`spell_required` table is empty!");
@@ -3562,7 +3549,6 @@ void SpellMgr::LoadSpellRanks()
if (!result)
{
sLog->outString(">> Loaded 0 spell rank records");
sLog->outString();
sLog->outErrorDb("`spell_ranks` table is empty!");
@@ -4414,7 +4400,6 @@ void SpellMgr::LoadEnchantCustomAttr()
for (uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i)
{
SpellEntry * spellInfo = (SpellEntry*)GetSpellStore()->LookupEntry(i);
if (!spellInfo)
continue;