Fix some codacy detected issues

This commit is contained in:
H0zen 2018-04-12 21:59:49 +01:00 committed by Antz
parent 3299820ab7
commit ef91e6f31c
8 changed files with 22 additions and 28 deletions

View File

@ -2595,8 +2595,6 @@ bool ChatHandler::HandleTicketDeleteCommand(char* args)
bool ChatHandler::HandleTicketInfoCommand(char *args)
{
char* px = ExtractLiteralArg(&args);
size_t count = sTicketMgr.GetTicketCount();
if (m_session)

View File

@ -6238,12 +6238,12 @@ bool ChatHandler::HandleAccountSetAddonCommand(char* args)
bool ChatHandler::HandleSendMailHelper(MailDraft& draft, char* args)
{
// format: "subject text" "mail text"
char* msgSubject = ExtractQuotedArg(&args);
if (!msgSubject)
std::string msgSubject = ExtractQuotedArg(&args);
if (msgSubject.empty())
{ return false; }
char* msgText = ExtractQuotedArg(&args);
if (!msgText)
std::string msgText = ExtractQuotedArg(&args);
if (msgText.empty())
{ return false; }
// msgSubject, msgText isn't NUL after prev. check
@ -6285,12 +6285,12 @@ bool ChatHandler::HandleSendMassMailCommand(char* args)
bool ChatHandler::HandleSendItemsHelper(MailDraft& draft, char* args)
{
// format: "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
char* msgSubject = ExtractQuotedArg(&args);
if (!msgSubject)
std::string msgSubject = ExtractQuotedArg(&args);
if (msgSubject.empty())
{ return false; }
char* msgText = ExtractQuotedArg(&args);
if (!msgText)
std::string msgText = ExtractQuotedArg(&args);
if (msgText.empty())
{ return false; }
// extract items
@ -6418,8 +6418,8 @@ bool ChatHandler::HandleSendMoneyHelper(MailDraft& draft, char* args)
{
/// format: "subject text" "mail text" money
char* msgSubject = ExtractQuotedArg(&args);
if (!msgSubject)
std::string msgSubject = ExtractQuotedArg(&args);
if (msgSubject.empty())
{ return false; }
char* msgText = ExtractQuotedArg(&args);

View File

@ -908,9 +908,9 @@ bool ChatHandler::HandleGetValueHelper(Object* target, uint32 field, char* typeS
// starting 0 if need as required bitstring format
std::string res;
res.reserve(1 + 32 + 1);
res = iValue & (1 << (32 - 1)) ? "0" : " ";
res = (iValue & (1 << (32 - 1))) ? "0" : " ";
for (int i = 32; i > 0; --i)
{ res += iValue & (1 << (i - 1)) ? "1" : "0"; }
{ res += (iValue & (1 << (i - 1))) ? "1" : "0"; }
DEBUG_LOG(GetMangosString(LANG_GET_BITSTR), guid.GetString().c_str(), field, res.c_str());
PSendSysMessage(LANG_GET_BITSTR_FIELD, guid.GetString().c_str(), field, res.c_str());
break;

View File

@ -74,8 +74,8 @@ void WorldSession::HandleJoinChannelOpcode(WorldPacket& recvPacket)
for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i)
{
ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(i);
AreaTableEntry const* area = sAreaStore.LookupEntry(
(channel->ChannelID == tradeChannelID || channel->ChannelID == guildRecruitmentChannelID) ? cityLookupAreaID : playerZoneId);
AreaTableEntry const* area = channel ? sAreaStore.LookupEntry(
(channel->ChannelID == tradeChannelID || channel->ChannelID == guildRecruitmentChannelID) ? cityLookupAreaID : playerZoneId) : NULL;
if (area && channel)
{

View File

@ -1085,7 +1085,6 @@ void Group::CountTheRoll(Rolls::iterator& rollI)
{
uint8 maxresul = 0;
ObjectGuid maxguid = (*roll->playerVote.begin()).first;
RollVote rollvote = ROLL_PASS; // Fixed: Using uninitialized memory 'rollvote'
Roll::PlayerVote::iterator itr;
for (itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr)
@ -1162,11 +1161,10 @@ bool Group::IsRollDoneForItem(WorldObject * pObject, const LootItem * pItem)
if(RollId.empty())
{ return true; }
Roll * roll;
for(Rolls::iterator i = RollId.begin(); i != RollId.end(); i++)
for(Rolls::iterator i = RollId.begin(); i != RollId.end(); ++i)
{
roll = *i;
Roll *roll = *i;
if(roll->lootedTargetGUID == pObject->GetObjectGuid() && roll->itemid == pItem->itemid && roll->totalPlayersRolling > 1)
{ return false; }
}
@ -1257,11 +1255,9 @@ void Group::SendTargetIconList(WorldSession* session)
void Group::SendUpdate()
{
Player* player;
for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr)
{
player = sObjectMgr.GetPlayer(citr->guid);
Player* player = sObjectMgr.GetPlayer(citr->guid);
if (!player || !player->GetSession() || player->GetGroup() != this)
{ continue; }
// guess size

View File

@ -1749,8 +1749,8 @@ bool Map::ScriptsStart(DBScriptType type, uint32 id, Object* source, Object* tar
for (ScriptScheduleMap::const_iterator searchItr = m_scriptSchedule.begin(); searchItr != m_scriptSchedule.end(); ++searchItr)
{
if (searchItr->second.IsSameScript(type, id,
execParams & SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE ? sourceGuid : ObjectGuid(),
execParams & SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET ? targetGuid : ObjectGuid(), ownerGuid))
(execParams & SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE) ? sourceGuid : ObjectGuid(),
(execParams & SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET) ? targetGuid : ObjectGuid(), ownerGuid))
{
DEBUG_LOG("DB-SCRIPTS: Process table `dbscripts [type=%d]` id %u. Skip script as script already started for source %s, target %s - ScriptsStartParams %u", type, id, sourceGuid.GetString().c_str(), targetGuid.GetString().c_str(), execParams);
return true;

View File

@ -1512,7 +1512,7 @@ bool ScriptAction::HandleScriptStep()
if (m_script->playSound.flags & 2)
{ pSource->PlayDistanceSound(m_script->playSound.soundId, pSoundTarget); }
else if (m_script->playSound.flags & (4 | 8))
{ m_map->PlayDirectSoundToMap(m_script->playSound.soundId, m_script->playSound.flags & 8 ? pSource->GetZoneId() : 0); }
{ m_map->PlayDirectSoundToMap(m_script->playSound.soundId, (m_script->playSound.flags & 8) ? pSource->GetZoneId() : 0); }
else
{ pSource->PlayDirectSound(m_script->playSound.soundId, pSoundTarget); }
}

View File

@ -2149,7 +2149,7 @@ void World::ShutdownMsg(bool show /*= false*/, Player* player /*= NULL*/)
ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_TIME : SERVER_MSG_SHUTDOWN_TIME;
SendServerMessage(msgid, str.c_str(), player);
DEBUG_LOG("Server is %s in %s", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutting down"), str.c_str());
DEBUG_LOG("Server is %s in %s", (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? "restart" : "shutting down", str.c_str());
}
}
@ -2169,7 +2169,7 @@ void World::ShutdownCancel()
m_ExitCode = SHUTDOWN_EXIT_CODE; // to default value
SendServerMessage(msgid);
DEBUG_LOG("Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutdown"));
DEBUG_LOG("Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? "restart" : "shutdown");
///- Used by Eluna
#ifdef ENABLE_ELUNA