Core/Misc: Fix static analysis issues

# Conflicts:
#	src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp
#	src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp
#	src/server/game/Entities/Unit/Unit.cpp
#	src/server/scripts/Commands/cs_ban.cpp
#	src/server/scripts/Commands/cs_disable.cpp
This commit is contained in:
jackpoz
2017-07-16 21:14:22 +02:00
committed by vincent-michael
parent 74e4f73fcb
commit fc6b488620
9 changed files with 18 additions and 32 deletions
@@ -129,7 +129,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)
@@ -1410,12 +1410,15 @@ int __cdecl WheatyExceptionReport::stackprintf(const TCHAR * format, va_list arg
int __cdecl WheatyExceptionReport::heapprintf(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;
}
@@ -535,8 +535,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->Loc.X, sg->Loc.Y, sg->Loc.Z, 3.124139f, TEAM_ALLIANCE))
{
TC_LOG_ERROR("sql.sql", "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created.");
@@ -780,8 +779,7 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point)
if (!BgCreatures[Point].IsEmpty())
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->Loc.X, sg->Loc.Y, sg->Loc.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);
@@ -191,9 +191,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)
{
TC_LOG_ERROR("bg.battleground", "SOTA: Can't find GY entry %u", BG_SA_GYEntries[i]);
+2 -4
View File
@@ -5475,8 +5475,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())
{
@@ -5528,7 +5526,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);
@@ -5541,7 +5539,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
@@ -864,7 +864,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
@@ -1371,8 +1371,7 @@ void Group::CountTheRoll(Rolls::iterator rollI)
// 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;
}
SendLootRollsComplete(*roll);
@@ -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 -2
View File
@@ -576,8 +576,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
@@ -188,8 +188,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);
@@ -314,8 +313,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);