Big update.

This commit is contained in:
UltraNix
2022-03-12 22:28:00 +01:00
parent 6006eeeb01
commit 12d41d1314
2064 changed files with 427245 additions and 268481 deletions

View File

@@ -121,12 +121,12 @@ public:
{ // check if 2FA already enabled
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_TOTP_SECRET);
stmt->setUInt32(0, accountId);
stmt->SetData(0, accountId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
{
LOG_ERROR("misc", "Account %u not found in login database when processing .account 2fa setup command.", accountId);
LOG_ERROR("misc", "Account {} not found in login database when processing .account 2fa setup command.", accountId);
handler->SendSysMessage(LANG_UNKNOWN_ERROR);
handler->SetSentErrorMessage(true);
return false;
@@ -155,8 +155,8 @@ public:
Acore::Crypto::AEEncryptWithRandomIV<Acore::Crypto::AES>(pair.first->second, *masterKey);
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET);
stmt->setBinary(0, pair.first->second);
stmt->setUInt32(1, accountId);
stmt->SetData(0, pair.first->second);
stmt->SetData(1, accountId);
LoginDatabase.Execute(stmt);
suggestions.erase(pair.first);
@@ -196,12 +196,12 @@ public:
Acore::Crypto::TOTP::Secret secret;
{ // get current TOTP secret
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_TOTP_SECRET);
stmt->setUInt32(0, accountId);
stmt->SetData(0, accountId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
{
LOG_ERROR("misc", "Account %u not found in login database when processing .account 2fa setup command.", accountId);
LOG_ERROR("misc", "Account {} not found in login database when processing .account 2fa setup command.", accountId);
handler->SendSysMessage(LANG_UNKNOWN_ERROR);
handler->SetSentErrorMessage(true);
return false;
@@ -215,7 +215,7 @@ public:
return false;
}
secret = field->GetBinary();
secret = field->Get<Binary>();
}
if (token)
@@ -225,7 +225,7 @@ public:
bool success = Acore::Crypto::AEDecrypt<Acore::Crypto::AES>(secret, *masterKey);
if (!success)
{
LOG_ERROR("misc", "Account %u has invalid ciphertext in TOTP token.", accountId);
LOG_ERROR("misc", "Account {} has invalid ciphertext in TOTP token.", accountId);
handler->SendSysMessage(LANG_UNKNOWN_ERROR);
handler->SetSentErrorMessage(true);
return false;
@@ -235,8 +235,8 @@ public:
if (Acore::Crypto::TOTP::ValidateToken(secret, *token))
{
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET);
stmt->setNull(0);
stmt->setUInt32(1, accountId);
stmt->SetData(0);
stmt->SetData(1, accountId);
LoginDatabase.Execute(stmt);
handler->SendSysMessage(LANG_2FA_REMOVE_COMPLETE);
return true;
@@ -263,8 +263,8 @@ public:
uint32 accountId = handler->GetSession()->GetAccountId();
int expansion = atoi(exp); //get int anyway (0 if error)
if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
auto expansion = Acore::StringTo<uint8>(exp); //get int anyway (0 if error)
if (!expansion || *expansion > sWorld->getIntConfig(CONFIG_EXPANSION))
{
handler->SendSysMessage(LANG_IMPROPER_VALUE);
handler->SetSentErrorMessage(true);
@@ -273,12 +273,12 @@ public:
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION);
stmt->setUInt8(0, uint8(expansion));
stmt->setUInt32(1, accountId);
stmt->SetData(0, *expansion);
stmt->SetData(1, accountId);
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_ACCOUNT_ADDON, expansion);
handler->PSendSysMessage(LANG_ACCOUNT_ADDON, *expansion);
return true;
}
@@ -301,9 +301,9 @@ public:
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
if (handler->GetSession())
{
LOG_DEBUG("warden", "Account: %d (IP: %s) Character:[%s] (%s) Change Password.",
handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(),
handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str());
LOG_DEBUG("warden", "Account: {} (IP: {}) Character:[{}] ({}) Change Password.",
handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress(),
handler->GetSession()->GetPlayer()->GetName(), handler->GetSession()->GetPlayer()->GetGUID().ToString());
}
break;
case AOR_NAME_TOO_LONG:
@@ -411,22 +411,22 @@ public:
do
{
Field* fieldsDB = result->Fetch();
std::string name = fieldsDB[0].GetString();
uint32 account = fieldsDB[1].GetUInt32();
std::string name = fieldsDB[0].Get<std::string>();
uint32 account = fieldsDB[1].Get<uint32>();
///- Get the username, last IP and GM level of each account
// No SQL injection. account is uint32.
LoginDatabasePreparedStatement* loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO);
loginStmt->setUInt32(0, account);
loginStmt->SetData(0, account);
PreparedQueryResult resultLogin = LoginDatabase.Query(loginStmt);
if (resultLogin)
{
Field* fieldsLogin = resultLogin->Fetch();
handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE,
fieldsLogin[0].GetCString(), name.c_str(), fieldsLogin[1].GetCString(),
fieldsDB[2].GetUInt16(), fieldsDB[3].GetUInt16(), fieldsLogin[3].GetUInt8(),
fieldsLogin[2].GetUInt8());
fieldsLogin[0].Get<std::string>().c_str(), name.c_str(), fieldsLogin[1].Get<std::string>().c_str(),
fieldsDB[2].Get<uint16>(), fieldsDB[3].Get<uint16>(), fieldsLogin[3].Get<uint8>(),
fieldsLogin[2].Get<uint8>());
}
else
handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str());
@@ -467,8 +467,8 @@ public:
}
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_COUNTRY);
stmt->setString(0, "00");
stmt->setUInt32(1, accountId);
stmt->SetData(0, "00");
stmt->SetData(1, accountId);
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
@@ -493,8 +493,8 @@ public:
if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(handler->GetSession()->GetRemoteAddress()))
{
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_COUNTRY);
stmt->setString(0, location->CountryCode);
stmt->setUInt32(1, handler->GetSession()->GetAccountId());
stmt->SetData(0, location->CountryCode);
stmt->SetData(1, handler->GetSession()->GetAccountId());
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
}
@@ -508,8 +508,8 @@ public:
else if (param == "off")
{
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_COUNTRY);
stmt->setString(0, "00");
stmt->setUInt32(1, handler->GetSession()->GetAccountId());
stmt->SetData(0, "00");
stmt->SetData(1, handler->GetSession()->GetAccountId());
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
}
@@ -538,16 +538,16 @@ public:
if (param == "on")
{
stmt->setBool(0, true); // locked
stmt->SetData(0, true); // locked
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED);
}
else if (param == "off")
{
stmt->setBool(0, false); // unlocked
stmt->SetData(0, false); // unlocked
handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED);
}
stmt->setUInt32(1, handler->GetSession()->GetAccountId());
stmt->SetData(1, handler->GetSession()->GetAccountId());
LoginDatabase.Execute(stmt);
return true;
@@ -658,8 +658,8 @@ public:
if (secret == "off")
{
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET);
stmt->setNull(0);
stmt->setUInt32(1, targetAccountId);
stmt->SetData(0);
stmt->SetData(1, targetAccountId);
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_2FA_REMOVE_COMPLETE);
return true;
@@ -692,8 +692,8 @@ public:
Acore::Crypto::AEEncryptWithRandomIV<Acore::Crypto::AES>(*decoded, *masterKey);
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET);
stmt->setBinary(0, *decoded);
stmt->setUInt32(1, targetAccountId);
stmt->SetData(0, *decoded);
stmt->SetData(1, targetAccountId);
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_2FA_SECRET_SET_COMPLETE, accountName.c_str());
@@ -756,18 +756,18 @@ public:
handler->HasLowerSecurityAccount(nullptr, accountId, true))
return false;
int expansion = atoi(exp); //get int anyway (0 if error)
if (expansion < 0 || uint8(expansion) > sWorld->getIntConfig(CONFIG_EXPANSION))
auto expansion = Acore::StringTo<uint8>(exp); //get int anyway (0 if error)
if (!expansion || *expansion > sWorld->getIntConfig(CONFIG_EXPANSION))
return false;
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION);
stmt->setUInt8(0, expansion);
stmt->setUInt32(1, accountId);
stmt->SetData(0, *expansion);
stmt->SetData(1, accountId);
LoginDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, expansion);
handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, *expansion);
return true;
}
@@ -809,7 +809,7 @@ public:
}
// Check for invalid specified GM level.
gm = (isAccountNameGiven) ? atoi(arg2) : atoi(arg1);
gm = (isAccountNameGiven) ? Acore::StringTo<int32>(arg2).value_or(0) : Acore::StringTo<int32>(arg1).value_or(0);
if (gm > SEC_CONSOLE)
{
handler->SendSysMessage(LANG_BAD_VALUE);
@@ -819,7 +819,7 @@ public:
// handler->getSession() == nullptr only for console
targetAccountId = (isAccountNameGiven) ? AccountMgr::GetId(targetAccountName) : handler->getSelectedPlayer()->GetSession()->GetAccountId();
int32 gmRealmID = (isAccountNameGiven) ? atoi(arg3) : atoi(arg2);
int32 gmRealmID = (isAccountNameGiven) ? Acore::StringTo<int32>(arg3).value_or(0) : Acore::StringTo<int32>(arg2).value_or(0);
uint32 playerSecurity;
if (handler->GetSession())
playerSecurity = AccountMgr::GetSecurity(handler->GetSession()->GetAccountId(), gmRealmID);
@@ -841,8 +841,8 @@ public:
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST);
stmt->setUInt32(0, targetAccountId);
stmt->setUInt8(1, uint8(gm));
stmt->SetData(0, targetAccountId);
stmt->SetData(1, uint8(gm));
PreparedQueryResult result = LoginDatabase.Query(stmt);
@@ -868,13 +868,13 @@ public:
if (gmRealmID == -1)
{
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
stmt->setUInt32(0, targetAccountId);
stmt->SetData(0, targetAccountId);
}
else
{
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM);
stmt->setUInt32(0, targetAccountId);
stmt->setUInt32(1, realm.Id.Realm);
stmt->SetData(0, targetAccountId);
stmt->SetData(1, realm.Id.Realm);
}
LoginDatabase.Execute(stmt);
@@ -883,9 +883,9 @@ public:
{
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS);
stmt->setUInt32(0, targetAccountId);
stmt->setUInt8(1, uint8(gm));
stmt->setInt32(2, gmRealmID);
stmt->SetData(0, targetAccountId);
stmt->SetData(1, uint8(gm));
stmt->SetData(2, gmRealmID);
LoginDatabase.Execute(stmt);
}

View File

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

View File

@@ -0,0 +1,160 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
#include "Chat.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
constexpr std::array<std::string_view, MAX_ITEM_QUALITY> itemQualityToString =
{
"poor",
"normal",
"uncommon",
"rare",
"epic",
"legendary",
"artifact",
"all"
};
using namespace Acore::ChatCommands;
class bg_commandscript : public CommandScript
{
public:
bg_commandscript() : CommandScript("bg_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable commandTable =
{
{ "bags clear", HandleBagsClearCommand, SEC_GAMEMASTER, Console::No },
};
return commandTable;
}
static bool HandleBagsClearCommand(ChatHandler* handler, std::string_view args)
{
if (args.empty())
{
return false;
}
Player* player = handler->GetSession()->GetPlayer();
if (!player)
{
return false;
}
uint8 itemQuality = MAX_ITEM_QUALITY;
for (uint8 i = ITEM_QUALITY_POOR; i < MAX_ITEM_QUALITY; ++i)
{
if (args == itemQualityToString[i])
{
itemQuality = i;
break;
}
}
if (itemQuality == MAX_ITEM_QUALITY)
{
return false;
}
std::array<uint32, MAX_ITEM_QUALITY> removedItems = { };
// in inventory
for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; ++i)
{
if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
{
if (ItemTemplate const* itemTemplate = item->GetTemplate())
{
if (itemTemplate->Quality <= itemQuality)
{
player->DestroyItem(INVENTORY_SLOT_BAG_0, i, true);
++removedItems[itemTemplate->Quality];
}
}
}
}
// in inventory bags
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
if (Bag* bag = player->GetBagByPos(i))
{
for (uint32 j = 0; j < bag->GetBagSize(); j++)
{
if (Item* item = bag->GetItemByPos(j))
{
if (ItemTemplate const* itemTemplate = item->GetTemplate())
{
if (itemTemplate->Quality <= itemQuality)
{
player->DestroyItem(i, j, true);
++removedItems[itemTemplate->Quality];
}
}
}
}
}
}
std::ostringstream str;
str << "Removed ";
if (itemQuality == ITEM_QUALITY_HEIRLOOM)
{
str << "all";
}
else
{
bool initialize = true;
for (uint8 i = ITEM_QUALITY_POOR; i < MAX_ITEM_QUALITY; ++i)
{
if (uint32 itemCount = removedItems[i])
{
std::string_view itemQualityString = itemQualityToString[i];
if (!initialize)
{
str << ", ";
}
str << "|c";
str << std::hex << ItemQualityColors[i] << std::dec;
str << itemCount << " " << itemQualityString << "|r";
initialize = false;
}
}
}
str << " items from your bags.";
handler->SendSysMessage(str.str().c_str());
return true;
};
};
void AddSC_bag_commandscript()
{
new bg_commandscript();
}

View File

@@ -26,6 +26,7 @@ EndScriptData */
#include "BanMgr.h"
#include "CharacterCache.h"
#include "Chat.h"
#include "GameTime.h"
#include "Language.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
@@ -291,7 +292,7 @@ public:
static bool HandleBanInfoHelper(uint32 accountId, char const* accountName, ChatHandler* handler)
{
QueryResult result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate, '%%Y-%%m-%%d..%%H:%%I:%%s') as bandate, unbandate-bandate, active, unbandate, banreason, bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC", accountId);
QueryResult result = LoginDatabase.Query("SELECT FROM_UNIXTIME(bandate, '%Y-%m-%d..%H:%I:%s') as bandate, unbandate-bandate, active, unbandate, banreason, bannedby FROM account_banned WHERE id = '{}' ORDER BY bandate ASC", accountId);
if (!result)
{
handler->PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountName);
@@ -303,14 +304,14 @@ public:
{
Field* fields = result->Fetch();
time_t unbanDate = time_t(fields[3].GetUInt32());
time_t unbanDate = time_t(fields[3].Get<uint32>());
bool active = false;
if (fields[2].GetBool() && (fields[1].GetUInt64() == uint64(0) || unbanDate >= time(nullptr)))
if (fields[2].Get<bool>() && (fields[1].Get<uint64>() == uint64(0) || unbanDate >= GameTime::GetGameTime().count()))
active = true;
bool permanent = (fields[1].GetUInt64() == uint64(0));
std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true);
bool permanent = (fields[1].Get<uint64>() == uint64(0));
std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].Get<uint64>(), true);
handler->PSendSysMessage(LANG_BANINFO_HISTORYENTRY,
fields[0].GetCString(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].GetCString(), fields[5].GetCString());
fields[0].Get<std::string>().c_str(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get<std::string>().c_str(), fields[5].Get<std::string>().c_str());
} while (result->NextRow());
return true;
@@ -338,7 +339,7 @@ public:
targetGuid = target->GetGUID();
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANINFO);
stmt->setUInt32(0, targetGuid.GetCounter());
stmt->SetData(0, targetGuid.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
@@ -351,14 +352,14 @@ public:
do
{
Field* fields = result->Fetch();
time_t unbanDate = time_t(fields[3].GetUInt32());
time_t unbanDate = time_t(fields[3].Get<uint32>());
bool active = false;
if (fields[2].GetUInt8() && (!fields[1].GetUInt32() || unbanDate >= time(nullptr)))
if (fields[2].Get<uint8>() && (!fields[1].Get<uint32>() || unbanDate >= GameTime::GetGameTime().count()))
active = true;
bool permanent = (fields[1].GetUInt32() == uint32(0));
std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true);
bool permanent = (fields[1].Get<uint32>() == uint32(0));
std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].Get<uint64>(), true);
handler->PSendSysMessage(LANG_BANINFO_HISTORYENTRY,
fields[0].GetCString(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].GetCString(), fields[5].GetCString());
fields[0].Get<std::string>().c_str(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get<std::string>().c_str(), fields[5].Get<std::string>().c_str());
} while (result->NextRow());
return true;
@@ -379,7 +380,7 @@ public:
std::string IP = ipStr;
LoginDatabase.EscapeString(IP);
QueryResult result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason, bannedby, unbandate-bandate FROM ip_banned WHERE ip = '%s'", IP.c_str());
QueryResult result = LoginDatabase.Query("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason, bannedby, unbandate-bandate FROM ip_banned WHERE ip = '{}'", IP);
if (!result)
{
handler->PSendSysMessage(LANG_BANINFO_NOIP);
@@ -387,10 +388,10 @@ public:
}
Field* fields = result->Fetch();
bool permanent = !fields[6].GetUInt64();
bool permanent = !fields[6].Get<uint64>();
handler->PSendSysMessage(LANG_BANINFO_IPENTRY,
fields[0].GetCString(), fields[1].GetCString(), permanent ? handler->GetAcoreString(LANG_BANINFO_NEVER) : fields[2].GetCString(),
permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetCString(), fields[5].GetCString());
fields[0].Get<std::string>().c_str(), fields[1].Get<std::string>().c_str(), permanent ? handler->GetAcoreString(LANG_BANINFO_NEVER) : fields[2].Get<std::string>().c_str(),
permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[3].Get<uint64>(), true).c_str(), fields[4].Get<std::string>().c_str(), fields[5].Get<std::string>().c_str());
return true;
}
@@ -413,7 +414,7 @@ public:
else
{
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME);
stmt2->setString(0, filter);
stmt2->SetData(0, filter);
result = LoginDatabase.Query(stmt2);
}
@@ -436,13 +437,13 @@ public:
do
{
Field* fields = result->Fetch();
uint32 accountid = fields[0].GetUInt32();
uint32 accountid = fields[0].Get<uint32>();
QueryResult banResult = LoginDatabase.PQuery("SELECT account.username FROM account, account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id", accountid);
QueryResult banResult = LoginDatabase.Query("SELECT account.username FROM account, account_banned WHERE account_banned.id='{}' AND account_banned.id=account.id", accountid);
if (banResult)
{
Field* fields2 = banResult->Fetch();
handler->PSendSysMessage("%s", fields2[0].GetCString());
handler->PSendSysMessage("%s", fields2[0].Get<std::string>().c_str());
}
} while (result->NextRow());
}
@@ -456,43 +457,39 @@ public:
{
handler->SendSysMessage("-------------------------------------------------------------------------------");
Field* fields = result->Fetch();
uint32 accountId = fields[0].GetUInt32();
uint32 accountId = fields[0].Get<uint32>();
std::string accountName;
// "account" case, name can be get in same query
if (result->GetFieldCount() > 1)
accountName = fields[1].GetString();
accountName = fields[1].Get<std::string>();
// "character" case, name need extract from another DB
else
AccountMgr::GetName(accountId, accountName);
// No SQL injection. id is uint32.
QueryResult banInfo = LoginDatabase.PQuery("SELECT bandate, unbandate, bannedby, banreason FROM account_banned WHERE id = %u ORDER BY unbandate", accountId);
QueryResult banInfo = LoginDatabase.Query("SELECT bandate, unbandate, bannedby, banreason FROM account_banned WHERE id = {} ORDER BY unbandate", accountId);
if (banInfo)
{
Field* fields2 = banInfo->Fetch();
do
{
time_t timeBan = time_t(fields2[0].GetUInt32());
tm tmBan;
localtime_r(&timeBan, &tmBan);
tm tmBan = Acore::Time::TimeBreakdown(fields2[0].Get<uint32>());
if (fields2[0].GetUInt32() == fields2[1].GetUInt32())
if (fields2[0].Get<uint32>() == fields2[1].Get<uint32>())
{
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
fields2[2].GetCString(), fields2[3].GetCString());
fields2[2].Get<std::string>().c_str(), fields2[3].Get<std::string>().c_str());
}
else
{
time_t timeUnban = time_t(fields2[1].GetUInt32());
tm tmUnban;
localtime_r(&timeUnban, &tmUnban);
tm tmUnban = Acore::Time::TimeBreakdown(fields2[1].Get<uint32>());
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
fields2[2].GetCString(), fields2[3].GetCString());
fields2[2].Get<std::string>().c_str(), fields2[3].Get<std::string>().c_str());
}
} while (banInfo->NextRow());
}
@@ -515,7 +512,7 @@ public:
std::string filter(filterStr);
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_BY_NAME_FILTER);
stmt->setString(0, filter);
stmt->SetData(0, filter);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (!result)
{
@@ -532,11 +529,11 @@ public:
{
Field* fields = result->Fetch();
CharacterDatabasePreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANNED_NAME);
stmt2->setUInt32(0, fields[0].GetUInt32());
stmt2->SetData(0, fields[0].Get<uint32>());
PreparedQueryResult banResult = CharacterDatabase.Query(stmt2);
if (banResult)
handler->PSendSysMessage("%s", (*banResult)[0].GetCString());
handler->PSendSysMessage("%s", (*banResult)[0].Get<std::string>().c_str());
} while (result->NextRow());
}
// Console wide output
@@ -551,10 +548,10 @@ public:
Field* fields = result->Fetch();
std::string char_name = fields[1].GetString();
std::string char_name = fields[1].Get<std::string>();
CharacterDatabasePreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANINFO_LIST);
stmt2->setUInt32(0, fields[0].GetUInt32());
stmt2->SetData(0, fields[0].Get<uint32>());
PreparedQueryResult banInfo = CharacterDatabase.Query(stmt2);
if (banInfo)
@@ -562,25 +559,21 @@ public:
Field* banFields = banInfo->Fetch();
do
{
time_t timeBan = time_t(banFields[0].GetUInt32());
tm tmBan;
localtime_r(&timeBan, &tmBan);
tm tmBan = Acore::Time::TimeBreakdown(banFields[0].Get<uint32>());
if (banFields[0].GetUInt32() == banFields[1].GetUInt32())
if (banFields[0].Get<uint32>() == banFields[1].Get<uint32>())
{
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
banFields[2].GetCString(), banFields[3].GetCString());
banFields[2].Get<std::string>().c_str(), banFields[3].Get<std::string>().c_str());
}
else
{
time_t timeUnban = time_t(banFields[1].GetUInt32());
tm tmUnban;
localtime_r(&timeUnban, &tmUnban);
tm tmUnban = Acore::Time::TimeBreakdown(banFields[1].Get<uint32>());
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
banFields[2].GetCString(), banFields[3].GetCString());
banFields[2].Get<std::string>().c_str(), banFields[3].Get<std::string>().c_str());
}
} while (banInfo->NextRow());
}
@@ -610,7 +603,7 @@ public:
else
{
LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_BY_IP);
stmt2->setString(0, filter);
stmt2->SetData(0, filter);
result = LoginDatabase.Query(stmt2);
}
@@ -627,7 +620,7 @@ public:
do
{
Field* fields = result->Fetch();
handler->PSendSysMessage("%s", fields[0].GetCString());
handler->PSendSysMessage("%s", fields[0].Get<std::string>().c_str());
} while (result->NextRow());
}
// Console wide output
@@ -640,24 +633,20 @@ public:
{
handler->SendSysMessage("-------------------------------------------------------------------------------");
Field* fields = result->Fetch();
time_t timeBan = time_t(fields[1].GetUInt32());
tm tmBan;
localtime_r(&timeBan, &tmBan);
if (fields[1].GetUInt32() == fields[2].GetUInt32())
tm tmBan = Acore::Time::TimeBreakdown(fields[1].Get<uint32>());
if (fields[1].Get<uint32>() == fields[2].Get<uint32>())
{
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
fields[0].GetCString(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
fields[3].GetCString(), fields[4].GetCString());
fields[0].Get<std::string>().c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
fields[3].Get<std::string>().c_str(), fields[4].Get<std::string>().c_str());
}
else
{
time_t timeUnban = time_t(fields[2].GetUInt32());
tm tmUnban;
localtime_r(&timeUnban, &tmUnban);
tm tmUnban = Acore::Time::TimeBreakdown(fields[2].Get<uint32>());
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
fields[0].GetCString(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
fields[0].Get<std::string>().c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
fields[3].GetCString(), fields[4].GetCString());
fields[3].Get<std::string>().c_str(), fields[4].Get<std::string>().c_str());
}
} while (result->NextRow());

View File

@@ -33,6 +33,7 @@ EndScriptData */
#include "PlayerDump.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "Timer.h"
#include "World.h"
#include "WorldSession.h"
@@ -119,7 +120,7 @@ public:
if (isNumeric(searchString.c_str()))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID);
stmt->setUInt32(0, uint32(atoi(searchString.c_str())));
stmt->SetData(0, *Acore::StringTo<uint32>(searchString));
result = CharacterDatabase.Query(stmt);
}
// search by name
@@ -129,7 +130,7 @@ public:
return false;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME);
stmt->setString(0, searchString);
stmt->SetData(0, searchString);
result = CharacterDatabase.Query(stmt);
}
}
@@ -147,13 +148,13 @@ public:
DeletedInfo info;
info.lowGuid = fields[0].GetUInt32();
info.name = fields[1].GetString();
info.accountId = fields[2].GetUInt32();
info.lowGuid = fields[0].Get<uint32>();
info.name = fields[1].Get<std::string>();
info.accountId = fields[2].Get<uint32>();
// account name will be empty for nonexisting account
AccountMgr::GetName(info.accountId, info.accountName);
info.deleteDate = time_t(fields[3].GetUInt32());
info.deleteDate = time_t(fields[3].Get<uint32>());
foundList.push_back(info);
} while (result->NextRow());
}
@@ -182,7 +183,7 @@ public:
for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
{
std::string dateStr = TimeToTimestampStr(itr->deleteDate);
std::string dateStr = Acore::Time::TimeToTimestampStr(Seconds(itr->deleteDate));
if (!handler->GetSession())
handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE,
@@ -231,16 +232,16 @@ public:
}
auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO);
stmt->setString(0, delInfo.name);
stmt->setUInt32(1, delInfo.accountId);
stmt->setUInt32(2, delInfo.lowGuid);
stmt->SetData(0, delInfo.name);
stmt->SetData(1, delInfo.accountId);
stmt->SetData(2, delInfo.lowGuid);
CharacterDatabase.Execute(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA);
stmt->setUInt32(0, delInfo.lowGuid);
stmt->SetData(0, delInfo.lowGuid);
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
{
sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, delInfo.lowGuid), delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8());
sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, delInfo.lowGuid), delInfo.accountId, delInfo.name, (*result)[2].Get<uint8>(), (*result)[0].Get<uint8>(), (*result)[1].Get<uint8>(), (*result)[3].Get<uint8>());
}
}
@@ -266,8 +267,8 @@ public:
{
// Update level and reset XP, everything else will be updated at login
auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL);
stmt->setUInt8(0, uint8(newLevel));
stmt->setUInt32(1, playerGuid.GetCounter());
stmt->SetData(0, uint8(newLevel));
stmt->SetData(1, playerGuid.GetCounter());
CharacterDatabase.Execute(stmt);
sCharacterCache->UpdateCharacterLevel(playerGuid, newLevel);
@@ -362,7 +363,7 @@ public:
}
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
stmt->setString(0, newName);
stmt->SetData(0, newName);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
@@ -373,7 +374,7 @@ public:
// Remove declined name from db
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
stmt->setUInt32(0, player->GetGUID().GetCounter());
stmt->SetData(0, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
if (Player* target = player->GetConnectedPlayer())
@@ -386,8 +387,8 @@ public:
else
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NAME_BY_GUID);
stmt->setString(0, newName);
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, newName);
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -411,8 +412,8 @@ public:
handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_RENAME));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_RENAME));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
}
@@ -466,8 +467,8 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -490,8 +491,8 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_CHANGE_FACTION));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -514,8 +515,8 @@ public:
{
handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter());
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE));
stmt->setUInt32(1, player->GetGUID().GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_CHANGE_RACE));
stmt->SetData(1, player->GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@@ -815,51 +816,96 @@ public:
if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
return false;
switch (PlayerDumpReader().LoadDump(fileName, account, name, characterGUID.value_or(0)))
switch (PlayerDumpReader().LoadDumpFromFile(fileName, account, name, characterGUID.value_or(0)))
{
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_BROKEN:
handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_TOO_MANY_CHARS:
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_BROKEN:
handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_TOO_MANY_CHARS:
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
static bool HandlePDumpCopyCommand(ChatHandler* handler, PlayerIdentifier player, AccountIdentifier account, Optional<std::string_view> characterName, Optional<ObjectGuid::LowType> characterGUID)
{
std::string name;
if (!ValidatePDumpTarget(handler, name, characterName, characterGUID))
return false;
std::string dump;
switch (PlayerDumpWriter().WriteDumpToString(dump, player.GetGUID().GetCounter()))
{
case DUMP_SUCCESS:
break;
case DUMP_CHARACTER_DELETED:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_OPEN_ERROR: // this error code should not happen
default:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
switch (PlayerDumpReader().LoadDumpFromString(dump, account, name, characterGUID.value_or(0)))
{
case DUMP_SUCCESS:
break;
case DUMP_TOO_MANY_CHARS:
handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID());
handler->SetSentErrorMessage(true);
return false;
case DUMP_FILE_OPEN_ERROR: // this error code should not happen
case DUMP_FILE_BROKEN: // this error code should not happen
default:
handler->PSendSysMessage(LANG_COMMAND_IMPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
// Original TC Notes from Refactor vvv
//ToDo: use a new trinity_string for this commands
handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS);
return true;
}
static bool HandlePDumpWriteCommand(ChatHandler* handler, std::string fileName, PlayerIdentifier player)
{
switch (PlayerDumpWriter().WriteDump(fileName, player.GetGUID().GetCounter()))
switch (PlayerDumpWriter().WriteDumpToFile(fileName, player.GetGUID().GetCounter()))
{
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_CHARACTER_DELETED:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
case DUMP_SUCCESS:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS);
break;
case DUMP_FILE_OPEN_ERROR:
handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str());
handler->SetSentErrorMessage(true);
return false;
case DUMP_CHARACTER_DELETED:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_DELETED_CHAR);
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_COMMAND_EXPORT_FAILED);
handler->SetSentErrorMessage(true);
return false;
}
return true;

View File

@@ -33,6 +33,7 @@
#include "Language.h"
#include "Log.h"
#include "MapMgr.h"
#include "M2Stores.h"
#include "ObjectMgr.h"
#include "PoolMgr.h"
#include "ScriptMgr.h"
@@ -115,7 +116,8 @@ public:
// cinematicId - ID from CinematicSequences.dbc
static bool HandleDebugPlayCinematicCommand(ChatHandler* handler, uint32 cinematicId)
{
if (!sCinematicSequencesStore.LookupEntry(cinematicId))
CinematicSequencesEntry const* cineSeq = sCinematicSequencesStore.LookupEntry(cinematicId);
if (!cineSeq)
{
handler->PSendSysMessage(LANG_CINEMATIC_NOT_EXIST, cinematicId);
handler->SetSentErrorMessage(true);
@@ -123,23 +125,19 @@ public:
}
// Dump camera locations
if (CinematicSequencesEntry const* cineSeq = sCinematicSequencesStore.LookupEntry(cinematicId))
if (std::vector<FlyByCamera> const* flyByCameras = GetFlyByCameras(cineSeq->cinematicCamera))
{
auto const& itr = sFlyByCameraStore.find(cineSeq->cinematicCamera);
if (itr != sFlyByCameraStore.end())
handler->PSendSysMessage("Waypoints for sequence %u, camera %u", cinematicId, cineSeq->cinematicCamera);
uint32 count = 1;
for (FlyByCamera const& cam : *flyByCameras)
{
handler->PSendSysMessage("Waypoints for sequence %u, camera %u", cinematicId, cineSeq->cinematicCamera);
uint32 count = 1;
for (FlyByCamera cam : itr->second)
{
handler->PSendSysMessage("%02u - %7ums [%f, %f, %f] Facing %f (%f degrees)", count, cam.timeStamp, cam.locations.x, cam.locations.y, cam.locations.z, cam.locations.w, cam.locations.w * (180 / M_PI));
count++;
}
handler->PSendSysMessage("%lu waypoints dumped", itr->second.size());
handler->PSendSysMessage("%02u - %7ums [%s (%f degrees)]", count, cam.timeStamp, cam.locations.ToString().c_str(), cam.locations.GetOrientation() * (180 / M_PI));
++count;
}
handler->PSendSysMessage("%u waypoints dumped", flyByCameras->size());
}
handler->GetSession()->GetPlayer()->SendCinematicStart(cinematicId);
handler->GetPlayer()->SendCinematicStart(cinematicId);
return true;
}
@@ -418,7 +416,7 @@ public:
}
else
{
LOG_ERROR("network.opcode", "Sending opcode that has unknown type '%s'", type.c_str());
LOG_ERROR("network.opcode", "Sending opcode that has unknown type '{}'", type);
break;
}
}
@@ -1240,7 +1238,7 @@ public:
{
Player* player = handler->GetSession()->GetPlayer();
LOG_INFO("sql.dev", "(@PATH, XX, %.3f, %.3f, %.5f, 0,0, 0,100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
LOG_INFO("sql.dev", "(@PATH, XX, {0:.3f}, {0:.3f}, {0:.5f}, 0,0, 0,100, 0),", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
handler->PSendSysMessage("Waypoint SQL written to SQL Developer log");
return true;

View File

@@ -149,8 +149,8 @@ public:
WorldDatabasePreparedStatement* stmt = nullptr;
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
stmt->SetData(0, entry);
stmt->SetData(1, disableType);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
{
@@ -160,10 +160,10 @@ public:
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
stmt->setUInt16(2, flags);
stmt->setString(3, disableComment);
stmt->SetData(0, entry);
stmt->SetData(1, disableType);
stmt->SetData(2, flags);
stmt->SetData(3, disableComment);
WorldDatabase.Execute(stmt);
handler->PSendSysMessage("Add Disabled %s (Id: %u) for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str());
@@ -237,8 +237,8 @@ public:
WorldDatabasePreparedStatement* stmt = nullptr;
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
stmt->SetData(0, entry);
stmt->SetData(1, disableType);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
@@ -248,8 +248,8 @@ public:
}
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_DISABLES);
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
stmt->SetData(0, entry);
stmt->SetData(1, disableType);
WorldDatabase.Execute(stmt);
handler->PSendSysMessage("Remove Disabled %s (Id: %u)", disableTypeStr.c_str(), entry);

View File

@@ -24,9 +24,11 @@
#include "Chat.h"
#include "GameEventMgr.h"
#include "GameTime.h"
#include "Language.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Timer.h"
using namespace Acore::ChatCommands;
@@ -111,12 +113,12 @@ public:
bool active = activeEvents.find(eventId) != activeEvents.end();
char const* activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : "";
std::string startTimeStr = TimeToTimestampStr(eventData.start);
std::string endTimeStr = TimeToTimestampStr(eventData.end);
std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.start));
std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.end));
uint32 delay = sGameEventMgr->NextCheck(eventId);
time_t nextTime = time(nullptr) + delay;
std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(nullptr) + delay) : "-";
time_t nextTime = GameTime::GetGameTime().count() + delay;
std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? Acore::Time::TimeToTimestampStr(Seconds(nextTime)) : "-";
std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE, true);
std::string lengthStr = secsToTimeString(eventData.length * MINUTE, true);

View File

@@ -0,0 +1,128 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
#include "Chat.h"
#include "Language.h"
#include "Log.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "WorldSession.h"
using namespace Acore::ChatCommands;
class gear_commandscript : public CommandScript
{
public:
gear_commandscript() : CommandScript("gear_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable gearCommandTable =
{
{ "repair", HandleGearRepairCommand, SEC_GAMEMASTER, Console::No },
{ "stats", HandleGearStatsCommand, SEC_PLAYER, Console::No }
};
static ChatCommandTable commandTable =
{
{ "gear", gearCommandTable }
};
return commandTable;
}
static bool HandleGearRepairCommand(ChatHandler* handler, Optional<PlayerIdentifier> target)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target || !target->IsConnected())
{
return false;
}
// check online security
if (handler->HasLowerSecurity(target->GetConnectedPlayer()))
{
return false;
}
// Repair items
target->GetConnectedPlayer()->DurabilityRepairAll(false, 0, false);
std::string nameLink = handler->playerLink(target->GetName());
handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, nameLink.c_str());
if (handler->needReportToTarget(target->GetConnectedPlayer()))
{
ChatHandler(target->GetConnectedPlayer()->GetSession()).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, nameLink.c_str());
}
return true;
}
static bool HandleGearStatsCommand(ChatHandler* handler)
{
Player* player = handler->getSelectedPlayerOrSelf();
if (!player)
{
return false;
}
handler->PSendSysMessage("Character: %s", player->GetPlayerName().c_str());
handler->PSendSysMessage("Current equipment average item level: |cff00ffff%u|r", (int16)player->GetAverageItemLevel());
if (sWorld->getIntConfig(CONFIG_MIN_LEVEL_STAT_SAVE))
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_STATS);
stmt->SetData(0, player->GetGUID().GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
Field* fields = result->Fetch();
uint32 MaxHealth = fields[0].Get<uint32>();
uint32 Strength = fields[1].Get<uint32>();
uint32 Agility = fields[2].Get<uint32>();
uint32 Stamina = fields[3].Get<uint32>();
uint32 Intellect = fields[4].Get<uint32>();
uint32 Spirit = fields[5].Get<uint32>();
uint32 Armor = fields[6].Get<uint32>();
uint32 AttackPower = fields[7].Get<uint32>();
uint32 SpellPower = fields[8].Get<uint32>();
uint32 Resilience = fields[9].Get<uint32>();
handler->PSendSysMessage("Health: |cff00ffff%u|r - Stamina: |cff00ffff%u|r", MaxHealth, Stamina);
handler->PSendSysMessage("Strength: |cff00ffff%u|r - Agility: |cff00ffff%u|r", Strength, Agility);
handler->PSendSysMessage("Intellect: |cff00ffff%u|r - Spirit: |cff00ffff%u|r", Intellect, Spirit);
handler->PSendSysMessage("AttackPower: |cff00ffff%u|r - SpellPower: |cff00ffff%u|r", AttackPower, SpellPower);
handler->PSendSysMessage("Armor: |cff00ffff%u|r - Resilience: |cff00ffff%u|r", Armor, Resilience);
}
}
return true;
}
};
void AddSC_gear_commandscript()
{
new gear_commandscript();
}

View File

@@ -45,13 +45,13 @@ public:
{
static ChatCommandTable gmCommandTable =
{
{ "chat", HandleGMChatCommand, SEC_GAMEMASTER, Console::No },
{ "fly", HandleGMFlyCommand, SEC_GAMEMASTER, Console::No },
{ "ingame", HandleGMListIngameCommand, SEC_PLAYER, Console::Yes },
{ "list", HandleGMListFullCommand, SEC_GAMEMASTER, Console::Yes },
{ "visible", HandleGMVisibleCommand, SEC_GAMEMASTER, Console::No },
{ "on", HandleGMOnCommand, SEC_GAMEMASTER, Console::No },
{ "off", HandleGMOffCommand, SEC_GAMEMASTER, Console::No }
{ "chat", HandleGMChatCommand, SEC_GAMEMASTER, Console::No },
{ "fly", HandleGMFlyCommand, SEC_GAMEMASTER, Console::No },
{ "ingame", HandleGMListIngameCommand, SEC_PLAYER, Console::Yes },
{ "list", HandleGMListFullCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "visible", HandleGMVisibleCommand, SEC_GAMEMASTER, Console::No },
{ "on", HandleGMOnCommand, SEC_MODERATOR, Console::No },
{ "off", HandleGMOffCommand, SEC_MODERATOR, Console::No }
};
static ChatCommandTable commandTable =
{
@@ -157,8 +157,8 @@ public:
{
///- Get the accounts with GM Level >0
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_GM_ACCOUNTS);
stmt->setUInt8(0, uint8(SEC_MODERATOR));
stmt->setInt32(1, int32(realm.Id.Realm));
stmt->SetData(0, uint8(SEC_MODERATOR));
stmt->SetData(1, int32(realm.Id.Realm));
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (result)
@@ -169,16 +169,16 @@ public:
do
{
Field* fields = result->Fetch();
char const* name = fields[0].GetCString();
uint8 security = fields[1].GetUInt8();
uint8 max = (16 - strlen(name)) / 2;
std::string name = fields[0].Get<std::string>();
uint8 security = fields[1].Get<uint8>();
uint8 max = (16 - name.length()) / 2;
uint8 max2 = max;
if ((max + max2 + strlen(name)) == 16)
if ((max + max2 + name.length()) == 16)
max2 = max - 1;
if (handler->GetSession())
handler->PSendSysMessage("| %s GMLevel %u", name, security);
handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security);
else
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security);
handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security);
} while (result->NextRow());
handler->SendSysMessage("========================");
}

View File

@@ -52,7 +52,8 @@ public:
{ "trigger", HandleGoTriggerCommand, SEC_MODERATOR, Console::No },
{ "zonexy", HandleGoZoneXYCommand, SEC_MODERATOR, Console::No },
{ "xyz", HandleGoXYZCommand, SEC_MODERATOR, Console::No },
{ "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No }
{ "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No },
{ "quest", HandleGoQuestCommand, SEC_MODERATOR, Console::No },
};
static ChatCommandTable commandTable =
@@ -91,20 +92,7 @@ public:
static bool HandleGoCreatureCIdCommand(ChatHandler* handler, Variant<Hyperlink<creature_entry>, uint32> cId)
{
CreatureData const* spawnpoint = nullptr;
for (auto const& pair : sObjectMgr->GetAllCreatureData())
{
if (pair.second.id != *cId)
continue;
if (!spawnpoint)
spawnpoint = &pair.second;
else
{
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
break;
}
}
CreatureData const* spawnpoint = GetCreatureData(handler, *cId);
if (!spawnpoint)
{
@@ -144,20 +132,7 @@ public:
static bool HandleGoGameObjectGOIdCommand(ChatHandler* handler, uint32 goId)
{
GameObjectData const* spawnpoint = nullptr;
for (auto const& pair : sObjectMgr->GetAllGOData())
{
if (pair.second.id != goId)
continue;
if (!spawnpoint)
spawnpoint = &pair.second;
else
{
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
break;
}
}
GameObjectData const* spawnpoint = GetGameObjectData(handler, goId);
if (!spawnpoint)
{
@@ -367,6 +342,146 @@ public:
ticket->TeleportTo(player);
return true;
}
static bool HandleGoQuestCommand(ChatHandler* handler, std::string_view type, Quest const* quest)
{
uint32 entry = quest->GetQuestId();
if (type == "starter")
{
QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
{
if (itr->second == entry)
{
CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
if (!spawnpoint)
{
handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
// We've found a creature, teleport to it.
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
}
}
qr = sObjectMgr->GetGOQuestRelationMap();
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
{
if (itr->second == entry)
{
GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
if (!spawnpoint)
{
handler->SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
}
}
}
else if (type == "ender")
{
QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
{
if (itr->second == entry)
{
CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
if (!spawnpoint)
{
handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
// We've found a creature, teleport to it.
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
}
}
qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
{
if (itr->second == entry)
{
GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
if (!spawnpoint)
{
handler->SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
handler->SetSentErrorMessage(true);
return false;
}
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
}
}
}
else
{
handler->SendSysMessage(LANG_CMD_GOQUEST_INVALID_SYNTAX);
handler->SetSentErrorMessage(true);
return false;
}
return false;
}
static CreatureData const* GetCreatureData(ChatHandler* handler, uint32 entry)
{
CreatureData const* spawnpoint = nullptr;
for (auto const& pair : sObjectMgr->GetAllCreatureData())
{
if (pair.second.id1 != entry)
{
continue;
}
if (!spawnpoint)
{
spawnpoint = &pair.second;
}
else
{
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
break;
}
}
return spawnpoint;
}
static GameObjectData const* GetGameObjectData(ChatHandler* handler, uint32 entry)
{
GameObjectData const* spawnpoint = nullptr;
for (auto const& pair : sObjectMgr->GetAllGOData())
{
if (pair.second.id != entry)
{
continue;
}
if (!spawnpoint)
{
spawnpoint = &pair.second;
}
else
{
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
break;
}
}
return spawnpoint;
}
};
void AddSC_go_commandscript()

View File

@@ -25,6 +25,7 @@ EndScriptData */
#include "Chat.h"
#include "GameEventMgr.h"
#include "GameObject.h"
#include "GameTime.h"
#include "Language.h"
#include "MapMgr.h"
#include "ObjectMgr.h"
@@ -105,7 +106,7 @@ public:
if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId))
{
// report to DB errors log as in loading case
LOG_ERROR("sql.sql", "Gameobject (Entry %u GoType: %u) have invalid displayId (%u), not spawned.", *objectId, objectInfo->type, objectInfo->displayId);
LOG_ERROR("sql.sql", "Gameobject (Entry {} GoType: {}) have invalid displayId ({}), not spawned.", *objectId, objectInfo->type, objectInfo->displayId);
handler->PSendSysMessage(LANG_GAMEOBJECT_HAVE_INVALID_DATA, uint32(objectId));
handler->SetSentErrorMessage(true);
return false;
@@ -171,7 +172,7 @@ public:
float z = player->GetPositionZ();
float ang = player->GetOrientation();
float rot2 = sin(ang / 2);
float rot2 = std::sin(ang / 2);
float rot3 = cos(ang / 2);
player->SummonGameObject(objectId, x, y, z, ang, 0, 0, rot2, rot3, spawntm);
@@ -189,17 +190,17 @@ public:
{
if (objectId->holds_alternative<GameObjectEntry>())
{
result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1",
result = WorldDatabase.Query("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM gameobject WHERE map = '{}' AND id = '{}' ORDER BY order_ ASC LIMIT 1",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), static_cast<uint32>(objectId->get<GameObjectEntry>()));
}
else
{
std::string name = std::string(objectId->get<std::string_view>());
WorldDatabase.EscapeString(name);
result = WorldDatabase.PQuery(
"SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ "
"FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = %i AND name LIKE '%%%s%%' ORDER BY order_ ASC LIMIT 1",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name.c_str());
result = WorldDatabase.Query(
"SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - {}, 2) + POW(position_y - {}, 2) + POW(position_z - {}, 2)) AS order_ "
"FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = {} AND name LIKE '%{}%' ORDER BY order_ ASC LIMIT 1",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name);
}
}
else
@@ -224,11 +225,11 @@ public:
else
eventFilter << ')';
result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, "
"(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject "
"LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10",
result = WorldDatabase.Query("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, "
"(POW(position_x - {}, 2) + POW(position_y - {}, 2) + POW(position_z - {}, 2)) AS order_ FROM gameobject "
"LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '{}' {} ORDER BY order_ ASC LIMIT 10",
handler->GetSession()->GetPlayer()->GetPositionX(), handler->GetSession()->GetPlayer()->GetPositionY(), handler->GetSession()->GetPlayer()->GetPositionZ(),
handler->GetSession()->GetPlayer()->GetMapId(), eventFilter.str().c_str());
handler->GetSession()->GetPlayer()->GetMapId(), eventFilter.str());
}
if (!result)
@@ -247,14 +248,14 @@ public:
do
{
Field* fields = result->Fetch();
guidLow = fields[0].GetUInt32();
id = fields[1].GetUInt32();
x = fields[2].GetFloat();
y = fields[3].GetFloat();
z = fields[4].GetFloat();
o = fields[5].GetFloat();
mapId = fields[6].GetUInt16();
phase = fields[7].GetUInt32();
guidLow = fields[0].Get<uint32>();
id = fields[1].Get<uint32>();
x = fields[2].Get<float>();
y = fields[3].Get<float>();
z = fields[4].Get<float>();
o = fields[5].Get<float>();
mapId = fields[6].Get<uint16>();
phase = fields[7].Get<uint32>();
poolId = sPoolMgr->IsPartOfAPool<GameObject>(guidLow);
if (!poolId || sPoolMgr->IsSpawnedObject<GameObject>(guidLow))
found = true;
@@ -280,7 +281,7 @@ public:
if (target)
{
int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - time(nullptr));
int32 curRespawnDelay = int32(target->GetRespawnTimeEx() - GameTime::GetGameTime().count());
if (curRespawnDelay < 0)
curRespawnDelay = 0;
@@ -456,15 +457,15 @@ public:
Player* player = handler->GetSession()->GetPlayer();
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAMEOBJECT_NEAREST);
stmt->setFloat(0, player->GetPositionX());
stmt->setFloat(1, player->GetPositionY());
stmt->setFloat(2, player->GetPositionZ());
stmt->setUInt32(3, player->GetMapId());
stmt->setFloat(4, player->GetPositionX());
stmt->setFloat(5, player->GetPositionY());
stmt->setFloat(6, player->GetPositionZ());
stmt->setFloat(7, distance * distance);
stmt->setUInt32(8, player->GetPhaseMask());
stmt->SetData(0, player->GetPositionX());
stmt->SetData(1, player->GetPositionY());
stmt->SetData(2, player->GetPositionZ());
stmt->SetData(3, player->GetMapId());
stmt->SetData(4, player->GetPositionX());
stmt->SetData(5, player->GetPositionY());
stmt->SetData(6, player->GetPositionZ());
stmt->SetData(7, distance * distance);
stmt->SetData(8, player->GetPhaseMask());
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
@@ -472,12 +473,12 @@ public:
do
{
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
float z = fields[4].GetFloat();
uint16 mapId = fields[5].GetUInt16();
ObjectGuid::LowType guid = fields[0].Get<uint32>();
uint32 entry = fields[1].Get<uint32>();
float x = fields[2].Get<float>();
float y = fields[3].Get<float>();
float z = fields[4].Get<float>();
uint16 mapId = fields[5].Get<uint16>();
GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry);
@@ -580,10 +581,7 @@ public:
object->SetByteValue(GAMEOBJECT_BYTES_1, objectType, *objectState);
else if (objectType == 4)
{
WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
data << object->GetGUID();
data << static_cast<uint32>(*objectState);
object->SendMessageToSet(&data, true);
object->SendCustomAnim(*objectState);
}
handler->PSendSysMessage("Set gobject type %d state %u", objectType, *objectState);
return true;

View File

@@ -0,0 +1,266 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
#include "Chat.h"
#include "DatabaseEnv.h"
#include "GroupMgr.h"
#include "Language.h"
#include "Player.h"
#include "ScriptMgr.h"
using namespace Acore::ChatCommands;
class group_commandscript : public CommandScript
{
public:
group_commandscript() : CommandScript("group_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable groupCommandTable =
{
{ "list", HandleGroupListCommand, SEC_GAMEMASTER, Console::No },
{ "join", HandleGroupJoinCommand, SEC_GAMEMASTER, Console::No },
{ "remove", HandleGroupRemoveCommand, SEC_GAMEMASTER, Console::No },
{ "disband", HandleGroupDisbandCommand, SEC_GAMEMASTER, Console::No },
{ "leader", HandleGroupLeaderCommand, SEC_GAMEMASTER, Console::No }
};
static ChatCommandTable commandTable =
{
{ "group", groupCommandTable }
};
return commandTable;
}
static bool HandleGroupLeaderCommand(ChatHandler* handler, Optional<PlayerIdentifier> target)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target)
{
return false;
}
Player* player = nullptr;
Group* group = nullptr;
ObjectGuid guid;
if (handler->GetPlayerGroupAndGUIDByName(target->GetName().c_str(), player, group, guid))
{
if (group && group->GetLeaderGUID() != guid)
{
group->ChangeLeader(guid);
group->SendUpdate();
}
}
return true;
}
static bool HandleGroupDisbandCommand(ChatHandler* handler, Optional<PlayerIdentifier> target)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target || !target->IsConnected())
{
return false;
}
Player* player = nullptr;
Group* group = nullptr;
ObjectGuid guid;
if (handler->GetPlayerGroupAndGUIDByName(target->GetName().c_str(), player, group, guid))
{
if (group)
{
group->Disband();
}
}
return true;
}
static bool HandleGroupRemoveCommand(ChatHandler* handler, Optional<PlayerIdentifier> target)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target || !target->IsConnected())
{
return false;
}
Player* player = nullptr;
Group* group = nullptr;
ObjectGuid guid;
if (handler->GetPlayerGroupAndGUIDByName(target->GetName().c_str(), player, group, guid, true))
{
if (group)
{
group->RemoveMember(guid);
}
}
return true;
}
static bool HandleGroupJoinCommand(ChatHandler* handler, std::string const& playerInGroup, std::string const& playerName)
{
if (playerInGroup.empty() || playerName.empty())
{
return false;
}
Player* playerSource = nullptr;
Group* groupSource = nullptr;
ObjectGuid guidSource;
ObjectGuid guidTarget;
if (handler->GetPlayerGroupAndGUIDByName(playerInGroup.c_str(), playerSource, groupSource, guidSource, true))
{
if (groupSource)
{
Group* groupTarget = nullptr;
Player* playerTarget = nullptr;
if (handler->GetPlayerGroupAndGUIDByName(playerName.c_str(), playerTarget, groupTarget, guidTarget, true))
{
if (!groupTarget && playerTarget->GetGroup() != groupSource)
{
if (!groupSource->IsFull())
{
groupSource->AddMember(playerTarget);
groupSource->BroadcastGroupUpdate();
handler->PSendSysMessage(LANG_GROUP_PLAYER_JOINED, playerTarget->GetName().c_str(), playerSource->GetName().c_str());
return true;
}
else
{
// group is full
handler->PSendSysMessage(LANG_GROUP_FULL);
return true;
}
}
else
{
// group is full or target player already in a group
handler->PSendSysMessage(LANG_GROUP_ALREADY_IN_GROUP, playerTarget->GetName().c_str());
return true;
}
}
}
else
{
// specified source player is not in a group
handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, playerSource->GetName().c_str());
return true;
}
}
return true;
}
static bool HandleGroupListCommand(ChatHandler* handler, Optional<PlayerIdentifier> target)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target)
{
return false;
}
Group* groupTarget = nullptr;
if (target->IsConnected())
{
groupTarget = target->GetConnectedPlayer()->GetGroup();
}
if (!groupTarget)
{
if (ObjectGuid groupGUID = sCharacterCache->GetCharacterGroupGuidByGuid(target->GetGUID()))
{
groupTarget = sGroupMgr->GetGroupByGUID(groupGUID.GetCounter());
}
}
if (!groupTarget)
{
handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, target->GetName().c_str());
return true;
}
handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"));
for (auto const& slot : groupTarget->GetMemberSlots())
{
std::string flags;
if (slot.flags & MEMBER_FLAG_ASSISTANT)
{
flags = "Assistant";
}
if (slot.flags & MEMBER_FLAG_MAINTANK)
{
if (!flags.empty())
{
flags.append(", ");
}
flags.append("MainTank");
}
if (slot.flags & MEMBER_FLAG_MAINASSIST)
{
if (!flags.empty())
{
flags.append(", ");
}
flags.append("MainAssist");
}
if (flags.empty())
{
flags = "None";
}
}
return true;
}
};
void AddSC_group_commandscript()
{
new group_commandscript();
}

View File

@@ -26,7 +26,6 @@ EndScriptData */
#include "Guild.h"
#include "GuildMgr.h"
#include "Language.h"
#include "ObjectAccessor.h"
#include "ScriptMgr.h"
#if AC_COMPILER == AC_COMPILER_GNU
@@ -49,6 +48,7 @@ public:
{ "invite", SEC_GAMEMASTER, true, &HandleGuildInviteCommand, "" },
{ "uninvite", SEC_GAMEMASTER, true, &HandleGuildUninviteCommand, "" },
{ "rank", SEC_GAMEMASTER, true, &HandleGuildRankCommand, "" },
{ "rename", SEC_GAMEMASTER, true, &HandleGuildRenameCommand, "" },
{ "info", SEC_GAMEMASTER, true, &HandleGuildInfoCommand, "" }
};
static ChatCommandTable commandTable =
@@ -207,6 +207,55 @@ public:
return targetGuild->ChangeMemberRank(player->GetGUID(), rank);
}
static bool HandleGuildRenameCommand(ChatHandler* handler, char const* _args)
{
if (!*_args)
return false;
char *args = (char *)_args;
char const* oldGuildStr = handler->extractQuotedArg(args);
if (!oldGuildStr)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
char const* newGuildStr = handler->extractQuotedArg(strtok(nullptr, ""));
if (!newGuildStr)
{
handler->SendSysMessage(LANG_INSERT_GUILD_NAME);
handler->SetSentErrorMessage(true);
return false;
}
Guild* guild = sGuildMgr->GetGuildByName(oldGuildStr);
if (!guild)
{
handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, oldGuildStr);
handler->SetSentErrorMessage(true);
return false;
}
if (sGuildMgr->GetGuildByName(newGuildStr))
{
handler->PSendSysMessage(LANG_GUILD_RENAME_ALREADY_EXISTS, newGuildStr);
handler->SetSentErrorMessage(true);
return false;
}
if (!guild->SetName(newGuildStr))
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
handler->PSendSysMessage(LANG_GUILD_RENAME_DONE, oldGuildStr, newGuildStr);
return true;
}
static bool HandleGuildInfoCommand(ChatHandler* handler, char const* args)
{
Guild* guild = nullptr;
@@ -232,14 +281,7 @@ public:
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().GetCounter()); // Guild Master
}
// Format creation date
char createdDateStr[20];
time_t createdDate = guild->GetCreatedDate();
tm localTm;
localtime_r(&createdDate, &localTm);
strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", &localTm);
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, Acore::Time::TimeToHumanReadable(Seconds(guild->GetCreatedDate())).c_str()); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMemberCount()); // Number of Members
handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, guild->GetTotalBankMoney() / 100 / 100); // Bank Gold (in gold coins)
handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD().c_str()); // Message of the day

View File

@@ -23,6 +23,7 @@
EndScriptData */
#include "Chat.h"
#include "GameTime.h"
#include "Group.h"
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
@@ -73,7 +74,7 @@ public:
{
InstanceSave const* save = bind.save;
uint32 resetTime = bind.extended ? save->GetExtendedResetTime() : save->GetResetTime();
uint32 ttr = (resetTime >= time(nullptr) ? resetTime - time(nullptr) : 0);
uint32 ttr = (resetTime >= GameTime::GetGameTime().count() ? resetTime - GameTime::GetGameTime().count() : 0);
std::string timeleft = secsToTimeString(ttr);
handler->PSendSysMessage("map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s",
mapId, save->GetInstanceId(), bind.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (bind.extended ? " (extended)" : ""));
@@ -111,7 +112,7 @@ public:
if (itr->first != player->GetMapId() && (!mapId || mapId == itr->first) && (!difficultyArg || difficultyArg == save->GetDifficulty()))
{
uint32 resetTime = itr->second.extended ? save->GetExtendedResetTime() : save->GetResetTime();
uint32 ttr = (resetTime >= time(nullptr) ? resetTime - time(nullptr) : 0);
uint32 ttr = (resetTime >= GameTime::GetGameTime().count() ? resetTime - GameTime::GetGameTime().count() : 0);
std::string timeleft = secsToTimeString(ttr);
handler->PSendSysMessage("unbinding map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (itr->second.extended ? " (extended)" : ""));
sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), itr->first, Difficulty(i), true, player);

View File

@@ -0,0 +1,187 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
#include "Chat.h"
#include "Language.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "WorldSession.h"
constexpr std::array<const char*, MAX_ITEM_SUBCLASS_CONTAINER> bagSpecsToString =
{
"normal",
"soul",
"herb",
"enchanting",
"engineering",
"gem",
"mining",
"leatherworking",
"inscription"
};
constexpr std::array<uint32, MAX_ITEM_SUBCLASS_CONTAINER> bagSpecsColors =
{
0xfff0de18, // YELLOW - Normal
0xffa335ee, // PURPLE - Souls
0xff1eff00, // GREEN - Herb
0xffe37166, // PINK - Enchanting
0xffa68b30, // BROWN - Engineering
0xff0070dd, // BLUE - Gem
0xffc1c8c9, // GREY - Mining
0xfff5a925, // ORANGE - Leatherworking
0xff54504f // DARK GREY - Inscription
};
//constexpr std::array<const char*, MAX_ITEM_SUBCLASS_CONTAINER> bagSpecsColorToString =
//{
// "normal",
// "soul",
// "herb",
// "enchanting",
// "engineering",
// "gem",
// "mining",
// "leatherworking",
// "inscription"
//};
using namespace Acore::ChatCommands;
class inventory_commandscript : public CommandScript
{
public:
inventory_commandscript() : CommandScript("inventory_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable inventoryCommandTable =
{
{ "count", HandleInventoryCountCommand, SEC_MODERATOR, Console::No }
};
static ChatCommandTable commandTable =
{
{ "inventory", inventoryCommandTable }
};
return commandTable;
}
static bool HandleInventoryCountCommand(ChatHandler* handler, Optional<PlayerIdentifier> player)
{
if (!player)
{
player = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!player)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
return false;
}
Player* target = player->GetConnectedPlayer();
if (!target)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
handler->SetSentErrorMessage(true);
return false;
}
std::array<uint32, MAX_ITEM_SUBCLASS_CONTAINER> freeSlotsInBags = { };
uint32 freeSlotsForBags = 0;
bool haveFreeSlot = false;
// Check backpack
for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; ++slot)
{
if (!target->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
{
haveFreeSlot = true;
++freeSlotsInBags[ITEM_SUBCLASS_CONTAINER];
}
}
// Check bags
for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
{
if (Bag* bag = target->GetBagByPos(i))
{
if (ItemTemplate const* bagTemplate = bag->GetTemplate())
{
if (bagTemplate->Class == ITEM_CLASS_CONTAINER || bagTemplate->Class == ITEM_CLASS_QUIVER)
{
haveFreeSlot = true;
freeSlotsInBags[bagTemplate->SubClass] += bag->GetFreeSlots();
}
}
}
else
{
++freeSlotsForBags;
}
}
std::ostringstream str;
if (haveFreeSlot)
{
str << "Player " << target->GetName() << " have ";
bool initialize = true;
for (uint8 i = ITEM_SUBCLASS_CONTAINER; i < MAX_ITEM_SUBCLASS_CONTAINER; ++i)
{
if (uint32 freeSlots = freeSlotsInBags[i])
{
std::string bagSpecString = bagSpecsToString[i];
if (!initialize)
{
str << ", ";
}
str << "|c";
str << std::hex << bagSpecsColors[i] << std::dec;
str << freeSlots << " in " << bagSpecString << " bags|r";
initialize = false;
}
}
}
else
{
str << "Player " << target->GetName() << " does not have free slots in their bags";
}
if (freeSlotsForBags)
{
str << " and also has " << freeSlotsForBags << " free slots for bags";
}
str << ".";
handler->SendSysMessage(str.str().c_str());
return true;
}
};
void AddSC_inventory_commandscript()
{
new inventory_commandscript();
}

View File

@@ -0,0 +1,385 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
/* ScriptData
Name: item_commandscript
%Complete: 0
Comment: All item related commands
Category: commandscripts
EndScriptData */
#include "Chat.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"
#include "Language.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
using namespace Acore::ChatCommands;
class item_commandscript : public CommandScript
{
public:
item_commandscript() : CommandScript("item_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable HandleItemRestoreCommandTable =
{
{ "list", HandleItemRestoreListCommand, SEC_GAMEMASTER, Console::Yes },
{ "", HandleItemRestoreCommand, SEC_GAMEMASTER, Console::Yes },
};
static ChatCommandTable itemCommandTable =
{
{ "restore", HandleItemRestoreCommandTable },
{ "move", HandleItemMoveCommand, SEC_GAMEMASTER, Console::Yes },
{ "refund", HandleItemRefundCommand, SEC_ADMINISTRATOR, Console::Yes },
};
static ChatCommandTable commandTable =
{
{ "item", itemCommandTable }
};
return commandTable;
}
static bool HandleItemRestoreCommand(ChatHandler* handler, uint32 restoreId, PlayerIdentifier player)
{
if (!restoreId)
{
return false;
}
if (!HasItemDeletionConfig())
{
handler->SendSysMessage(LANG_COMMAND_DISABLED);
handler->SetSentErrorMessage(true);
return false;
}
// Check existence of item in recovery table
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_RECOVERY_ITEM);
stmt->SetData(0, restoreId);
PreparedQueryResult fields = CharacterDatabase.Query(stmt);
if (!fields || !(*fields)[1].Get<uint32>() || (*fields)[3].Get<uint32>() != player.GetGUID().GetCounter())
{
handler->SendSysMessage(LANG_ITEM_RESTORE_MISSING);
handler->SetSentErrorMessage(true);
return false;
}
// Mail item to player
uint32 itemEntry = (*fields)[1].Get<uint32>();
uint32 itemCount = (*fields)[2].Get<uint32>();
if (Player* onlinePlayer = player.GetConnectedPlayer())
{
onlinePlayer->SendItemRetrievalMail({ { itemEntry, itemCount } });
}
else
{
MailSender sender(MAIL_CREATURE, 34337 /* The Postmaster */);
MailDraft draft("Recovered Item", "We recovered a lost item in the twisting nether and noted that it was yours.$B$BPlease find said object enclosed.");
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
// Save to prevent loss at next mail load. Item deletes on fail
if (Item* item = Item::CreateItem(itemEntry, itemCount, 0))
{
item->SaveToDB(trans);
draft.AddItem(item);
}
draft.SendMailTo(trans, MailReceiver(player.GetGUID().GetCounter()), sender);
CharacterDatabase.CommitTransaction(trans);
}
// Remove from recovery table
CharacterDatabasePreparedStatement* delStmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RECOVERY_ITEM_BY_RECOVERY_ID);
delStmt->SetData(0, (*fields)[0].Get<uint32>());
CharacterDatabase.Execute(delStmt);
std::string nameLink = handler->playerLink(player.GetName());
handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
return true;
}
static bool HandleItemRestoreListCommand(ChatHandler* handler, PlayerIdentifier player)
{
if (!HasItemDeletionConfig())
{
handler->SendSysMessage(LANG_COMMAND_DISABLED);
handler->SetSentErrorMessage(true);
return false;
}
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_RECOVERY_ITEM_LIST);
stmt->SetData(0, player.GetGUID().GetCounter());
PreparedQueryResult disposedItems = CharacterDatabase.Query(stmt);
if (!disposedItems)
{
handler->SendSysMessage(LANG_ITEM_RESTORE_LIST_EMPTY);
handler->SetSentErrorMessage(true);
return false;
}
do
{
Field* fields = disposedItems->Fetch();
uint32 id = fields[0].Get<uint32>();
uint32 itemId = fields[1].Get<uint32>();
uint32 count = fields[2].Get<uint32>();
std::string itemName = "";
if (ItemTemplate const* item = sObjectMgr->GetItemTemplate(itemId))
{
itemName = item->Name1;
}
handler->PSendSysMessage(LANG_ITEM_RESTORE_LIST, id, itemName, itemId, count);
} while (disposedItems->NextRow());
return true;
}
// TODO - move item to other slot
static bool HandleItemMoveCommand(ChatHandler* handler, uint8 srcSlot, uint8 dstSlot)
{
if (srcSlot == dstSlot)
return true;
if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, srcSlot, true))
return false;
if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, dstSlot, false))
return false;
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcSlot);
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstSlot);
handler->GetSession()->GetPlayer()->SwapItem(src, dst);
return true;
}
static bool HasItemDeletionConfig()
{
return sWorld->getBoolConfig(CONFIG_ITEMDELETE_METHOD) || sWorld->getBoolConfig(CONFIG_ITEMDELETE_VENDOR);
}
static bool HandleItemRefundCommand(ChatHandler* handler, PlayerIdentifier player, uint32 itemId, uint32 extendedCost)
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCost);
if (!iece)
{
handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_BAD_EXTENDED_COST);
handler->SetSentErrorMessage(true);
return false;
}
ItemTemplate const* item = sObjectMgr->GetItemTemplate(itemId);
if (!item)
{
handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
handler->SetSentErrorMessage(true);
return false;
}
if (Player* target = player.GetConnectedPlayer())
{
if (!target->HasItemCount(itemId, 1, true))
{
handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_NOT_FOUND, itemId);
handler->SetSentErrorMessage(true);
return false;
}
if (iece->reqhonorpoints)
{
uint32 honor = target->GetHonorPoints() + iece->reqhonorpoints;
if (honor > sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS))
{
handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_HONOR, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS), target->GetHonorPoints(), iece->reqhonorpoints);
ChatHandler(target->GetSession()).PSendSysMessage(LANG_CMD_ITEM_REFUND_HONOR_FAILED, item->Name1);
handler->SetSentErrorMessage(true);
return false;
}
target->SetHonorPoints(honor);
ChatHandler(target->GetSession()).PSendSysMessage(LANG_CMD_ITEM_REFUNDED_HONOR, item->Name1, item->ItemId, iece->reqhonorpoints);
handler->PSendSysMessage(LANG_CMD_ITEM_REFUNDED_HONOR, item->Name1, item->ItemId, iece->reqhonorpoints);
}
if (iece->reqarenapoints)
{
uint32 arenapoints = target->GetArenaPoints() + iece->reqarenapoints;
if (arenapoints > sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS))
{
handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_AP, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS), target->GetArenaPoints(), iece->reqarenapoints);
ChatHandler(target->GetSession()).PSendSysMessage(LANG_CMD_ITEM_REFUND_AP_FAILED, item->Name1);
handler->SetSentErrorMessage(true);
return false;
}
target->SetArenaPoints(arenapoints);
ChatHandler(target->GetSession()).PSendSysMessage(LANG_CMD_ITEM_REFUNDED_AP, item->Name1, item->ItemId, iece->reqarenapoints);
handler->PSendSysMessage(LANG_CMD_ITEM_REFUNDED_AP, item->Name1, item->ItemId, iece->reqarenapoints);
}
uint8 count = 0;
for (uint32 const& reqItem : iece->reqitem)
{
if (reqItem)
{
target->AddItem(reqItem, iece->reqitemcount[count]);
}
++count;
}
target->DestroyItemCount(itemId, 1, true);
}
else
{
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
CharacterDatabasePreparedStatement* stmt;
ObjectGuid::LowType guid = player.GetGUID().GetCounter();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER);
stmt->SetData(0, itemId);
stmt->SetData(1, guid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
if (iece->reqhonorpoints)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_HONORPOINTS);
stmt->SetData(0, guid);
PreparedQueryResult queryResult = CharacterDatabase.Query(stmt);
if (queryResult)
{
Field* fields = queryResult->Fetch();
if ((fields[0].Get<uint32>() + iece->reqhonorpoints) > sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS))
{
handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_HONOR, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS), fields[0].Get<uint32>(), iece->reqhonorpoints);
handler->SetSentErrorMessage(true);
return false;
}
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_HONOR_POINTS_ACCUMULATIVE);
stmt->SetData(0, iece->reqhonorpoints);
stmt->SetData(1, guid);
trans->Append(stmt);
handler->PSendSysMessage(LANG_CMD_ITEM_REFUNDED_HONOR, item->Name1, item->ItemId, iece->reqhonorpoints);
}
if (iece->reqarenapoints)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ARENAPOINTS);
stmt->SetData(0, guid);
PreparedQueryResult queryResult = CharacterDatabase.Query(stmt);
if (queryResult)
{
Field* fields = queryResult->Fetch();
if ((fields[0].Get<uint32>() + iece->reqhonorpoints) > sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS))
{
handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_AP, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS), fields[0].Get<uint32>(), iece->reqarenapoints);
handler->SetSentErrorMessage(true);
return false;
}
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_ARENA_POINTS_ACCUMULATIVE);
stmt->SetData(0, iece->reqarenapoints);
stmt->SetData(1, guid);
trans->Append(stmt);
handler->PSendSysMessage(LANG_CMD_ITEM_REFUNDED_AP, item->Name1, item->ItemId, iece->reqarenapoints);
}
MailSender sender(MAIL_NORMAL, guid, MAIL_STATIONERY_GM);
// fill mail
std::string msg = "Your item " + item->Name1 + " has been removed and the used currency restored. This mail contains any items used as currency.";
MailDraft draft("Item Refund", msg);
uint8 count = 0;
bool foundItems = false;
for (uint32 const& reqItem : iece->reqitem)
{
if (reqItem)
{
// Skip invalid items.
if (!sObjectMgr->GetItemTemplate(reqItem))
{
continue;
}
if (Item* item = Item::CreateItem(reqItem, iece->reqitemcount[count]))
{
item->SaveToDB(trans);
draft.AddItem(item);
foundItems = true;
}
}
++count;
}
if (foundItems)
{
draft.SendMailTo(trans, MailReceiver(nullptr, guid), sender);
}
Field* fields = result->Fetch();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);
}
else
{
handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_NOT_FOUND, itemId);
handler->SetSentErrorMessage(true);
return false;
}
}
return true;
}
};
void AddSC_item_commandscript()
{
new item_commandscript();
}

View File

@@ -85,30 +85,30 @@ public:
QueryResult result;
uint32 creatureCount = 0;
result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'", uint32(creatureId));
result = WorldDatabase.Query("SELECT COUNT(guid) FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}'", uint32(creatureId), uint32(creatureId), uint32(creatureId));
if (result)
creatureCount = (*result)[0].GetUInt64();
creatureCount = (*result)[0].Get<uint64>();
if (handler->GetSession())
{
Player* player = handler->GetSession()->GetPlayer();
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(creatureId), count);
result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}' ORDER BY order_ ASC LIMIT {}",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
}
else
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
uint32(creatureId), count);
result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id1='{}' OR id2='{}' OR id3='{}' LIMIT {}",
uint32(creatureId), uint32(creatureId), uint32(creatureId), count);
if (result)
{
do
{
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint16 mapId = fields[4].GetUInt16();
ObjectGuid::LowType guid = fields[0].Get<uint32>();
float x = fields[1].Get<float>();
float y = fields[2].Get<float>();
float z = fields[3].Get<float>();
uint16 mapId = fields[4].Get<uint16>();
bool liveFound = false;
// Get map (only support base map from console)
@@ -175,15 +175,15 @@ public:
uint32 inventoryCount = 0;
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM);
stmt->setUInt32(0, itemId);
stmt->SetData(0, itemId);
result = CharacterDatabase.Query(stmt);
if (result)
inventoryCount = (*result)[0].GetUInt64();
inventoryCount = (*result)[0].Get<uint64>();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY);
stmt->setUInt32(0, itemId);
stmt->setUInt32(1, count);
stmt->SetData(0, itemId);
stmt->SetData(1, count);
result = CharacterDatabase.Query(stmt);
if (result)
@@ -191,12 +191,12 @@ public:
do
{
Field* fields = result->Fetch();
uint32 itemGuid = fields[0].GetUInt32();
uint32 itemBag = fields[1].GetUInt32();
uint8 itemSlot = fields[2].GetUInt8();
uint32 ownerGuid = fields[3].GetUInt32();
uint32 ownerAccountId = fields[4].GetUInt32();
std::string ownerName = fields[5].GetString();
uint32 itemGuid = fields[0].Get<uint32>();
uint32 itemBag = fields[1].Get<uint32>();
uint8 itemSlot = fields[2].Get<uint8>();
uint32 ownerGuid = fields[3].Get<uint32>();
uint32 ownerAccountId = fields[4].Get<uint32>();
std::string ownerName = fields[5].Get<std::string>();
char const* itemPos = nullptr;
if (Player::IsEquipmentPos(itemBag, itemSlot))
@@ -224,17 +224,17 @@ public:
uint32 mailCount = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM);
stmt->setUInt32(0, itemId);
stmt->SetData(0, itemId);
result = CharacterDatabase.Query(stmt);
if (result)
mailCount = (*result)[0].GetUInt64();
mailCount = (*result)[0].Get<uint64>();
if (count > 0)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY);
stmt->setUInt32(0, itemId);
stmt->setUInt32(1, count);
stmt->SetData(0, itemId);
stmt->SetData(1, count);
result = CharacterDatabase.Query(stmt);
}
else
@@ -245,13 +245,13 @@ public:
do
{
Field* fields = result->Fetch();
ObjectGuid::LowType itemGuid = fields[0].GetUInt32();
ObjectGuid::LowType itemSender = fields[1].GetUInt32();
uint32 itemReceiver = fields[2].GetUInt32();
uint32 itemSenderAccountId = fields[3].GetUInt32();
std::string itemSenderName = fields[4].GetString();
uint32 itemReceiverAccount = fields[5].GetUInt32();
std::string itemReceiverName = fields[6].GetString();
ObjectGuid::LowType itemGuid = fields[0].Get<uint32>();
ObjectGuid::LowType itemSender = fields[1].Get<uint32>();
uint32 itemReceiver = fields[2].Get<uint32>();
uint32 itemSenderAccountId = fields[3].Get<uint32>();
std::string itemSenderName = fields[4].Get<std::string>();
uint32 itemReceiverAccount = fields[5].Get<uint32>();
std::string itemReceiverName = fields[6].Get<std::string>();
char const* itemPos = "[in mail]";
@@ -271,17 +271,17 @@ public:
uint32 auctionCount = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM);
stmt->setUInt32(0, itemId);
stmt->SetData(0, itemId);
result = CharacterDatabase.Query(stmt);
if (result)
auctionCount = (*result)[0].GetUInt64();
auctionCount = (*result)[0].Get<uint64>();
if (count > 0)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY);
stmt->setUInt32(0, itemId);
stmt->setUInt32(1, count);
stmt->SetData(0, itemId);
stmt->SetData(1, count);
result = CharacterDatabase.Query(stmt);
}
else
@@ -292,10 +292,10 @@ public:
do
{
Field* fields = result->Fetch();
uint32 itemGuid = fields[0].GetUInt32();
uint32 owner = fields[1].GetUInt32();
uint32 ownerAccountId = fields[2].GetUInt32();
std::string ownerName = fields[3].GetString();
uint32 itemGuid = fields[0].Get<uint32>();
uint32 owner = fields[1].Get<uint32>();
uint32 ownerAccountId = fields[2].Get<uint32>();
std::string ownerName = fields[3].Get<std::string>();
char const* itemPos = "[in auction]";
@@ -308,15 +308,15 @@ public:
uint32 guildCount = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM);
stmt->setUInt32(0, itemId);
stmt->SetData(0, itemId);
result = CharacterDatabase.Query(stmt);
if (result)
guildCount = (*result)[0].GetUInt64();
guildCount = (*result)[0].Get<uint64>();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY);
stmt->setUInt32(0, itemId);
stmt->setUInt32(1, count);
stmt->SetData(0, itemId);
stmt->SetData(1, count);
result = CharacterDatabase.Query(stmt);
if (result)
@@ -324,9 +324,9 @@ public:
do
{
Field* fields = result->Fetch();
uint32 itemGuid = fields[0].GetUInt32();
uint32 guildGuid = fields[1].GetUInt32();
std::string guildName = fields[2].GetString();
uint32 itemGuid = fields[0].Get<uint32>();
uint32 guildGuid = fields[1].Get<uint32>();
std::string guildName = fields[2].Get<std::string>();
char const* itemPos = "[in guild bank]";
@@ -372,18 +372,18 @@ public:
QueryResult result;
uint32 objectCount = 0;
result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'", uint32(gameObjectId));
result = WorldDatabase.Query("SELECT COUNT(guid) FROM gameobject WHERE id='{}'", uint32(gameObjectId));
if (result)
objectCount = (*result)[0].GetUInt64();
objectCount = (*result)[0].Get<uint64>();
if (handler->GetSession())
{
Player* player = handler->GetSession()->GetPlayer();
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM gameobject WHERE id = '{}' ORDER BY order_ ASC LIMIT {}",
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(gameObjectId), count);
}
else
result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '%u' LIMIT %u",
result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '{}' LIMIT {}",
uint32(gameObjectId), count);
if (result)
@@ -391,12 +391,12 @@ public:
do
{
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint16 mapId = fields[4].GetUInt16();
uint32 entry = fields[5].GetUInt32();
ObjectGuid::LowType guid = fields[0].Get<uint32>();
float x = fields[1].Get<float>();
float y = fields[2].Get<float>();
float z = fields[3].Get<float>();
uint16 mapId = fields[4].Get<uint16>();
uint32 entry = fields[5].Get<uint32>();
bool liveFound = false;
// Get map (only support base map from console)

View File

@@ -57,7 +57,7 @@ public:
{ "event", HandleLookupEventCommand, SEC_MODERATOR, Console::Yes },
{ "faction", HandleLookupFactionCommand, SEC_MODERATOR, Console::Yes },
{ "item", HandleLookupItemCommand, SEC_MODERATOR, Console::Yes },
{ "itemset", HandleLookupItemSetCommand, SEC_MODERATOR, Console::Yes },
{ "item set", HandleLookupItemSetCommand, SEC_MODERATOR, Console::Yes },
{ "map", HandleLookupMapCommand, SEC_MODERATOR, Console::Yes },
{ "object", HandleLookupObjectCommand, SEC_MODERATOR, Console::Yes },
{ "gobject", HandleLookupObjectCommand, SEC_MODERATOR, Console::Yes },
@@ -1617,7 +1617,7 @@ public:
}
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
stmt->setStringView(0, *ip);
stmt->SetData(0, *ip);
PreparedQueryResult result = LoginDatabase.Query(stmt);
return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
@@ -1631,7 +1631,7 @@ public:
}
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME);
stmt->setString(0, account);
stmt->SetData(0, account);
PreparedQueryResult result = LoginDatabase.Query(stmt);
return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
@@ -1640,7 +1640,7 @@ public:
static bool HandleLookupPlayerEmailCommand(ChatHandler* handler, std::string email, Optional<int32> limit)
{
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL);
stmt->setString(0, email);
stmt->SetData(0, email);
PreparedQueryResult result = LoginDatabase.Query(stmt);
return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler);
@@ -1668,11 +1668,11 @@ public:
}
Field* fields = result->Fetch();
uint32 accountId = fields[0].GetUInt32();
std::string accountName = fields[1].GetString();
uint32 accountId = fields[0].Get<uint32>();
std::string accountName = fields[1].Get<std::string>();
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_NAME_BY_ACC);
stmt->setUInt32(0, accountId);
stmt->SetData(0, accountId);
PreparedQueryResult result2 = CharacterDatabase.Query(stmt);
if (result2)
@@ -1682,8 +1682,8 @@ public:
do
{
Field* characterFields = result2->Fetch();
ObjectGuid::LowType guid = characterFields[0].GetUInt32();
std::string name = characterFields[1].GetString();
ObjectGuid::LowType guid = characterFields[0].Get<uint32>();
std::string name = characterFields[1].Get<std::string>();
uint8 plevel = 0, prace = 0, pclass = 0;
bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr;

View File

@@ -23,7 +23,6 @@ Category: commandscripts
EndScriptData */
#include "Channel.h"
#include "ChannelMgr.h"
#include "Chat.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"

File diff suppressed because it is too large Load Diff

View File

@@ -103,7 +103,7 @@ public:
Movement::PointsArray const& pointPath = path.GetPath();
handler->PSendSysMessage("%s's path to %s:", target->GetName().c_str(), player->GetName().c_str());
handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : useRaycast ? "Raycast" : "SmoothPath");
handler->PSendSysMessage("Result: %s - Length: " SZFMTD " - Type: %u", (result ? "true" : "false"), pointPath.size(), path.GetPathType());
handler->PSendSysMessage(Acore::StringFormatFmt("Result: {} - Length: {} - Type: {}", (result ? "true" : "false"), pointPath.size(), path.GetPathType()).c_str());
G3D::Vector3 const& start = path.GetStartPosition();
G3D::Vector3 const& end = path.GetEndPosition();
@@ -270,7 +270,7 @@ public:
if (!creatureList.empty())
{
handler->PSendSysMessage("Found " SZFMTD " Creatures.", creatureList.size());
handler->PSendSysMessage(Acore::StringFormatFmt("Found {} Creatures.", creatureList.size()).c_str());
uint32 paths = 0;
uint32 uStartTime = getMSTime();

View File

@@ -644,9 +644,9 @@ public:
if (newmoney > MAX_MONEY_AMOUNT)
newmoney = MAX_MONEY_AMOUNT;
handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(moneyToAdd), handler->GetNameLink(target).c_str());
handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, std::abs(moneyToAdd), handler->GetNameLink(target).c_str());
if (handler->needReportToTarget(target))
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(moneyToAdd));
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), std::abs(moneyToAdd));
target->SetMoney(newmoney);
}
}
@@ -851,7 +851,7 @@ public:
return false;
}
target->GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false);
target->GetReputationMgr().SetOneFactionReputation(factionEntry, float(amount), false);
target->GetReputationMgr().SendState(target->GetReputationMgr().GetState(factionEntry));
handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[handler->GetSessionDbcLocale()], factionId,

View File

@@ -25,6 +25,7 @@ EndScriptData */
#include "Chat.h"
#include "CreatureAI.h"
#include "CreatureGroups.h"
#include "GameTime.h"
#include "Language.h"
#include "ObjectMgr.h"
#include "Pet.h"
@@ -223,7 +224,8 @@ public:
{
ObjectGuid::LowType guid = sObjectMgr->GenerateCreatureSpawnId();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
data.id = id;
data.spawnId = guid;
data.id1 = id;
data.phaseMask = chr->GetPhaseMaskForSpawn();
data.posX = chr->GetTransOffsetX();
data.posY = chr->GetTransOffsetY();
@@ -314,10 +316,8 @@ public:
// Update movement type
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE));
stmt->setUInt32(1, lowGuid);
stmt->SetData(0, uint8(WAYPOINT_MOTION_TYPE));
stmt->SetData(1, uint32(lowGuid));
WorldDatabase.Execute(stmt);
handler->SendSysMessage(LANG_WAYPOINT_ADDED);
@@ -467,8 +467,8 @@ public:
// ..and DB
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_FACTION);
stmt->setUInt16(0, uint16(factionId));
stmt->setUInt32(1, creature->GetEntry());
stmt->SetData(0, uint16(factionId));
stmt->SetData(1, creature->GetEntry());
WorldDatabase.Execute(stmt);
@@ -478,13 +478,13 @@ public:
//set tempfaction for creature
static bool HandleNpcSetFactionTempIdCommand(ChatHandler* handler, uint32 tempfaction)
{
Player* me = handler->GetSession()->GetPlayer();
Unit* SelectedCreature = me->GetSelectedUnit();
Player* player = handler->GetSession()->GetPlayer();
Unit* unit = player->GetSelectedUnit();
if (!SelectedCreature)
if (!unit)
return false;
Creature* creature = SelectedCreature->ToCreature();
Creature* creature = unit->ToCreature();
if (!creature)
return false;
@@ -497,12 +497,12 @@ public:
//set orginal faction for npc
static bool HandleNpcSetOriginalFaction(ChatHandler* handler)
{
Player* me = handler->GetSession()->GetPlayer();
Player* player = handler->GetSession()->GetPlayer();
if (!me)
if (!player)
return false;
Creature* creature = me->GetSelectedUnit()->ToCreature();
Creature* creature = player->GetSelectedUnit()->ToCreature();
if (!creature)
return false;
@@ -528,8 +528,8 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_NPCFLAG);
stmt->setUInt32(0, NPCFlags(npcFlags));
stmt->setUInt32(1, creature->GetEntry());
stmt->SetData(0, NPCFlags(npcFlags));
stmt->SetData(1, creature->GetEntry());
WorldDatabase.Execute(stmt);
@@ -594,15 +594,24 @@ public:
uint32 spellSchoolImmuneMask = cInfo->SpellSchoolImmuneMask;
uint32 displayid = target->GetDisplayId();
uint32 nativeid = target->GetNativeDisplayId();
uint32 Entry = target->GetEntry();
uint32 entry = target->GetEntry();
uint32 id1 = 0;
uint32 id2 = 0;
uint32 id3 = 0;
if (CreatureData const* cData = target->GetCreatureData())
{
id1 = cData->id1;
id2 = cData->id2;
id3 = cData->id3;
}
int64 curRespawnDelay = target->GetRespawnTimeEx() - time(nullptr);
int64 curRespawnDelay = target->GetRespawnTimeEx() - GameTime::GetGameTime().count();
if (curRespawnDelay < 0)
curRespawnDelay = 0;
std::string curRespawnDelayStr = secsToTimeString(uint64(curRespawnDelay), true);
std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true);
handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), faction, npcflags, Entry, displayid, nativeid);
handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags);
handler->PSendSysMessage(LANG_NPCINFO_LEVEL, target->getLevel());
handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId());
handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth());
@@ -652,15 +661,15 @@ public:
Player* player = handler->GetSession()->GetPlayer();
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_NEAREST);
stmt->setFloat(0, player->GetPositionX());
stmt->setFloat(1, player->GetPositionY());
stmt->setFloat(2, player->GetPositionZ());
stmt->setUInt32(3, player->GetMapId());
stmt->setFloat(4, player->GetPositionX());
stmt->setFloat(5, player->GetPositionY());
stmt->setFloat(6, player->GetPositionZ());
stmt->setFloat(7, distance * distance);
stmt->setUInt32(8, player->GetPhaseMask());
stmt->SetData(0, player->GetPositionX());
stmt->SetData(1, player->GetPositionY());
stmt->SetData(2, player->GetPositionZ());
stmt->SetData(3, player->GetMapId());
stmt->SetData(4, player->GetPositionX());
stmt->SetData(5, player->GetPositionY());
stmt->SetData(6, player->GetPositionZ());
stmt->SetData(7, distance * distance);
stmt->SetData(8, player->GetPhaseMask());
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
@@ -668,12 +677,13 @@ public:
do
{
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[0].GetUInt32();
uint32 entry = fields[1].GetUInt32();
float x = fields[2].GetFloat();
float y = fields[3].GetFloat();
float z = fields[4].GetFloat();
uint16 mapId = fields[5].GetUInt16();
ObjectGuid::LowType guid = fields[0].Get<uint32>();
uint32 entry = fields[1].Get<uint32>();
//uint32 entry2 = fields[2].Get<uint32>();
float x = fields[3].Get<float>();
float y = fields[4].Get<float>();
float z = fields[5].Get<float>();
uint16 mapId = fields[6].Get<uint16>();
CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry);
if (!creatureTemplate)
@@ -694,11 +704,12 @@ public:
static bool HandleNpcMoveCommand(ChatHandler* handler)
{
Creature* creature = handler->getSelectedCreature();
ObjectGuid::LowType lowguid = creature->GetSpawnId();
if (!creature)
return false;
ObjectGuid::LowType lowguid = creature->GetSpawnId();
CreatureData const* data = sObjectMgr->GetCreatureData(lowguid);
if (!data)
{
@@ -740,11 +751,11 @@ public:
}
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_POSITION);
stmt->setFloat(0, x);
stmt->setFloat(1, y);
stmt->setFloat(2, z);
stmt->setFloat(3, o);
stmt->setUInt32(4, lowguid);
stmt->SetData(0, x);
stmt->SetData(1, y);
stmt->SetData(2, z);
stmt->SetData(3, o);
stmt->SetData(4, lowguid);
WorldDatabase.Execute(stmt);
@@ -966,9 +977,9 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_WANDER_DISTANCE);
stmt->setFloat(0, option);
stmt->setUInt8(1, uint8(mtype));
stmt->setUInt32(2, guidLow);
stmt->SetData(0, option);
stmt->SetData(1, uint8(mtype));
stmt->SetData(2, guidLow);
WorldDatabase.Execute(stmt);
@@ -984,8 +995,8 @@ public:
return false;
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS);
stmt->setUInt32(0, spawnTime);
stmt->setUInt32(1, creature->GetSpawnId());
stmt->SetData(0, spawnTime);
stmt->SetData(1, creature->GetSpawnId());
WorldDatabase.Execute(stmt);
creature->SetRespawnDelay(spawnTime);
@@ -1147,10 +1158,10 @@ public:
Player* player = handler->GetSession()->GetPlayer();
if (player->GetPetGUID())
if (player->IsExistPet())
{
handler->SendSysMessage (LANG_YOU_ALREADY_HAVE_PET);
handler->SetSentErrorMessage (true);
handler->SendSysMessage(LANG_YOU_ALREADY_HAVE_PET);
handler->SetSentErrorMessage(true);
return false;
}
@@ -1158,46 +1169,18 @@ public:
if (!cInfo->IsTameable(player->CanTameExoticPets()))
{
handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE, cInfo->Entry);
handler->PSendSysMessage(LANG_CREATURE_NON_TAMEABLE, cInfo->Entry);
handler->SetSentErrorMessage (true);
return false;
}
// Everything looks OK, create new pet
Pet* pet = player->CreateTamedPetFrom(creatureTarget);
if (!pet)
if (!player->CreatePet(creatureTarget))
{
handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE, cInfo->Entry);
handler->SetSentErrorMessage (true);
handler->PSendSysMessage(LANG_CREATURE_NON_TAMEABLE, cInfo->Entry);
handler->SetSentErrorMessage(true);
return false;
}
// place pet before player
float x, y, z;
player->GetClosePoint (x, y, z, creatureTarget->GetObjectSize(), CONTACT_DISTANCE);
pet->Relocate(x, y, z, M_PI - player->GetOrientation());
// set pet to defensive mode by default (some classes can't control controlled pets in fact).
pet->SetReactState(REACT_DEFENSIVE);
// calculate proper level
uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel();
// prepare visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
// add to world
pet->GetMap()->AddToMap(pet->ToCreature());
// visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, level);
// caster have pet now
player->SetMinion(pet, true);
pet->SavePetToDB(PET_SAVE_AS_CURRENT, false);
player->PetSpellInitialize();
return true;
}
@@ -1233,11 +1216,11 @@ public:
creature->SearchFormation();
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION);
stmt->setUInt32(0, leaderGUID);
stmt->setUInt32(1, lowguid);
stmt->setFloat(2, group_member.follow_dist);
stmt->setFloat(3, group_member.follow_angle);
stmt->setUInt32(4, uint32(group_member.groupAI));
stmt->SetData(0, leaderGUID);
stmt->SetData(1, lowguid);
stmt->SetData(2, group_member.follow_dist);
stmt->SetData(3, group_member.follow_angle);
stmt->SetData(4, uint32(group_member.groupAI));
WorldDatabase.Execute(stmt);

View File

@@ -0,0 +1,178 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
#include "Chat.h"
#include "Language.h"
#include "Log.h"
#include "ObjectMgr.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "WorldSession.h"
using namespace Acore::ChatCommands;
class pet_commandscript : public CommandScript
{
public:
pet_commandscript() : CommandScript("pet_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable petCommandTable =
{
{ "create", HandlePetCreateCommand, SEC_GAMEMASTER, Console::No },
{ "learn", HandlePetLearnCommand, SEC_GAMEMASTER, Console::No },
{ "unlearn", HandlePetUnlearnCommand, SEC_GAMEMASTER, Console::No }
};
static ChatCommandTable commandTable =
{
{ "pet", petCommandTable }
};
return commandTable;
}
static bool HandlePetCreateCommand(ChatHandler* handler)
{
Player* player = handler->GetSession()->GetPlayer();
Creature* creatureTarget = handler->getSelectedCreature();
if (!creatureTarget || creatureTarget->IsPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
{
handler->PSendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
CreatureTemplate const* creatrueTemplate = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
// Creatures with family 0 crashes the server
if (!creatrueTemplate->family)
{
handler->PSendSysMessage(LANG_CREATURE_NON_TAMEABLE, creatrueTemplate->Entry);
handler->SetSentErrorMessage(true);
return false;
}
if (player->IsExistPet())
{
handler->SendSysMessage(LANG_YOU_ALREADY_HAVE_PET);
handler->SetSentErrorMessage(true);
return false;
}
if (!player->CreatePet(creatureTarget))
{
handler->PSendSysMessage(LANG_CREATURE_NON_TAMEABLE, creatrueTemplate->Entry);
handler->SetSentErrorMessage(true);
return false;
}
return true;
}
static bool HandlePetLearnCommand(ChatHandler* handler, SpellInfo const* spell)
{
if (!spell)
{
handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
handler->SetSentErrorMessage(true);
return false;
}
if (!SpellMgr::IsSpellValid(spell))
{
handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
handler->SetSentErrorMessage(true);
return false;
}
Pet* pet = handler->GetSession()->GetPlayer()->GetPet();
if (!pet)
{
handler->PSendSysMessage("You have no pet");
handler->SetSentErrorMessage(true);
return false;
}
SpellScriptsBounds bounds = sObjectMgr->GetSpellScriptsBounds(spell->Id);
uint32 spellDifficultyId = sSpellMgr->GetSpellDifficultyId(spell->Id);
if (bounds.first != bounds.second || spellDifficultyId)
{
handler->PSendSysMessage("Spell %u cannot be learnt using a command!", spell->Id);
handler->SetSentErrorMessage(true);
return false;
}
// Check if pet already has it
if (pet->HasSpell(spell->Id))
{
handler->PSendSysMessage("Pet already has spell: %u", spell->Id);
handler->SetSentErrorMessage(true);
return false;
}
pet->learnSpell(spell->Id);
handler->PSendSysMessage("Pet has learned spell %u", spell->Id);
return true;
}
static bool HandlePetUnlearnCommand(ChatHandler* handler, SpellInfo const* spell)
{
if (!spell)
{
handler->PSendSysMessage(LANG_COMMAND_NOSPELLFOUND);
handler->SetSentErrorMessage(true);
return false;
}
if (!SpellMgr::IsSpellValid(spell))
{
handler->PSendSysMessage(LANG_COMMAND_SPELL_BROKEN, spell->Id);
handler->SetSentErrorMessage(true);
return false;
}
Pet* pet = handler->GetSession()->GetPlayer()->GetPet();
if (!pet)
{
handler->PSendSysMessage("You have no pet");
handler->SetSentErrorMessage(true);
return false;
}
if (pet->HasSpell(spell->Id))
{
pet->removeSpell(spell->Id, false);
}
else
{
handler->PSendSysMessage("Pet doesn't have that spell");
}
return true;
}
};
void AddSC_pet_commandscript()
{
new pet_commandscript();
}

View File

@@ -0,0 +1,81 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
#include "Chat.h"
#include "Player.h"
#include "PlayerSettings.h"
#include "ScriptMgr.h"
using namespace Acore::ChatCommands;
class player_settings_commandscript : public CommandScript
{
public:
player_settings_commandscript() : CommandScript("player_settings_commandscript") {}
ChatCommandTable GetCommands() const override
{
static ChatCommandTable playerSettingsCommandTable =
{
{ "announcer", HandleSettingsAnnouncerFlags, SEC_MODERATOR, Console::No },
};
static ChatCommandTable commandTable =
{
{ "settings", playerSettingsCommandTable },
};
return commandTable;
}
static bool HandleSettingsAnnouncerFlags(ChatHandler* handler, std::string type, bool on)
{
Player* player = handler->GetPlayer();
PlayerSetting setting;
setting = player->GetPlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS);
if (type == "bg")
{
on ? setting.RemoveFlag(ANNOUNCER_FLAG_DISABLE_BG_QUEUE) : setting.AddFlag(ANNOUNCER_FLAG_DISABLE_BG_QUEUE);
player->UpdatePlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS, setting.value);
}
else if (type == "arena")
{
on ? setting.RemoveFlag(ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE) : setting.AddFlag(ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE);
player->UpdatePlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS, setting.value);
}
else if (type == "autobroadcast")
{
if (player->getLevel() < sWorld->getIntConfig(CONFIG_AUTOBROADCAST_MIN_LEVEL_DISABLE))
{
handler->SetSentErrorMessage(true);
handler->PSendSysMessage(LANG_CMD_AUTOBROADCAST_LVL_ERROR, sWorld->getIntConfig(CONFIG_AUTOBROADCAST_MIN_LEVEL_DISABLE));
}
on ? setting.RemoveFlag(ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST) : setting.AddFlag(ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST);
player->UpdatePlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS, setting.value);
}
handler->SetSentErrorMessage(false);
handler->PSendSysMessage(on ? LANG_CMD_SETTINGS_ANNOUNCER_ON : LANG_CMD_SETTINGS_ANNOUNCER_OFF, type);
return true;
}
};
void AddSC_player_settings_commandscript()
{
new player_settings_commandscript();
}

View File

@@ -23,6 +23,7 @@ Category: commandscripts
EndScriptData */
#include "Chat.h"
#include "GameTime.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ReputationMgr.h"
@@ -96,7 +97,7 @@ public:
else
{
ObjectGuid::LowType guid = playerTarget->GetGUID().GetCounter();
QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM character_queststatus WHERE guid = %u AND quest = %u", guid, entry);
QueryResult result = CharacterDatabase.Query("SELECT 1 FROM character_queststatus WHERE guid = {} AND quest = {}", guid, entry);
if (result)
{
@@ -108,23 +109,23 @@ public:
uint8 index = 0;
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_QUESTSTATUS);
stmt->setUInt32(index++, guid);
stmt->setUInt32(index++, entry);
stmt->setUInt8(index++, 1);
stmt->setBool(index++, false);
stmt->setUInt32(index++, 0);
stmt->SetData(index++, guid);
stmt->SetData(index++, entry);
stmt->SetData(index++, 1);
stmt->SetData(index++, false);
stmt->SetData(index++, 0);
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
{
stmt->setUInt16(index++, 0);
stmt->SetData(index++, 0);
}
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
{
stmt->setUInt16(index++, 0);
stmt->SetData(index++, 0);
}
stmt->setUInt16(index, 0);
stmt->SetData(index, 0);
CharacterDatabase.Execute(stmt);
}
@@ -187,20 +188,20 @@ public:
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED_BY_QUEST);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->SetData(0, guid);
stmt->SetData(1, entry);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_BY_QUEST);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->SetData(0, guid);
stmt->SetData(1, entry);
trans->Append(stmt);
for (uint32 const& requiredItem : quest->RequiredItemId)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER);
stmt->setUInt32(0, requiredItem);
stmt->setUInt32(1, guid);
stmt->SetData(0, requiredItem);
stmt->SetData(1, guid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -209,11 +210,11 @@ public:
Field* fields = result->Fetch();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
stmt->setUInt32(0, fields[0].GetUInt32());
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, fields[0].GetUInt32());
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
}
}
@@ -298,6 +299,15 @@ public:
}
}
// player kills
if (quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_PLAYER_KILL))
{
if (uint32 reqPlayers = quest->GetPlayersSlain())
{
player->KilledPlayerCreditForQuest(reqPlayers, quest);
}
}
// If the quest requires reputation to complete
if (uint32 repFaction = quest->GetRepObjectiveFaction())
{
@@ -307,7 +317,7 @@ public:
{
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(repFaction))
{
player->GetReputationMgr().SetReputation(factionEntry, repValue);
player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue));
}
}
}
@@ -321,7 +331,7 @@ public:
{
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(repFaction))
{
player->GetReputationMgr().SetReputation(factionEntry, repValue2);
player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue2));
}
}
}
@@ -338,7 +348,7 @@ public:
else
{
ObjectGuid::LowType guid = playerTarget->GetGUID().GetCounter();
QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM character_queststatus WHERE guid = %u AND quest = %u", guid, entry);
QueryResult result = CharacterDatabase.Query("SELECT 1 FROM character_queststatus WHERE guid = {} AND quest = {}", guid, entry);
if (!result)
{
@@ -370,7 +380,7 @@ public:
// fill mail
MailDraft draft(quest->GetTitle(), std::string());
for (auto itr : questItems)
for (auto const& itr : questItems)
{
if (Item* item = Item::CreateItem(itr.first, itr.second))
{
@@ -385,24 +395,24 @@ public:
uint8 index = 0;
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_QUESTSTATUS);
stmt->setUInt32(index++, guid);
stmt->setUInt32(index++, entry);
stmt->setUInt8(index++, 1);
stmt->setBool(index++, quest->HasFlag(QUEST_FLAGS_EXPLORATION));
stmt->setUInt32(index++, 0);
stmt->SetData(index++, guid);
stmt->SetData(index++, entry);
stmt->SetData(index++, 1);
stmt->SetData(index++, quest->HasFlag(QUEST_FLAGS_EXPLORATION));
stmt->SetData(index++, 0);
for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
{
stmt->setUInt16(index++, quest->RequiredNpcOrGoCount[i]);
stmt->SetData(index++, quest->RequiredNpcOrGoCount[i]);
}
for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
{
// Will be updated once they loot the items from the mailbox.
stmt->setUInt16(index++, 0);
stmt->SetData(index++, 0);
}
stmt->setUInt16(index, 0);
stmt->SetData(index, 0);
trans->Append(stmt);
@@ -412,24 +422,24 @@ public:
uint32 repValue = quest->GetRepObjectiveValue();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION);
stmt->setUInt32(0, repFaction);
stmt->setUInt32(1, guid);
stmt->SetData(0, repFaction);
stmt->SetData(1, guid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
Field* fields = result->Fetch();
uint32 curRep = fields[0].GetUInt32();
uint32 curRep = fields[0].Get<uint32>();
if (curRep < repValue)
{
if (sFactionStore.LookupEntry(repFaction))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE);
stmt->setUInt32(0, repFaction);
stmt->setUInt32(1, repValue);
stmt->setUInt32(2, repFaction);
stmt->setUInt32(3, guid);
stmt->SetData(0, repFaction);
stmt->SetData(1, repValue);
stmt->SetData(2, repFaction);
stmt->SetData(3, guid);
trans->Append(stmt);
}
}
@@ -442,24 +452,24 @@ public:
uint32 repValue = quest->GetRepObjectiveValue();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION);
stmt->setUInt32(0, repFaction);
stmt->setUInt32(1, guid);
stmt->SetData(0, repFaction);
stmt->SetData(1, guid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
{
Field* fields = result->Fetch();
uint32 curRep = fields[0].GetUInt32();
uint32 curRep = fields[0].Get<uint32>();
if (curRep < repValue)
{
if (sFactionStore.LookupEntry(repFaction))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE);
stmt->setUInt32(0, repFaction);
stmt->setUInt32(1, repValue);
stmt->setUInt32(2, repFaction);
stmt->setUInt32(3, guid);
stmt->SetData(0, repFaction);
stmt->SetData(1, repValue);
stmt->SetData(2, repFaction);
stmt->SetData(3, guid);
trans->Append(stmt);
}
}
@@ -474,8 +484,8 @@ public:
{
// prepare Quest Tracker datas
auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE);
stmt->setUInt32(0, entry);
stmt->setUInt32(1, playerTarget->GetGUID().GetCounter());
stmt->SetData(0, entry);
stmt->SetData(1, playerTarget->GetGUID().GetCounter());
// add to Quest Tracker
CharacterDatabase.Execute(stmt);
@@ -526,7 +536,7 @@ public:
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
CharacterDatabasePreparedStatement* stmt;
QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM character_queststatus WHERE guid = %u AND quest = %u AND status = 1", guid, entry);
QueryResult result = CharacterDatabase.Query("SELECT 1 FROM character_queststatus WHERE guid = {} AND quest = {} AND status = 1", guid, entry);
if (!result)
{
@@ -538,8 +548,8 @@ public:
for (uint32 const& requiredItem : quest->RequiredItemId)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER);
stmt->setUInt32(0, requiredItem);
stmt->setUInt32(1, guid);
stmt->SetData(0, requiredItem);
stmt->SetData(1, guid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -548,11 +558,11 @@ public:
Field* fields = result->Fetch();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
stmt->setUInt32(0, fields[0].GetUInt32());
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, fields[0].GetUInt32());
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
}
}
@@ -560,8 +570,8 @@ public:
for (uint32 const& sourceItem : quest->ItemDrop)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER);
stmt->setUInt32(0, sourceItem);
stmt->setUInt32(1, guid);
stmt->SetData(0, sourceItem);
stmt->SetData(1, guid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -570,11 +580,11 @@ public:
Field* fields = result->Fetch();
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
stmt->setUInt32(0, fields[0].GetUInt32());
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
stmt->setUInt32(0, fields[0].GetUInt32());
stmt->SetData(0, fields[0].Get<uint32>());
trans->Append(stmt);
}
}
@@ -606,7 +616,7 @@ public:
// fill mail
MailDraft draft(quest->GetTitle(), "This quest has been manually rewarded to you. This mail contains your quest rewards.");
for (auto itr : questRewardItems)
for (auto const& itr : questRewardItems)
{
if (!itr.first || !itr.second)
{
@@ -641,48 +651,48 @@ public:
if (quest->IsDaily() || quest->IsDFQuest())
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->setUInt64(2, time(nullptr));
stmt->SetData(0, guid);
stmt->SetData(1, entry);
stmt->SetData(2, GameTime::GetGameTime().count());
trans->Append(stmt);
}
else if (quest->IsWeekly())
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_WEEKLYQUESTSTATUS);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->SetData(0, guid);
stmt->SetData(1, entry);
trans->Append(stmt);
}
else if (quest->IsMonthly())
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_MONTHLYQUESTSTATUS);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->SetData(0, guid);
stmt->SetData(1, entry);
trans->Append(stmt);
}
else if (quest->IsSeasonal())
{
// We can't know which event is the quest linked to, so we can't do anything about this.
/* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SEASONALQUESTSTATUS);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->setUInt32(2, event_id);
stmt->SetData(0, guid);
stmt->SetData(1, entry);
stmt->SetData(2, event_id);
trans->Append(stmt);*/
}
if (uint32 honor = quest->CalculateHonorGain(charLevel))
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_HONOR_POINTS_ACCUMULATIVE);
stmt->setUInt32(0, honor);
stmt->setUInt32(1, guid);
stmt->SetData(0, honor);
stmt->SetData(1, guid);
trans->Append(stmt);
}
if (quest->GetRewArenaPoints())
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_ARENA_POINTS_ACCUMULATIVE);
stmt->setUInt32(0, quest->GetRewArenaPoints());
stmt->setUInt32(1, guid);
stmt->SetData(0, quest->GetRewArenaPoints());
stmt->SetData(1, guid);
trans->Append(stmt);
}
@@ -697,8 +707,8 @@ public:
// Some experience might get lost on level up.
uint32 xp = uint32(quest->XPValue(charLevel) * sWorld->getRate(RATE_XP_QUEST));
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_XP_ACCUMULATIVE);
stmt->setUInt32(0, xp);
stmt->setUInt32(1, guid);
stmt->SetData(0, xp);
stmt->SetData(1, guid);
trans->Append(stmt);
}
@@ -711,19 +721,19 @@ public:
if (rewMoney > 0)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_MONEY_ACCUMULATIVE);
stmt->setUInt32(0, rewMoney);
stmt->setUInt32(1, guid);
stmt->SetData(0, rewMoney);
stmt->SetData(1, guid);
trans->Append(stmt);
}
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_QUESTSTATUS_REWARDED);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->SetData(0, guid);
stmt->SetData(1, entry);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_BY_QUEST);
stmt->setUInt32(0, guid);
stmt->setUInt32(1, entry);
stmt->SetData(0, guid);
stmt->SetData(1, entry);
trans->Append(stmt);
CharacterDatabase.CommitTransaction(trans);

View File

@@ -89,7 +89,8 @@ public:
{ "creature_questender", HandleReloadCreatureQuestEnderCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "creature_linked_respawn", HandleReloadLinkedRespawnCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "creature_loot_template", HandleReloadLootTemplatesCreatureCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "creature_onkill_reputation", HandleReloadOnKillReputationCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "creature_movement_override", HandleReloadCreatureMovementOverrideCommand, SEC_ADMINISTRATOR, Console::Yes},
{ "creature_onkill_reputation", HandleReloadOnKillReputationCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "creature_queststarter", HandleReloadCreatureQuestStarterCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "creature_template", HandleReloadCreatureTemplateCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "disables", HandleReloadDisablesCommand, SEC_ADMINISTRATOR, Console::Yes },
@@ -132,6 +133,8 @@ public:
{ "pickpocketing_loot_template", HandleReloadLootTemplatesPickpocketingCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "points_of_interest", HandleReloadPointsOfInterestCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "prospecting_loot_template", HandleReloadLootTemplatesProspectingCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "quest_greeting", HandleReloadQuestGreetingCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "quest_greeting_locale", HandleReloadLocalesQuestGreetingCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "quest_poi", HandleReloadQuestPOICommand, SEC_ADMINISTRATOR, Console::Yes },
{ "quest_template", HandleReloadQuestTemplateCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "reference_loot_template", HandleReloadLootTemplatesReferenceCommand, SEC_ADMINISTRATOR, Console::Yes },
@@ -198,6 +201,7 @@ public:
HandleReloadReservedNameCommand(handler);
HandleReloadAcoreStringCommand(handler);
HandleReloadGameTeleCommand(handler);
HandleReloadCreatureMovementOverrideCommand(handler);
HandleReloadVehicleAccessoryCommand(handler);
HandleReloadVehicleTemplateAccessoryCommand(handler);
@@ -252,9 +256,11 @@ public:
static bool HandleReloadAllQuestCommand(ChatHandler* handler)
{
HandleReloadQuestGreetingCommand(handler);
HandleReloadQuestAreaTriggersCommand(handler);
HandleReloadQuestPOICommand(handler);
HandleReloadQuestTemplateCommand(handler);
HandleReloadLocalesQuestGreetingCommand(handler);
LOG_INFO("server.loading", "Re-Loading Quests Relations...");
sObjectMgr->LoadQuestStartersAndEnders();
@@ -433,7 +439,7 @@ public:
uint32 entry = Acore::StringTo<uint32>(entryStr).value_or(0);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEMPLATE);
stmt->setUInt32(0, entry);
stmt->SetData(0, entry);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -449,7 +455,7 @@ public:
continue;
}
LOG_INFO("server.loading", "Reloading creature template entry %u", entry);
LOG_INFO("server.loading", "Reloading creature template entry {}", entry);
Field* fields = result->Fetch();
@@ -527,6 +533,22 @@ public:
return true;
}
static bool HandleReloadQuestGreetingCommand(ChatHandler* handler)
{
LOG_INFO("server.loading", "Re-Loading Quest Greeting ...");
sObjectMgr->LoadQuestGreetings();
handler->SendGlobalGMSysMessage("DB table `quest_greeting` reloaded.");
return true;
}
static bool HandleReloadLocalesQuestGreetingCommand(ChatHandler* handler)
{
LOG_INFO("server.loading", "Re-Loading Quest Greeting locales...");
sObjectMgr->LoadQuestGreetingsLocales();
handler->SendGlobalGMSysMessage("DB table `quest_greeting_locale` reloaded.");
return true;
}
static bool HandleReloadQuestTemplateCommand(ChatHandler* handler)
{
LOG_INFO("server.loading", "Re-Loading Quest Templates...");
@@ -550,6 +572,14 @@ public:
return true;
}
static bool HandleReloadCreatureMovementOverrideCommand(ChatHandler* handler)
{
LOG_INFO("server.loading", "Re-Loading Creature movement overrides...");
sObjectMgr->LoadCreatureMovementOverrides();
handler->SendGlobalGMSysMessage("DB table `creature_movement_override` reloaded.");
return true;
}
static bool HandleReloadLootTemplatesDisenchantCommand(ChatHandler* handler)
{
LOG_INFO("server.loading", "Re-Loading Loot Tables... (`disenchant_loot_template`)");

View File

@@ -96,7 +96,7 @@ public:
ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(player->getClass());
if (!classEntry)
{
LOG_ERROR("dbc", "Class %u not found in DBC (Wrong DBC files?)", player->getClass());
LOG_ERROR("dbc", "Class {} not found in DBC (Wrong DBC files?)", player->getClass());
return false;
}
@@ -178,8 +178,8 @@ public:
else
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS));
stmt->setUInt32(1, targetGuid.GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_RESET_SPELLS));
stmt->SetData(1, targetGuid.GetCounter());
CharacterDatabase.Execute(stmt);
handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str());
@@ -252,8 +252,8 @@ public:
else if (targetGuid)
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS));
stmt->setUInt32(1, targetGuid.GetCounter());
stmt->SetData(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS));
stmt->SetData(1, targetGuid.GetCounter());
CharacterDatabase.Execute(stmt);
std::string nameLink = handler->playerLink(targetName);
@@ -298,7 +298,7 @@ public:
}
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ALL_AT_LOGIN_FLAGS);
stmt->setUInt16(0, uint16(atLogin));
stmt->SetData(0, uint16(atLogin));
CharacterDatabase.Execute(stmt);
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());

View File

@@ -19,6 +19,7 @@
void AddSC_account_commandscript();
void AddSC_achievement_commandscript();
void AddSC_arena_commandscript();
void AddSC_bag_commandscript();
void AddSC_ban_commandscript();
void AddSC_bf_commandscript();
void AddSC_cast_commandscript();
@@ -28,12 +29,15 @@ void AddSC_debug_commandscript();
void AddSC_deserter_commandscript();
void AddSC_disable_commandscript();
void AddSC_event_commandscript();
void AddSC_gear_commandscript();
void AddSC_gm_commandscript();
void AddSC_go_commandscript();
void AddSC_gobject_commandscript();
void AddSC_group_commandscript();
void AddSC_guild_commandscript();
void AddSC_honor_commandscript();
void AddSC_instance_commandscript();
void AddSC_inventory_commandscript();
void AddSC_learn_commandscript();
void AddSC_lfg_commandscript();
void AddSC_list_commandscript();
@@ -43,17 +47,21 @@ void AddSC_misc_commandscript();
void AddSC_mmaps_commandscript();
void AddSC_modify_commandscript();
void AddSC_npc_commandscript();
void AddSC_pet_commandscript();
void AddSC_player_commandscript();
void AddSC_quest_commandscript();
void AddSC_reload_commandscript();
void AddSC_reset_commandscript();
void AddSC_send_commandscript();
void AddSC_server_commandscript();
void AddSC_spectator_commandscript();
void AddSC_tele_commandscript();
void AddSC_ticket_commandscript();
void AddSC_titles_commandscript();
void AddSC_wp_commandscript();
void AddSC_player_commandscript();
void AddSC_cache_commandscript();
void AddSC_item_commandscript();
void AddSC_player_settings_commandscript();
// The name of this function should match:
// void Add${NameOfDirectory}Scripts()
@@ -62,6 +70,7 @@ void AddCommandsScripts()
AddSC_account_commandscript();
AddSC_achievement_commandscript();
AddSC_arena_commandscript();
AddSC_bag_commandscript();
AddSC_ban_commandscript();
AddSC_bf_commandscript();
AddSC_cast_commandscript();
@@ -71,12 +80,15 @@ void AddCommandsScripts()
AddSC_deserter_commandscript();
AddSC_disable_commandscript();
AddSC_event_commandscript();
AddSC_gear_commandscript();
AddSC_gm_commandscript();
AddSC_go_commandscript();
AddSC_gobject_commandscript();
AddSC_group_commandscript();
AddSC_guild_commandscript();
AddSC_honor_commandscript();
AddSC_instance_commandscript();
AddSC_inventory_commandscript();
AddSC_learn_commandscript();
AddSC_lfg_commandscript();
AddSC_list_commandscript();
@@ -86,15 +98,19 @@ void AddCommandsScripts()
AddSC_mmaps_commandscript();
AddSC_modify_commandscript();
AddSC_npc_commandscript();
AddSC_pet_commandscript();
AddSC_player_commandscript();
AddSC_quest_commandscript();
AddSC_reload_commandscript();
AddSC_reset_commandscript();
AddSC_send_commandscript();
AddSC_server_commandscript();
AddSC_spectator_commandscript();
AddSC_tele_commandscript();
AddSC_ticket_commandscript();
AddSC_titles_commandscript();
AddSC_wp_commandscript();
AddSC_player_commandscript();
AddSC_cache_commandscript();
AddSC_item_commandscript();
AddSC_player_settings_commandscript();
}

View File

@@ -0,0 +1,219 @@
/*
* This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by the
* Free Software Foundation; either version 3 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 Affero 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/>.
*/
#include "Chat.h"
#include "DatabaseEnv.h"
#include "Item.h"
#include "Language.h"
#include "Mail.h"
#include "ObjectMgr.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Tokenize.h"
using namespace Acore::ChatCommands;
class send_commandscript : public CommandScript
{
public:
send_commandscript() : CommandScript("send_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable sendCommandTable =
{
{ "items", HandleSendItemsCommand, SEC_GAMEMASTER, Console::Yes },
{ "mail", HandleSendMailCommand, SEC_GAMEMASTER, Console::Yes },
{ "message", HandleSendMessageCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "money", HandleSendMoneyCommand, SEC_GAMEMASTER, Console::Yes }
};
static ChatCommandTable commandTable =
{
{ "send", sendCommandTable }
};
return commandTable;
}
static bool HandleSendItemsCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, QuotedString subject, QuotedString text, Tail items)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target)
{
return false;
}
// extract items
std::vector<std::pair<uint32, uint32>> itemList;
for (auto const& itemString : Acore::Tokenize(items, ' ', true))
{
auto itemTokens = Acore::Tokenize(itemString, ':', false);
if (itemTokens.size() != 2)
{
handler->SendSysMessage(Acore::StringFormatFmt("> Incorrect item list format for '{}'", itemString));
continue;
}
uint32 itemID = *Acore::StringTo<uint32>(itemTokens.at(0));
uint32 itemCount = *Acore::StringTo<uint32>(itemTokens.at(1));
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemID);
if (!itemTemplate)
{
handler->PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemID);
handler->SetSentErrorMessage(true);
return false;
}
if (!itemCount || (itemTemplate->MaxCount > 0 && itemCount > uint32(itemTemplate->MaxCount)))
{
handler->PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT, itemCount, itemID);
handler->SetSentErrorMessage(true);
return false;
}
while (itemCount > itemTemplate->GetMaxStackSize())
{
itemList.emplace_back(itemID, itemTemplate->GetMaxStackSize());
itemCount -= itemTemplate->GetMaxStackSize();
}
itemList.emplace_back(itemID, itemCount);
if (itemList.size() > MAX_MAIL_ITEMS)
{
handler->PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS);
handler->SetSentErrorMessage(true);
return false;
}
}
// If the message is sent from console, set it as sent by the target itself, like the other Customer Support mails.
ObjectGuid::LowType senderGuid = handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : target->GetGUID().GetCounter();
// fill mail
MailDraft draft(subject, text);
MailSender sender(MAIL_NORMAL, senderGuid, MAIL_STATIONERY_GM);
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
for (auto const& [itemID, itemCount] : itemList)
{
if (Item* item = Item::CreateItem(itemID, itemCount, handler->GetSession() ? handler->GetSession()->GetPlayer() : 0))
{
item->SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted
draft.AddItem(item);
}
}
draft.SendMailTo(trans, MailReceiver(target->GetConnectedPlayer(), target->GetGUID().GetCounter()), sender);
CharacterDatabase.CommitTransaction(trans);
handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName()).c_str());
return true;
}
static bool HandleSendMailCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, QuotedString subject, QuotedString text)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target)
{
return false;
}
ObjectGuid::LowType senderGuid = handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : target->GetGUID().GetCounter();
// If the message is sent from console, set it as sent by the target itself, like the other Customer Support mails.
MailSender sender(MAIL_NORMAL, senderGuid, MAIL_STATIONERY_GM);
MailDraft draft(subject, text);
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
draft.SendMailTo(trans, MailReceiver(target->GetConnectedPlayer(), target->GetGUID().GetCounter()), sender);
CharacterDatabase.CommitTransaction(trans);
handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName()).c_str());
return true;
}
static bool HandleSendMessageCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, Tail message)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target || !target->IsConnected())
{
return false;
}
Player* player = target->GetConnectedPlayer();
std::string msg = std::string{ message };
/// - Send the message
// Use SendAreaTriggerMessage for fastest delivery.
player->GetSession()->SendAreaTriggerMessage("%s", msg.c_str());
player->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
// Confirmation message
handler->PSendSysMessage(LANG_SENDMESSAGE, handler->playerLink(target->GetName()).c_str(), msg.c_str());
return true;
}
static bool HandleSendMoneyCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, QuotedString subject, QuotedString text, uint32 money)
{
if (!target)
{
target = PlayerIdentifier::FromTargetOrSelf(handler);
}
if (!target)
{
return false;
}
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUID().GetCounter() : 0, MAIL_STATIONERY_GM);
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft(subject, text)
.AddMoney(money)
.SendMailTo(trans, MailReceiver(target->GetConnectedPlayer(), target->GetGUID().GetCounter()), sender);
CharacterDatabase.CommitTransaction(trans);
handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName()).c_str());
return true;
}
};
void AddSC_send_commandscript()
{
new send_commandscript();
}

View File

@@ -22,9 +22,9 @@
Category: commandscripts
EndScriptData */
#include "AvgDiffTracker.h"
#include "Chat.h"
#include "Config.h"
#include "GameTime.h"
#include "GitRevision.h"
#include "Language.h"
#include "ModuleMgr.h"
@@ -34,6 +34,7 @@
#include "ScriptMgr.h"
#include "ServerMotd.h"
#include "StringConvert.h"
#include "UpdateTime.h"
#include "VMapFactory.h"
#include "VMapMgr2.h"
#include <boost/version.hpp>
@@ -77,7 +78,6 @@ public:
static ChatCommandTable serverSetCommandTable =
{
{ "difftime", HandleServerSetDiffTimeCommand, SEC_CONSOLE, Console::Yes },
{ "loglevel", HandleServerSetLogLevelCommand, SEC_CONSOLE, Console::Yes },
{ "motd", HandleServerSetMotdCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "closed", HandleServerSetClosedCommand, SEC_CONSOLE, Console::Yes },
@@ -119,11 +119,11 @@ public:
{
uint16 dbPort = 0;
if (QueryResult res = LoginDatabase.PQuery("SELECT port FROM realmlist WHERE id = %u", realm.Id.Realm))
dbPort = (*res)[0].GetUInt16();
if (QueryResult res = LoginDatabase.Query("SELECT port FROM realmlist WHERE id = {}", realm.Id.Realm))
dbPort = (*res)[0].Get<uint16>();
if (dbPort)
dbPortOutput = Acore::StringFormat("Realmlist (Realm Id: %u) configured in port %" PRIu16, realm.Id.Realm, dbPort);
dbPortOutput = Acore::StringFormatFmt("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort);
else
dbPortOutput = Acore::StringFormat("Realm Id: %u not found in `realmlist` table. Please check your setup", realm.Id.Realm);
}
@@ -183,7 +183,7 @@ public:
return val;
});
handler->PSendSysMessage("%s directory located in %s. Total size: " SZFMTD " bytes", subDir.c_str(), mapPath.generic_string().c_str(), folderSize);
handler->PSendSysMessage(Acore::StringFormatFmt("{} directory located in {}. Total size: {} bytes", subDir.c_str(), mapPath.generic_string().c_str(), folderSize).c_str());
}
LocaleConstant defaultLocale = sWorld->GetDefaultDbcLocale();
@@ -216,12 +216,22 @@ public:
handler->PSendSysMessage("Using World DB Revision: %s", sWorld->GetWorldDBRevision());
handler->PSendSysMessage("Using Character DB Revision: %s", sWorld->GetCharacterDBRevision());
handler->PSendSysMessage("Using Auth DB Revision: %s", sWorld->GetAuthDBRevision());
#ifdef MOD_PLAYERBOTS
handler->PSendSysMessage("Using Playerbots DB Revision: %s", sWorld->GetPlayerbotsDBRevision());
#endif
handler->PSendSysMessage("LoginDatabase queue size: %zu", LoginDatabase.QueueSize());
handler->PSendSysMessage("CharacterDatabase queue size: %zu", CharacterDatabase.QueueSize());
handler->PSendSysMessage("WorldDatabase queue size: %zu", WorldDatabase.QueueSize());
handler->SendSysMessage("> List enable modules:");
#ifdef MOD_PLAYERBOTS
handler->PSendSysMessage("PlayerbotsDatabase queue size: %zu", PlayerbotsDatabase.QueueSize());
#endif
if (Acore::Module::GetEnableModulesList().empty())
handler->SendSysMessage("No modules enabled");
else
handler->SendSysMessage("> List enable modules:");
for (auto const& modName : Acore::Module::GetEnableModulesList())
{
@@ -238,23 +248,16 @@ public:
uint32 activeSessionCount = sWorld->GetActiveSessionCount();
uint32 queuedSessionCount = sWorld->GetQueuedSessionCount();
uint32 connPeak = sWorld->GetMaxActiveSessionCount();
std::string uptime = secsToTimeString(sWorld->GetUptime()).append(".");
uint32 updateTime = sWorld->GetUpdateTime();
uint32 avgUpdateTime = avgDiffTracker.getAverage();
handler->PSendSysMessage("%s", GitRevision::GetFullVersion());
if (!queuedSessionCount)
handler->PSendSysMessage("Connected players: %u. Characters in world: %u.", activeSessionCount, playerCount);
else
handler->PSendSysMessage("Connected players: %u. Characters in world: %u. Queue: %u.", activeSessionCount, playerCount, queuedSessionCount);
handler->PSendSysMessage("Connection peak: %u.", connPeak);
handler->PSendSysMessage(LANG_UPTIME, uptime.c_str());
handler->PSendSysMessage("Update time diff: %ums, average: %ums.", updateTime, avgUpdateTime);
if (handler->GetSession())
if (Player* p = handler->GetSession()->GetPlayer())
if (p->IsDeveloper())
handler->PSendSysMessage("DEV wavg: %ums, nsmax: %ums, nsavg: %ums. LFG avg: %ums, max: %ums.", avgDiffTracker.getTimeWeightedAverage(), devDiffTracker.getMax(), devDiffTracker.getAverage(), lfgDiffTracker.getAverage(), lfgDiffTracker.getMax());
handler->PSendSysMessage("Connection peak: %u.", connPeak);
handler->PSendSysMessage(LANG_UPTIME, secsToTimeString(GameTime::GetUptime().count()).c_str());
handler->PSendSysMessage("Update time diff: %ums, average: %ums.", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetAverageUpdateTime());
//! Can't use sWorld->ShutdownMsg here in case of console command
if (sWorld->IsShuttingDown())
@@ -439,18 +442,6 @@ public:
sLog->SetLogLevel(name, level, isLogger);
return true;
}
// set diff time record interval
static bool HandleServerSetDiffTimeCommand(ChatHandler* /*handler*/, int32 newTime)
{
if (newTime < 0)
return false;
sWorld->SetRecordDiffInterval(newTime);
printf("Record diff every %u ms\n", newTime);
return true;
}
};
void AddSC_server_commandscript()

View File

@@ -23,8 +23,8 @@ Category: commandscripts
EndScriptData */
#include "Chat.h"
#include "DatabaseEnv.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"
#include "Group.h"
#include "Language.h"
#include "MapMgr.h"
@@ -186,14 +186,14 @@ public:
else
{
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_HOMEBIND);
stmt->setUInt32(0, player->GetGUID().GetCounter());
stmt->SetData(0, player->GetGUID().GetCounter());
PreparedQueryResult resultDB = CharacterDatabase.Query(stmt);
if (resultDB)
{
Field* fieldsDB = resultDB->Fetch();
WorldLocation loc(fieldsDB[0].GetUInt16(), fieldsDB[2].GetFloat(), fieldsDB[3].GetFloat(), fieldsDB[4].GetFloat(), 0.0f);
uint32 zoneId = fieldsDB[1].GetUInt16();
WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f);
uint32 zoneId = fieldsDB[1].Get<uint16>();
Player::SavePositionInDB(loc, zoneId, player->GetGUID(), nullptr);
}
@@ -328,7 +328,7 @@ public:
CreatureData const* spawnpoint = nullptr;
for (auto const& pair : sObjectMgr->GetAllCreatureData())
{
if (pair.second.id != *creatureId)
if (pair.second.id1 != *creatureId)
continue;
if (!spawnpoint)
@@ -362,7 +362,7 @@ public:
return false;
}
CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id));
CreatureTemplate const* creatureTemplate = ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(spawnpoint->id1));
return DoNameTeleport(handler, player, spawnpoint->mapid, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, creatureTemplate->Name);
}
@@ -372,7 +372,8 @@ public:
std::string normalizedName(name);
WorldDatabase.EscapeString(normalizedName);
QueryResult result = WorldDatabase.PQuery("SELECT c.position_x, c.position_y, c.position_z, c.orientation, c.map, ct.name FROM creature c INNER JOIN creature_template ct ON c.id = ct.entry WHERE ct.name LIKE '%s'", normalizedName.c_str());
// May need work //PussyWizardEliteMalcrom
QueryResult result = WorldDatabase.Query("SELECT c.position_x, c.position_y, c.position_z, c.orientation, c.map, ct.name FROM creature c INNER JOIN creature_template ct ON c.id1 = ct.entry WHERE ct.name LIKE '{}'", normalizedName);
if (!result)
{
handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
@@ -384,7 +385,7 @@ public:
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
Field* fields = result->Fetch();
return DoNameTeleport(handler, player, fields[4].GetUInt16(), { fields[0].GetFloat(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat() }, fields[5].GetString());
return DoNameTeleport(handler, player, fields[4].Get<uint16>(), { fields[0].Get<float>(), fields[1].Get<float>(), fields[2].Get<float>(), fields[3].Get<float>() }, fields[5].Get<std::string>());
}
};

View File

@@ -101,7 +101,7 @@ public:
PreparedQueryResult result = WorldDatabase.Query(stmt);
uint32 maxpathid = result->Fetch()->GetInt32();
uint32 maxpathid = result->Fetch()->Get<int32>();
pathid = maxpathid + 1;
handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started.");
}
@@ -119,22 +119,22 @@ public:
}
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_MAX_POINT);
stmt->setUInt32(0, pathid);
stmt->SetData(0, pathid);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (result)
point = (*result)[0].GetUInt32();
point = (*result)[0].Get<uint32>();
Player* player = handler->GetSession()->GetPlayer();
//Map* map = player->GetMap();
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA);
stmt->setUInt32(0, pathid);
stmt->setUInt32(1, point + 1);
stmt->setFloat(2, player->GetPositionX());
stmt->setFloat(3, player->GetPositionY());
stmt->setFloat(4, player->GetPositionZ());
stmt->SetData(0, pathid);
stmt->SetData(1, point + 1);
stmt->SetData(2, player->GetPositionX());
stmt->SetData(3, player->GetPositionY());
stmt->SetData(4, player->GetPositionZ());
WorldDatabase.Execute(stmt);
@@ -187,7 +187,7 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_ADDON_BY_GUID);
stmt->setUInt32(0, guidLow);
stmt->SetData(0, guidLow);
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -195,23 +195,23 @@ public:
{
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_ADDON_PATH);
stmt->setUInt32(0, pathid);
stmt->setUInt32(1, guidLow);
stmt->SetData(0, pathid);
stmt->SetData(1, guidLow);
}
else
{
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_ADDON);
stmt->setUInt32(0, guidLow);
stmt->setUInt32(1, pathid);
stmt->SetData(0, guidLow);
stmt->SetData(1, pathid);
}
WorldDatabase.Execute(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE));
stmt->setUInt32(1, guidLow);
stmt->SetData(0, uint8(WAYPOINT_MOTION_TYPE));
stmt->SetData(1, guidLow);
WorldDatabase.Execute(stmt);
@@ -255,15 +255,15 @@ public:
if (target->GetCreatureAddon()->path_id != 0)
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON);
stmt->setUInt32(0, guildLow);
stmt->SetData(0, guildLow);
WorldDatabase.Execute(stmt);
target->UpdateWaypointID(0);
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
stmt->setUInt8(0, uint8(IDLE_MOTION_TYPE));
stmt->setUInt32(1, guildLow);
stmt->SetData(0, uint8(IDLE_MOTION_TYPE));
stmt->SetData(1, guildLow);
WorldDatabase.Execute(stmt);
@@ -302,14 +302,14 @@ public:
if (id)
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
stmt->setUInt32(0, id);
stmt->SetData(0, id);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT);
stmt->setUInt32(0, id);
stmt->SetData(0, id);
WorldDatabase.Execute(stmt);
@@ -324,11 +324,11 @@ public:
PreparedQueryResult result = WorldDatabase.Query(stmt);
id = result->Fetch()->GetUInt32();
id = result->Fetch()->Get<uint32>();
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT);
stmt->setUInt32(0, id + 1);
stmt->SetData(0, id + 1);
WorldDatabase.Execute(stmt);
@@ -353,7 +353,7 @@ public:
char const* a7;
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID);
stmt->setUInt32(0, id);
stmt->SetData(0, id);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -367,16 +367,16 @@ public:
do
{
fields = result->Fetch();
a2 = fields[0].GetUInt32();
a3 = fields[1].GetUInt32();
a4 = fields[2].GetUInt32();
a5 = fields[3].GetUInt32();
a6 = fields[4].GetUInt32();
a7 = fields[5].GetCString();
a8 = fields[6].GetFloat();
a9 = fields[7].GetFloat();
a10 = fields[8].GetFloat();
a11 = fields[9].GetFloat();
a2 = fields[0].Get<uint32>();
a3 = fields[1].Get<uint32>();
a4 = fields[2].Get<uint32>();
a5 = fields[3].Get<uint32>();
a6 = fields[4].Get<uint32>();
a7 = fields[5].Get<std::string>().c_str();
a8 = fields[6].Get<float>();
a9 = fields[7].Get<float>();
a10 = fields[8].Get<float>();
a11 = fields[9].Get<float>();
handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
} while (result->NextRow());
@@ -394,7 +394,7 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
stmt->setUInt32(0, id);
stmt->SetData(0, id);
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -402,7 +402,7 @@ public:
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_SCRIPT);
stmt->setUInt32(0, id);
stmt->SetData(0, id);
WorldDatabase.Execute(stmt);
@@ -465,8 +465,8 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_ID);
stmt->setUInt32(0, newid);
stmt->setUInt32(1, id);
stmt->SetData(0, newid);
stmt->SetData(1, id);
WorldDatabase.Execute(stmt);
@@ -475,7 +475,7 @@ public:
else
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID);
stmt->setUInt32(0, id);
stmt->SetData(0, id);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -488,8 +488,8 @@ public:
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_X);
stmt->setFloat(0, float(atof(arg_3)));
stmt->setUInt32(1, id);
stmt->SetData(0, float(atof(arg_3)));
stmt->SetData(1, id);
WorldDatabase.Execute(stmt);
@@ -500,8 +500,8 @@ public:
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Y);
stmt->setFloat(0, float(atof(arg_3)));
stmt->setUInt32(1, id);
stmt->SetData(0, float(atof(arg_3)));
stmt->SetData(1, id);
WorldDatabase.Execute(stmt);
@@ -512,8 +512,8 @@ public:
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Z);
stmt->setFloat(0, float(atof(arg_3)));
stmt->setUInt32(1, id);
stmt->SetData(0, float(atof(arg_3)));
stmt->SetData(1, id);
WorldDatabase.Execute(stmt);
@@ -524,8 +524,8 @@ public:
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_O);
stmt->setFloat(0, float(atof(arg_3)));
stmt->setUInt32(1, id);
stmt->SetData(0, float(atof(arg_3)));
stmt->SetData(1, id);
WorldDatabase.Execute(stmt);
@@ -534,7 +534,7 @@ public:
}
else if (arg_str_2 == "dataint")
{
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement
WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement
handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id);
return true;
@@ -543,7 +543,7 @@ public:
{
std::string arg_str_3 = arg_3;
WorldDatabase.EscapeString(arg_str_3);
WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", arg_2, arg_str_3.c_str(), id); // Query can't be a prepared statement
WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, arg_str_3, id); // Query can't be a prepared statement
}
}
handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r", "|cff00ff00", "Waypoint script:", id, arg_2, "updated.");
@@ -596,7 +596,7 @@ public:
// Check the creature
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID);
stmt->setUInt32(0, wpSpawnId);
stmt->SetData(0, wpSpawnId);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -611,12 +611,12 @@ public:
std::string maxDiff = "0.01";
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_POS);
stmt->setFloat(0, target->GetPositionX());
stmt->setString(1, maxDiff);
stmt->setFloat(2, target->GetPositionY());
stmt->setString(3, maxDiff);
stmt->setFloat(4, target->GetPositionZ());
stmt->setString(5, maxDiff);
stmt->SetData(0, target->GetPositionX());
stmt->SetData(1, maxDiff);
stmt->SetData(2, target->GetPositionY());
stmt->SetData(3, maxDiff);
stmt->SetData(4, target->GetPositionZ());
stmt->SetData(5, maxDiff);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -629,8 +629,8 @@ public:
do
{
Field* fields = result->Fetch();
pathid = fields[0].GetUInt32();
point = fields[1].GetUInt32();
pathid = fields[0].Get<uint32>();
point = fields[1].Get<uint32>();
} while (result->NextRow());
// We have the waypoint number and the GUID of the "master npc"
@@ -657,14 +657,14 @@ public:
}
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA);
stmt->setUInt32(0, pathid);
stmt->setUInt32(1, point);
stmt->SetData(0, pathid);
stmt->SetData(1, point);
WorldDatabase.Execute(stmt);
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POINT);
stmt->setUInt32(0, pathid);
stmt->setUInt32(1, point);
stmt->SetData(0, pathid);
stmt->SetData(1, point);
WorldDatabase.Execute(stmt);
@@ -715,11 +715,11 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION);
stmt->setFloat(0, chr->GetPositionX());
stmt->setFloat(1, chr->GetPositionY());
stmt->setFloat(2, chr->GetPositionZ());
stmt->setUInt32(3, pathid);
stmt->setUInt32(4, point);
stmt->SetData(0, chr->GetPositionX());
stmt->SetData(1, chr->GetPositionY());
stmt->SetData(2, chr->GetPositionZ());
stmt->SetData(3, pathid);
stmt->SetData(4, point);
WorldDatabase.Execute(stmt);
@@ -733,14 +733,14 @@ public:
if (text == 0)
{
// show_str check for present in list of correct values, no sql injection possible
WorldDatabase.PExecute("UPDATE waypoint_data SET %s=nullptr WHERE id='%u' AND point='%u'", show_str, pathid, point); // Query can't be a prepared statement
WorldDatabase.Execute("UPDATE waypoint_data SET {}=nullptr WHERE id='{}' AND point='{}'", show_str, pathid, point); // Query can't be a prepared statement
}
else
{
// show_str check for present in list of correct values, no sql injection possible
std::string text2 = text;
WorldDatabase.EscapeString(text2);
WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", show_str, text2.c_str(), pathid, point); // Query can't be a prepared statement
WorldDatabase.Execute("UPDATE waypoint_data SET {}='{}' WHERE id='{}' AND point='{}'", show_str, text2, pathid, point); // Query can't be a prepared statement
}
handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str);
@@ -807,7 +807,7 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID);
stmt->setUInt32(0, target->GetSpawnId());
stmt->SetData(0, target->GetSpawnId());
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -821,12 +821,12 @@ public:
do
{
Field* fields = result->Fetch();
pathid = fields[0].GetUInt32();
uint32 point = fields[1].GetUInt32();
uint32 delay = fields[2].GetUInt32();
uint32 flag = fields[3].GetUInt32();
uint32 ev_id = fields[4].GetUInt32();
uint32 ev_chance = fields[5].GetUInt32();
pathid = fields[0].Get<uint32>();
uint32 point = fields[1].Get<uint32>();
uint32 delay = fields[2].Get<uint32>();
uint32 flag = fields[3].Get<uint32>();
uint32 ev_id = fields[4].Get<uint32>();
uint32 ev_chance = fields[5].Get<uint32>();
handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid);
handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay);
@@ -842,7 +842,7 @@ public:
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_BY_ID);
stmt->setUInt32(0, pathid);
stmt->SetData(0, pathid);
PreparedQueryResult result = WorldDatabase.Query(stmt);
@@ -858,7 +858,7 @@ public:
// Delete all visuals for this NPC
stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID);
stmt->setUInt32(0, pathid);
stmt->SetData(0, pathid);
PreparedQueryResult result2 = WorldDatabase.Query(stmt);
@@ -868,7 +868,7 @@ public:
do
{
Field* fields = result2->Fetch();
uint32 wpguid = fields[0].GetUInt32();
uint32 wpguid = fields[0].Get<uint32>();
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, wpguid));
if (!creature)
@@ -877,7 +877,7 @@ public:
hasError = true;
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, wpguid);
stmt->SetData(0, wpguid);
WorldDatabase.Execute(stmt);
}
@@ -900,10 +900,10 @@ public:
do
{
Field* fields = result->Fetch();
uint32 point = fields[0].GetUInt32();
float x = fields[1].GetFloat();
float y = fields[2].GetFloat();
float z = fields[3].GetFloat();
uint32 point = fields[0].Get<uint32>();
float x = fields[1].Get<float>();
float y = fields[2].Get<float>();
float z = fields[3].Get<float>();
uint32 id = VISUAL_WAYPOINT;
@@ -921,9 +921,9 @@ public:
// Set "wpguid" column to the visual waypoint
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
stmt->setInt32(0, int32(wpCreature->GetSpawnId()));
stmt->setUInt32(1, pathid);
stmt->setUInt32(2, point);
stmt->SetData(0, int32(wpCreature->GetSpawnId()));
stmt->SetData(1, pathid);
stmt->SetData(2, point);
WorldDatabase.Execute(stmt);
@@ -953,7 +953,7 @@ public:
handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID);
stmt->setUInt32(0, pathid);
stmt->SetData(0, pathid);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -964,9 +964,9 @@ public:
}
Field* fields = result->Fetch();
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
float z = fields[2].GetFloat();
float x = fields[0].Get<float>();
float y = fields[1].Get<float>();
float z = fields[2].Get<float>();
uint32 id = VISUAL_WAYPOINT;
Player* chr = handler->GetSession()->GetPlayer();
@@ -1003,7 +1003,7 @@ public:
handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID);
stmt->setUInt32(0, pathid);
stmt->SetData(0, pathid);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -1014,10 +1014,10 @@ public:
}
Field* fields = result->Fetch();
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
float z = fields[2].GetFloat();
float o = fields[3].GetFloat();
float x = fields[0].Get<float>();
float y = fields[1].Get<float>();
float z = fields[2].Get<float>();
float o = fields[3].Get<float>();
uint32 id = VISUAL_WAYPOINT;
Player* chr = handler->GetSession()->GetPlayer();
@@ -1051,7 +1051,7 @@ public:
if (show == "off")
{
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_BY_ID);
stmt->setUInt32(0, 1);
stmt->SetData(0, 1);
PreparedQueryResult result = WorldDatabase.Query(stmt);
if (!result)
@@ -1066,7 +1066,7 @@ public:
do
{
Field* fields = result->Fetch();
ObjectGuid::LowType guid = fields[0].GetUInt32();
ObjectGuid::LowType guid = fields[0].Get<uint32>();
Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, guid));
if (!creature)
{
@@ -1075,7 +1075,7 @@ public:
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
stmt->setUInt32(0, guid);
stmt->SetData(0, guid);
WorldDatabase.Execute(stmt);
}