Core/Misc: Another batch of fixes for issues found by static analysis

This commit is contained in:
Shauren
2013-05-19 11:15:54 +02:00
parent 933f50558b
commit 7da33b6bce
6 changed files with 15 additions and 53 deletions
@@ -4702,12 +4702,6 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
charDelete_method = CHAR_DELETE_REMOVE;
else if (CharacterNameData const* nameData = sWorld->GetCharacterNameData(guid)) // To avoid a query, we select loaded data. If it doesn't exist, return.
{
if (!nameData)
{
TC_LOG_ERROR(LOG_FILTER_PLAYER, "Cannot find CharacterNameData entry for player %u from account %u. Could not delete character.", guid, accountId);
return;
}
// Define the required variables
uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->m_class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL);
+1 -1
View File
@@ -2167,7 +2167,7 @@ namespace Trinity
{
WorldPacket* data = new WorldPacket();
uint32 lineLength = (line ? strlen(line) : 0) + 1;
uint32 lineLength = strlen(line) + 1;
data->Initialize(SMSG_MESSAGECHAT, 100); // guess size
*data << uint8(CHAT_MSG_SYSTEM);
+2 -20
View File
@@ -962,12 +962,7 @@ public:
uint32 id = atoi((char*)args);
bool found = false;
uint32 count = 0;
uint32 maxResults = 1;
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id);
if (spellInfo)
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id))
{
int locale = handler->GetSessionDbcLocale();
std::string name = spellInfo->SpellName[locale];
@@ -977,14 +972,6 @@ public:
return true;
}
if (locale < TOTAL_LOCALES)
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
bool known = target && target->HasSpell(id);
bool learn = (spellInfo->Effects[0].Effect == SPELL_EFFECT_LEARN_SPELL);
@@ -1028,13 +1015,8 @@ public:
ss << handler->GetTrinityString(LANG_ACTIVE);
handler->SendSysMessage(ss.str().c_str());
if (!found)
found = true;
}
}
if (!found)
else
handler->SendSysMessage(LANG_COMMAND_NOSPELLFOUND);
return true;
+4 -8
View File
@@ -1071,9 +1071,7 @@ public:
Player* player = handler->GetSession()->GetPlayer();
uint32 zone_id = player->GetZoneId();
WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team);
WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team);
if (graveyard)
{
uint32 graveyardId = graveyard->ID;
@@ -1103,14 +1101,12 @@ public:
{
std::string team_name;
if (team == 0)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY);
else if (team == HORDE)
if (team == HORDE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE);
else if (team == ALLIANCE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
if (team == ~uint32(0))
if (!team)
handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id);
else
handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str());
@@ -2144,7 +2140,7 @@ public:
return true;
}
uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL;
uint32 school = atoi((char*)schoolStr);
if (school >= MAX_SPELL_SCHOOL)
return false;
+7 -17
View File
@@ -309,24 +309,14 @@ public:
if (!pfactionid)
{
if (target)
{
uint32 factionid = target->getFaction();
uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag);
}
uint32 factionid = target->getFaction();
uint32 flag = target->GetUInt32Value(UNIT_FIELD_FLAGS);
uint32 npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
uint32 dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUIDLow(), factionid, flag, npcflag, dyflag);
return true;
}
if (!target)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
uint32 factionid = atoi(pfactionid);
uint32 flag;
@@ -340,7 +330,7 @@ public:
uint32 npcflag;
if (!pnpcflag)
npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
npcflag = target->GetUInt32Value(UNIT_NPC_FLAGS);
else
npcflag = atoi(pnpcflag);
@@ -348,7 +338,7 @@ public:
uint32 dyflag;
if (!pdyflag)
dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
dyflag = target->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
else
dyflag = atoi(pdyflag);
+1 -1
View File
@@ -252,7 +252,7 @@ public:
return false;
}
uint32 vendor_entry = vendor ? vendor->GetEntry() : 0;
uint32 vendor_entry = vendor->GetEntry();
if (!sObjectMgr->IsVendorItemValid(vendor_entry, itemId, maxcount, incrtime, extendedcost, handler->GetSession()->GetPlayer()))
{