Core/Misc: Fix static analysis issues (#25194)

(cherry picked from commit 07fd84b679fd6958b7e669a96c78783875e1b949)
This commit is contained in:
Giacomo Pozzoni
2022-01-26 14:06:40 +01:00
committed by Shauren
parent afcb13cd44
commit 864d775280
18 changed files with 35 additions and 39 deletions
@@ -67,9 +67,7 @@ SmartScript::~SmartScript()
{
}
// @todo this is an utter clusterfuck in terms of design - why in the world does this thing side effect?
// seriously, WHO WRITES THIS SHIT
bool SmartScript::IsSmart(Creature* c, bool silent)
bool SmartScript::IsSmart(Creature* c, bool silent) const
{
if (!c)
return false;
@@ -79,13 +77,12 @@ bool SmartScript::IsSmart(Creature* c, bool silent)
smart = false;
if (!smart && !silent)
TC_LOG_ERROR("sql.sql", "SmartScript: Action target Creature (GUID: " UI64FMTD " Entry: %u) is not using SmartAI, action called by Creature (GUID: " UI64FMTD " Entry: %u) skipped to prevent crash.", uint64(c ? c->GetSpawnId() : UI64LIT(0)), c ? c->GetEntry() : 0, uint64(me ? me->GetSpawnId() : UI64LIT(0)), me ? me->GetEntry() : 0);
TC_LOG_ERROR("sql.sql", "SmartScript: Action target Creature (GUID: " UI64FMTD " Entry: %u) is not using SmartAI, action called by Creature (GUID: " UI64FMTD " Entry: %u) skipped to prevent crash.", c->GetSpawnId(), c->GetEntry(), uint64(me ? me->GetSpawnId() : UI64LIT(0)), me ? me->GetEntry() : 0);
return smart;
}
// @todo this, too
bool SmartScript::IsSmart(GameObject* g, bool silent)
bool SmartScript::IsSmart(GameObject* g, bool silent) const
{
if (!g)
return false;
@@ -95,12 +92,12 @@ bool SmartScript::IsSmart(GameObject* g, bool silent)
smart = false;
if (!smart && !silent)
TC_LOG_ERROR("sql.sql", "SmartScript: Action target GameObject (GUID: " UI64FMTD " Entry: %u) is not using SmartGameObjectAI, action called by GameObject (GUID: " UI64FMTD " Entry: %u) skipped to prevent crash.", uint64(g ? g->GetSpawnId() : UI64LIT(0)), g ? g->GetEntry() : 0, uint64(go ? go->GetSpawnId() : UI64LIT(0)), go ? go->GetEntry() : 0);
TC_LOG_ERROR("sql.sql", "SmartScript: Action target GameObject (GUID: " UI64FMTD " Entry: %u) is not using SmartGameObjectAI, action called by GameObject (GUID: " UI64FMTD " Entry: %u) skipped to prevent crash.", g->GetSpawnId(), g->GetEntry(), uint64(go ? go->GetSpawnId() : UI64LIT(0)), go ? go->GetEntry() : 0);
return smart;
}
bool SmartScript::IsSmart(bool silent)
bool SmartScript::IsSmart(bool silent) const
{
if (me)
return IsSmart(me, silent);
@@ -74,9 +74,9 @@ class TC_GAME_API SmartScript
void DoFindFriendlyMissingBuff(std::vector<Creature*>& creatures, float range, uint32 spellid) const;
Unit* DoFindClosestFriendlyInRange(float range, bool playerOnly) const;
bool IsSmart(Creature* c, bool silent = false);
bool IsSmart(GameObject* g, bool silent = false);
bool IsSmart(bool silent = false);
bool IsSmart(Creature* c, bool silent = false) const;
bool IsSmart(GameObject* g, bool silent = false) const;
bool IsSmart(bool silent = false) const;
void StoreTargetList(ObjectVector const& targets, uint32 id);
void AddToStoredTargetList(ObjectVector const& targets, uint32 id);
@@ -2013,7 +2013,7 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const
if (!_IsTargetAcceptable(who))
return false;
if (!force && (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance)))
if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAttackDistance(who) + m_CombatDistance))
return false;
}
+1 -1
View File
@@ -2999,7 +2999,7 @@ bool WorldObject::IsValidAssistTarget(WorldObject const* target, SpellInfo const
// can't assist player out of sanctuary from sanctuary if has pvp enabled
if (unitTarget->IsPvP())
if (unit && unit->IsInSanctuary() && !unitTarget->IsInSanctuary())
if (unit->IsInSanctuary() && !unitTarget->IsInSanctuary())
return false;
}
}
+1 -1
View File
@@ -21882,7 +21882,7 @@ void Player::UpdatePvPFlag(time_t currTime)
if (!pvpInfo.EndTimer || (currTime < pvpInfo.EndTimer +300) || pvpInfo.IsHostile)
return;
if (pvpInfo.EndTimer && pvpInfo.EndTimer <= currTime)
if (pvpInfo.EndTimer <= currTime)
{
pvpInfo.EndTimer = 0;
RemovePlayerFlag(PLAYER_FLAGS_PVP_TIMER);
+1 -1
View File
@@ -11111,7 +11111,7 @@ void Unit::RemoveCharmedBy(Unit* charmer)
CharmType type;
if (HasUnitState(UNIT_STATE_POSSESSED))
type = CHARM_TYPE_POSSESS;
else if (charmer && charmer->IsOnVehicle(this))
else if (charmer->IsOnVehicle(this))
type = CHARM_TYPE_VEHICLE;
else
type = CHARM_TYPE_CHARM;
+2 -2
View File
@@ -930,7 +930,7 @@ void WorldSession::HandleSetDungeonDifficultyOpcode(WorldPackets::Misc::SetDunge
if (!groupGuy)
continue;
if (!groupGuy->IsInMap(groupGuy))
if (!groupGuy->IsInWorld())
return;
if (groupGuy->GetMap()->IsNonRaidDungeon())
@@ -1009,7 +1009,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPackets::Misc::SetRaidDiff
if (!groupGuy)
continue;
if (!groupGuy->IsInMap(groupGuy))
if (!groupGuy->IsInWorld())
return;
if (groupGuy->GetMap()->IsRaid())
+1 -1
View File
@@ -4343,7 +4343,7 @@ void SpellMgr::LoadSpellInfoCorrections()
// Val'kyr Target Search
ApplySpellFix({ 69030 }, [](SpellInfo* spellInfo)
{
spellInfo->Attributes |= SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY;
spellInfo->Attributes |= SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY;
});
// Raging Spirit Visual
+1 -1
View File
@@ -145,7 +145,7 @@ public:
handler->SendSysMessage("========================");
}
std::string const& name = itr->second->GetName();
uint8 size = name.size();
uint8 size = uint8(name.size());
uint8 security = itrSec;
uint8 max = ((16 - size) / 2);
uint8 max2 = max;
+3 -3
View File
@@ -248,7 +248,7 @@ public:
if (count > resultCount)
count -= resultCount;
else if (count)
else
count = 0;
}
@@ -295,7 +295,7 @@ public:
if (count > resultCount)
count -= resultCount;
else if (count)
else
count = 0;
}
@@ -370,7 +370,7 @@ public:
if (count > resultCount)
count -= resultCount;
else if (count)
else
count = 0;
}
+1 -1
View File
@@ -1569,7 +1569,7 @@ public:
// the max level of the new profession.
uint16 max = maxPureSkill ? atoul(maxPureSkill) : targetHasSkill ? target->GetPureMaxSkillValue(skill) : uint16(level);
if (level == 0 || level > max || max <= 0)
if (level == 0 || level > max)
return false;
// If the player has the skill, we get the current skill step. If they don't have the skill, we
@@ -325,7 +325,6 @@ public:
if (RaidWiped)
{
RaidWiped = true;
EnterEvadeMode();
return;
}
@@ -305,7 +305,7 @@ struct npc_head : public ScriptedAI
ReturnToBody(true);
break;
case PHASE_HEAD_3:
if (!_die && damage >= me->GetHealth())
if (damage >= me->GetHealth())
{
_die = true;
damage = 0;
@@ -234,7 +234,7 @@ class spell_koralon_meteor_fists_damage : public SpellScriptLoader
private:
void FilterTargets(std::list<WorldObject*>& targets)
{
_chainTargets = targets.size();
_chainTargets = uint8(targets.size());
}
void CalculateSplitDamage()
@@ -686,8 +686,7 @@ public:
while (unit == nullptr || !unit->IsAlive())
unit = selectAdvisorUnit();
if (unit && unit->IsAlive())
DoCast(unit, SPELL_HEAL);
DoCast(unit, SPELL_HEAL);
Heal_Timer = 60000;
}
else
@@ -222,7 +222,7 @@ public:
{
//Teleport 4 players under the waterfalls
GuidSet targets;
GuidSet::const_iterator itr;
GuidSet::const_iterator itr = targets.begin();
for (uint8 i = 0; i < 4; ++i)
{
counter = 0;
@@ -260,7 +260,7 @@ public:
if (WateryGlobules_Timer <= diff)
{
GuidSet globules;
GuidSet::const_iterator itr;
GuidSet::const_iterator itr = globules.begin();
for (uint8 g = 0; g < 4; g++) //one unit can't cast more than one spell per update, so some players have to cast for us XD
{
counter = 0;
@@ -274,6 +274,7 @@ public:
break;
++counter;
} while (itr != globules.end());
if (pGlobuleTarget)
{
globules.insert(pGlobuleTarget->GetGUID());
@@ -190,19 +190,19 @@ class instance_blood_furnace : public InstanceMapScript
void ResetPrisons()
{
ResetPrisoners(PrisonersCell5);
PrisonerCounter5 = PrisonersCell5.size();
PrisonerCounter5 = uint8(PrisonersCell5.size());
HandleGameObject(PrisonCellGUIDs[DATA_PRISON_CELL5 - DATA_PRISON_CELL1], false);
ResetPrisoners(PrisonersCell6);
PrisonerCounter6 = PrisonersCell6.size();
PrisonerCounter6 = uint8(PrisonersCell6.size());
HandleGameObject(PrisonCellGUIDs[DATA_PRISON_CELL6 - DATA_PRISON_CELL1], false);
ResetPrisoners(PrisonersCell7);
PrisonerCounter7 = PrisonersCell7.size();
PrisonerCounter7 = uint8(PrisonersCell7.size());
HandleGameObject(PrisonCellGUIDs[DATA_PRISON_CELL7 - DATA_PRISON_CELL1], false);
ResetPrisoners(PrisonersCell8);
PrisonerCounter8 = PrisonersCell8.size();
PrisonerCounter8 = uint8(PrisonersCell8.size());
HandleGameObject(PrisonCellGUIDs[DATA_PRISON_CELL8 - DATA_PRISON_CELL1], false);
}
@@ -242,12 +242,12 @@ class instance_blood_furnace : public InstanceMapScript
if (posX >= 405.0f && posX <= 423.0f && posZ <= 17)
{
if (posY >= 106.0f && posY <= 123.0f && posZ <= 17)
if (posY >= 106.0f && posY <= 123.0f)
{
PrisonersCell5.insert(creature->GetGUID());
++PrisonerCounter5;
}
else if (posY >= 76.0f && posY <= 91.0f && posZ <= 17)
else if (posY >= 76.0f && posY <= 91.0f)
{
PrisonersCell6.insert(creature->GetGUID());
++PrisonerCounter6;
@@ -256,12 +256,12 @@ class instance_blood_furnace : public InstanceMapScript
}
else if (posX >= 490.0f && posX <= 506.0f && posZ <= 17)
{
if (posY >= 106.0f && posY <= 123.0f && posZ <= 17)
if (posY >= 106.0f && posY <= 123.0f)
{
PrisonersCell7.insert(creature->GetGUID());
++PrisonerCounter7;
}
else if (posY >= 76.0f && posY <= 91.0f && posZ <= 17)
else if (posY >= 76.0f && posY <= 91.0f)
{
PrisonersCell8.insert(creature->GetGUID());
++PrisonerCounter8;
+1 -1
View File
@@ -147,7 +147,7 @@ void CreateDir(boost::filesystem::path const& path)
return;
if (!fs::create_directory(path))
throw new std::runtime_error("Unable to create directory" + path.string());
throw std::runtime_error("Unable to create directory" + path.string());
}
void Usage(char const* prg)