Core/Misc: fix issues reported by static analysis

This commit is contained in:
ariel- committed 2016-07-26 03:15:20 -03:00
1 parent 291a633c35
commit 88bb891a71
6 files changed
+55 -44

No files matched your search

+4 -4
View File
@@ -18534,10 +18534,10 @@ void Player::_LoadQuestStatusRewarded(PreparedQueryResult result)
if (uint32 talents = quest->GetBonusTalents())
AddQuestRewardedTalentCount(talents);
}
if (quest->CanIncreaseRewardedQuestCounters())
m_RewardedQuests.insert(quest_id);
if (quest->CanIncreaseRewardedQuestCounters())
m_RewardedQuests.insert(quest_id);
}
}
while (result->NextRow());
}
@@ -25207,7 +25207,7 @@ bool Player::CanFlyInZone(uint32 mapid, uint32 areaid) const
case 530: // Outland
// Draenei and blood elves starting zones belong to Outland map, but are not flyable
// These zones don't have flag AREA_FLAG_OUTLAND2
if (sAreaTableStore.LookupEntry(areaid)->flags & AREA_FLAG_OUTLAND2)
if (sAreaTableStore.AssertEntry(areaid)->flags & AREA_FLAG_OUTLAND2)
can_fly = true;
default:
break;
+1
View File
@@ -3365,6 +3365,7 @@ void SpellMgr::LoadSpellInfoCorrections()
case 42490: // Energized!
case 42492: // Cast Energized
spellInfo->AttributesEx |= SPELL_ATTR1_NO_THREAT;
break;
case 85123: // Siege Cannon (Tol Barad)
spellInfo->Effects[EFFECT_0].RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_200_YARDS);
spellInfo->Effects[EFFECT_0].TargetA = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ENTRY);
@@ -47,7 +47,22 @@ class boss_pit_lord_argaloth : public CreatureScript
struct boss_pit_lord_argalothAI : public BossAI
{
boss_pit_lord_argalothAI(Creature* creature) : BossAI(creature, DATA_ARGALOTH) { }
boss_pit_lord_argalothAI(Creature* creature) : BossAI(creature, DATA_ARGALOTH)
{
Initialize();
}
void Initialize()
{
first_fel_firestorm = false;
second_fel_firestorm = false;
}
void Reset() override
{
_Reset();
Initialize();
}
void EnterCombat(Unit* /*who*/) override
{
@@ -69,13 +84,12 @@ class boss_pit_lord_argaloth : public CreatureScript
void DamageTaken(Unit* /*attacker*/, uint32& damage) override
{
if (me->HealthBelowPctDamaged(66,damage) && !first_fel_firestorm)
if (me->HealthBelowPctDamaged(66, damage) && !first_fel_firestorm)
{
first_fel_firestorm = true;
DoCastAOE(SPELL_FEL_FIRESTORM);
}
else
if(me->HealthBelowPctDamaged(33,damage) && !second_fel_firestorm)
else if (me->HealthBelowPctDamaged(33, damage) && !second_fel_firestorm)
{
second_fel_firestorm = true;
DoCastAOE(SPELL_FEL_FIRESTORM);
@@ -120,6 +134,7 @@ class boss_pit_lord_argaloth : public CreatureScript
DoMeleeAttackIfReady();
}
private:
bool first_fel_firestorm;
bool second_fel_firestorm;
@@ -72,8 +72,7 @@ enum Events
EVENT_COUNTDOWN = 5,
EVENT_BERSERK = 6,
EVENT_SHARD_SPAWN_EFFECT = 7,
EVENT_UNLOCK_YELLSPAM = 8
EVENT_SHARD_SPAWN_EFFECT = 7
};
enum Emotes
@@ -108,8 +107,6 @@ class boss_baleroc : public CreatureScript
{
boss_balerocAI(Creature* creature) : BossAI(creature, DATA_BALEROC) { }
bool _canYellKilledPlayer;
void Reset() override
{
_Reset();
@@ -156,12 +153,11 @@ class boss_baleroc : public CreatureScript
void KilledUnit(Unit* who) override
{
if (who->GetTypeId() == TYPEID_PLAYER && _canYellKilledPlayer)
{
_canYellKilledPlayer = false;
events.ScheduleEvent(EVENT_UNLOCK_YELLSPAM, 8000);
if (who->GetTypeId() != TYPEID_PLAYER)
return;
if (!(rand32() % 5))
Talk(EMOTE_KILL);
}
}
void JustDied(Unit* /*killer*/) override
@@ -281,9 +277,6 @@ class boss_baleroc : public CreatureScript
Talk(EMOTE_ENRAGE);
Talk(EMOTE_ENRAGE_2);
break;
case EVENT_UNLOCK_YELLSPAM:
_canYellKilledPlayer = true;
break;
default:
break;
}
@@ -362,7 +355,6 @@ class npc_shard_of_torment : public CreatureScript
DoCast(SPELL_TORMENT_COSMETIC_1);
_events.ScheduleEvent(EVENT_SHARD_SPAWN_EFFECT, 5000);
me->SetInCombatWithZone();
_baleroc = summoner->ToCreature();
}
else
me->DespawnOrUnsummon();
@@ -371,8 +363,8 @@ class npc_shard_of_torment : public CreatureScript
void KilledUnit(Unit* who) override
{
if (who->GetTypeId() == TYPEID_PLAYER)
if (_baleroc)
_baleroc->AI()->KilledUnit(who);
if (Creature* baleroc = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_BALEROC)))
baleroc->AI()->KilledUnit(who);
}
void UpdateAI(uint32 diff) override
@@ -396,7 +388,6 @@ class npc_shard_of_torment : public CreatureScript
private:
InstanceScript* _instance;
EventMap _events;
Creature* _baleroc;
};
CreatureAI* GetAI(Creature* creature) const
@@ -416,6 +407,8 @@ class spell_countdown_p1 : public SpellScriptLoader
bool Load() override
{
target1 = nullptr;
target2 = nullptr;
return GetCaster()->GetTypeId() == TYPEID_UNIT;
}
@@ -433,10 +426,9 @@ class spell_countdown_p1 : public SpellScriptLoader
void FilterTargets(std::list<WorldObject*>& targets)
{
//Remove current tank if we have one
if (GetCaster()->GetVictim())
targets.remove(GetCaster()->ToCreature()->GetVictim());
if (Unit* victim = GetCaster()->GetVictim())
targets.remove(victim);
if (targets.size() < 2)
{
@@ -445,11 +437,8 @@ class spell_countdown_p1 : public SpellScriptLoader
}
Trinity::Containers::RandomResizeList(targets, 2);
std::list<WorldObject*>::const_iterator itr = targets.begin();
target1 = (*itr);
itr++;
target2 = (*itr);
target1 = targets.front();
target2 = targets.back();
}
void Register() override
@@ -676,24 +665,26 @@ class spell_baleroc_torment : public SpellScriptLoader
if (targets.empty())
{
//No targets found, start pulsating immediately.
GetCaster()->ToCreature()->AI()->DoCast(SPELL_WAVE_OF_TORMENT);
GetCaster()->GetAI()->DoCast(SPELL_WAVE_OF_TORMENT);
return;
}
targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster(), true));
targets.resize(1);
WorldObject* target = targets.front();
if (target->GetTypeId() != TYPEID_PLAYER)
return;
if ((*targets.begin())->GetDistance2d(GetCaster()) > 15.0f)
GetCaster()->ToCreature()->AI()->DoCast(SPELL_WAVE_OF_TORMENT);
if (target->GetDistance2d(GetCaster()) > 15.0f)
GetCaster()->GetAI()->DoCast(SPELL_WAVE_OF_TORMENT);
else
{
if ((*targets.begin())->ToPlayer()->GetAura(SPELL_TORMENT_PERIODIC))
if ((*targets.begin())->ToPlayer()->GetAura(SPELL_TORMENT_PERIODIC)->GetCaster() != GetCaster())
GetCaster()->CastSpell((*targets.begin())->ToPlayer(), SPELL_TORMENT_PERIODIC, false);
else{
}
if (Aura* torment = target->ToPlayer()->GetAura(SPELL_TORMENT_PERIODIC))
{
if (torment->GetCaster() != GetCaster())
GetCaster()->CastSpell(target->ToPlayer(), SPELL_TORMENT_PERIODIC, false);
}
else
GetCaster()->CastSpell((*targets.begin())->ToPlayer(), SPELL_TORMENT_PERIODIC, false);
GetCaster()->CastSpell(target->ToPlayer(), SPELL_TORMENT_PERIODIC, false);
}
}
@@ -350,7 +350,7 @@ class spell_upwind_of_altairus : public SpellScriptLoader
}
private:
float upwindDistance;
float upwindDistance = 0.f;
};
SpellScript* GetSpellScript() const override
@@ -883,10 +883,14 @@ public:
{
PrepareSpellScript(spell_grounding_field_SpellScript);
void GetNearbyGroundFields()
bool Load() override
{
prevent = false;
return true;
}
void GetNearbyGroundFields()
{
std::list<Creature*> groundingFields;
GetCaster()->GetCreatureListWithEntryInGrid(groundingFields, NPC_GROUNDING_FIELD, 60.0f);