refactor(Scripts/Commands): code cleanup (part 4) (#6921)
This commit is contained in:
@@ -389,14 +389,14 @@ public:
|
|||||||
|
|
||||||
if (filter.empty())
|
if (filter.empty())
|
||||||
{
|
{
|
||||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_ALL);
|
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_ALL);
|
||||||
result = LoginDatabase.Query(stmt);
|
result = LoginDatabase.Query(stmt2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME);
|
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME);
|
||||||
stmt->setString(0, filter);
|
stmt2->setString(0, filter);
|
||||||
result = LoginDatabase.Query(stmt);
|
result = LoginDatabase.Query(stmt2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
@@ -586,14 +586,14 @@ public:
|
|||||||
|
|
||||||
if (filter.empty())
|
if (filter.empty())
|
||||||
{
|
{
|
||||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_ALL);
|
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_ALL);
|
||||||
result = LoginDatabase.Query(stmt);
|
result = LoginDatabase.Query(stmt2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_BY_IP);
|
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_BY_IP);
|
||||||
stmt->setString(0, filter);
|
stmt2->setString(0, filter);
|
||||||
result = LoginDatabase.Query(stmt);
|
result = LoginDatabase.Query(stmt2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ EndScriptData */
|
|||||||
|
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "ObjectAccessor.h"
|
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
|
|||||||
@@ -131,10 +131,10 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tokenizer::const_iterator i = tokens.begin();
|
Tokenizer::const_iterator tokensItr = tokens.begin();
|
||||||
|
|
||||||
std::set<BattlegroundTypeId> allowedArenas;
|
std::set<BattlegroundTypeId> allowedArenas;
|
||||||
std::string arenasStr = *(i++);
|
std::string arenasStr = *(tokensItr++);
|
||||||
std::string tmpStr;
|
std::string tmpStr;
|
||||||
Tokenizer arenaTokens(arenasStr, ',');
|
Tokenizer arenaTokens(arenasStr, ',');
|
||||||
for (Tokenizer::const_iterator itr = arenaTokens.begin(); itr != arenaTokens.end(); ++itr)
|
for (Tokenizer::const_iterator itr = arenaTokens.begin(); itr != arenaTokens.end(); ++itr)
|
||||||
@@ -175,9 +175,9 @@ public:
|
|||||||
BattlegroundTypeId randomizedArenaBgTypeId = Acore::Containers::SelectRandomContainerElement(allowedArenas);
|
BattlegroundTypeId randomizedArenaBgTypeId = Acore::Containers::SelectRandomContainerElement(allowedArenas);
|
||||||
|
|
||||||
uint8 count = 0;
|
uint8 count = 0;
|
||||||
if (i != tokens.end())
|
if (tokensItr != tokens.end())
|
||||||
{
|
{
|
||||||
std::string mode = *(i++);
|
std::string mode = *(tokensItr++);
|
||||||
if (mode == "1v1") count = 2;
|
if (mode == "1v1") count = 2;
|
||||||
else if (mode == "2v2") count = 4;
|
else if (mode == "2v2") count = 4;
|
||||||
else if (mode == "3v3") count = 6;
|
else if (mode == "3v3") count = 6;
|
||||||
@@ -204,9 +204,9 @@ public:
|
|||||||
Player* plr = nullptr;
|
Player* plr = nullptr;
|
||||||
Player* players[10] = {nullptr};
|
Player* players[10] = {nullptr};
|
||||||
uint8 cnt = 0;
|
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);
|
plr = ObjectAccessor::FindPlayerByName(last_name, false);
|
||||||
if (!plr) { error = 1; break; }
|
if (!plr) { error = 1; break; }
|
||||||
if (!plr->IsInWorld() || !plr->FindMap() || plr->IsBeingTeleported()) { error = 2; 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 i = 0; i < cnt && !error; ++i)
|
||||||
|
{
|
||||||
for (uint8 j = i + 1; j < cnt; ++j)
|
for (uint8 j = i + 1; j < cnt; ++j)
|
||||||
|
{
|
||||||
if (players[i]->GetGUID() == players[j]->GetGUID())
|
if (players[i]->GetGUID() == players[j]->GetGUID())
|
||||||
{
|
{
|
||||||
last_name = players[i]->GetName();
|
last_name = players[i]->GetName();
|
||||||
error = 13;
|
error = 13;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (error)
|
switch (error)
|
||||||
{
|
{
|
||||||
@@ -830,7 +834,7 @@ public:
|
|||||||
|
|
||||||
std::string plNameLink = handler->GetNameLink(player);
|
std::string plNameLink = handler->GetNameLink(player);
|
||||||
|
|
||||||
if (player->IsBeingTeleported() == true)
|
if (player->IsBeingTeleported())
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
|
handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
@@ -2002,12 +2006,12 @@ public:
|
|||||||
PreparedQueryResult guildInfoResult = CharacterDatabase.Query(guildQuery);
|
PreparedQueryResult guildInfoResult = CharacterDatabase.Query(guildQuery);
|
||||||
if (guildInfoResult)
|
if (guildInfoResult)
|
||||||
{
|
{
|
||||||
Field* fields = guildInfoResult->Fetch();
|
Field* guildInfoFields = guildInfoResult->Fetch();
|
||||||
guildId = fields[0].GetUInt32();
|
guildId = guildInfoFields[0].GetUInt32();
|
||||||
guildName = fields[1].GetString();
|
guildName = guildInfoFields[1].GetString();
|
||||||
guildRank = fields[2].GetString();
|
guildRank = guildInfoFields[2].GetString();
|
||||||
note = fields[3].GetString();
|
note = guildInfoFields[3].GetString();
|
||||||
officeNote = fields[4].GetString();
|
officeNote = guildInfoFields[4].GetString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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/>
|
* 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 "CellImpl.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "DisableMgr.h"
|
|
||||||
#include "GridNotifiers.h"
|
#include "GridNotifiers.h"
|
||||||
#include "GridNotifiersImpl.h"
|
#include "GridNotifiersImpl.h"
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
|
|||||||
@@ -1085,7 +1085,7 @@ public:
|
|||||||
if (creature)
|
if (creature)
|
||||||
{
|
{
|
||||||
// update movement type
|
// update movement type
|
||||||
if (doNotDelete == false)
|
if (!doNotDelete)
|
||||||
creature->LoadPath(0);
|
creature->LoadPath(0);
|
||||||
|
|
||||||
creature->SetDefaultMovementType(move_type);
|
creature->SetDefaultMovementType(move_type);
|
||||||
@@ -1097,7 +1097,7 @@ public:
|
|||||||
}
|
}
|
||||||
creature->SaveToDB();
|
creature->SaveToDB();
|
||||||
}
|
}
|
||||||
if (doNotDelete == false)
|
if (!doNotDelete)
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage(LANG_MOVE_TYPE_SET, type_str);
|
handler->PSendSysMessage(LANG_MOVE_TYPE_SET, type_str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,15 +34,20 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* playerName = strtok((char*)args, " ");
|
char* playerName = strtok((char*)args, " ");
|
||||||
char* spellid = strtok(nullptr, " ");
|
char* spellId = strtok(nullptr, " ");
|
||||||
char const* all = strtok(nullptr, " ");
|
char const* all = strtok(nullptr, " ");
|
||||||
Player* targetPlayer = FindPlayer(handler, playerName);
|
Player* targetPlayer = FindPlayer(handler, playerName);
|
||||||
if (!spellid || !targetPlayer)
|
if (!spellId || !targetPlayer)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 spell = handler->extractSpellIdFromLink(spellId);
|
||||||
|
|
||||||
uint32 spell = handler->extractSpellIdFromLink(spellid);
|
|
||||||
if (!spell)
|
if (!spell)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return Learn(handler, targetPlayer, spell, all);
|
return Learn(handler, targetPlayer, spell, all);
|
||||||
}
|
}
|
||||||
@@ -53,15 +58,21 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
char* playerName = strtok((char*)args, " ");
|
char* playerName = strtok((char*)args, " ");
|
||||||
char* spellid = strtok(nullptr, " ");
|
char* spellId = strtok(nullptr, " ");
|
||||||
char const* all = strtok(nullptr, " ");
|
char const* all = strtok(nullptr, " ");
|
||||||
Player* targetPlayer = FindPlayer(handler, playerName);
|
Player* targetPlayer = FindPlayer(handler, playerName);
|
||||||
if (!spellid || !targetPlayer)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 spell = handler->extractSpellIdFromLink(spellid);
|
if (!spellId || !targetPlayer)
|
||||||
if (!spell)
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 spell = handler->extractSpellIdFromLink(spellId);
|
||||||
|
|
||||||
|
if (!spell)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return UnLearn(handler, targetPlayer, spell, all);
|
return UnLearn(handler, targetPlayer, spell, all);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ EndScriptData */
|
|||||||
#include "GitRevision.h"
|
#include "GitRevision.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "MySQLThreading.h"
|
#include "MySQLThreading.h"
|
||||||
#include "ObjectAccessor.h"
|
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "Realm.h"
|
#include "Realm.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ public:
|
|||||||
|
|
||||||
std::string chrNameLink = handler->playerLink(target_name);
|
std::string chrNameLink = handler->playerLink(target_name);
|
||||||
|
|
||||||
if (target->IsBeingTeleported() == true)
|
if (target->IsBeingTeleported())
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
|
handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str());
|
||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
|
|||||||
@@ -235,10 +235,10 @@ public:
|
|||||||
if (response)
|
if (response)
|
||||||
ticket->AppendResponse(response);
|
ticket->AppendResponse(response);
|
||||||
|
|
||||||
if (Player* player = ticket->GetPlayer())
|
if (Player* player2 = ticket->GetPlayer())
|
||||||
{
|
{
|
||||||
ticket->SendResponse(player->GetSession());
|
ticket->SendResponse(player2->GetSession());
|
||||||
ChatHandler(player->GetSession()).SendSysMessage(LANG_TICKET_COMPLETED);
|
ChatHandler(player2->GetSession()).SendSysMessage(LANG_TICKET_COMPLETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* gm = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
|
Player* gm = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user