mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Misc: Fix static analysis issues
Fix static analysis issues reported by 3rd party tools
(cherry picked from commit 24e82fe83d)
This commit is contained in:
@@ -277,7 +277,7 @@ Creature* BattlegroundAV::AddAVCreature(uint16 cinfoid, uint16 type)
|
||||
{
|
||||
bool isStatic = false;
|
||||
Creature* creature = nullptr;
|
||||
ASSERT(type <= AV_CPLACE_MAX + AV_STATICCPLACE_MAX);
|
||||
ASSERT(type < AV_CPLACE_MAX + AV_STATICCPLACE_MAX);
|
||||
if (type >= AV_CPLACE_MAX) //static
|
||||
{
|
||||
type -= AV_CPLACE_MAX;
|
||||
|
||||
@@ -648,6 +648,6 @@ void CalendarMgr::SendPacketToAllEventRelatives(WorldPacket const* packet, Calen
|
||||
CalendarInviteStore invites = _invites[calendarEvent.GetEventId()];
|
||||
for (CalendarInviteStore::iterator itr = invites.begin(); itr != invites.end(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindConnectedPlayer((*itr)->GetInviteeGUID()))
|
||||
if (!calendarEvent.IsGuildEvent() || (calendarEvent.IsGuildEvent() && player->GetGuildId() != calendarEvent.GetGuildId()))
|
||||
if (!calendarEvent.IsGuildEvent() || player->GetGuildId() != calendarEvent.GetGuildId())
|
||||
player->SendDirectMessage(packet);
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
|
||||
// Load creature equipment
|
||||
if (!data || data->equipmentId == 0)
|
||||
LoadEquipment(); // use default equipment (if available)
|
||||
else if (data && data->equipmentId != 0) // override, 0 means no equipment
|
||||
else // override, 0 means no equipment
|
||||
{
|
||||
m_originalEquipmentId = data->equipmentId;
|
||||
LoadEquipment(data->equipmentId);
|
||||
|
||||
@@ -3285,7 +3285,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled /*= false*/, bool learn_
|
||||
}
|
||||
|
||||
// now re-learn if need re-activate
|
||||
if (cur_active && !prev_itr->second->active && learn_low_rank)
|
||||
if (!prev_itr->second->active && learn_low_rank)
|
||||
{
|
||||
if (AddSpell(prev_id, true, false, prev_itr->second->dependent, prev_itr->second->disabled))
|
||||
{
|
||||
@@ -13751,7 +13751,7 @@ void Player::SwapItem(uint16 src, uint16 dst)
|
||||
}
|
||||
}
|
||||
|
||||
if (!released && IsBagPos(dst) && pDstItem)
|
||||
if (!released && IsBagPos(dst))
|
||||
{
|
||||
Bag* bag = pDstItem->ToBag();
|
||||
for (uint32 i = 0; i < bag->GetBagSize(); ++i)
|
||||
@@ -14179,7 +14179,7 @@ void Player::AddEnchantmentDuration(Item* item, EnchantmentSlot slot, uint32 dur
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (item && duration > 0)
|
||||
if (duration > 0)
|
||||
{
|
||||
GetSession()->SendItemEnchantTimeUpdate(GetGUID(), item->GetGUID(), slot, uint32(duration/1000));
|
||||
m_enchantDuration.push_back(EnchantDuration(item, slot, duration));
|
||||
@@ -18298,7 +18298,7 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder* holder)
|
||||
RelocateToHomebind();
|
||||
}
|
||||
// Player was saved in Arena or Bg
|
||||
else if (mapEntry && mapEntry->IsBattlegroundOrArena())
|
||||
else if (mapEntry->IsBattlegroundOrArena())
|
||||
{
|
||||
Battleground* currentBg = nullptr;
|
||||
if (m_bgData.bgInstanceID) //saved in Battleground
|
||||
@@ -21986,7 +21986,7 @@ Pet* Player::GetPet() const
|
||||
if (!pet)
|
||||
return nullptr;
|
||||
|
||||
if (IsInWorld() && pet)
|
||||
if (IsInWorld())
|
||||
return pet;
|
||||
|
||||
// there may be a guardian in this slot
|
||||
|
||||
@@ -1231,7 +1231,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
||||
}
|
||||
}
|
||||
|
||||
if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size()))
|
||||
if (internal_event_id >= int32(mGameEventGameobjectGuids.size()))
|
||||
{
|
||||
TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempted access to out of range mGameEventGameobjectGuids element %i (size: %zu).",
|
||||
internal_event_id, mGameEventGameobjectGuids.size());
|
||||
@@ -1263,7 +1263,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
|
||||
}
|
||||
}
|
||||
|
||||
if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
|
||||
if (internal_event_id >= int32(mGameEventPoolIds.size()))
|
||||
{
|
||||
TC_LOG_ERROR("gameevent", "GameEventMgr::GameEventSpawn attempted access to out of range mGameEventPoolIds element %u (size: %zu).",
|
||||
internal_event_id, mGameEventPoolIds.size());
|
||||
|
||||
@@ -199,7 +199,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
||||
|
||||
pet->ClearUnitState(UNIT_STATE_FOLLOW);
|
||||
// This is true if pet has no target or has target but targets differs.
|
||||
if (pet->GetVictim() != TargetUnit || (pet->GetVictim() == TargetUnit && !pet->GetCharmInfo()->IsCommandAttack()))
|
||||
if (pet->GetVictim() != TargetUnit || !pet->GetCharmInfo()->IsCommandAttack())
|
||||
{
|
||||
if (pet->GetVictim())
|
||||
pet->AttackStop();
|
||||
|
||||
@@ -5091,7 +5091,7 @@ void Spell::EffectGameObjectDamage(SpellEffIndex /*effIndex*/)
|
||||
FactionTemplateEntry const* casterFaction = caster->GetFactionTemplateEntry();
|
||||
FactionTemplateEntry const* targetFaction = sFactionTemplateStore.LookupEntry(gameObjTarget->GetFaction());
|
||||
// Do not allow to damage GO's of friendly factions (ie: Wintergrasp Walls/Ulduar Storm Beacons)
|
||||
if (!targetFaction || (casterFaction && targetFaction && !casterFaction->IsFriendlyTo(targetFaction)))
|
||||
if (!targetFaction || (casterFaction && !casterFaction->IsFriendlyTo(targetFaction)))
|
||||
gameObjTarget->ModifyHealth(-damage, caster, GetSpellInfo()->Id);
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
|
||||
if (Creature* fetchVesp = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_VESPERON)))
|
||||
{
|
||||
if (fetchVesp && fetchVesp->IsAlive() && !fetchVesp->GetVictim())
|
||||
if (fetchVesp->IsAlive() && !fetchVesp->GetVictim())
|
||||
{
|
||||
_canUseWill = true;
|
||||
if (!fetchVesp->IsInCombat())
|
||||
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 250, true))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
{
|
||||
DoCast(target, SPELL_HAMMER_JUSTICE);
|
||||
DoCast(target, SPELL_HAMMER_RIGHTEOUS);
|
||||
@@ -353,7 +353,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 250, true))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, SPELL_HOLY_FIRE);
|
||||
}
|
||||
if (me->HasAura(SPELL_SHIELD))
|
||||
@@ -366,7 +366,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 250, true))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, SPELL_SMITE);
|
||||
}
|
||||
if (me->HasAura(SPELL_SHIELD))
|
||||
@@ -459,7 +459,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, SPELL_OLD_WOUNDS);
|
||||
}
|
||||
uiOldWoundsTimer = 12000;
|
||||
@@ -475,7 +475,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, SPELL_SHADOWS_PAST);
|
||||
}
|
||||
uiShadowPastTimer = 5000;
|
||||
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, SPELL_DEATH_RESPITE);
|
||||
}
|
||||
uiDeathRespiteTimer = urand(15000, 16000);
|
||||
@@ -225,7 +225,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, SPELL_DESECRATION);
|
||||
}
|
||||
uiDesecration = urand(15000, 16000);
|
||||
@@ -252,7 +252,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, SPELL_MARKED_DEATH);
|
||||
}
|
||||
uiMarkedDeathTimer = urand(5000, 7000);
|
||||
@@ -333,7 +333,7 @@ public:
|
||||
{
|
||||
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true))
|
||||
{
|
||||
if (target && target->IsAlive())
|
||||
if (target->IsAlive())
|
||||
DoCast(target, (SPELL_LEAP));
|
||||
}
|
||||
uiAttackTimer = 3500;
|
||||
|
||||
@@ -1004,7 +1004,7 @@ class npc_ball_of_flame : public CreatureScript
|
||||
{
|
||||
// need to clear states now because this call is before AuraEffect is fully removed
|
||||
me->ClearUnitState(UNIT_STATE_CASTING | UNIT_STATE_STUNNED);
|
||||
if (target && me->Attack(target, true))
|
||||
if (me->Attack(target, true))
|
||||
me->GetMotionMaster()->MoveChase(target, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,7 +924,7 @@ class spell_q9874_liquid_fire : public SpellScriptLoader
|
||||
{
|
||||
Player* caster = GetCaster()->ToPlayer();
|
||||
if (Creature* target = GetHitCreature())
|
||||
if (target && !target->HasAura(SPELL_FLAMES))
|
||||
if (!target->HasAura(SPELL_FLAMES))
|
||||
{
|
||||
caster->KilledMonsterCredit(NPC_VILLAGER_KILL_CREDIT);
|
||||
target->CastSpell(target, SPELL_FLAMES, true);
|
||||
|
||||
Reference in New Issue
Block a user