refactor(Scripts/Commands): code cleanup (part 4) (#6921)

This commit is contained in:
Francesco Borzì
2021-07-18 13:25:44 +02:00
committed by GitHub
parent a57c4fd3b8
commit fab0fc421b
9 changed files with 53 additions and 53 deletions

View File

@@ -389,14 +389,14 @@ public:
if (filter.empty())
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_ALL);
result = LoginDatabase.Query(stmt);
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_ALL);
result = LoginDatabase.Query(stmt2);
}
else
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME);
stmt->setString(0, filter);
result = LoginDatabase.Query(stmt);
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME);
stmt2->setString(0, filter);
result = LoginDatabase.Query(stmt2);
}
if (!result)
@@ -586,14 +586,14 @@ public:
if (filter.empty())
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_ALL);
result = LoginDatabase.Query(stmt);
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_ALL);
result = LoginDatabase.Query(stmt2);
}
else
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_BY_IP);
stmt->setString(0, filter);
result = LoginDatabase.Query(stmt);
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_BY_IP);
stmt2->setString(0, filter);
result = LoginDatabase.Query(stmt2);
}
if (!result)

View File

@@ -13,7 +13,6 @@ EndScriptData */
#include "Chat.h"
#include "Language.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"

View File

@@ -131,10 +131,10 @@ public:
return false;
}
Tokenizer::const_iterator i = tokens.begin();
Tokenizer::const_iterator tokensItr = tokens.begin();
std::set<BattlegroundTypeId> allowedArenas;
std::string arenasStr = *(i++);
std::string arenasStr = *(tokensItr++);
std::string tmpStr;
Tokenizer arenaTokens(arenasStr, ',');
for (Tokenizer::const_iterator itr = arenaTokens.begin(); itr != arenaTokens.end(); ++itr)
@@ -175,9 +175,9 @@ public:
BattlegroundTypeId randomizedArenaBgTypeId = Acore::Containers::SelectRandomContainerElement(allowedArenas);
uint8 count = 0;
if (i != tokens.end())
if (tokensItr != tokens.end())
{
std::string mode = *(i++);
std::string mode = *(tokensItr++);
if (mode == "1v1") count = 2;
else if (mode == "2v2") count = 4;
else if (mode == "3v3") count = 6;
@@ -204,9 +204,9 @@ public:
Player* plr = nullptr;
Player* players[10] = {nullptr};
uint8 cnt = 0;
for (; i != tokens.end(); ++i)
for (; tokensItr != tokens.end(); ++tokensItr)
{
last_name = std::string(*i);
last_name = std::string(*tokensItr);
plr = ObjectAccessor::FindPlayerByName(last_name, false);
if (!plr) { error = 1; break; }
if (!plr->IsInWorld() || !plr->FindMap() || plr->IsBeingTeleported()) { error = 2; break; }
@@ -234,13 +234,17 @@ public:
}
for (uint8 i = 0; i < cnt && !error; ++i)
{
for (uint8 j = i + 1; j < cnt; ++j)
{
if (players[i]->GetGUID() == players[j]->GetGUID())
{
last_name = players[i]->GetName();
error = 13;
break;
}
}
}
switch (error)
{
@@ -830,7 +834,7 @@ public:
std::string plNameLink = handler->GetNameLink(player);
if (player->IsBeingTeleported() == true)
if (player->IsBeingTeleported())
{
handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
handler->SetSentErrorMessage(true);
@@ -2002,12 +2006,12 @@ public:
PreparedQueryResult guildInfoResult = CharacterDatabase.Query(guildQuery);
if (guildInfoResult)
{
Field* fields = guildInfoResult->Fetch();
guildId = fields[0].GetUInt32();
guildName = fields[1].GetString();
guildRank = fields[2].GetString();
note = fields[3].GetString();
officeNote = fields[4].GetString();
Field* guildInfoFields = guildInfoResult->Fetch();
guildId = guildInfoFields[0].GetUInt32();
guildName = guildInfoFields[1].GetString();
guildRank = guildInfoFields[2].GetString();
note = guildInfoFields[3].GetString();
officeNote = guildInfoFields[4].GetString();
}
}
}

View File

@@ -1,18 +1,6 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
@@ -25,7 +13,6 @@
#include "CellImpl.h"
#include "Chat.h"
#include "DisableMgr.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Map.h"

View File

@@ -1085,7 +1085,7 @@ public:
if (creature)
{
// update movement type
if (doNotDelete == false)
if (!doNotDelete)
creature->LoadPath(0);
creature->SetDefaultMovementType(move_type);
@@ -1097,7 +1097,7 @@ public:
}
creature->SaveToDB();
}
if (doNotDelete == false)
if (!doNotDelete)
{
handler->PSendSysMessage(LANG_MOVE_TYPE_SET, type_str);
}

View File

@@ -34,15 +34,20 @@ public:
return false;
char* playerName = strtok((char*)args, " ");
char* spellid = strtok(nullptr, " ");
char* spellId = strtok(nullptr, " ");
char const* all = strtok(nullptr, " ");
Player* targetPlayer = FindPlayer(handler, playerName);
if (!spellid || !targetPlayer)
if (!spellId || !targetPlayer)
{
return false;
}
uint32 spell = handler->extractSpellIdFromLink(spellId);
uint32 spell = handler->extractSpellIdFromLink(spellid);
if (!spell)
{
return false;
}
return Learn(handler, targetPlayer, spell, all);
}
@@ -53,15 +58,21 @@ public:
return false;
char* playerName = strtok((char*)args, " ");
char* spellid = strtok(nullptr, " ");
char* spellId = strtok(nullptr, " ");
char const* all = strtok(nullptr, " ");
Player* targetPlayer = FindPlayer(handler, playerName);
if (!spellid || !targetPlayer)
return false;
uint32 spell = handler->extractSpellIdFromLink(spellid);
if (!spell)
if (!spellId || !targetPlayer)
{
return false;
}
uint32 spell = handler->extractSpellIdFromLink(spellId);
if (!spell)
{
return false;
}
return UnLearn(handler, targetPlayer, spell, all);
}

View File

@@ -17,7 +17,6 @@ EndScriptData */
#include "GitRevision.h"
#include "Language.h"
#include "MySQLThreading.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "Realm.h"
#include "ScriptMgr.h"

View File

@@ -158,7 +158,7 @@ public:
std::string chrNameLink = handler->playerLink(target_name);
if (target->IsBeingTeleported() == true)
if (target->IsBeingTeleported())
{
handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
handler->SetSentErrorMessage(true);

View File

@@ -235,10 +235,10 @@ public:
if (response)
ticket->AppendResponse(response);
if (Player* player = ticket->GetPlayer())
if (Player* player2 = ticket->GetPlayer())
{
ticket->SendResponse(player->GetSession());
ChatHandler(player->GetSession()).SendSysMessage(LANG_TICKET_COMPLETED);
ticket->SendResponse(player2->GetSession());
ChatHandler(player2->GetSession()).SendSysMessage(LANG_TICKET_COMPLETED);
}
Player* gm = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;