Core/Misc: Fix static analysis issues

This commit is contained in:
Aokromes committed 2017-07-16 19:05:26 +02:00
1 parent e4841c960b
commit 8b6261c809
12 files changed
+24 -37

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ namespace VMAP
struct TC_COMMON_API LocationInfo
{
LocationInfo(): hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { }
LocationInfo(): rootId(-1), hitInstance(nullptr), hitModel(nullptr), ground_Z(-G3D::finf()) { }
int32 rootId;
const ModelInstance* hitInstance;
const GroupModel* hitModel;
@@ -123,7 +123,7 @@ PEXCEPTION_POINTERS pExceptionInfo)
++pos;
TCHAR crash_folder_path[MAX_PATH];
sprintf(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder);
sprintf_s(crash_folder_path, "%s\\%s", module_folder_name, CrashFolder);
if (!CreateDirectory(crash_folder_path, NULL))
{
if (GetLastError() != ERROR_ALREADY_EXISTS)
@@ -1382,12 +1382,15 @@ int __cdecl WheatyExceptionReport::StackLog(const TCHAR * format, va_list argptr
int __cdecl WheatyExceptionReport::HeapLog(const TCHAR * format, va_list argptr)
{
int retValue;
int retValue = 0;
DWORD cbWritten;
TCHAR* szBuff = (TCHAR*)malloc(sizeof(TCHAR) * WER_LARGE_BUFFER_SIZE);
retValue = vsprintf(szBuff, format, argptr);
WriteFile(m_hReportFile, szBuff, retValue * sizeof(TCHAR), &cbWritten, 0);
free(szBuff);
if (szBuff != nullptr)
{
retValue = vsprintf(szBuff, format, argptr);
WriteFile(m_hReportFile, szBuff, retValue * sizeof(TCHAR), &cbWritten, 0);
free(szBuff);
}
return retValue;
}
@@ -518,8 +518,7 @@ bool BattlegroundEY::SetupBattleground()
TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Could not spawn Speedbuff Fel Reaver.");
}
WorldSafeLocsEntry const* sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE);
WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(EY_GRAVEYARD_MAIN_ALLIANCE);
if (!sg || !AddSpiritGuide(EY_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, TEAM_ALLIANCE))
{
TC_LOG_ERROR("sql.sql", "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created.");
@@ -763,8 +762,7 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point)
if (BgCreatures[Point])
DelCreature(Point);
WorldSafeLocsEntry const* sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveYardId);
WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[Point].GraveyardId);
if (!sg || !AddSpiritGuide(Point, sg->x, sg->y, sg->z, 3.124139f, GetTeamIndexByTeamId(Team)))
TC_LOG_ERROR("bg.battleground", "BatteGroundEY: Failed to spawn spirit guide. point: %u, team: %u, graveyard_id: %u",
Point, Team, m_CapturingPointTypes[Point].GraveYardId);
@@ -186,8 +186,7 @@ bool BattlegroundSA::ResetObjs()
//Graveyards
for (uint8 i = 0; i < BG_SA_MAX_GY; i++)
{
WorldSafeLocsEntry const* sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
if (!sg)
{
+3 -5
View File
@@ -2514,7 +2514,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo)
{
// Can`t miss on dead target (on skinning for example)
if ((!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER))
if (!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER)
return SPELL_MISS_NONE;
SpellSchoolMask schoolMask = spellInfo->GetSchoolMask();
@@ -5336,8 +5336,6 @@ ReputationRank Unit::GetFactionReactionTo(FactionTemplateEntry const* factionTem
return REP_NEUTRAL;
FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry();
if (!targetFactionTemplateEntry)
return REP_NEUTRAL;
if (Player const* targetPlayerOwner = target->GetAffectingPlayer())
{
@@ -5389,7 +5387,7 @@ bool Unit::IsFriendlyTo(Unit const* unit) const
bool Unit::IsHostileToPlayers() const
{
FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
if (!my_faction || !my_faction->faction)
if (!my_faction->faction)
return false;
FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
@@ -5402,7 +5400,7 @@ bool Unit::IsHostileToPlayers() const
bool Unit::IsNeutralToAll() const
{
FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
if (!my_faction || !my_faction->faction)
if (!my_faction->faction)
return true;
FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->faction);
+1 -1
View File
@@ -869,7 +869,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists non-existing Modelid1 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid1);
const_cast<CreatureTemplate*>(cInfo)->Modelid1 = 0;
}
else if (!displayScaleEntry)
else
displayScaleEntry = displayEntry;
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid1);
+1 -2
View File
@@ -1567,8 +1567,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap)
// remove is_blocked so that the item is lootable by all players
LootItem* item = &(roll->itemSlot >= roll->getLoot()->items.size() ? roll->getLoot()->quest_items[roll->itemSlot - roll->getLoot()->items.size()] : roll->getLoot()->items[roll->itemSlot]);
if (item)
item->is_blocked = false;
item->is_blocked = false;
}
RollId.erase(rollI);
@@ -207,9 +207,6 @@ bool CanCreatePerfectItem(Player* player, uint32 spellId, float &perfectCreateCh
return false;
SkillPerfectItemEntry const* thisEntry = &ret->second;
// lack of entry means no perfection proc possible
if (!thisEntry)
return false;
// if you don't have the spell needed, then no procs for you
if (!player->HasSpell(thisEntry->requiredSpecialization))
@@ -232,10 +229,6 @@ bool CanCreateExtraItems(Player* player, uint32 spellId, float &additionalChance
SkillExtraItemEntry const* specEntry = &ret->second;
// if no entry, then no extra items can be created
if (!specEntry)
return false;
// the player doesn't have the required specialization, return false
if (!player->HasSpell(specEntry->requiredSpecialization))
return false;
+1
View File
@@ -524,6 +524,7 @@ m_caster((info->HasAttribute(SPELL_ATTR6_CAST_BY_CHARMER) && caster->GetCharmerO
m_referencedFromCurrentSpell = false;
m_executedCurrently = false;
m_needComboPoints = m_spellInfo->NeedsComboPoints();
m_comboTarget = nullptr;
m_comboPointGain = 0;
m_delayStart = 0;
m_delayAtDamageCount = 0;
+3 -4
View File
@@ -1468,10 +1468,9 @@ bool SpellInfo::CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const
if (HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
{
// ...but not these (Divine shield, Ice block, Cyclone and Banish for example)
if (!auraSpellInfo ||
(auraSpellInfo->Mechanic != MECHANIC_IMMUNE_SHIELD &&
auraSpellInfo->Mechanic != MECHANIC_INVULNERABILITY &&
(auraSpellInfo->Mechanic != MECHANIC_BANISH || (IsRankOf(auraSpellInfo) && auraSpellInfo->Dispel != DISPEL_NONE)))) // Banish shouldn't be immune to itself, but Cyclone should
if (auraSpellInfo->Mechanic != MECHANIC_IMMUNE_SHIELD &&
auraSpellInfo->Mechanic != MECHANIC_INVULNERABILITY &&
(auraSpellInfo->Mechanic != MECHANIC_BANISH || (IsRankOf(auraSpellInfo) && auraSpellInfo->Dispel != DISPEL_NONE))) // Banish shouldn't be immune to itself, but Cyclone should
return true;
}
+1 -2
View File
@@ -583,8 +583,7 @@ public:
static bool HandleBanListIPCommand(ChatHandler* handler, char const* args)
{
PreparedStatement* stmt = NULL;
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS);
LoginDatabase.Execute(stmt);
char* filterStr = strtok((char*)args, " ");
+2 -4
View File
@@ -185,8 +185,7 @@ public:
break;
}
PreparedStatement* stmt = NULL;
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -311,8 +310,7 @@ public:
break;
}
PreparedStatement* stmt = NULL;
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES);
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
PreparedQueryResult result = WorldDatabase.Query(stmt);