diff options
author | Naios <naios-dev@live.de> | 2015-03-11 09:29:20 +0100 |
---|---|---|
committer | Naios <naios-dev@live.de> | 2015-03-11 09:29:20 +0100 |
commit | 1920e9c4423b40b37e1a12f687b6e8ef427034f6 (patch) | |
tree | 9457f7660f7f4e83fb4d3e94cc0bbd8369aaaa20 /src | |
parent | 9a61049f88835fd6bdb75905f042583d038d0667 (diff) |
Scripts/Spells: Fix some issues detected by static analysis.
* Prefer prefix ++/-- operators for non-primitive types.
* Variable 'ownerBonus' is reassigned a value before the old one has been used.
* Fix a wrong type of ownerBonus, sometimes it is float sometimes uint32
Diffstat (limited to 'src')
-rw-r--r-- | src/server/scripts/Spells/spell_mage.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_pet.cpp | 56 |
2 files changed, 15 insertions, 43 deletions
diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index c5e2deaac24..8105f7de5ff 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -1301,7 +1301,7 @@ class spell_mage_ring_of_frost : public SpellScriptLoader GetTarget()->GetAllMinionsByEntry(MinionList, GetSpellInfo()->GetEffect(EFFECT_0)->MiscValue); // Get the last summoned RoF, save it and despawn older ones - for (std::list<TempSummon*>::iterator itr = MinionList.begin(); itr != MinionList.end(); itr++) + for (std::list<TempSummon*>::iterator itr = MinionList.begin(); itr != MinionList.end(); ++itr) { TempSummon* summon = (*itr); diff --git a/src/server/scripts/Spells/spell_pet.cpp b/src/server/scripts/Spells/spell_pet.cpp index d8b63150e3c..9a7ebc9625c 100644 --- a/src/server/scripts/Spells/spell_pet.cpp +++ b/src/server/scripts/Spells/spell_pet.cpp @@ -392,9 +392,7 @@ public: if (pet->IsPet()) if (Unit* owner = pet->ToPet()->GetOwner()) { - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetStat(STAT_INTELLECT), 30); + int32 const ownerBonus = CalculatePct(owner->GetStat(STAT_INTELLECT), 30); amount += ownerBonus; _tempBonus = ownerBonus; @@ -445,8 +443,7 @@ public: if (pet->IsPet()) if (Unit* owner = pet->ToPet()->GetOwner()) { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetArmor(), 35); + int32 const ownerBonus = CalculatePct(owner->GetArmor(), 35); amount += ownerBonus; } } @@ -457,8 +454,7 @@ public: if (pet->IsPet()) if (Unit* owner = pet->ToPet()->GetOwner()) { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FIRE), 40); + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FIRE), 40); amount += ownerBonus; } } @@ -504,8 +500,7 @@ public: if (pet->IsPet()) if (Unit* owner = pet->ToPet()->GetOwner()) { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FROST), 40); + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FROST), 40); amount += ownerBonus; } } @@ -516,8 +511,7 @@ public: if (pet->IsPet()) if (Unit* owner = pet->ToPet()->GetOwner()) { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_ARCANE), 40); + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_ARCANE), 40); amount += ownerBonus; } } @@ -528,8 +522,7 @@ public: if (pet->IsPet()) if (Unit* owner = pet->ToPet()->GetOwner()) { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_NATURE), 40); + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_NATURE), 40); amount += ownerBonus; } } @@ -570,8 +563,7 @@ public: if (pet->IsPet()) if (Unit* owner = pet->ToPet()->GetOwner()) { - float ownerBonus = 0.0f; - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_SHADOW), 40); + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_SHADOW), 40); amount += ownerBonus; } } @@ -906,7 +898,6 @@ public: if (Unit* owner = pet->ToPet()->GetOwner()) { float mod = 0.45f; - float ownerBonus = 0.0f; PetSpellMap::const_iterator itr = (pet->ToPet()->m_spells.find(62758)); // Wild Hunt rank 1 if (itr == pet->ToPet()->m_spells.end()) @@ -918,8 +909,7 @@ public: AddPct(mod, spellInfo->GetEffect(EFFECT_0)->CalcValue()); } - ownerBonus = owner->GetStat(STAT_STAMINA)*mod; - + int32 const ownerBonus = owner->GetStat(STAT_STAMINA) * mod; amount += ownerBonus; } } @@ -1043,10 +1033,7 @@ public: if (!owner) return; - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FROST), 40); - + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FROST), 40); amount += ownerBonus; } } @@ -1062,10 +1049,7 @@ public: if (!owner) return; - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FIRE), 40); - + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_FIRE), 40); amount += ownerBonus; } } @@ -1081,10 +1065,7 @@ public: if (!owner) return; - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_NATURE), 40); - + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_NATURE), 40); amount += ownerBonus; } } @@ -1130,10 +1111,7 @@ public: if (!owner) return; - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_SHADOW), 40); - + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_SHADOW), 40); amount += ownerBonus; } } @@ -1149,10 +1127,7 @@ public: if (!owner) return; - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_ARCANE), 40); - + int32 const ownerBonus = CalculatePct(owner->GetResistance(SPELL_SCHOOL_ARCANE), 40); amount += ownerBonus; } } @@ -1168,10 +1143,7 @@ public: if (!owner) return; - float ownerBonus = 0.0f; - - ownerBonus = CalculatePct(owner->GetArmor(), 35); - + int32 const ownerBonus = CalculatePct(owner->GetArmor(), 35); amount += ownerBonus; } } |