mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/Misc: Fix a couple of warnings, some of them performance related
Errors were found using Cppcheck, open-source static analysis tool
This commit is contained in:
@@ -241,7 +241,7 @@ void BIH::subdivide(int left, int right, std::vector<uint32> &tempTree, buildDat
|
||||
bool BIH::writeToFile(FILE* wf) const
|
||||
{
|
||||
uint32 treeSize = tree.size();
|
||||
uint32 check=0, count=0;
|
||||
uint32 check=0, count;
|
||||
check += fwrite(&bounds.low(), sizeof(float), 3, wf);
|
||||
check += fwrite(&bounds.high(), sizeof(float), 3, wf);
|
||||
check += fwrite(&treeSize, sizeof(uint32), 1, wf);
|
||||
|
||||
@@ -746,15 +746,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
|
||||
break;
|
||||
case ACTION_T_SUMMON_GO:
|
||||
{
|
||||
GameObject* object = NULL;
|
||||
|
||||
float x, y, z;
|
||||
me->GetPosition(x, y, z);
|
||||
object = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2);
|
||||
GameObject* object = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2);
|
||||
if (!object)
|
||||
{
|
||||
sLog->outError(LOG_FILTER_TSCR, "EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, eventId, me->GetEntry());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ACTION_T_SET_SHEATH:
|
||||
|
||||
@@ -37,9 +37,8 @@ struct AddonInfo
|
||||
|
||||
struct SavedAddon
|
||||
{
|
||||
SavedAddon(const std::string& name, uint32 crc)
|
||||
SavedAddon(const std::string& name, uint32 crc) : Name(name)
|
||||
{
|
||||
Name = name;
|
||||
CRC = crc;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ Battlefield::Battlefield()
|
||||
m_TypeId = 0;
|
||||
m_BattleId = 0;
|
||||
m_ZoneId = 0;
|
||||
m_Map = NULL;
|
||||
m_MapId = 0;
|
||||
m_MaxPlayer = 0;
|
||||
m_MinPlayer = 0;
|
||||
|
||||
@@ -337,7 +337,7 @@ void ArenaTeam::Disband(WorldSession* session)
|
||||
// Broadcast update
|
||||
if (session)
|
||||
{
|
||||
BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName().c_str(), GetName(), "");
|
||||
BroadcastEvent(ERR_ARENA_TEAM_DISBANDED_S, 0, 2, session->GetPlayerName(), GetName(), "");
|
||||
|
||||
if (Player* player = session->GetPlayer())
|
||||
sLog->outDebug(LOG_FILTER_ARENAS, "Player: %s [GUID: %u] disbanded arena team type: %u [Id: %u].", player->GetName().c_str(), player->GetGUIDLow(), GetType(), GetId());
|
||||
|
||||
@@ -1135,9 +1135,8 @@ BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId)
|
||||
|
||||
if (weight)
|
||||
{
|
||||
uint32 selectedWeight = 0;
|
||||
// Select a random value
|
||||
selectedWeight = urand(0, weight - 1);
|
||||
uint32 selectedWeight = urand(0, weight - 1);
|
||||
// Select the correct bg (if we have in DB A(10), B(20), C(10), D(15) --> [0---A---9|10---B---29|30---C---39|40---D---54])
|
||||
weight = 0;
|
||||
for (BattlegroundSelectionWeightMap::const_iterator it = selectionWeights.begin(); it != selectionWeights.end(); ++it)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
BattlegroundAB::BattlegroundAB()
|
||||
{
|
||||
m_IsInformedNearVictory = false;
|
||||
m_BuffChange = true;
|
||||
BgObjects.resize(BG_AB_OBJECT_MAX);
|
||||
BgCreatures.resize(BG_AB_ALL_NODES_COUNT + 5);//+5 for aura triggers
|
||||
|
||||
@@ -1775,8 +1775,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/)
|
||||
ss << id;
|
||||
|
||||
need_comma = true;
|
||||
}
|
||||
while (resultPets->NextRow());
|
||||
} while (resultPets->NextRow());
|
||||
|
||||
ss << ") AND spell IN (";
|
||||
|
||||
|
||||
@@ -200,10 +200,9 @@ void Player::UpdateResistances(uint32 school)
|
||||
|
||||
void Player::UpdateArmor()
|
||||
{
|
||||
float value = 0.0f;
|
||||
UnitMods unitMod = UNIT_MOD_ARMOR;
|
||||
|
||||
value = GetModifierValue(unitMod, BASE_VALUE); // base armor (from items)
|
||||
float value = GetModifierValue(unitMod, BASE_VALUE); // base armor (from items)
|
||||
value *= GetModifierValue(unitMod, BASE_PCT); // armor percent from items
|
||||
value += GetStat(STAT_AGILITY) * 2.0f; // armor bonus from stats
|
||||
value += GetModifierValue(unitMod, TOTAL_VALUE);
|
||||
@@ -1091,10 +1090,9 @@ bool Guardian::UpdateStats(Stats stat)
|
||||
case STAT_STRENGTH: mod = 0.7f; break; // Default Owner's Strength scale
|
||||
default: break;
|
||||
}
|
||||
// Ravenous Dead
|
||||
AuraEffect const* aurEff = NULL;
|
||||
|
||||
// Check just if owner has Ravenous Dead since it's effect is not an aura
|
||||
aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0);
|
||||
AuraEffect const* aurEff = owner->GetAuraEffect(SPELL_AURA_MOD_TOTAL_STAT_PERCENTAGE, SPELLFAMILY_DEATHKNIGHT, 3010, 0);
|
||||
if (aurEff)
|
||||
{
|
||||
SpellInfo const* spellInfo = aurEff->GetSpellInfo(); // Then get the SpellProto and add the dummy effect value
|
||||
|
||||
@@ -115,7 +115,7 @@ std::string GetScriptCommandName(ScriptCommands command)
|
||||
default:
|
||||
{
|
||||
char sz[32];
|
||||
sprintf(sz, "Unknown command: %u", command);
|
||||
sprintf(sz, "Unknown command: %d", command);
|
||||
res = sz;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -67,9 +67,8 @@ bool LoginQueryHolder::Initialize()
|
||||
|
||||
bool res = true;
|
||||
uint32 lowGuid = GUID_LOPART(m_guid);
|
||||
PreparedStatement* stmt = NULL;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_FROM, stmt);
|
||||
|
||||
|
||||
@@ -664,7 +664,7 @@ void Loot::DeleteLootItemFromContainerItemDB(uint32 itemID)
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// Mark the item looted to prevent resaving
|
||||
for (LootItemList::iterator _itr = items.begin(); _itr != items.end(); _itr++)
|
||||
for (LootItemList::iterator _itr = items.begin(); _itr != items.end(); ++_itr)
|
||||
{
|
||||
if (_itr->itemid != itemID)
|
||||
continue;
|
||||
|
||||
@@ -179,6 +179,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
|
||||
else // attempt to downscale
|
||||
mapDiff = GetDownscaledMapDifficultyData(entry->MapID, targetDifficulty);
|
||||
}
|
||||
// FIXME: mapDiff is never used
|
||||
|
||||
//Bypass checks for GMs
|
||||
if (player->isGameMaster())
|
||||
|
||||
@@ -162,9 +162,11 @@ namespace Movement
|
||||
{
|
||||
if (_transformForTransport)
|
||||
{
|
||||
float unused = 0.0f;
|
||||
if (TransportBase* transport = _owner.GetDirectTransport())
|
||||
transport->CalculatePassengerOffset(input.x, input.y, input.z, unused);
|
||||
{
|
||||
float unused = 0.0f; // need reference
|
||||
transport->CalculatePassengerOffset(input.x, input.y, input.z, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
|
||||
@@ -60,7 +60,7 @@ class ReactorRunnable : protected ACE_Task_Base
|
||||
m_Connections(0),
|
||||
m_ThreadId(-1)
|
||||
{
|
||||
ACE_Reactor_Impl* imp = 0;
|
||||
ACE_Reactor_Impl* imp;
|
||||
|
||||
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
|
||||
|
||||
|
||||
@@ -453,8 +453,8 @@ void WardenWin::HandleData(ByteBuffer &buff)
|
||||
if (luaStrLen != 0)
|
||||
{
|
||||
char *str = new char[luaStrLen + 1];
|
||||
memset(str, 0, luaStrLen + 1);
|
||||
memcpy(str, buff.contents() + buff.rpos(), luaStrLen);
|
||||
str[luaStrLen] = '\0'; // null terminator
|
||||
sLog->outDebug(LOG_FILTER_WARDEN, "Lua string: %s", str);
|
||||
delete[] str;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
RARunnable::RARunnable()
|
||||
{
|
||||
ACE_Reactor_Impl* imp = NULL;
|
||||
ACE_Reactor_Impl* imp;
|
||||
|
||||
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
|
||||
imp = new ACE_Dev_Poll_Reactor();
|
||||
|
||||
@@ -77,8 +77,7 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
|
||||
return false;
|
||||
}
|
||||
fwrite(szRawVMAPMagic, 8, 1, output);
|
||||
uint32 nVertices = 0;
|
||||
nVertices = header.nBoundingVertices;
|
||||
uint32 nVertices = header.nBoundingVertices;
|
||||
fwrite(&nVertices, sizeof(int), 1, output);
|
||||
uint32 nofgroups = 1;
|
||||
fwrite(&nofgroups,sizeof(uint32), 1, output);
|
||||
@@ -91,8 +90,7 @@ bool Model::ConvertToVMAPModel(const char * outfilename)
|
||||
wsize = sizeof(branches) + sizeof(uint32) * branches;
|
||||
fwrite(&wsize, sizeof(int), 1, output);
|
||||
fwrite(&branches,sizeof(branches), 1, output);
|
||||
uint32 nIndexes = 0;
|
||||
nIndexes = header.nBoundingTriangles;
|
||||
uint32 nIndexes = header.nBoundingTriangles;
|
||||
fwrite(&nIndexes,sizeof(uint32), 1, output);
|
||||
fwrite("INDX",4, 1, output);
|
||||
wsize = sizeof(uint32) + sizeof(unsigned short) * nIndexes;
|
||||
|
||||
Reference in New Issue
Block a user